General Utility Library for C++14  2.11
utility.h
Go to the documentation of this file.
1 
24 #ifndef GUL14_UTILITY_H_
25 #define GUL14_UTILITY_H_
26 
27 #include <functional>
28 
29 namespace gul14 {
30 
41 struct in_place_t
42 {
43  explicit in_place_t() = default;
44 };
45 
50 static constexpr in_place_t in_place{};
51 
53 template <typename T>
55  explicit in_place_type_t() = default;
56 };
57 
59 template <typename T>
60 static constexpr in_place_type_t<T> in_place_type{};
61 
63 template <std::size_t I>
64 struct in_place_index_t { explicit in_place_index_t() = default; };
65 
67 template <std::size_t I>
68 static constexpr in_place_index_t<I> in_place_index{};
69 
71 struct monostate {};
72 inline constexpr bool operator<(monostate, monostate) noexcept { return false; }
73 inline constexpr bool operator>(monostate, monostate) noexcept { return false; }
74 inline constexpr bool operator<=(monostate, monostate) noexcept { return true; }
75 inline constexpr bool operator>=(monostate, monostate) noexcept { return true; }
76 inline constexpr bool operator==(monostate, monostate) noexcept { return true; }
77 inline constexpr bool operator!=(monostate, monostate) noexcept { return false; }
78 
80 
81 } // namespace gul14
82 
83 namespace std {
84 
89 template <>
90 struct hash<gul14::monostate>
91 {
93  using result_type = std::size_t;
94 
95  inline result_type operator()(const argument_type&) const noexcept
96  {
97  return 66740831; // random value (as proposed in https://github.com/mpark/variant)
98  }
99 };
100 
101 } // namespace std
102 
103 #endif
Namespace gul14 contains all functions and classes of the General Utility Library.
Definition: doxygen.h:26
A type for constructor disambiguation.
Definition: utility.h:64
A type for constructor disambiguation, used by gul14::expected, gul14::optional, and gul14::variant.
Definition: utility.h:42
A type for constructor disambiguation.
Definition: utility.h:54
A well-behaved empty type for use with gul14::variant and gul14::expected.
Definition: utility.h:71