make use of partial template specialization where available.

-> fixed metrowerks


[SVN r22555]
This commit is contained in:
Pavol Droba
2004-03-26 09:14:17 +00:00
parent 6dccaf3fcb
commit d9f4e3524d
5 changed files with 209 additions and 52 deletions

View File

@ -35,6 +35,8 @@ namespace boost {
// sequence traits -----------------------------------------------//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//! Native replace tester
/*!
Declare an override of this tester function with return
@ -45,21 +47,6 @@ namespace boost {
*/
no_type has_native_replace_tester(...);
//! Native replace trait
/*!
This trait specifies that the sequence has \c std::string like replace method
*/
template< typename T >
class has_native_replace
{
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_native_replace_tester(t))==sizeof(yes_type) ) );
typedef mpl::bool_<value> type;
};
//! Stable iterators tester
/*!
Declare an override of this tester function with return
@ -70,23 +57,6 @@ namespace boost {
*/
no_type has_stable_iterators_tester(...);
//! Stable iterators trait
/*!
This trait specifies that the sequence has stable iterators. It means,
that operations like insert/erase/replace do not invalidate iterators.
*/
template< typename T >
class has_stable_iterators
{
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_stable_iterators_tester(t))==sizeof(yes_type) ) );
typedef mpl::bool_<value> type;
};
//! const time insert tester
/*!
Declare an override of this tester function with return
@ -96,22 +66,6 @@ namespace boost {
*/
no_type has_const_time_insert_tester(...);
//! Const time insert trait
/*!
This trait specifies that the sequence's insert method has
constant time complexity.
*/
template< typename T >
class has_const_time_insert
{
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_const_time_insert_tester(t))==sizeof(yes_type) ) );
typedef mpl::bool_<value> type;
};
//! const time erase tester
/*!
Declare an override of this tester function with return
@ -121,6 +75,78 @@ namespace boost {
*/
no_type has_const_time_erase_tester(...);
#endif //BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//! Native replace trait
/*!
This trait specifies that the sequence has \c std::string like replace method
*/
template< typename T >
class has_native_replace
{
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_native_replace_tester(t))==sizeof(yes_type) ) );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
public:
BOOST_STATIC_CONSTANT(bool, value=false);
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef mpl::bool_<value> type;
};
//! Stable iterators trait
/*!
This trait specifies that the sequence has stable iterators. It means,
that operations like insert/erase/replace do not invalidate iterators.
*/
template< typename T >
class has_stable_iterators
{
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_stable_iterators_tester(t))==sizeof(yes_type) ) );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
public:
BOOST_STATIC_CONSTANT(bool, value=false);
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef mpl::bool_<value> type;
};
//! Const time insert trait
/*!
This trait specifies that the sequence's insert method has
constant time complexity.
*/
template< typename T >
class has_const_time_insert
{
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_const_time_insert(t))==sizeof(yes_type) ) );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
public:
BOOST_STATIC_CONSTANT(bool, value=false);
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef mpl::bool_<value> type;
};
//! Const time erase trait
/*!
This trait specifies that the sequence's erase method has
@ -129,11 +155,17 @@ namespace boost {
template< typename T >
class has_const_time_erase
{
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
private:
static T* t;
public:
BOOST_STATIC_CONSTANT(bool, value=(
sizeof(has_const_time_erase_tester(t))==sizeof(yes_type) ) );
sizeof(has_const_time_erase))==sizeof(yes_type) ) );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
public:
BOOST_STATIC_CONSTANT(bool, value=false);
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef mpl::bool_<value> type;
};

View File

@ -18,18 +18,52 @@ namespace boost {
// std::list<> traits -----------------------------------------------//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// stable iterators tester
template<typename T, typename AllocT>
yes_type has_stable_iterators_tester( const std::list<T,AllocT>* );
yes_type has_stable_iterators_tester( const ::std::list<T,AllocT>* )
// const time insert tester
template<typename T, typename AllocT>
yes_type has_const_time_insert_tester( const std::list<T,AllocT>* );
yes_type has_const_time_insert_tester( const ::std::list<T,AllocT>* )
// const time erase tester
template<typename T, typename AllocT>
yes_type has_const_time_erase_tester( const std::list<T,AllocT>* );
yes_type has_const_time_erase_tester( const ::std::list<T,AllocT>* );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// stable iterators trait
template<typename T, typename AllocT>
class has_stable_iterators< ::std::list<T,AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
// const time insert trait
template<typename T, typename AllocT>
class has_const_time_insert< ::std::list<T,AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
// const time erase trait
template<typename T, typename AllocT>
class has_const_time_erase< ::std::list<T,AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
#endif
} // namespace algorithm
} // namespace boost

View File

@ -18,6 +18,8 @@ namespace boost {
// SGI's std::rope<> traits -----------------------------------------------//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// native replace tester
template<typename T, typename TraitsT, typename AllocT>
yes_type has_native_replace_tester( const std::rope<T, TraitsT, AllocT>* );
@ -34,6 +36,46 @@ namespace boost {
template<typename T, typename TraitsT, typename AllocT>
yes_type has_const_time_erase_tester( const std::rope<T, TraitsT, AllocT>* );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// native replace trait
template<typename T, typename TraitsT, typename AllocT>
class has_native_replace< std::rope<T,TraitsT,AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
// stable iterators trait
template<typename T, typename TraitsT, typename AllocT>
class has_stable_iterators< std::rope<T,TraitsT,AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
// const time insert trait
template<typename T, typename TraitsT, typename AllocT>
class has_const_time_insert< std::rope<T,TraitsT,AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
// const time erase trait
template<typename T, typename TraitsT, typename AllocT>
class has_const_time_erase< std::rope<T,TraitsT,AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
#endif
} // namespace algorithm
} // namespace boost

View File

@ -18,6 +18,8 @@ namespace boost {
// SGI's std::slist<> traits -----------------------------------------------//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// stable iterators tester
template<typename T, typename AllocT>
yes_type has_stable_iterators_tester( const std::slist<T,AllocT>* );
@ -30,6 +32,37 @@ namespace boost {
template<typename T, typename AllocT>
yes_type has_const_time_erase_tester( const std::slist<T,AllocT>* );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// stable iterators trait
template<typename T, typename AllocT>
class has_stable_iterators< std::slist<T,AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
// const time insert trait
template<typename T, typename AllocT>
class has_const_time_insert< std::slist<T,AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
// const time erase trait
template<typename T, typename AllocT>
class has_const_time_erase< std::slist<T,AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
#endif
} // namespace algorithm
} // namespace boost

View File

@ -18,10 +18,26 @@ namespace boost {
// std::basic_string<> traits -----------------------------------------------//
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// native replace tester
template<typename T, typename TraitsT, typename AllocT>
yes_type has_native_replace_tester( const std::basic_string<T, TraitsT, AllocT>* );
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// native replace trait
template<typename T, typename TraitsT, typename AllocT>
class has_native_replace< std::basic_string<T, TraitsT, AllocT> >
{
public:
BOOST_STATIC_CONSTANT(bool, value=true);
typedef mpl::bool_<value> type;
};
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
} // namespace algorithm
} // namespace boost