19#include <bsoncxx/config/prelude.hpp>
22BSONCXX_INLINE_NAMESPACE_BEGIN
32template <
typename FunctionLike,
typename Signature>
33using is_functor = std::is_convertible<FunctionLike, std::function<Signature>>;
39template <
typename,
typename>
40struct build_free_function;
42template <
typename F,
typename R,
typename... Args>
43struct build_free_function<F, R(Args...)> {
44 typedef R (*type)(Args...);
47template <
typename,
typename>
48struct build_class_function;
50template <
typename C,
typename R,
typename... Args>
51struct build_class_function<C, R(Args...)> {
52 typedef R (C::*
type)(Args...);
56struct strip_cv_from_class_function;
58template <
typename C,
typename R,
typename... Args>
59struct strip_cv_from_class_function<R (C::*)(Args...)> {
60 typedef R (C::*
type)(Args...);
63template <
typename C,
typename R,
typename... Args>
64struct strip_cv_from_class_function<R (C::*)(Args...) const> {
65 typedef R (C::*
type)(Args...);
68template <
typename C,
typename R,
typename... Args>
69struct strip_cv_from_class_function<R (C::*)(Args...) volatile> {
70 typedef R (C::*
type)(Args...);
73template <
typename C,
typename S>
74struct is_class_method_with_signature {
80 static typename std::enable_if<std::is_convertible<typename build_class_function<C, S>::type,
81 typename strip_cv_from_class_function<
82 decltype(&T::operator())>::type>::value,
87 static no sfinae(...);
89 static bool constexpr value =
sizeof(sfinae<C>(
nullptr)) ==
sizeof(yes);
92template <
typename F,
typename S>
93struct is_function_with_signature
94 : std::is_convertible<F, typename build_free_function<F, S>::type> {};
96template <
typename C,
typename S,
bool>
97struct is_functor_impl : is_class_method_with_signature<C, S> {};
99template <
typename F,
typename S>
100struct is_functor_impl<F, S, false> : is_function_with_signature<F, S> {};
104template <
typename C,
typename S>
105struct is_functor : functor::is_functor_impl<C, S, std::is_class<C>::value> {};
110BSONCXX_INLINE_NAMESPACE_END
113#include <bsoncxx/config/postlude.hpp>
Top level namespace for MongoDB C++ BSON functionality.
Definition element.hpp:24
type
An enumeration of each BSON type.
Definition types.hpp:39