]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/test/utils/is_cstring.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / test / utils / is_cstring.hpp
1 // (C) Copyright Gennadiy Rozental 2001.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5
6 // See http://www.boost.org/libs/test for the library home page.
7 //
8 // File : $RCSfile$
9 //
10 // Version : $Revision$
11 //
12 // Description : defines the is_cstring type trait
13 // ***************************************************************************
14
15 #ifndef BOOST_TEST_UTILS_IS_CSTRING_HPP
16 #define BOOST_TEST_UTILS_IS_CSTRING_HPP
17
18 // Boost
19 #include <boost/mpl/bool.hpp>
20 #include <boost/type_traits/is_same.hpp>
21 #include <boost/type_traits/decay.hpp>
22 #include <boost/type_traits/remove_pointer.hpp>
23 #include <boost/type_traits/remove_const.hpp>
24 #include <boost/type_traits/add_const.hpp>
25
26 #include <boost/test/utils/basic_cstring/basic_cstring_fwd.hpp>
27 #include <string>
28
29 //____________________________________________________________________________//
30
31 namespace boost {
32 namespace unit_test {
33
34 // ************************************************************************** //
35 // ************** is_cstring ************** //
36 // ************************************************************************** //
37
38 namespace ut_detail {
39
40 template<typename T>
41 struct is_cstring_impl : public mpl::false_ {};
42
43 template<typename T>
44 struct is_cstring_impl<T const*> : public is_cstring_impl<T*> {};
45
46 template<typename T>
47 struct is_cstring_impl<T const* const> : public is_cstring_impl<T*> {};
48
49 template<>
50 struct is_cstring_impl<char*> : public mpl::true_ {};
51
52 template<>
53 struct is_cstring_impl<wchar_t*> : public mpl::true_ {};
54
55 template <typename T, bool is_cstring = is_cstring_impl<typename boost::decay<T>::type>::value >
56 struct deduce_cstring_impl;
57
58 template <typename T, bool is_cstring >
59 struct deduce_cstring_impl<T&, is_cstring> : public deduce_cstring_impl<T, is_cstring>{};
60
61 template <typename T, bool is_cstring >
62 struct deduce_cstring_impl<T const, is_cstring> : public deduce_cstring_impl<T, is_cstring>{};
63
64 template <typename T>
65 struct deduce_cstring_impl<T, true> {
66 typedef typename boost::add_const<
67 typename boost::remove_pointer<
68 typename boost::decay<T>::type
69 >::type
70 >::type U;
71 typedef boost::unit_test::basic_cstring<U> type;
72 };
73
74 template <typename T>
75 struct deduce_cstring_impl< T, false > {
76 typedef typename
77 boost::remove_const<
78 typename boost::remove_reference<T>::type
79 >::type type;
80 };
81
82 template <typename T>
83 struct deduce_cstring_impl< std::basic_string<T, std::char_traits<T> >, false > {
84 typedef boost::unit_test::basic_cstring<typename boost::add_const<T>::type> type;
85 };
86
87 } // namespace ut_detail
88
89 template<typename T>
90 struct is_cstring : public ut_detail::is_cstring_impl<typename decay<T>::type> {};
91
92 template<typename T, bool is_cstring = is_cstring<typename boost::decay<T>::type>::value >
93 struct is_cstring_comparable: public mpl::false_ {};
94
95 template<typename T>
96 struct is_cstring_comparable< T, true > : public mpl::true_ {};
97
98 template<typename T>
99 struct is_cstring_comparable< std::basic_string<T, std::char_traits<T> >, false > : public mpl::true_ {};
100
101 template<typename T>
102 struct is_cstring_comparable< boost::unit_test::basic_cstring<T>, false > : public mpl::true_ {};
103
104 template <class T>
105 struct deduce_cstring {
106 typedef typename
107 boost::remove_const<
108 typename boost::remove_reference<T>::type
109 >::type U;
110 typedef typename ut_detail::deduce_cstring_impl<typename boost::decay<U>::type>::type type;
111 };
112
113 } // namespace unit_test
114 } // namespace boost
115
116 #endif // BOOST_TEST_UTILS_IS_CSTRING_HPP