30using type_t =
typename T::type;
34using value_type_t =
typename T::value_type;
36template <
bool B,
typename T =
void>
37using enable_if_t =
typename std::enable_if<B, T>::type;
39#pragma push_macro("DECL_ALIAS")
41#define DECL_ALIAS(Name) \
42 template <typename T> \
43 using Name##_t = type_t<std::Name<T>>
45DECL_ALIAS(make_signed);
46DECL_ALIAS(make_unsigned);
47DECL_ALIAS(remove_reference);
48DECL_ALIAS(remove_const);
49DECL_ALIAS(remove_volatile);
50DECL_ALIAS(remove_pointer);
52DECL_ALIAS(add_pointer);
54DECL_ALIAS(add_volatile);
55DECL_ALIAS(add_lvalue_reference);
56DECL_ALIAS(add_rvalue_reference);
57#pragma pop_macro("DECL_ALIAS")
59template <
typename... Ts>
60using common_type_t = type_t<std::common_type<Ts...>>;
64using remove_cvref_t = remove_cv_t<remove_reference_t<T>>;
68using const_reference_t = add_lvalue_reference_t<remove_cvref_t<T>
const>;
79template <
typename... Ts>
81#if defined(_MSC_VER) && _MSC_VER < 1910
84 typename just_void<Ts...>
::type;
91using bool_constant = std::integral_constant<bool, B>;
100namespace impl_detection {
105 template <
class...>
class Oper,
111 typename SfinaeHere = Oper<Args...>>
112std::true_type is_detected_f(mp_list<Args...>*);
116template <
template <
class...>
class Oper>
117std::false_type is_detected_f(...);
120template <
bool IsDetected>
125struct detection<false> {
127 template <
typename Default,
template <
class...>
class,
typename...>
133struct detection<true> {
134 template <
typename,
template <
class...>
class Oper,
typename... Args>
135 using f = Oper<Args...>;
140template <
typename Dflt,
typename Void,
template <
class...>
class Oper,
typename... Args>
141struct vc140_detection {
145template <
typename Dflt,
template <
class...>
class Oper,
typename... Args>
146struct vc140_detection<Dflt, void_t<Oper<Args...>>, Oper, Args...> {
147 using type = Oper<Args...>;
154 ~nonesuch() =
delete;
155 nonesuch(nonesuch
const&) =
delete;
156 void operator=(nonesuch
const&) =
delete;
164template <
template <
class...>
class Oper,
typename... Args>
165struct is_detected : decltype(impl_detection::is_detected_f<Oper>(static_cast<mp_list<Args...>*>(nullptr))) {};
172template <
typename Dflt,
template <
class...>
class Oper,
typename... Args>
174#if defined(_MSC_VER) && _MSC_VER < 1910
175 typename impl_detection::vc140_detection<Dflt, void, Oper, Args...>
::type
177 typename impl_detection::detection<is_detected<Oper, Args...>::value>::template f<Dflt, Oper, Args...>
186template <
template <
class...>
class Oper,
typename... Args>
187using detected_t = detected_or<nonesuch, Oper, Args...>;
195 template <
typename IfTrue,
typename>
200struct conditional<false> {
201 template <
typename,
typename IfFalse>
210template <
bool B,
typename T,
typename F>
211using conditional_t =
typename conditional<B>::template f<T, F>;
214namespace impl_logic {
216template <
typename FalseType,
typename Opers>
219template <
typename H,
typename... Tail>
220struct conj<bool_constant<H::
value || !sizeof...(Tail)>, mp_list<H, Tail...>> : H {};
222template <
typename F,
typename H,
typename... Tail>
223struct conj<F, mp_list<H, Tail...>> : conj<F, mp_list<Tail...>> {};
226struct conj<std::false_type, mp_list<H>> : H {};
229struct conj<std::false_type, mp_list<>> : std::true_type {};
231template <
typename TrueType,
typename Opers>
234template <
typename H,
typename... Tail>
235struct disj<bool_constant<H::
value && sizeof...(Tail)>, mp_list<H, Tail...>> : H {};
237template <
typename F,
typename H,
typename... Tail>
238struct disj<F, mp_list<H, Tail...>> : disj<F, mp_list<Tail...>> {};
241struct disj<std::true_type, mp_list<H>> : H {};
244struct disj<std::true_type, mp_list<>> : std::false_type {};
255template <
typename... Cond>
256struct conjunction : impl_logic::conj<std::false_type, mp_list<Cond...>> {};
264template <
typename... Cond>
265struct disjunction : impl_logic::disj<std::true_type, mp_list<Cond...>> {};
271struct negation : bool_constant<!T::value> {};
277template <
typename...>
278using true_t = std::true_type;
280namespace impl_requires {
283R norm_conjunction(R
const&);
285template <
typename R,
typename... Cs>
286conjunction<Cs...> norm_conjunction(conjunction<Cs...>
const&);
289using norm_conjunction_t =
decltype(norm_conjunction<T>(std::declval<T const&>()));
291template <
typename Constra
int,
typename =
void>
294template <
typename FailingRequirement>
295struct failed_requirement {
296 failed_requirement(
int) =
delete;
298 template <
typename T>
299 static T explain(failed_requirement);
302template <
typename... SubRequirements>
303struct failed_requirement<conjunction<SubRequirements...>> {
304 failed_requirement(
int) =
delete;
306 template <
typename T>
307 static auto explain(
int) -> common_type_t<
decltype(requirement<SubRequirements>::test::template explain<T>(0))...>;
310template <
typename Constra
int,
typename>
312 using test = failed_requirement<impl_requires::norm_conjunction_t<Constraint>>;
315template <
typename Constra
int>
316struct requirement<Constraint, enable_if_t<Constraint::
value>> {
318 template <
typename T>
319 static T explain(
int);
331template <
typename Type,
typename... Traits>
332#if defined _MSC_VER && _MSC_VER < 1920
334using requires_t = enable_if_t<conjunction<Traits...>::value, Type>;
337using requires_t =
decltype(impl_requires::requirement<conjunction<Traits...>>::test::template explain<Type>(0));
346template <
typename Type,
typename... Traits>
347using requires_not_t = requires_t<Type, negation<disjunction<Traits...>>>;
350namespace impl_invoke {
352template <
bool IsMemberObject,
bool IsMemberFunction>
354 template <
typename F,
typename... Args>
355 constexpr static auto apply(F&& fun, Args&&... args)
356 BSONCXX_PRIVATE_RETURNS(
static_cast<F&&
>(fun)(
static_cast<Args&&
>(args)...));
360struct invoker<false, true> {
361 template <
typename F,
typename Self,
typename... Args>
362 constexpr static auto apply(F&& fun, Self&& self, Args&&... args)
363 BSONCXX_PRIVATE_RETURNS((
static_cast<Self&&
>(self).*fun)(
static_cast<Args&&
>(args)...));
367struct invoker<true, false> {
368 template <
typename F,
typename Self>
369 constexpr static auto apply(F&& fun, Self&& self) BSONCXX_PRIVATE_RETURNS(
static_cast<Self&&
>(self).*fun);
374static constexpr struct invoke_fn {
380 template <
typename F,
typename... Args,
typename Fd = remove_cvref_t<F>>
381 constexpr auto operator()(F&& fn, Args&&... args)
const
382 BSONCXX_PRIVATE_RETURNS(impl_invoke::invoker<std::is_member_object_pointer<Fd>::value, std::is_member_function_pointer<Fd>::value>::apply(
static_cast<F&&
>(fn),
static_cast<Args&&
>(args)...));
390template <
typename F,
typename... Args>
391using invoke_result_t =
decltype(invoke(std::declval<F>(), std::declval<Args>()...));
397template <
typename F,
typename... Args>
398#if defined(_MSC_VER) && _MSC_VER < 1910
399using is_invocable = is_detected<invoke_result_t, F, Args...>;
401struct is_invocable : is_detected<invoke_result_t, F, Args...> {
407template <
typename T,
typename U>
408struct is_alike : std::is_same<remove_cvref_t<T>, remove_cvref_t<U>> {};
414template <std::
size_t N>
424namespace swap_detection {
430void swap(...) =
delete;
432template <
typename T,
typename U>
433auto is_swappable_f(rank<0>) -> std::false_type;
435template <
typename T,
typename U>
436auto is_swappable_f(rank<1>)
noexcept(
437 noexcept(swap(std::declval<T>(), std::declval<U>())) &&
noexcept(swap(std::declval<U>(), std::declval<T>())))
439 decltype(swap(std::declval<T>(), std::declval<U>())),
440 decltype(swap(std::declval<U>(), std::declval<T>()))>;
442template <
typename T,
typename U>
443auto is_nothrow_swappable_f(rank<0>) -> std::false_type;
445template <
typename T,
typename U>
446auto is_nothrow_swappable_f(rank<1>) -> bool_constant<
447 noexcept(swap(std::declval<T>(), std::declval<U>())) &&
noexcept(swap(std::declval<U>(), std::declval<T>()))>;
451template <
typename T,
typename U>
452struct is_swappable_with : decltype(swap_detection::is_swappable_f<T, U>(rank<1>{})) {};
454template <
typename T,
typename U>
455struct is_nothrow_swappable_with : decltype(swap_detection::is_nothrow_swappable_f<T, U>(rank<1>{})) {};
458struct is_swappable : is_swappable_with<T&, T&> {};
461struct is_nothrow_swappable : is_nothrow_swappable_with<T&, T&> {};
463template <
typename L,
typename R>
464auto is_equality_comparable_f(...) -> std::false_type;
466BSONCXX_PRIVATE_WARNINGS_PUSH();
467BSONCXX_PRIVATE_WARNINGS_DISABLE(GNU(
"-Wfloat-equal"));
468template <
typename L,
typename R>
469auto is_equality_comparable_f(
int,
bool b =
false)
471 decltype((std::declval<L const&>() == std::declval<R const&>()) ? 0 : 0, (std::declval<R const&>() == std::declval<L const&>()) ? 0 : 0, (std::declval<L const&>() != std::declval<R const&>()) ? 0 : 0, (std::declval<R const&>() != std::declval<L const&>()) ? 0 : 0)>;
472BSONCXX_PRIVATE_WARNINGS_POP();
477template <
typename L,
typename R = L>
478struct is_equality_comparable : decltype(is_equality_comparable_f<L, R>(0)) {};
480template <
typename L,
typename R>
481std::false_type is_partially_ordered_with_f(rank<0>);
483BSONCXX_PRIVATE_WARNINGS_PUSH();
484BSONCXX_PRIVATE_WARNINGS_DISABLE(Clang(
"-Wordered-compare-function-pointers"));
485template <
typename L,
typename R>
486auto is_partially_ordered_with_f(rank<1>) -> true_t<
487 decltype(std::declval<L const&>() > std::declval<R const&>()),
488 decltype(std::declval<L const&>() < std::declval<R const&>()),
489 decltype(std::declval<L const&>() >= std::declval<R const&>()),
490 decltype(std::declval<L const&>() <= std::declval<R const&>()),
491 decltype(std::declval<R const&>() < std::declval<L const&>()),
492 decltype(std::declval<R const&>() > std::declval<L const&>()),
493 decltype(std::declval<R const&>() <= std::declval<L const&>()),
494 decltype(std::declval<R const&>() >= std::declval<L const&>())>;
495BSONCXX_PRIVATE_WARNINGS_POP();
497template <
typename T,
typename U>
498struct is_partially_ordered_with : decltype(is_partially_ordered_with_f<T, U>(rank<1>{})) {};
501struct is_totally_ordered : conjunction<is_equality_comparable<T>, is_partially_ordered_with<T, T>> {};
503template <
typename T,
typename U>
504struct is_totally_ordered_with : conjunction<
505 is_totally_ordered<T>,
506 is_totally_ordered<U>,
507 is_equality_comparable<T, U>,
508 is_partially_ordered_with<T, U>> {};
The bsoncxx v1 macro guard postlude header.
The bsoncxx v1 macro guard prelude header.
bson_value::value value
Equivalent to bsoncxx::v_noabi::types::bson_value::value.
Definition value-fwd.hpp:35
type
An enumeration of each BSON type.
Definition types.hpp:47
The top-level namespace within which all bsoncxx library entities are declared.