forked from boostorg/range
initial commitment
[SVN r28874]
This commit is contained in:
138
include/boost/range/detail/remove_extent.hpp
Executable file
138
include/boost/range/detail/remove_extent.hpp
Executable file
@ -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 <boost/config.hpp> // MSVC, NO_INTRINSIC_WCHAR_T, put size_t in std.
|
||||
#include <cstddef>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
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<Type1>, mpl::eval_if<
|
||||
Case2, mpl::identity<Type2>, mpl::eval_if<
|
||||
Case3, mpl::identity<Type3>, mpl::eval_if<
|
||||
Case4, mpl::identity<Type4>, mpl::eval_if<
|
||||
Case5, mpl::identity<Type5>, mpl::eval_if<
|
||||
Case6, mpl::identity<Type6>, mpl::eval_if<
|
||||
Case7, mpl::identity<Type7>, mpl::eval_if<
|
||||
Case8, mpl::identity<Type8>, mpl::eval_if<
|
||||
Case9, mpl::identity<Type9>, mpl::if_<
|
||||
Case10, Type10, mpl::void_ > > > > > > > > >
|
||||
>::type temp1;
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
Case11, mpl::identity<Type11>, mpl::eval_if<
|
||||
Case12, mpl::identity<Type12>, mpl::eval_if<
|
||||
Case13, mpl::identity<Type13>, mpl::eval_if<
|
||||
Case14, mpl::identity<Type14>, mpl::eval_if<
|
||||
Case15, mpl::identity<Type15>, mpl::eval_if<
|
||||
Case16, mpl::identity<Type16>, mpl::eval_if<
|
||||
Case17, mpl::identity<Type17>, mpl::eval_if<
|
||||
Case18, mpl::identity<Type18>, mpl::eval_if<
|
||||
Case19, mpl::identity<Type19>, mpl::if_<
|
||||
Case20, Type20, mpl::void_ > > > > > > > > >
|
||||
> temp2;
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
is_same<temp1, mpl::void_>,
|
||||
temp2,
|
||||
mpl::identity<temp1>
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct remove_extent {
|
||||
static T* ar;
|
||||
BOOST_STATIC_CONSTANT(std::size_t, size = sizeof(*ar) / sizeof((*ar)[0]));
|
||||
|
||||
typedef typename
|
||||
select<
|
||||
is_same<T, bool[size]>, bool,
|
||||
is_same<T, char[size]>, char,
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
is_same<T, wchar_t[size]>, wchar_t,
|
||||
#endif
|
||||
is_same<T, short[size]>, short,
|
||||
is_same<T, unsigned short[size]>, unsigned short,
|
||||
is_same<T, int[size]>, int,
|
||||
is_same<T, unsigned int[size]>, unsigned int,
|
||||
is_same<T, long[size]>, long,
|
||||
is_same<T, unsigned long[size]>, unsigned long,
|
||||
is_same<T, const bool[size]>, const bool,
|
||||
is_same<T, const char[size]>, const char,
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
is_same<T, const wchar_t[size]>, const wchar_t,
|
||||
#endif
|
||||
is_same<T, const short[size]>, const short,
|
||||
is_same<T, const unsigned short[size]>, const unsigned short,
|
||||
is_same<T, const int[size]>, const int,
|
||||
is_same<T, const unsigned int[size]>, const unsigned int,
|
||||
is_same<T, const long[size]>, const long,
|
||||
is_same<T, const unsigned long[size]>, const unsigned long
|
||||
>::type type;
|
||||
};
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
#endif
|
170
include/boost/range/detail/vc6/end.hpp
Executable file
170
include/boost/range/detail/vc6/end.hpp
Executable file
@ -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 <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/result_iterator.hpp>
|
||||
#include <boost/range/detail/common.hpp>
|
||||
#include <boost/range/detail/remove_extent.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
template< typename T >
|
||||
struct range_end;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// default
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<std_container_>
|
||||
{
|
||||
template< typename C >
|
||||
struct inner {
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type
|
||||
fun( C& c )
|
||||
{
|
||||
return c.end();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// pair
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<std_pair_>
|
||||
{
|
||||
template< typename P >
|
||||
struct inner {
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type
|
||||
fun( const P& p )
|
||||
{
|
||||
return p.second;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
|
||||
fun(T& t)
|
||||
{
|
||||
return t + remove_extent<T>::size;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct range_end<char_array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
|
||||
fun(T& t)
|
||||
{
|
||||
return t + remove_extent<T>::size;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<wchar_t_array_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
|
||||
fun(T& t)
|
||||
{
|
||||
return t + remove_extent<T>::size;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_end<char_ptr_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static char* fun( char* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<const_char_ptr_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static const char* fun( const char* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_end<wchar_t_ptr_>
|
||||
{
|
||||
template< typename T >
|
||||
struct inner {
|
||||
static wchar_t* fun( wchar_t* s )
|
||||
{
|
||||
return boost::range_detail::str_end( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct range_end<const_wchar_t_ptr_>
|
||||
{
|
||||
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<C>::type
|
||||
end( C& c )
|
||||
{
|
||||
return range_detail::range_end<range_detail::range<C>::type>::inner<C>::fun( c );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
#endif
|
211
include/boost/range/detail/vc6/size.hpp
Executable file
211
include/boost/range/detail/vc6/size.hpp
Executable file
@ -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 <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/detail/size_type.hpp>
|
||||
#include <boost/range/detail/common.hpp>
|
||||
#include <boost/range/detail/remove_extent.hpp>
|
||||
#include <iterator>
|
||||
|
||||
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_<std_container_>
|
||||
{
|
||||
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<P>::type
|
||||
fun( const P& p )
|
||||
{
|
||||
return std::distance( p.first, p.second );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<std_pair_>
|
||||
{
|
||||
template< typename P >
|
||||
struct inner {
|
||||
static BOOST_RANGE_DEDUCED_TYPENAME range_size<P>::type
|
||||
fun( const P& p )
|
||||
{
|
||||
return range_size_std_pair_::fun( p );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// array
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct range_size_array_
|
||||
{
|
||||
template<typename T>
|
||||
static std::size_t fun(T& t)
|
||||
{
|
||||
return remove_extent<T>::size;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<array_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun(T& t)
|
||||
{
|
||||
return remove_extent<T>::size;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct range_size_char_array_
|
||||
{
|
||||
template<typename T>
|
||||
static std::size_t fun(T& t)
|
||||
{
|
||||
return sizeof(T) / sizeof(T[0]);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<char_array_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun(T& t)
|
||||
{
|
||||
range_size_char_array_::fun(t);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct range_size_wchar_t_array_
|
||||
{
|
||||
template<typename T>
|
||||
static std::size_t fun(T& t)
|
||||
{
|
||||
return sizeof(T) / sizeof(T[0]);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<wchar_t_array_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun(T& t)
|
||||
{
|
||||
range_size_wchar_t_array_::fun(t);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// string
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<>
|
||||
struct range_size_<char_ptr_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun( const char* s )
|
||||
{
|
||||
return boost::range_detail::str_size( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<const_char_ptr_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun( const char* s )
|
||||
{
|
||||
return boost::range_detail::str_size( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<wchar_t_ptr_>
|
||||
{
|
||||
template<typename T>
|
||||
struct inner {
|
||||
static std::size_t fun( const wchar_t* s )
|
||||
{
|
||||
return boost::range_detail::str_size( s );
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct range_size_<const_wchar_t_ptr_>
|
||||
{
|
||||
template<typename T>
|
||||
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<C>::type
|
||||
size( const C& c )
|
||||
{
|
||||
return range_detail::range_size_<range_detail::range<C>::type>::inner<C>::fun( c );
|
||||
}
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user