*** empty log message ***

[SVN r23240]
This commit is contained in:
Thorsten Jørgen Ottosen
2004-06-29 02:50:07 +00:00
commit 6a455033ee
35 changed files with 3239 additions and 0 deletions

View File

@ -0,0 +1,120 @@
// 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_BEGIN_HPP
#define BOOST_RANGE_DETAIL_BEGIN_HPP
#include <boost/range/detail/result_iterator.hpp>
#include <boost/range/detail/common.hpp>
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_begin;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<std_container_>
{
template< typename C >
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<C>::type fun( C& c )
{
return c.begin();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<std_pair_>
{
template< typename P >
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<P>::type fun( const P& p )
{
return p.first;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<array_>
{
template< typename T, std::size_t sz >
static T* fun( T BOOST_ARRAY_REF[sz] )
{
return array;
}
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<char_ptr_>
{
static char* fun( char* s )
{
return s;
}
};
template<>
struct range_begin<const_char_ptr_>
{
static const char* fun( const char* s )
{
return s;
}
};
template<>
struct range_begin<wchar_t_ptr_>
{
static wchar_t* fun( wchar_t* s )
{
return s;
}
};
template<>
struct range_begin<const_wchar_t_ptr_>
{
static const wchar_t* fun( const wchar_t* s )
{
return s;
}
};
} // namespace 'range_traits_detail'
template< typename C >
inline BOOST_DEDUCED_TYPENAME result_iterator_of<C>::type
begin( C& c )
{
return range_traits_detail::range_begin< BOOST_DEDUCED_TYPENAME range_traits_detail::range<C>::type >::fun( c );
}
} // namespace 'boost'
#endif

View File

@ -0,0 +1,117 @@
// 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_COMMON_HPP
#define BOOST_RANGE_DETAIL_COMMON_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <boost/range/detail/sfinae.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/detail/ice_or.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <cstddef>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
// 1 = std containers
// 2 = std::pair
// 3 = const std::pair
// 4 = array
// 5 = const array
// 6 = char array
// 7 = wchar_t array
// 8 = char*
// 9 = const char*
// 10 = whar_t*
// 11 = const wchar_t*
// 12 = string
typedef mpl::int_<1>::type std_container_;
typedef mpl::int_<2>::type std_pair_;
typedef mpl::int_<3>::type const_std_pair_;
typedef mpl::int_<4>::type array_;
typedef mpl::int_<5>::type const_array_;
typedef mpl::int_<6>::type char_array_;
typedef mpl::int_<7>::type wchar_t_array_;
typedef mpl::int_<8>::type char_ptr_;
typedef mpl::int_<9>::type const_char_ptr_;
typedef mpl::int_<10>::type wchar_t_ptr_;
typedef mpl::int_<11>::type const_wchar_t_ptr_;
typedef mpl::int_<12>::type string_;
template< typename C >
struct collection_helper
{
static C* c;
static C ptr;
BOOST_STATIC_CONSTANT( bool, is_pair_ = sizeof( boost::range_detail::is_pair_impl( c ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_char_ptr_ = sizeof( boost::range_detail::is_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_const_char_ptr_ = sizeof( boost::range_detail::is_const_char_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_wchar_t_ptr_ = sizeof( boost::range_detail::is_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) );
BOOST_STATIC_CONSTANT( bool, is_string_ = (boost::type_traits::ice_or<is_const_char_ptr_, is_const_wchar_t_ptr_>::value ));
BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array<C>::value );
};
template< typename C >
class range
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_pair_,
boost::range_detail::std_pair_,
void >::type pair_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_array_,
boost::range_detail::array_,
pair_t >::type array_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_string_,
boost::range_detail::string_,
array_t >::type string_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_const_char_ptr_,
boost::range_detail::const_char_ptr_,
string_t >::type const_char_ptr_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_char_ptr_,
boost::range_detail::char_ptr_,
const_char_ptr_t >::type char_ptr_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_const_wchar_t_ptr_,
boost::range_detail::const_wchar_t_ptr_,
char_ptr_t >::type const_wchar_ptr_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_wchar_t_ptr_,
boost::range_detail::wchar_t_ptr_,
const_wchar_ptr_t >::type wchar_ptr_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_wchar_t_array_,
boost::range_detail::wchar_t_array_,
wchar_ptr_t >::type wchar_array_t;
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::range_detail::collection_helper<C>::is_char_array_,
boost::range_detail::char_array_,
wchar_array_t >::type char_array_t;
public:
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< boost::is_void<char_array_t>::value,
boost::range_detail::std_container_,
char_array_t >::type type;
}; // class 'range'
}
}
#endif

View File

@ -0,0 +1,102 @@
// 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_CONST_ITERATOR_HPP
#define BOOST_RANGE_DETAIL_CONST_ITERATOR_HPP
#include <boost/range/detail/common.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_const_iterator_;
template<>
struct range_const_iterator_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::const_iterator type;
};
};
template<>
struct range_const_iterator_<std_pair_>
{
template< typename P >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME P::first_type type;
};
};
template<>
struct range_const_iterator_<array_>; // give up
template<>
struct range_const_iterator_<char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_const_iterator_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_const_iterator_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
template<>
struct range_const_iterator_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
}
template< typename C >
class const_iterator_of
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_DEDUCED_TYPENAME range_detail::range_const_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}
#endif

View File

@ -0,0 +1,111 @@
// 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_DIFFERENCE_TYPE_HPP
#define BOOST_RANGE_DETAIL_DIFFERENCE_TYPE_HPP
#include <boost/range/detail/common.hpp>
#include <boost/iterator/iterator_traits.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_difference_type_;
template<>
struct range_difference_type_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::difference_type type;
};
};
template<>
struct range_difference_type_<std_pair_>
{
template< typename P >
struct pts
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::iterator_difference< BOOST_DEDUCED_TYPENAME P::first_type>::type type;
};
};
template<>
struct range_difference_type_<array_>
{
template< typename A >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<char_ptr_>
{
template< typename S >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::ptrdiff_t type;
};
};
template<>
struct range_difference_type_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::ptrdiff_t type;
};
};
}
template< typename C >
class difference_type_of
{
typedef BOOST_CT_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_CT_DEDUCED_TYPENAME range_detail::range_difference_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}
#endif

View File

@ -0,0 +1,120 @@
// 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_EMPTY_HPP
#define BOOST_RANGE_DETAIL_EMPTY_HPP
#include <boost/range/detail/common.hpp>
namespace boost
{
namespace range_detail
{
template< typename T >
struct collection_empty;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct collection_empty<std_container_>
{
template< typename C >
static bool fun( C& c )
{
return c.empty();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct collection_empty<std_pair_>
{
template< typename P >
static bool fun( const P& p )
{
return p.first == p.second;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct collection_empty<array_>
{
template< typename T, std::size_t sz >
static bool fun( T BOOST_ARRAY_REF[sz] )
{
if( array == 0 )
return true;
return false;
}
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct collection_empty<char_ptr_>
{
static bool fun( const char* s )
{
return s == 0 || s[0] == 0;
}
};
template<>
struct collection_empty<const_char_ptr_>
{
static bool fun( const char* s )
{
return s == 0 || s[0] == 0;
}
};
template<>
struct collection_empty<wchar_t_ptr_>
{
static bool fun( const wchar_t* s )
{
return s == 0 || s[0] == 0;
}
};
template<>
struct collection_empty<const_wchar_t_ptr_>
{
static bool fun( const wchar_t* s )
{
return s == 0 || s[0] == 0;
}
};
} // namespace 'range_detail'
template< typename C >
inline bool
empty( const C& c )
{
return range_detail::collection_empty< BOOST_CT_DEDUCED_TYPENAME range_detail::collection<C>::type >::fun( c );
}
} // namespace 'boost'
#endif

View File

@ -0,0 +1,141 @@
// 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_END_HPP
#define BOOST_RANGE_DETAIL_END_HPP
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/detail/result_iterator.hpp>
#include <boost/range/detail/common.hpp>
namespace boost
{
namespace range_detail
{
template< typename T >
struct collection_end;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct collection_end<std_container_>
{
template< typename C >
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<C>::type fun( C& c )
{
return c.end();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct collection_end<std_pair_>
{
template< typename P >
static BOOST_CT_DEDUCED_TYPENAME result_iterator_of<P>::type fun( const P& p )
{
return p.second;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct collection_end<array_>
{
template< typename T, std::size_t sz >
static T* fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_end( array );
}
};
template<>
struct collection_end<char_array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_end( array );
}
};
template<>
struct collection_end<wchar_t_array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_end( array );
}
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct collection_end<char_ptr_>
{
static char* fun( char* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct collection_end<const_char_ptr_>
{
static const char* fun( const char* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct collection_end<wchar_t_ptr_>
{
static wchar_t* fun( wchar_t* s )
{
return boost::range_detail::str_end( s );
}
};
template<>
struct collection_end<const_wchar_t_ptr_>
{
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 result_iterator_of<C>::type
end( C& c )
{
return range_detail::collection_end< BOOST_DEDUCED_TYPENAME range_detail::collection<C>::type >::fun( c );
}
} // namespace 'boost'
#endif

View File

@ -0,0 +1,161 @@
// 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_IMPLEMENTATION_HELP_HPP
#define BOOST_RANGE_DETAIL_IMPLEMENTATION_HELP_HPP
#include <boost/range/config.hpp>
#include <boost/range/detail/common.hpp>
#include <boost/type_traits/is_same.hpp>
#include <cstddef>
#include <string.h>
#ifndef BOOST_NO_CWCHAR
#include <wchar.h>
#endif
namespace boost
{
namespace range_detail
{
/////////////////////////////////////////////////////////////////////
// end() help
/////////////////////////////////////////////////////////////////////
inline const char* str_end( const char* s, const char* )
{
return s + strlen( s );
}
#ifndef BOOST_NO_CWCHAR
inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
{
return s + wcslen( s );
}
#else
inline const wchar_t* str_end( const wchar_t* s, const wchar_t* )
{
if( s == 0 && s[0] == 0 )
return s;
while( *++s != 0 )
;
return s;
}
#endif
template< typename Char >
inline Char* str_end( Char* s )
{
return (Char*)str_end( s, s );
}
template< typename T, std::size_t sz >
inline T* array_end( T (&array)[sz], int )
{
return array + sz;
}
template< typename T, std::size_t sz >
inline const T* array_end( const T (&array)[sz], int )
{
return array + sz;
}
template< typename T, std::size_t sz >
inline T* array_end( T (&arrays)[sz], char_or_wchar_t_array_tag )
{
return array + sz - 1;
}
template< typename T, std::size_t sz >
inline const T* array_end( const T (&array)[sz], char_or_wchar_t_array_tag )
{
return array + sz - 1;
}
template< typename T, std::size_t sz >
inline T* array_end( T (&array)[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_end<T,sz>( array, tag() );
}
template< typename T, std::size_t sz >
inline const T* array_end( const T (&array)[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_end<T,sz>( array, tag() );
}
/////////////////////////////////////////////////////////////////////
// size() help
/////////////////////////////////////////////////////////////////////
template< typename Char >
inline std::size_t str_size( const Char* s )
{
return str_end( s ) - s;
}
template< typename T, std::size_t sz >
inline std::size_t array_size( T BOOST_ARRAY_REF[sz], int )
{
return sz;
}
template< typename T, std::size_t sz >
inline std::size_t array_size( const T BOOST_ARRAY_REF[sz], int )
{
return sz;
}
template< typename T, std::size_t sz >
inline std::size_t array_size( T BOOST_ARRAY_REF[sz], char_or_wchar_t_array_tag )
{
return sz - 1;
}
template< typename T, std::size_t sz >
inline std::size_t array_size( const T BOOST_ARRAY_REF[sz], char_or_wchar_t_array_tag )
{
return sz - 1;
}
template< typename T, std::size_t sz >
inline std::size_t array_size( T (&array)[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_size<T,sz>( array, tag() );
}
template< typename T, std::size_t sz >
inline std::size_t array_size( const T (&array)[sz] )
{
typedef BOOST_CT_DEDUCED_TYPENAME boost::mpl::if_c< is_same<char,T>::value || is_same<wchar_t,T>::value,
char_or_wchar_t_array_tag,
int >::type tag;
return array_size<T,sz>( array, tag() );
}
} // namespace 'range_detail'
} // namespace 'boost'
#endif

View File

@ -0,0 +1,101 @@
// 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_ITERATOR_HPP
#define BOOST_RANGE_DETAIL_ITERATOR_HPP
#include <boost/range/detail/common.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_iterator_;
template<>
struct range_iterator_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::iterator type;
};
};
template<>
struct range_iterator_<std_pair_>
{
template< typename P >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME P::first_type type;
};
};
template<>
struct range_iterator_<array_>; // give up
template<>
struct range_iterator_<char_ptr_>
{
template< typename S >
struct pts
{
typedef char* type;
};
};
template<>
struct range_iterator_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char* type;
};
};
template<>
struct range_iterator_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef wchar_t* type;
};
};
template<>
struct range_iterator_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t* type;
};
};
}
template< typename C >
class iterator_of
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_DEDUCED_TYPENAME range_detail::range_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}
#endif

View File

@ -0,0 +1,77 @@
// 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_SFINAE_HPP
#define BOOST_RANGE_DETAIL_SFINAE_HPP
#include <boost/range/config.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <utility>
namespace boost
{
namespace range_detail
{
using type_traits::yes_type;
using type_traits::no_type;
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
yes_type is_string_impl( const char* );
yes_type is_string_impl( const wchar_t* );
no_type is_string_impl( ... );
template< std::size_t sz >
yes_type is_char_array_impl( char BOOST_ARRAY_REF[sz] );
template< std::size_t sz >
yes_type is_char_array_impl( const char BOOST_ARRAY_REF[sz] );
no_type is_char_array_impl( ... );
template< std::size_t sz >
yes_type is_wchar_t_array_impl( wchar_t BOOST_ARRAY_REF[sz] );
template< std::size_t sz >
yes_type is_wchar_t_array_impl( const wchar_t BOOST_ARRAY_REFx[sz] );
no_type is_wchar_t_array_impl( ... );
yes_type is_char_ptr_impl( char* );
no_type is_char_ptr_impl( ... );
yes_type is_const_char_ptr_impl( const char* );
no_type is_const_char_ptr_impl( ... );
yes_type is_wchar_t_ptr_impl( wchar_t* );
no_type is_wchar_t_ptr_impl( ... );
yes_type is_const_wchar_t_ptr_impl( const wchar_t* );
no_type is_const_wchar_t_ptr_impl( ... );
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
yes_type is_pair_impl( const std::pair<Iterator,Iterator>* );
no_type is_pair_impl( ... );
//////////////////////////////////////////////////////////////////////
// tags
//////////////////////////////////////////////////////////////////////
struct char_or_wchar_t_array_tag {};
} // namespace 'range_detail'
} // namespace 'boost'
#endif

View File

@ -0,0 +1,142 @@
// 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_SIZE_HPP
#define BOOST_RANGE_DETAIL_SIZE_HPP
#include <boost/range/detail/implementation_help.hpp>
#include <boost/range/detail/size_type.hpp>
#include <boost/range/detail/common.hpp>
#include <iterator>
namespace boost
{
namespace range_detail
{
template< typename T >
struct collection_size;
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct collection_size<std_container_>
{
template< typename C >
static BOOST_CT_DEDUCED_TYPENAME C::size_type fun( const C& c )
{
return c.size();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct collection_size<std_pair_>
{
template< typename P >
static BOOST_CT_DEDUCED_TYPENAME size_type_of<P>::type fun( const P& p )
{
return std::distance( p.first, p.second );
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct collection_size<array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return sz;
}
};
template<>
struct collection_size<char_array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_size( array );
}
};
template<>
struct collection_size<wchar_t_array_>
{
template< typename T, std::size_t sz >
static std::size_t fun( T BOOST_ARRAY_REF[sz] )
{
return boost::range_detail::array_size( array );
}
};
//////////////////////////////////////////////////////////////////////
// string
//////////////////////////////////////////////////////////////////////
template<>
struct collection_size<char_ptr_>
{
static std::size_t fun( const char* s )
{
return boost::range_detail::str_size( s );
}
};
template<>
struct collection_size<const_char_ptr_>
{
static std::size_t fun( const char* s )
{
return boost::range_detail::str_size( s );
}
};
template<>
struct collection_size<wchar_t_ptr_>
{
static std::size_t fun( const wchar_t* s )
{
return boost::range_detail::str_size( s );
}
};
template<>
struct collection_size<const_wchar_t_ptr_>
{
static std::size_t fun( const wchar_t* s )
{
return boost::range_detail::str_size( s );
}
};
} // namespace 'range_detail'
template< typename C >
BOOST_CT_DEDUCED_TYPENAME size_type_of<C>::type
size( const C& c )
{
return range_detail::collection_size< BOOST_CT_DEDUCED_TYPENAME range_detail::collection<C>::type >::fun( c );
}
} // namespace 'boost'
#endif

View File

@ -0,0 +1,109 @@
// 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_SIZE_TYPE_HPP
#define BOOST_RANGE_DETAIL_SIZE_TYPE_HPP
#include <boost/range/detail/common.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_size_type_;
template<>
struct range_size_type_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
};
};
template<>
struct range_size_type_<std_pair_>
{
template< typename P >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<array_>
{
template< typename A >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<char_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
template<>
struct range_size_type_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef std::size_t type;
};
};
}
template< typename C >
class size_type_of
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_DEDUCED_TYPENAME range_detail::range_size_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}
#endif

View File

@ -0,0 +1,37 @@
// 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_SIZER_HPP
#define BOOST_RANGE_DETAIL_SIZER_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/range/config.hpp>
#include <cstddef>
namespace boost
{
//////////////////////////////////////////////////////////////////////
// constant array size
//////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
char&
sizer( const T BOOST_ARRAY_REF[sz] )[sz];
template< typename T, std::size_t sz >
char&
sizer( T BOOST_ARRAY_REF[sz] )[sz];
} // namespace 'boost'
#endif

View File

@ -0,0 +1,104 @@
// 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_VALUE_TYPE_HPP
#define BOOST_RANGE_DETAIL_VALUE_TYPE_HPP
#include <boost/range/detail/common.hpp>
#include <boost/iterator/iterator_traits.hpp>
//////////////////////////////////////////////////////////////////////////////
// missing partial specialization workaround.
//////////////////////////////////////////////////////////////////////////////
namespace boost
{
namespace range_detail
{
template< typename T >
struct range_value_type_;
template<>
struct range_value_type_<std_container_>
{
template< typename C >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME C::value_type type;
};
};
template<>
struct range_value_type_<std_pair_>
{
template< typename P >
struct pts
{
typedef BOOST_DEDUCED_TYPENAME boost::iterator_value< BOOST_CT_DEDUCED_TYPENAME P::first_type >::type type;
};
};
template<>
struct range_value_type_<array_>; // give up
template<>
struct range_value_type_<char_ptr_>
{
template< typename S >
struct pts
{
typedef char type;
};
};
template<>
struct range_value_type_<const_char_ptr_>
{
template< typename S >
struct pts
{
typedef const char type;
};
};
template<>
struct range_value_type_<wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef wchar_t type;
};
};
template<>
struct range_value_type_<const_wchar_t_ptr_>
{
template< typename S >
struct pts
{
typedef const wchar_t type;
};
};
}
template< typename C >
class value_type_of
{
typedef BOOST_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
public:
typedef BOOST_DEDUCED_TYPENAME range_detail::range_value_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
};
}
#endif