zookeeper-cpp
ZooKeeper Client for C++
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups
optional.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <zk/config.hpp>
9 
18 #ifndef ZKPP_OPTIONAL_USE_STD_EXPERIMENTAL
19 # define ZKPP_OPTIONAL_USE_STD_EXPERIMENTAL 0
20 #endif
21 
39 #ifndef ZKPP_OPTIONAL_USE_CUSTOM
40 # define ZKPP_OPTIONAL_USE_CUSTOM 0
41 #endif
42 
47 #ifndef ZKPP_OPTIONAL_USE_STD
48 # if ZKPP_OPTIONAL_USE_STD_EXPERIMENTAL || ZKPP_OPTIONAL_USE_CUSTOM
49 # define ZKPP_OPTIONAL_USE_STD 0
50 # else
51 # define ZKPP_OPTIONAL_USE_STD 1
52 # endif
53 #endif
54 
55 #if ZKPP_OPTIONAL_USE_STD
56 # define ZKPP_OPTIONAL_INCLUDE <optional>
57 # define ZKPP_OPTIONAL_TEMPLATE std::optional
58 # define ZKPP_NULLOPT_TYPE std::nullopt_t
59 # define ZKPP_NULLOPT_VALUE std::nullopt
60 #elif ZKPP_OPTIONAL_USE_STD_EXPERIMENTAL
61 # define ZKPP_OPTIONAL_INCLUDE <experimental/optional>
62 # define ZKPP_OPTIONAL_TEMPLATE std::experimental::optional
63 # define ZKPP_NULLOPT_TYPE std::experimental::nullopt_t
64 # define ZKPP_NULLOPT_VALUE std::experimental::nullopt
65 #elif ZKPP_OPTIONAL_USE_CUSTOM
66 # if !defined ZKPP_OPTIONAL_INCLUDE || !defined ZKPP_NULLOPT_TYPE || !defined ZKPP_NULLOPT_VALUE
67 # error "When ZKPP_OPTIONAL_USE_CUSTOM is set, you must also define ZKPP_OPTIONAL_INCLUDE, ZKPP_NULLOPT_TYPE, and"
68 # error "ZKPP_NULLOPT_VALUE."
69 # endif
70 #else
71 # error "Unknown type to use for zk::optional, zk::nullopt_t, and zk::nullopt"
72 #endif
73 
76 #include ZKPP_OPTIONAL_INCLUDE
77 
78 namespace zk
79 {
80 
85 template <typename T>
86 using optional = ZKPP_OPTIONAL_TEMPLATE<T>;
87 
88 using nullopt_t = ZKPP_NULLOPT_TYPE;
89 
90 using ZKPP_NULLOPT_VALUE;
91 
94 }
#define ZKPP_NULLOPT_TYPE
The type to use for zk::nullopt_t.
Definition: optional.hpp:58
#define ZKPP_NULLOPT_VALUE
The value to use for zk::nullopt.
Definition: optional.hpp:59