17 #include <type_traits>
19 #include <bsoncxx/config/prelude.hpp>
22 BSONCXX_INLINE_NAMESPACE_BEGIN
30 #if !defined(_MSC_VER)
32 template <
typename FunctionLike,
typename Signature>
33 using is_functor = std::is_convertible<FunctionLike, std::function<Signature>>;
39 template <
typename,
typename>
40 struct build_free_function;
42 template <
typename F,
typename R,
typename... Args>
43 struct build_free_function<F, R(Args...)> {
44 typedef R (*type)(Args...);
47 template <
typename,
typename>
48 struct build_class_function;
50 template <
typename C,
typename R,
typename... Args>
51 struct build_class_function<C, R(Args...)> {
52 typedef R (C::*type)(Args...);
56 struct strip_cv_from_class_function;
58 template <
typename C,
typename R,
typename... Args>
59 struct strip_cv_from_class_function<R (C::*)(Args...)> {
60 typedef R (C::*type)(Args...);
63 template <
typename C,
typename R,
typename... Args>
64 struct strip_cv_from_class_function<R (C::*)(Args...) const> {
65 typedef R (C::*type)(Args...);
68 template <
typename C,
typename R,
typename... Args>
69 struct strip_cv_from_class_function<R (C::*)(Args...) volatile> {
70 typedef R (C::*type)(Args...);
73 template <
typename C,
typename S>
74 struct 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);
92 template <
typename F,
typename S>
93 struct is_function_with_signature
94 : std::is_convertible<F, typename build_free_function<F, S>::type> {};
96 template <
typename C,
typename S,
bool>
97 struct is_functor_impl : is_class_method_with_signature<C, S> {};
99 template <
typename F,
typename S>
100 struct is_functor_impl<F, S, false> : is_function_with_signature<F, S> {};
104 template <
typename C,
typename S>
105 struct is_functor : functor::is_functor_impl<C, S, std::is_class<C>::value> {};
110 BSONCXX_INLINE_NAMESPACE_END
113 #include <bsoncxx/config/postlude.hpp>
Definition: element.hpp:24