MongoDB C++ Driver current
Loading...
Searching...
No Matches
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
23namespace bsoncxx {
24inline namespace v_noabi {
25namespace stdx {
26
27using ::core::make_optional;
28using ::core::nullopt;
29using ::core::nullopt_t;
30using ::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
42namespace bsoncxx {
43inline namespace v_noabi {
44namespace stdx {
45
46using ::boost::optional;
47using nullopt_t = ::boost::none_t;
48
49// TODO(MSVC): This would be better expressed as constexpr, but VS2015U1 can't do it.
50const nullopt_t nullopt{::boost::none};
51using ::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
61namespace bsoncxx {
62inline namespace v_noabi {
63namespace stdx {
64
65using ::std::experimental::make_optional;
66using ::std::experimental::nullopt;
67using ::std::experimental::nullopt_t;
68using ::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
78namespace bsoncxx {
79inline namespace v_noabi {
80namespace stdx {
81
82using ::std::make_optional;
83using ::std::nullopt;
84using ::std::nullopt_t;
85using ::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