blob: 6eff9db05415e480b575fca0d509cce89b7991ba [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// Boost.Range library
2//
3// Copyright Thorsten Ottosen 2003-2004. Use, modification and
4// distribution is subject to the Boost Software License, Version
5// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7//
8// For more information, see http://www.boost.org/libs/range/
9//
10
Jeff Thompson3d613fd2013-10-15 15:39:04 -070011#ifndef NDNBOOST_RANGE_DETAIL_COMMON_HPP
12#define NDNBOOST_RANGE_DETAIL_COMMON_HPP
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070013
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif
17
18#include <ndnboost/range/config.hpp>
19#include <ndnboost/range/detail/sfinae.hpp>
20#include <ndnboost/type_traits/is_void.hpp>
21#include <ndnboost/type_traits/detail/ice_or.hpp>
22#include <ndnboost/mpl/if.hpp>
23#include <ndnboost/mpl/int.hpp>
24#include <cstddef>
25
26//////////////////////////////////////////////////////////////////////////////
27// missing partial specialization workaround.
28//////////////////////////////////////////////////////////////////////////////
29
30namespace ndnboost
31{
32 namespace range_detail
33 {
34 // 1 = std containers
35 // 2 = std::pair
36 // 3 = const std::pair
37 // 4 = array
38 // 5 = const array
39 // 6 = char array
40 // 7 = wchar_t array
41 // 8 = char*
42 // 9 = const char*
43 // 10 = whar_t*
44 // 11 = const wchar_t*
45 // 12 = string
46
47 typedef mpl::int_<1>::type std_container_;
48 typedef mpl::int_<2>::type std_pair_;
49 typedef mpl::int_<3>::type const_std_pair_;
50 typedef mpl::int_<4>::type array_;
51 typedef mpl::int_<5>::type const_array_;
52 typedef mpl::int_<6>::type char_array_;
53 typedef mpl::int_<7>::type wchar_t_array_;
54 typedef mpl::int_<8>::type char_ptr_;
55 typedef mpl::int_<9>::type const_char_ptr_;
56 typedef mpl::int_<10>::type wchar_t_ptr_;
57 typedef mpl::int_<11>::type const_wchar_t_ptr_;
58 typedef mpl::int_<12>::type string_;
59
60 template< typename C >
61 struct range_helper
62 {
63 static C* c;
64 static C ptr;
65
Jeff Thompson3d613fd2013-10-15 15:39:04 -070066 NDNBOOST_STATIC_CONSTANT( bool, is_pair_ = sizeof( ndnboost::range_detail::is_pair_impl( c ) ) == sizeof( yes_type ) );
67 NDNBOOST_STATIC_CONSTANT( bool, is_char_ptr_ = sizeof( ndnboost::range_detail::is_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
68 NDNBOOST_STATIC_CONSTANT( bool, is_const_char_ptr_ = sizeof( ndnboost::range_detail::is_const_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
69 NDNBOOST_STATIC_CONSTANT( bool, is_wchar_t_ptr_ = sizeof( ndnboost::range_detail::is_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
70 NDNBOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( ndnboost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
71 NDNBOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( ndnboost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) );
72 NDNBOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( ndnboost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) );
73 NDNBOOST_STATIC_CONSTANT( bool, is_string_ = (ndnboost::type_traits::ice_or<is_const_char_ptr_, is_const_wchar_t_ptr_>::value ));
74 NDNBOOST_STATIC_CONSTANT( bool, is_array_ = ndnboost::is_array<C>::value );
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070075
76 };
77
78 template< typename C >
79 class range
80 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070081 typedef NDNBOOST_RANGE_DEDUCED_TYPENAME ndnboost::mpl::if_c< ::ndnboost::range_detail::range_helper<C>::is_pair_,
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070082 ndnboost::range_detail::std_pair_,
83 void >::type pair_t;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070084 typedef NDNBOOST_RANGE_DEDUCED_TYPENAME ndnboost::mpl::if_c< ::ndnboost::range_detail::range_helper<C>::is_array_,
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070085 ndnboost::range_detail::array_,
86 pair_t >::type array_t;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070087 typedef NDNBOOST_RANGE_DEDUCED_TYPENAME ndnboost::mpl::if_c< ::ndnboost::range_detail::range_helper<C>::is_string_,
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070088 ndnboost::range_detail::string_,
89 array_t >::type string_t;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070090 typedef NDNBOOST_RANGE_DEDUCED_TYPENAME ndnboost::mpl::if_c< ::ndnboost::range_detail::range_helper<C>::is_const_char_ptr_,
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070091 ndnboost::range_detail::const_char_ptr_,
92 string_t >::type const_char_ptr_t;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070093 typedef NDNBOOST_RANGE_DEDUCED_TYPENAME ndnboost::mpl::if_c< ::ndnboost::range_detail::range_helper<C>::is_char_ptr_,
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070094 ndnboost::range_detail::char_ptr_,
95 const_char_ptr_t >::type char_ptr_t;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070096 typedef NDNBOOST_RANGE_DEDUCED_TYPENAME ndnboost::mpl::if_c< ::ndnboost::range_detail::range_helper<C>::is_const_wchar_t_ptr_,
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070097 ndnboost::range_detail::const_wchar_t_ptr_,
98 char_ptr_t >::type const_wchar_ptr_t;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070099 typedef NDNBOOST_RANGE_DEDUCED_TYPENAME ndnboost::mpl::if_c< ::ndnboost::range_detail::range_helper<C>::is_wchar_t_ptr_,
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700100 ndnboost::range_detail::wchar_t_ptr_,
101 const_wchar_ptr_t >::type wchar_ptr_t;
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700102 typedef NDNBOOST_RANGE_DEDUCED_TYPENAME ndnboost::mpl::if_c< ::ndnboost::range_detail::range_helper<C>::is_wchar_t_array_,
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700103 ndnboost::range_detail::wchar_t_array_,
104 wchar_ptr_t >::type wchar_array_t;
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700105 typedef NDNBOOST_RANGE_DEDUCED_TYPENAME ndnboost::mpl::if_c< ::ndnboost::range_detail::range_helper<C>::is_char_array_,
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700106 ndnboost::range_detail::char_array_,
107 wchar_array_t >::type char_array_t;
108 public:
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700109 typedef NDNBOOST_RANGE_DEDUCED_TYPENAME ndnboost::mpl::if_c< ::ndnboost::is_void<char_array_t>::value,
Jeff Thompsonef2d5a42013-08-22 19:09:24 -0700110 ndnboost::range_detail::std_container_,
111 char_array_t >::type type;
112 }; // class 'range'
113 }
114}
115
116#endif
117