17 #include <mangrove/config/prelude.hpp> 23 #include <type_traits> 26 #include <bsoncxx/stdx/optional.hpp> 27 #include <bsoncxx/types.hpp> 30 MANGROVE_INLINE_NAMESPACE_BEGIN
40 struct all_true :
public std::is_same<bool_pack<bs..., true>, bool_pack<true, bs...>> {};
47 : std::integral_constant<
48 bool, std::is_same<char *, typename std::decay<S>::type>::value ||
49 std::is_same<const char *, typename std::decay<S>::type>::value ||
50 std::is_same<wchar_t *, typename std::decay<S>::type>::value ||
51 std::is_same<const wchar_t *, typename std::decay<S>::type>::value> {};
53 template <
typename Char,
typename Traits,
typename Allocator>
54 struct is_string<std::basic_string<Char, Traits, Allocator>> : std::true_type {};
69 auto is_iterable_impl(
int)
70 -> decltype(begin(std::declval<T &>()) !=
71 end(std::declval<T &>()),
73 ++std::declval<decltype(begin(std::declval<T &>())) &>(),
74 void(*begin(std::declval<T &>())),
78 std::false_type is_iterable_impl(...);
81 using is_iterable = decltype(is_iterable_impl<T>(0));
84 constexpr
bool is_iterable_v = is_iterable<T>::value;
88 using is_iterable_not_string = std::integral_constant<int, is_iterable_v<T> && !is_string_v<T>>;
91 constexpr
bool is_iterable_not_string_v = is_iterable_not_string<T>::value;
99 typename T::iterator::value_type iterable_value_impl(
int);
101 template <
typename T>
102 T iterable_value_impl(...);
104 template <
typename T>
105 using iterable_value_t = decltype(iterable_value_impl<T>(0));
110 template <
typename T>
113 template <
typename T>
114 struct is_optional<bsoncxx::stdx::optional<T>> :
public std::true_type {};
116 template <
typename T>
123 template <
typename T>
128 template <
typename T>
133 template <
typename T>
134 using remove_optional_t =
typename remove_optional<T>::type;
136 constexpr std::int64_t bit_positions_to_mask() {
140 template <
typename... Args>
141 constexpr std::int64_t bit_positions_to_mask(std::int64_t pos, Args... positions) {
142 pos<0 || pos> 63 ?
throw std::logic_error(
"Invalid pos") : 0;
143 return (1 << pos) | bit_positions_to_mask(positions...);
152 template <
typename T>
155 template <
typename Rep,
typename Period>
156 struct is_date<std::chrono::duration<Rep, Period>> :
public std::true_type {};
158 template <
typename Clock,
typename Duration>
159 struct is_date<std::chrono::time_point<Clock, Duration>> :
public std::true_type {};
162 struct is_date<bsoncxx::types::b_date> :
public std::true_type {};
164 template <
typename T>
170 template <
typename Map,
typename... Ts,
size_t... idxs>
171 constexpr
void tuple_for_each_impl(
const std::tuple<Ts...> &tup, Map &&map,
172 std::index_sequence<idxs...>) {
173 (void)std::initializer_list<int>{(map(std::get<idxs>(tup)), 0)...};
176 template <
typename Map,
typename... Ts>
177 constexpr
void tuple_for_each(
const std::tuple<Ts...> &tup, Map &&map) {
178 return tuple_for_each_impl(tup, std::forward<Map>(map), std::index_sequence_for<Ts...>());
186 template <
typename... Ts>
189 template <
typename T,
typename T2,
typename... Ts>
198 template <
typename container_type,
typename T>
199 struct container_of :
public std::is_same<typename container_type::value_type, T> {};
201 template <
typename container_type,
typename T>
210 template <
typename iterator_type,
typename T>
212 :
public std::is_same<typename std::iterator_traits<iterator_type>::value_type, T> {};
214 template <
typename iterator_type,
typename T>
217 MANGROVE_INLINE_NAMESPACE_END
220 #include <mangrove/config/postlude.hpp> Type trait that checks whether or not an iterator iterates a particular type.
Definition: util.hpp:211
A templated struct that contains its templated type, but with optionals unwrapped.
Definition: util.hpp:124
A type trait struct for determining whether a type is a string or C string.
Definition: util.hpp:46
A type trait struct for determining whether a type is an optional.
Definition: util.hpp:111
A type traits struct that determines whether a certain type stores a date.
Definition: util.hpp:153
Definition: collection_wrapper.hpp:28
A templated struct for determining whether a variadic list of boolean conditions is all true...
Definition: util.hpp:40
Type trait that checks whether or not a type is a container that contains a particular type...
Definition: util.hpp:199
Helper type trait widget that helps properly forward arguments to _id constructor in mangrove::model...
Definition: util.hpp:187