]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/convert/include/boost/convert/detail/is_converter.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / convert / include / boost / convert / detail / is_converter.hpp
1 // Copyright (c) 2009-2016 Vladimir Batov.
2 // Use, modification and distribution are subject to the Boost Software License,
3 // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt.
4
5 #ifndef BOOST_CONVERT_IS_CONVERTER_HPP
6 #define BOOST_CONVERT_IS_CONVERTER_HPP
7
8 #include <boost/convert/detail/forward.hpp>
9 #include <boost/convert/detail/is_callable.hpp>
10 #include <boost/utility/enable_if.hpp>
11 #include <boost/type_traits.hpp>
12 #include <boost/ref.hpp>
13
14 namespace boost { namespace cnv
15 {
16 template<typename, typename, typename, typename =void>
17 struct is_cnv { BOOST_STATIC_CONSTANT(bool, value = false); };
18
19 template<typename Class, typename TypeIn, typename TypeOut>
20 struct is_cnv<Class, TypeIn, TypeOut, typename enable_if<is_class<Class>, void>::type>
21 {
22 typedef typename ::boost::unwrap_reference<Class>::type class_type;
23 typedef void signature_type(TypeIn const&, optional<TypeOut>&);
24
25 BOOST_DECLARE_IS_CALLABLE(is_callable, operator());
26
27 BOOST_STATIC_CONSTANT(bool, value = (is_callable<class_type, signature_type>::value));
28 };
29
30 template<typename Function, typename TypeIn, typename TypeOut>
31 struct is_cnv<Function, TypeIn, TypeOut,
32 typename enable_if_c<is_function<Function>::value && function_types::function_arity<Function>::value == 2,
33 void>::type>
34 {
35 typedef TypeIn in_type;
36 typedef optional<TypeOut>& out_type;
37 typedef typename function_traits<Function>::arg1_type func_in_type;
38 typedef typename function_traits<Function>::arg2_type func_out_type;
39
40 BOOST_STATIC_CONSTANT(bool, in_good = (is_convertible<in_type, func_in_type>::value));
41 BOOST_STATIC_CONSTANT(bool, out_good = (is_same<out_type, func_out_type>::value));
42 BOOST_STATIC_CONSTANT(bool, value = (in_good && out_good));
43 };
44 }}
45
46 #endif // BOOST_CONVERT_IS_CONVERTER_HPP
47