MongoDB C++ Driver  mongocxx-3.9.0
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
optional.hpp
1 // Copyright 2015 MongoDB Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <bsoncxx/config/prelude.hpp>
18 
19 #if defined(BSONCXX_POLY_USE_MNMLSTC)
20 
21 #include <core/optional.hpp>
22 
23 namespace bsoncxx {
24 inline namespace v_noabi {
25 namespace stdx {
26 
27 using ::core::make_optional;
28 using ::core::nullopt;
29 using ::core::nullopt_t;
30 using ::core::optional;
31 
32 } // namespace stdx
33 } // namespace v_noabi
34 } // namespace bsoncxx
35 
36 #elif defined(BSONCXX_POLY_USE_BOOST)
37 
38 #include <boost/none.hpp>
39 #include <boost/optional/optional.hpp>
40 #include <boost/optional/optional_io.hpp>
41 
42 namespace bsoncxx {
43 inline namespace v_noabi {
44 namespace stdx {
45 
46 using ::boost::optional;
47 using nullopt_t = ::boost::none_t;
48 
49 // TODO(MSVC): This would be better expressed as constexpr, but VS2015U1 can't do it.
50 const nullopt_t nullopt{::boost::none};
51 using ::boost::make_optional;
52 
53 } // namespace stdx
54 } // namespace v_noabi
55 } // namespace bsoncxx
56 
57 #elif defined(BSONCXX_POLY_USE_STD_EXPERIMENTAL)
58 
59 #include <experimental/optional>
60 
61 namespace bsoncxx {
62 inline namespace v_noabi {
63 namespace stdx {
64 
65 using ::std::experimental::make_optional;
66 using ::std::experimental::nullopt;
67 using ::std::experimental::nullopt_t;
68 using ::std::experimental::optional;
69 
70 } // namespace stdx
71 } // namespace v_noabi
72 } // namespace bsoncxx
73 
74 #elif defined(BSONCXX_POLY_USE_STD)
75 
76 #include <optional>
77 
78 namespace bsoncxx {
79 inline namespace v_noabi {
80 namespace stdx {
81 
82 using ::std::make_optional;
83 using ::std::nullopt;
84 using ::std::nullopt_t;
85 using ::std::optional;
86 
87 } // namespace stdx
88 } // namespace v_noabi
89 } // namespace bsoncxx
90 
91 #else
92 #error "Cannot find a valid polyfill for optional"
93 #endif
94 
95 #include <bsoncxx/config/postlude.hpp>
The top-level namespace for bsoncxx library entities.
Definition: element.hpp:24