blob: 94de5489cee1d2cc85f919fa3676db32501ae40c [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
2// (C) Copyright John Maddock 2005.
3// Use, modification and distribution are subject to the Boost Software License,
4// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt).
6//
7// See http://www.boost.org/libs/type_traits for most recent version including documentation.
8
9
Jeff Thompson3d613fd2013-10-15 15:39:04 -070010#ifndef NDNBOOST_TT_EXTENT_HPP_INCLUDED
11#define NDNBOOST_TT_EXTENT_HPP_INCLUDED
Jeff Thompsona28eed82013-08-22 16:21:10 -070012
13// should be the last #include
14#include <ndnboost/type_traits/detail/size_t_trait_def.hpp>
15
16namespace ndnboost {
17
18namespace detail{
19
20#if defined( __CODEGEARC__ )
21 // wrap the impl as main trait provides additional MPL lambda support
22 template < typename T, std::size_t N >
23 struct extent_imp {
24 static const std::size_t value = __array_extent(T, N);
25 };
26
27#else
28
29template <class T, std::size_t N>
30struct extent_imp
31{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070032 NDNBOOST_STATIC_CONSTANT(std::size_t, value = 0);
Jeff Thompsona28eed82013-08-22 16:21:10 -070033};
Jeff Thompson3d613fd2013-10-15 15:39:04 -070034#if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(NDNBOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
Jeff Thompsona28eed82013-08-22 16:21:10 -070035template <class T, std::size_t R, std::size_t N>
36struct extent_imp<T[R], N>
37{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070038 NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value));
Jeff Thompsona28eed82013-08-22 16:21:10 -070039};
40
41template <class T, std::size_t R, std::size_t N>
42struct extent_imp<T const[R], N>
43{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070044 NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value));
Jeff Thompsona28eed82013-08-22 16:21:10 -070045};
46
47template <class T, std::size_t R, std::size_t N>
48struct extent_imp<T volatile[R], N>
49{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070050 NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value));
Jeff Thompsona28eed82013-08-22 16:21:10 -070051};
52
53template <class T, std::size_t R, std::size_t N>
54struct extent_imp<T const volatile[R], N>
55{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070056 NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value));
Jeff Thompsona28eed82013-08-22 16:21:10 -070057};
58
59template <class T, std::size_t R>
60struct extent_imp<T[R],0>
61{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070062 NDNBOOST_STATIC_CONSTANT(std::size_t, value = R);
Jeff Thompsona28eed82013-08-22 16:21:10 -070063};
64
65template <class T, std::size_t R>
66struct extent_imp<T const[R], 0>
67{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070068 NDNBOOST_STATIC_CONSTANT(std::size_t, value = R);
Jeff Thompsona28eed82013-08-22 16:21:10 -070069};
70
71template <class T, std::size_t R>
72struct extent_imp<T volatile[R], 0>
73{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070074 NDNBOOST_STATIC_CONSTANT(std::size_t, value = R);
Jeff Thompsona28eed82013-08-22 16:21:10 -070075};
76
77template <class T, std::size_t R>
78struct extent_imp<T const volatile[R], 0>
79{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070080 NDNBOOST_STATIC_CONSTANT(std::size_t, value = R);
Jeff Thompsona28eed82013-08-22 16:21:10 -070081};
82
Jeff Thompson3d613fd2013-10-15 15:39:04 -070083#if !NDNBOOST_WORKAROUND(__BORLANDC__, < 0x600) && !defined(__IBMCPP__) && !NDNBOOST_WORKAROUND(__DMC__, NDNBOOST_TESTED_AT(0x840)) && !defined(__MWERKS__)
Jeff Thompsona28eed82013-08-22 16:21:10 -070084template <class T, std::size_t N>
85struct extent_imp<T[], N>
86{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070087 NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value));
Jeff Thompsona28eed82013-08-22 16:21:10 -070088};
89template <class T, std::size_t N>
90struct extent_imp<T const[], N>
91{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070092 NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value));
Jeff Thompsona28eed82013-08-22 16:21:10 -070093};
94template <class T, std::size_t N>
95struct extent_imp<T volatile[], N>
96{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070097 NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value));
Jeff Thompsona28eed82013-08-22 16:21:10 -070098};
99template <class T, std::size_t N>
100struct extent_imp<T const volatile[], N>
101{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700102 NDNBOOST_STATIC_CONSTANT(std::size_t, value = (::ndnboost::detail::extent_imp<T, N-1>::value));
Jeff Thompsona28eed82013-08-22 16:21:10 -0700103};
104template <class T>
105struct extent_imp<T[], 0>
106{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700107 NDNBOOST_STATIC_CONSTANT(std::size_t, value = 0);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700108};
109template <class T>
110struct extent_imp<T const[], 0>
111{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700112 NDNBOOST_STATIC_CONSTANT(std::size_t, value = 0);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700113};
114template <class T>
115struct extent_imp<T volatile[], 0>
116{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700117 NDNBOOST_STATIC_CONSTANT(std::size_t, value = 0);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700118};
119template <class T>
120struct extent_imp<T const volatile[], 0>
121{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700122 NDNBOOST_STATIC_CONSTANT(std::size_t, value = 0);
Jeff Thompsona28eed82013-08-22 16:21:10 -0700123};
124#endif
125#endif
126
127#endif // non-CodeGear implementation
128} // ::ndnboost::detail
129
130template <class T, std::size_t N = 0>
131struct extent
132 : public ::ndnboost::integral_constant<std::size_t, ::ndnboost::detail::extent_imp<T,N>::value>
133{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700134#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700135 typedef ::ndnboost::integral_constant<std::size_t, ::ndnboost::detail::extent_imp<T,N>::value> base_;
136 using base_::value;
137#endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700138 NDNBOOST_MPL_AUX_LAMBDA_SUPPORT(1,extent,(T))
Jeff Thompsona28eed82013-08-22 16:21:10 -0700139};
140
141} // namespace ndnboost
142
143#include <ndnboost/type_traits/detail/size_t_trait_undef.hpp>
144
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700145#endif // NDNBOOST_TT_IS_MEMBER_FUNCTION_POINTER_HPP_INCLUDED