From 9b1cdde025d4f9ea8b027798ad3ee1a584bf9b97 Mon Sep 17 00:00:00 2001 From: Jonathan Turkanis Date: Fri, 13 May 2005 15:29:36 +0000 Subject: [PATCH] initial commitment [SVN r28874] --- include/boost/range/detail/remove_extent.hpp | 138 ++++++++++++ include/boost/range/detail/vc6/end.hpp | 170 +++++++++++++++ include/boost/range/detail/vc6/size.hpp | 211 +++++++++++++++++++ 3 files changed, 519 insertions(+) create mode 100755 include/boost/range/detail/remove_extent.hpp create mode 100755 include/boost/range/detail/vc6/end.hpp create mode 100755 include/boost/range/detail/vc6/size.hpp diff --git a/include/boost/range/detail/remove_extent.hpp b/include/boost/range/detail/remove_extent.hpp new file mode 100755 index 0000000..6b69041 --- /dev/null +++ b/include/boost/range/detail/remove_extent.hpp @@ -0,0 +1,138 @@ +// Boost.Range library +// +// Copyright Jonathan Turkanis 2005. Use, modification and +// distribution is subject to the Boost Software License, Version +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// For more information, see http://www.boost.org/libs/range/ +// + + +#ifndef BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP +#define BOOST_RANGE_DETAIL_REMOVE_BOUNDS_HPP + +#include // MSVC, NO_INTRINSIC_WCHAR_T, put size_t in std. +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + + template< typename Case1 = mpl::true_, + typename Type1 = mpl::void_, + typename Case2 = mpl::true_, + typename Type2 = mpl::void_, + typename Case3 = mpl::true_, + typename Type3 = mpl::void_, + typename Case4 = mpl::true_, + typename Type4 = mpl::void_, + typename Case5 = mpl::true_, + typename Type5 = mpl::void_, + typename Case6 = mpl::true_, + typename Type6 = mpl::void_, + typename Case7 = mpl::true_, + typename Type7 = mpl::void_, + typename Case8 = mpl::true_, + typename Type8 = mpl::void_, + typename Case9 = mpl::true_, + typename Type9 = mpl::void_, + typename Case10 = mpl::true_, + typename Type10 = mpl::void_, + typename Case11 = mpl::true_, + typename Type11 = mpl::void_, + typename Case12 = mpl::true_, + typename Type12 = mpl::void_, + typename Case13 = mpl::true_, + typename Type13 = mpl::void_, + typename Case14 = mpl::true_, + typename Type14 = mpl::void_, + typename Case15 = mpl::true_, + typename Type15 = mpl::void_, + typename Case16 = mpl::true_, + typename Type16 = mpl::void_, + typename Case17 = mpl::true_, + typename Type17 = mpl::void_, + typename Case18 = mpl::true_, + typename Type18 = mpl::void_, + typename Case19 = mpl::true_, + typename Type19 = mpl::void_, + typename Case20 = mpl::true_, + typename Type20 = mpl::void_> + struct select { + typedef typename + mpl::eval_if< + Case1, mpl::identity, mpl::eval_if< + Case2, mpl::identity, mpl::eval_if< + Case3, mpl::identity, mpl::eval_if< + Case4, mpl::identity, mpl::eval_if< + Case5, mpl::identity, mpl::eval_if< + Case6, mpl::identity, mpl::eval_if< + Case7, mpl::identity, mpl::eval_if< + Case8, mpl::identity, mpl::eval_if< + Case9, mpl::identity, mpl::if_< + Case10, Type10, mpl::void_ > > > > > > > > > + >::type temp1; + typedef typename + mpl::eval_if< + Case11, mpl::identity, mpl::eval_if< + Case12, mpl::identity, mpl::eval_if< + Case13, mpl::identity, mpl::eval_if< + Case14, mpl::identity, mpl::eval_if< + Case15, mpl::identity, mpl::eval_if< + Case16, mpl::identity, mpl::eval_if< + Case17, mpl::identity, mpl::eval_if< + Case18, mpl::identity, mpl::eval_if< + Case19, mpl::identity, mpl::if_< + Case20, Type20, mpl::void_ > > > > > > > > > + > temp2; + typedef typename + mpl::eval_if< + is_same, + temp2, + mpl::identity + >::type type; + }; + + template + struct remove_extent { + static T* ar; + BOOST_STATIC_CONSTANT(std::size_t, size = sizeof(*ar) / sizeof((*ar)[0])); + + typedef typename + select< + is_same, bool, + is_same, char, + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + is_same, wchar_t, + #endif + is_same, short, + is_same, unsigned short, + is_same, int, + is_same, unsigned int, + is_same, long, + is_same, unsigned long, + is_same, const bool, + is_same, const char, + #ifndef BOOST_NO_INTRINSIC_WCHAR_T + is_same, const wchar_t, + #endif + is_same, const short, + is_same, const unsigned short, + is_same, const int, + is_same, const unsigned int, + is_same, const long, + is_same, const unsigned long + >::type type; + }; + + } // namespace 'range_detail' + +} // namespace 'boost' + + +#endif diff --git a/include/boost/range/detail/vc6/end.hpp b/include/boost/range/detail/vc6/end.hpp new file mode 100755 index 0000000..4f76af5 --- /dev/null +++ b/include/boost/range/detail/vc6/end.hpp @@ -0,0 +1,170 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2004. Use, modification and +// distribution is subject to the Boost Software License, Version +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#ifndef BOOST_RANGE_DETAIL_VC6_END_HPP +#define BOOST_RANGE_DETAIL_VC6_END_HPP + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template< typename T > + struct range_end; + + ////////////////////////////////////////////////////////////////////// + // default + ////////////////////////////////////////////////////////////////////// + + template<> + struct range_end + { + template< typename C > + struct inner { + static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator::type + fun( C& c ) + { + return c.end(); + }; + }; + }; + + ////////////////////////////////////////////////////////////////////// + // pair + ////////////////////////////////////////////////////////////////////// + + template<> + struct range_end + { + template< typename P > + struct inner { + static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator

::type + fun( const P& p ) + { + return p.second; + } + }; + }; + + ////////////////////////////////////////////////////////////////////// + // array + ////////////////////////////////////////////////////////////////////// + + template<> + struct range_end + { + template< typename T > + struct inner { + static BOOST_DEDUCED_TYPENAME remove_extent::type* + fun(T& t) + { + return t + remove_extent::size; + } + }; + }; + + + template<> + struct range_end + { + template< typename T > + struct inner { + static BOOST_DEDUCED_TYPENAME remove_extent::type* + fun(T& t) + { + return t + remove_extent::size; + } + }; + }; + + template<> + struct range_end + { + template< typename T > + struct inner { + static BOOST_DEDUCED_TYPENAME remove_extent::type* + fun(T& t) + { + return t + remove_extent::size; + } + }; + }; + + ////////////////////////////////////////////////////////////////////// + // string + ////////////////////////////////////////////////////////////////////// + + template<> + struct range_end + { + template< typename T > + struct inner { + static char* fun( char* s ) + { + return boost::range_detail::str_end( s ); + } + }; + }; + + template<> + struct range_end + { + template< typename T > + struct inner { + static const char* fun( const char* s ) + { + return boost::range_detail::str_end( s ); + } + }; + }; + + template<> + struct range_end + { + template< typename T > + struct inner { + static wchar_t* fun( wchar_t* s ) + { + return boost::range_detail::str_end( s ); + } + }; + }; + + + template<> + struct range_end + { + template< typename T > + struct inner { + static const wchar_t* fun( const wchar_t* s ) + { + return boost::range_detail::str_end( s ); + } + }; + }; + + } // namespace 'range_detail' + + template< typename C > + inline BOOST_DEDUCED_TYPENAME range_result_iterator::type + end( C& c ) + { + return range_detail::range_end::type>::inner::fun( c ); + } + +} // namespace 'boost' + + +#endif diff --git a/include/boost/range/detail/vc6/size.hpp b/include/boost/range/detail/vc6/size.hpp new file mode 100755 index 0000000..ae416f6 --- /dev/null +++ b/include/boost/range/detail/vc6/size.hpp @@ -0,0 +1,211 @@ +// Boost.Range library +// +// Copyright Thorsten Ottosen 2003-2004. Use, modification and +// distribution is subject to the Boost Software License, Version +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// For more information, see http://www.boost.org/libs/range/ +// + + +#ifndef BOOST_RANGE_DETAIL_VC6_SIZE_HPP +#define BOOST_RANGE_DETAIL_VC6_SIZE_HPP + +#include +#include +#include +#include +#include + +namespace boost +{ + namespace range_detail + { + template< typename T > + struct range_size_; + + struct range_size_std_container_ + { + template< typename C > + static BOOST_RANGE_DEDUCED_TYPENAME C::size_type fun( const C& c ) + { + return c.size(); + }; + }; + + ////////////////////////////////////////////////////////////////////// + // default + ////////////////////////////////////////////////////////////////////// + + template<> + struct range_size_ + { + template< typename C > + struct inner { + static BOOST_RANGE_DEDUCED_TYPENAME C::size_type fun( const C& c ) + { + return range_size_std_container_::fun(c.size()); + }; + }; + }; + + ////////////////////////////////////////////////////////////////////// + // pair + ////////////////////////////////////////////////////////////////////// + + struct range_size_std_pair_ { + template< typename P > + static BOOST_RANGE_DEDUCED_TYPENAME range_size

::type + fun( const P& p ) + { + return std::distance( p.first, p.second ); + } + }; + + template<> + struct range_size_ + { + template< typename P > + struct inner { + static BOOST_RANGE_DEDUCED_TYPENAME range_size

::type + fun( const P& p ) + { + return range_size_std_pair_::fun( p ); + } + }; + }; + + ////////////////////////////////////////////////////////////////////// + // array + ////////////////////////////////////////////////////////////////////// + + struct range_size_array_ + { + template + static std::size_t fun(T& t) + { + return remove_extent::size; + } + }; + + template<> + struct range_size_ + { + template + struct inner { + static std::size_t fun(T& t) + { + return remove_extent::size; + } + }; + }; + + struct range_size_char_array_ + { + template + static std::size_t fun(T& t) + { + return sizeof(T) / sizeof(T[0]); + } + }; + + template<> + struct range_size_ + { + template + struct inner { + static std::size_t fun(T& t) + { + range_size_char_array_::fun(t); + } + }; + }; + + struct range_size_wchar_t_array_ + { + template + static std::size_t fun(T& t) + { + return sizeof(T) / sizeof(T[0]); + } + }; + + template<> + struct range_size_ + { + template + struct inner { + static std::size_t fun(T& t) + { + range_size_wchar_t_array_::fun(t); + } + }; + }; + + ////////////////////////////////////////////////////////////////////// + // string + ////////////////////////////////////////////////////////////////////// + + template<> + struct range_size_ + { + template + struct inner { + static std::size_t fun( const char* s ) + { + return boost::range_detail::str_size( s ); + } + }; + }; + + template<> + struct range_size_ + { + template + struct inner { + static std::size_t fun( const char* s ) + { + return boost::range_detail::str_size( s ); + } + }; + }; + + template<> + struct range_size_ + { + template + struct inner { + static std::size_t fun( const wchar_t* s ) + { + return boost::range_detail::str_size( s ); + } + }; + }; + + template<> + struct range_size_ + { + template + struct inner { + static std::size_t fun( const wchar_t* s ) + { + return boost::range_detail::str_size( s ); + } + }; + }; + + } // namespace 'range_detail' + + + template< typename C > + BOOST_RANGE_DEDUCED_TYPENAME range_size::type + size( const C& c ) + { + return range_detail::range_size_::type>::inner::fun( c ); + } + +} // namespace 'boost' + + +#endif