]> git.lyx.org Git - lyx.git/blob - boost/boost/type_traits/array_traits.hpp
622c28fcb90b62cc0ac6e33fed695868980c2a89
[lyx.git] / boost / boost / type_traits / array_traits.hpp
1 //  (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard
2 //  Hinnant & John Maddock 2000.  Permission to copy, use, modify,
3 //  sell and distribute this software is granted provided this
4 //  copyright notice appears in all copies. This software is provided
5 //  "as is" without express or implied warranty, and with no claim as
6 //  to its suitability for any purpose.
7 //
8 //  See http://www.boost.org for most recent version including documentation.
9 //
10 #ifndef BOOST_TT_ARRAY_TRAITS_HPP
11 # define BOOST_TT_ARRAY_TRAITS_HPP
12 # include <cstddef>
13 # include <boost/type_traits/utility.hpp>
14 # include <boost/type_traits/ice.hpp>
15
16 namespace boost { 
17
18 /**********************************************
19  *
20  * is_array
21  *
22  **********************************************/
23 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
24 template <typename T> struct is_array
25 { BOOST_STATIC_CONSTANT(bool, value = false); };
26 template <typename T, std::size_t N> struct is_array<T[N]>
27 { BOOST_STATIC_CONSTANT(bool, value = true); };
28 template <typename T, std::size_t N> struct is_array<const T[N]>
29 { BOOST_STATIC_CONSTANT(bool, value = true); };
30 template <typename T, std::size_t N> struct is_array<volatile T[N]>
31 { BOOST_STATIC_CONSTANT(bool, value = true); };
32 template <typename T, std::size_t N> struct is_array<const volatile T[N]>
33 { BOOST_STATIC_CONSTANT(bool, value = true); };
34 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
35 namespace detail
36 {
37   using ::boost::type_traits::yes_type;
38   using ::boost::type_traits::no_type;
39   using ::boost::type_traits::wrap;
40   
41   template <class T> T(* is_array_helper1(wrap<T>) )(wrap<T>);
42   char is_array_helper1(...);
43
44   template <class T> no_type is_array_helper2(T(*)(wrap<T>));
45   yes_type is_array_helper2(...);
46 }
47
48 template <typename T> 
49 struct is_array
50
51 public:
52    BOOST_STATIC_CONSTANT(
53        bool, value = sizeof(
54            ::boost::detail::is_array_helper2(
55                ::boost::detail::is_array_helper1(
56                    ::boost::type_traits::wrap<T>()))) == 1
57        );
58 };
59
60 template <> 
61 struct is_array<void>
62
63    BOOST_STATIC_CONSTANT(bool, value = false);
64 };
65
66 # ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
67 template <> 
68 struct is_array<const void>
69
70    BOOST_STATIC_CONSTANT(bool, value = false);
71 };
72 template <> 
73 struct is_array<volatile void>
74
75    BOOST_STATIC_CONSTANT(bool, value = false);
76 };
77 template <> 
78 struct is_array<const volatile void>
79
80    BOOST_STATIC_CONSTANT(bool, value = false);
81 };
82 # endif
83 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
84
85 } // namespace boost
86
87 #endif // BOOST_TT_ARRAY_TRAITS_HPP