mirror of
https://github.com/boostorg/detail.git
synced 2025-06-27 21:11:07 +02:00
Compare commits
44 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
e08d9254b3 | |||
19ae70bcd8 | |||
8f9b1e35bd | |||
c21dc776d1 | |||
1ee4d8ac0d | |||
69dccc47b5 | |||
cf8fe4f2b1 | |||
66f30e813e | |||
863361ded0 | |||
fe148355a2 | |||
be12189340 | |||
01426d35f3 | |||
a8ae9d9941 | |||
1b51ce460c | |||
aab735c64e | |||
83b8fcefc7 | |||
6b15777c8f | |||
7c91125060 | |||
03b1bb7a1e | |||
58bff4af87 | |||
5044712ff6 | |||
2f6f7af430 | |||
1e0e965f07 | |||
7523daa905 | |||
3cb4fe87a9 | |||
dc1186e73f | |||
d0f656c4da | |||
08a2ab3fe6 | |||
2947fb7051 | |||
cd1eecd245 | |||
9ac4d90d82 | |||
a7ae27dc5b | |||
ddccb755f4 | |||
8ffb174556 | |||
8b60ca8d0a | |||
3cbecf5ddd | |||
82af891892 | |||
4bfd4da650 | |||
37d08acea1 | |||
708fd64f4e | |||
5963c3d44d | |||
4d24f82e6e | |||
de2904c9a1 | |||
9b9d2241a7 |
42
include/boost/cstdlib.hpp
Normal file
42
include/boost/cstdlib.hpp
Normal file
@ -0,0 +1,42 @@
|
||||
// boost/cstdlib.hpp header ------------------------------------------------//
|
||||
|
||||
// (C) Copyright Beman Dawes 2001. Permission to copy, use, modify, sell
|
||||
// and distribute this software is granted provided this copyright notice
|
||||
// appears in all copies. This software is provided "as is" without express or
|
||||
// implied warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
// See http://www.boost.org for updates and documentation.
|
||||
|
||||
// Revision History
|
||||
// 26 Feb 01 Initial version (Beman Dawes)
|
||||
|
||||
#ifndef BOOST_CSTDLIB_HPP
|
||||
#define BOOST_CSTDLIB_HPP
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
// The intent is to propose the following for addition to namespace std
|
||||
// in the C++ Standard Library, and to then deprecate EXIT_SUCCESS and
|
||||
// EXIT_FAILURE. As an implementation detail, this header defines the
|
||||
// new constants in terms of EXIT_SUCCESS and EXIT_FAILURE. In a new
|
||||
// standard, the constants would be implementation-defined, although it
|
||||
// might be worthwhile to "suggest" (which a standard is allowed to do)
|
||||
// values of 0 and 1 respectively.
|
||||
|
||||
// Rationale for having multiple failure values: some environments may
|
||||
// wish to distinguish between different classes of errors.
|
||||
// Rationale for choice of values: programs often use values < 100 for
|
||||
// their own error reporting. Values > 255 are sometimes reserved for
|
||||
// system detected errors. 200/201 were suggested to minimize conflict.
|
||||
|
||||
const int exit_success = EXIT_SUCCESS; // implementation-defined value
|
||||
const int exit_failure = EXIT_FAILURE; // implementation-defined value
|
||||
const int exit_exception_failure = 200; // otherwise uncaught exception
|
||||
const int exit_test_failure = 201; // report_error or
|
||||
// report_critical_error called.
|
||||
}
|
||||
|
||||
#endif
|
||||
|
134
include/boost/detail/catch_exceptions.hpp
Normal file
134
include/boost/detail/catch_exceptions.hpp
Normal file
@ -0,0 +1,134 @@
|
||||
// boost/catch_exceptions.hpp -----------------------------------------------//
|
||||
|
||||
// (C) Copyright Beman Dawes 1995-2001. Permission to copy, use, modify, sell
|
||||
// and distribute this software is granted provided this copyright notice
|
||||
// appears in all copies. This software is provided "as is" without express or
|
||||
// implied warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// Revision History
|
||||
// 13 Jun 01 report_exception() made inline. (John Maddock, Jesse Jones)
|
||||
// 26 Feb 01 Numerous changes suggested during formal review. (Beman)
|
||||
// 25 Jan 01 catch_exceptions.hpp code factored out of cpp_main.cpp.
|
||||
// 22 Jan 01 Remove test_tools dependencies to reduce coupling.
|
||||
// 5 Nov 00 Initial boost version (Beman Dawes)
|
||||
|
||||
#ifndef BOOST_CATCH_EXCEPTIONS_HPP
|
||||
#define BOOST_CATCH_EXCEPTIONS_HPP
|
||||
|
||||
// header dependencies are deliberately restricted to the standard library
|
||||
// to reduce coupling to other boost libraries.
|
||||
#include <string> // for string
|
||||
#include <new> // for bad_alloc
|
||||
#include <typeinfo> // for bad_cast, bad_typeid
|
||||
#include <exception> // for exception, bad_exception
|
||||
#include <stdexcept> // for std exception hierarchy
|
||||
#include <boost/cstdlib.hpp> // for exit codes
|
||||
# if __GNUC__ != 2 || __GNUC_MINOR__ > 96
|
||||
# include <ostream> // for ostream
|
||||
# else
|
||||
# include <iostream> // workaround GNU missing ostream header
|
||||
# endif
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// A separate reporting function was requested during formal review.
|
||||
inline void report_exception( std::ostream & os,
|
||||
const char * name, const char * info )
|
||||
{ os << "\n** uncaught exception: " << name << " " << info << std::endl; }
|
||||
}
|
||||
|
||||
// catch_exceptions ------------------------------------------------------//
|
||||
|
||||
template< class Generator > // Generator is function object returning int
|
||||
int catch_exceptions( Generator function_object,
|
||||
std::ostream & out, std::ostream & err )
|
||||
{
|
||||
int result = 0; // quiet compiler warnings
|
||||
bool exception_thrown = true; // avoid setting result for each excptn type
|
||||
|
||||
try
|
||||
{
|
||||
result = function_object();
|
||||
exception_thrown = false;
|
||||
}
|
||||
|
||||
// As a result of hard experience with strangely interleaved output
|
||||
// under some compilers, there is a lot of use of endl in the code below
|
||||
// where a simple '\n' might appear to do.
|
||||
|
||||
// The rules for catch & arguments are a bit different from function
|
||||
// arguments (ISO 15.3 paragraphs 18 & 19). Apparently const isn't
|
||||
// required, but it doesn't hurt and some programmers ask for it.
|
||||
|
||||
catch ( const char * ex )
|
||||
{ detail::report_exception( out, "", ex ); }
|
||||
catch ( const std::string & ex )
|
||||
{ detail::report_exception( out, "", ex.c_str() ); }
|
||||
|
||||
// std:: exceptions
|
||||
catch ( const std::bad_alloc & ex )
|
||||
{ detail::report_exception( out, "std::bad_alloc:", ex.what() ); }
|
||||
|
||||
# if !defined(__BORLANDC__) || __BORLANDC__ > 0x0551
|
||||
catch ( const std::bad_cast & ex )
|
||||
{ detail::report_exception( out, "std::bad_cast:", ex.what() ); }
|
||||
catch ( const std::bad_typeid & ex )
|
||||
{ detail::report_exception( out, "std::bad_typeid:", ex.what() ); }
|
||||
# else
|
||||
catch ( const std::bad_cast & ex )
|
||||
{ detail::report_exception( out, "std::bad_cast", "" ); }
|
||||
catch ( const std::bad_typeid & ex )
|
||||
{ detail::report_exception( out, "std::bad_typeid", "" ); }
|
||||
# endif
|
||||
|
||||
catch ( const std::bad_exception & ex )
|
||||
{ detail::report_exception( out, "std::bad_exception:", ex.what() ); }
|
||||
catch ( const std::domain_error & ex )
|
||||
{ detail::report_exception( out, "std::domain_error:", ex.what() ); }
|
||||
catch ( const std::invalid_argument & ex )
|
||||
{ detail::report_exception( out, "std::invalid_argument:", ex.what() ); }
|
||||
catch ( const std::length_error & ex )
|
||||
{ detail::report_exception( out, "std::length_error:", ex.what() ); }
|
||||
catch ( const std::out_of_range & ex )
|
||||
{ detail::report_exception( out, "std::out_of_range:", ex.what() ); }
|
||||
catch ( const std::range_error & ex )
|
||||
{ detail::report_exception( out, "std::range_error:", ex.what() ); }
|
||||
catch ( const std::overflow_error & ex )
|
||||
{ detail::report_exception( out, "std::overflow_error:", ex.what() ); }
|
||||
catch ( const std::underflow_error & ex )
|
||||
{ detail::report_exception( out, "std::underflow_error:", ex.what() ); }
|
||||
catch ( const std::logic_error & ex )
|
||||
{ detail::report_exception( out, "std::logic_error:", ex.what() ); }
|
||||
catch ( const std::runtime_error & ex )
|
||||
{ detail::report_exception( out, "std::runtime_error:", ex.what() ); }
|
||||
catch ( const std::exception & ex )
|
||||
{ detail::report_exception( out, "std::exception:", ex.what() ); }
|
||||
|
||||
catch ( ... )
|
||||
{ detail::report_exception( out, "unknown exception", "" ); }
|
||||
|
||||
if ( exception_thrown ) result = boost::exit_exception_failure;
|
||||
|
||||
if ( result != 0 && result != exit_success )
|
||||
{
|
||||
out << std::endl << "**** returning with error code "
|
||||
<< result << std::endl;
|
||||
err
|
||||
<< "********** errors detected; see stdout for details ***********"
|
||||
<< std::endl;
|
||||
}
|
||||
else { out << std::flush << "no errors detected" << std::endl; }
|
||||
|
||||
return result;
|
||||
} // catch_exceptions
|
||||
|
||||
} // boost
|
||||
|
||||
#endif // BOOST_CATCH_EXCEPTIONS_HPP
|
||||
|
435
include/boost/detail/iterator.hpp
Normal file
435
include/boost/detail/iterator.hpp
Normal file
@ -0,0 +1,435 @@
|
||||
// (C) Copyright David Abrahams 2001. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
|
||||
// Boost versions of
|
||||
//
|
||||
// std::iterator_traits<>::iterator_category
|
||||
// std::iterator_traits<>::difference_type
|
||||
// std::distance()
|
||||
//
|
||||
// ...for all compilers and iterators
|
||||
//
|
||||
// Additionally, if X is a pointer
|
||||
// std::iterator_traits<X>::pointer
|
||||
|
||||
// Otherwise, if partial specialization is supported or X is not a pointer
|
||||
// std::iterator_traits<X>::value_type
|
||||
// std::iterator_traits<X>::pointer
|
||||
// std::iterator_traits<X>::reference
|
||||
//
|
||||
// CAVEAT: When using the VC6 standard library, an iterator derived from
|
||||
// std::iterator but not boost::iterator or from one supplied by the standard
|
||||
// will always have pointer == const value_type* and reference == const
|
||||
// value_type&, whether that's correct or not.
|
||||
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
|
||||
// Revision History
|
||||
// 04 Mar 2001 - More attempted fixes for Intel C++ (David Abrahams)
|
||||
// 03 Mar 2001 - Put all implementation into namespace
|
||||
// boost::detail::iterator_traits_. Some progress made on fixes
|
||||
// for Intel compiler. (David Abrahams)
|
||||
// 02 Mar 2001 - Changed BOOST_MSVC to BOOST_MSVC_STD_ITERATOR in a few
|
||||
// places. (Jeremy Siek)
|
||||
// 19 Feb 2001 - Improved workarounds for stock MSVC6; use yes_type and
|
||||
// no_type from type_traits.hpp; stopped trying to remove_cv
|
||||
// before detecting is_pointer, in honor of the new type_traits
|
||||
// semantics. (David Abrahams)
|
||||
// 13 Feb 2001 - Make it work with nearly all standard-conforming iterators
|
||||
// under raw VC6. The one category remaining which will fail is
|
||||
// that of iterators derived from std::iterator but not
|
||||
// boost::iterator and which redefine difference_type.
|
||||
// 11 Feb 2001 - Clean away code which can never be used (David Abrahams)
|
||||
// 09 Feb 2001 - Always have a definition for each traits member, even if it
|
||||
// can't be properly deduced. These will be incomplete types in
|
||||
// some cases (undefined<void>), but it helps suppress MSVC errors
|
||||
// elsewhere (David Abrahams)
|
||||
// 07 Feb 2001 - Support for more of the traits members where possible, making
|
||||
// this useful as a replacement for std::iterator_traits<T> when
|
||||
// used as a default template parameter.
|
||||
// 06 Feb 2001 - Removed useless #includes of standard library headers
|
||||
// (David Abrahams)
|
||||
|
||||
#ifndef ITERATOR_DWA122600_HPP_
|
||||
# define ITERATOR_DWA122600_HPP_
|
||||
|
||||
# include <boost/config.hpp>
|
||||
# include <boost/type_traits.hpp>
|
||||
# include <boost/iterator.hpp>
|
||||
# include <iterator>
|
||||
# include <cstddef>
|
||||
|
||||
# if defined(BOOST_MSVC_STD_ITERATOR)
|
||||
# include <xtree>
|
||||
# include <deque>
|
||||
# include <list>
|
||||
# if 0 && defined(__ICL) // Re-enable this to pick up the Intel fixes where they left off
|
||||
# include <iosfwd>
|
||||
# include <memory>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
|
||||
// STLPort 4.0 and betas have a bug when debugging is enabled and there is no
|
||||
// partial specialization: instead of an iterator_category typedef, the standard
|
||||
// container iterators have _Iterator_category.
|
||||
//
|
||||
// Also, whether debugging is enabled or not, there is a broken specialization
|
||||
// of std::iterator<output_iterator_tag,void,void,void,void> which has no
|
||||
// typedefs but iterator_category.
|
||||
# if defined(__SGI_STL_PORT) && (__SGI_STL_PORT <= 0x410) && !defined(__STL_CLASS_PARTIAL_SPECIALIZATION)
|
||||
|
||||
# ifdef __STL_DEBUG
|
||||
# define BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
|
||||
# endif
|
||||
|
||||
# define BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
|
||||
|
||||
# endif // STLPort <= 4.1b4 && no partial specialization
|
||||
|
||||
namespace boost { namespace detail {
|
||||
# if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR)
|
||||
using std::iterator_traits;
|
||||
using std::distance;
|
||||
# else
|
||||
|
||||
namespace iterator_traits_ {
|
||||
|
||||
// Workarounds for less-capable implementations
|
||||
template <bool is_ptr> struct iterator_traits_select;
|
||||
|
||||
template <class T> struct undefined;
|
||||
template <> struct iterator_traits_select<true>
|
||||
{
|
||||
template <class Ptr>
|
||||
struct traits
|
||||
{
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
typedef Ptr pointer;
|
||||
#ifdef BOOST_MSVC
|
||||
// Keeps MSVC happy under certain circumstances. It seems class template default
|
||||
// arguments are partly instantiated even when not used when the class template
|
||||
// is the return type of a function template.
|
||||
typedef undefined<void> value_type;
|
||||
typedef undefined<void> reference;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
typedef char yes_type;
|
||||
typedef double no_type;
|
||||
|
||||
# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
|
||||
|
||||
no_type bad_category_helper(...);
|
||||
template <class C, class T> yes_type bad_category_helper(std::_DBG_iter<C,T>*);
|
||||
|
||||
template <bool has_bad_category_typedef> struct bad_category_select;
|
||||
template <>
|
||||
struct bad_category_select<true>
|
||||
{
|
||||
template <class Iterator>
|
||||
struct category { typedef typename Iterator::_Iterator_category type; };
|
||||
};
|
||||
template <>
|
||||
struct bad_category_select<false>
|
||||
{
|
||||
template <class Iterator>
|
||||
struct category { typedef typename Iterator::iterator_category type; };
|
||||
};
|
||||
|
||||
template <class Iterator>
|
||||
struct iterator_category_select
|
||||
{
|
||||
private:
|
||||
static Iterator p;
|
||||
enum { has_bad_category
|
||||
= sizeof(bad_category_helper(&p)) == sizeof(yes_type) };
|
||||
typedef bad_category_select<has_bad_category> category_select;
|
||||
public:
|
||||
typedef typename category_select::template category<Iterator>::type type;
|
||||
};
|
||||
|
||||
# endif
|
||||
|
||||
# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
|
||||
template <bool is_bad_output_iterator> struct bad_output_iterator_select;
|
||||
template <>
|
||||
struct bad_output_iterator_select<true>
|
||||
{
|
||||
template <class Iterator>
|
||||
struct non_category_traits {
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
};
|
||||
};
|
||||
template <>
|
||||
struct bad_output_iterator_select<false>
|
||||
{
|
||||
template <class Iterator>
|
||||
struct non_category_traits {
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef typename Iterator::pointer pointer;
|
||||
typedef typename Iterator::reference reference;
|
||||
};
|
||||
};
|
||||
# endif
|
||||
|
||||
# if defined(BOOST_MSVC_STD_ITERATOR)
|
||||
|
||||
// We'll sort iterator types into one of these classifications, from which we
|
||||
// can determine the difference_type, pointer, reference, and value_type
|
||||
enum {
|
||||
not_msvc_stdlib_iterator,
|
||||
msvc_stdlib_const_iterator,
|
||||
msvc_stdlib_mutable_iterator,
|
||||
msvc_stdlib_ostream_iterator
|
||||
};
|
||||
|
||||
template <unsigned> struct msvc_traits_select;
|
||||
|
||||
template <> struct msvc_traits_select<not_msvc_stdlib_iterator>
|
||||
{
|
||||
template <class Iterator>
|
||||
struct traits_ // calling this "traits" will confuse VC.
|
||||
{
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef typename Iterator::pointer pointer;
|
||||
typedef typename Iterator::reference reference;
|
||||
};
|
||||
};
|
||||
|
||||
template <> struct msvc_traits_select<msvc_stdlib_mutable_iterator>
|
||||
{
|
||||
template <class Iterator>
|
||||
struct traits_
|
||||
{
|
||||
typedef typename Iterator::distance_type difference_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef value_type& reference;
|
||||
};
|
||||
};
|
||||
|
||||
template <> struct msvc_traits_select<msvc_stdlib_const_iterator>
|
||||
{
|
||||
template <class Iterator>
|
||||
struct traits_
|
||||
{
|
||||
typedef typename Iterator::distance_type difference_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef const value_type* pointer;
|
||||
typedef const value_type& reference;
|
||||
};
|
||||
};
|
||||
|
||||
template <> struct msvc_traits_select<msvc_stdlib_ostream_iterator>
|
||||
{
|
||||
template <class Iterator>
|
||||
struct traits_
|
||||
{
|
||||
typedef typename Iterator::distance_type difference_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef void pointer;
|
||||
typedef void reference;
|
||||
};
|
||||
};
|
||||
|
||||
// These functions allow us to detect which classification a given iterator type
|
||||
// falls into.
|
||||
|
||||
// Is the iterator derived from std::iterator?
|
||||
no_type is_std_iterator_helper(...);
|
||||
template <class V, class D, class C>
|
||||
yes_type is_std_iterator_helper(const volatile std::iterator<V,D,C>*);
|
||||
|
||||
#if 0 && defined(__ICL) // re-enable this to pick up with the Intel C++ fixes where they left off
|
||||
// for some reason, it's unable to make the deduction of derivation :(
|
||||
template<class K, class Ty, class Kfn, class Pr, class A>
|
||||
yes_type is_std_iterator_helper(const volatile typename std::_Tree<K,Ty,Kfn,Pr,A>::iterator*);
|
||||
template<class Ty, class A>
|
||||
yes_type is_std_iterator_helper(const volatile typename std::list<Ty,A>::iterator*);
|
||||
template<class Ty, class A>
|
||||
yes_type is_std_iterator_helper(const volatile typename std::deque<Ty,A>::iterator*);
|
||||
|
||||
template<class K, class Ty, class Kfn, class Pr, class A>
|
||||
yes_type is_std_iterator_helper(const volatile typename std::_Tree<K,Ty,Kfn,Pr,A>::const_iterator*);
|
||||
template<class Ty, class A>
|
||||
yes_type is_std_iterator_helper(const volatile typename std::list<Ty,A>::const_iterator*);
|
||||
template<class Ty, class A>
|
||||
yes_type is_std_iterator_helper(const volatile typename std::deque<Ty,A>::const_iterator*);
|
||||
|
||||
template<class RI, class Ty, class Rt, class Pt, class D>
|
||||
yes_type is_std_iterator_helper(const volatile std::reverse_iterator<RI,Ty,Rt,Pt,D>*);
|
||||
template<class BI, class Ty, class Rt, class Pt, class D>
|
||||
yes_type is_std_iterator_helper(const volatile std::reverse_bidirectional_iterator<BI,Ty,Rt,Pt,D>*);
|
||||
template<class C>
|
||||
yes_type is_std_iterator_helper(const volatile std::back_insert_iterator<C>*);
|
||||
template<class C>
|
||||
yes_type is_std_iterator_helper(const volatile std::front_insert_iterator<C>*);
|
||||
template<class C>
|
||||
yes_type is_std_iterator_helper(const volatile std::insert_iterator<C>*);
|
||||
template<class U, class E, class Tr>
|
||||
yes_type is_std_iterator_helper(const volatile std::istream_iterator<U,E,Tr>*);
|
||||
template<class E, class Tr>
|
||||
yes_type is_std_iterator_helper(const volatile std::istreambuf_iterator<E,Tr>*);
|
||||
template<class E, class Tr>
|
||||
yes_type is_std_iterator_helper(const volatile std::ostreambuf_iterator<E,Tr>*);
|
||||
template<class Oi, class Ty>
|
||||
yes_type is_std_iterator_helper(const volatile std::raw_storage_iterator<Oi,Ty>*);
|
||||
#endif
|
||||
|
||||
// Is the iterator derived from boost::iterator?
|
||||
template <class C, class T, class D, class P, class R>
|
||||
yes_type is_boost_iterator_helper(const volatile boost::iterator<C,T,D,P,R>*);
|
||||
no_type is_boost_iterator_helper(...);
|
||||
|
||||
// Is the iterator one of the known mutable container iterators?
|
||||
template<class K, class Ty, class Kfn, class Pr, class A>
|
||||
yes_type is_mutable_iterator_helper(const volatile typename std::_Tree<K,Ty,Kfn,Pr,A>::iterator*);
|
||||
template<class Ty, class A>
|
||||
yes_type is_mutable_iterator_helper(const volatile typename std::list<Ty,A>::iterator*);
|
||||
template<class Ty, class A>
|
||||
yes_type is_mutable_iterator_helper(const volatile typename std::deque<Ty,A>::iterator*);
|
||||
no_type is_mutable_iterator_helper(...);
|
||||
|
||||
// Is the iterator an ostream_iterator?
|
||||
template<class T, class CharT, class Traits>
|
||||
yes_type is_ostream_iterator_helper(const volatile std::ostream_iterator<T,CharT,Traits>*);
|
||||
no_type is_ostream_iterator_helper(...);
|
||||
|
||||
#if 0 && defined(__ICL)
|
||||
// this static assertion highlights the first of a few problems getting this to
|
||||
// work with the Intel compiler. We can get past it with the many definitions
|
||||
// for is_std_iterator_helper above, but there are other failures.
|
||||
template <bool> struct check;
|
||||
template <> struct check<true> {};
|
||||
check<(sizeof(is_std_iterator_helper((std::istream_iterator<int>*)0)) == sizeof(yes_type))> assertion;
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
struct msvc_iterator_classification {
|
||||
BOOST_STATIC_CONSTANT(unsigned,
|
||||
value = (sizeof(is_ostream_iterator_helper((T*)0)) == sizeof(yes_type))
|
||||
? msvc_stdlib_ostream_iterator
|
||||
: (sizeof(is_mutable_iterator_helper((T*)0)) == sizeof(yes_type))
|
||||
? msvc_stdlib_mutable_iterator
|
||||
: (sizeof(is_std_iterator_helper((T*)0)) == sizeof(yes_type)
|
||||
&& sizeof(is_boost_iterator_helper((T*)0)) == sizeof(no_type))
|
||||
? msvc_stdlib_const_iterator
|
||||
: not_msvc_stdlib_iterator
|
||||
);
|
||||
};
|
||||
# endif
|
||||
|
||||
template <> struct iterator_traits_select<false>
|
||||
{
|
||||
template <class Iterator>
|
||||
struct traits
|
||||
{
|
||||
# if defined(BOOST_MSVC_STD_ITERATOR)
|
||||
typedef msvc_traits_select<(
|
||||
msvc_iterator_classification<Iterator>::value
|
||||
)>::template traits_<Iterator> inner_traits;
|
||||
|
||||
typedef typename inner_traits::difference_type difference_type;
|
||||
typedef typename inner_traits::value_type value_type;
|
||||
typedef typename inner_traits::pointer pointer;
|
||||
typedef typename inner_traits::reference reference;
|
||||
# elif !defined(BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION)
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef typename Iterator::pointer pointer;
|
||||
typedef typename Iterator::reference reference;
|
||||
# else
|
||||
typedef bad_output_iterator_select<
|
||||
is_convertible<const volatile Iterator*,
|
||||
const volatile std::iterator<std::output_iterator_tag,void,void,void,void>*
|
||||
>::value> non_category_traits_select;
|
||||
typedef non_category_traits_select::template non_category_traits<Iterator> non_category_traits;
|
||||
public:
|
||||
typedef typename non_category_traits::value_type value_type;
|
||||
typedef typename non_category_traits::difference_type difference_type;
|
||||
typedef typename non_category_traits::pointer pointer;
|
||||
typedef typename non_category_traits::reference reference;
|
||||
# endif
|
||||
|
||||
# if !defined(BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF)
|
||||
typedef typename Iterator::iterator_category iterator_category;
|
||||
# else
|
||||
typedef typename iterator_category_select<Iterator>::type iterator_category;
|
||||
# endif
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace boost::detail::iterator_traits_
|
||||
|
||||
template <class Iterator>
|
||||
struct iterator_traits
|
||||
: iterator_traits_::iterator_traits_select<is_pointer<Iterator>::value>::template traits<Iterator>
|
||||
{
|
||||
private:
|
||||
typedef typename iterator_traits_::iterator_traits_select<
|
||||
is_pointer<remove_cv<Iterator>::type>::value>::template traits<Iterator> traits;
|
||||
public:
|
||||
// Why do I need to define these typedefs? It keeps MSVC happy somehow.
|
||||
// Why don't I need to define the other typedefs? Who knows?!?
|
||||
typedef typename traits::difference_type difference_type;
|
||||
typedef typename traits::iterator_category iterator_category;
|
||||
};
|
||||
|
||||
namespace iterator_traits_ {
|
||||
|
||||
template <class Category>
|
||||
struct distance_select {
|
||||
template <class Iterator>
|
||||
static typename ::boost::detail::iterator_traits<Iterator>::difference_type
|
||||
distance(Iterator i1, const Iterator i2)
|
||||
{
|
||||
typename ::boost::detail::iterator_traits<Iterator>::difference_type result = 0;
|
||||
while (i1 != i2)
|
||||
{
|
||||
++i1;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct distance_select<std::random_access_iterator_tag> {
|
||||
template <class Iterator>
|
||||
static typename ::boost::detail::iterator_traits<Iterator>::difference_type
|
||||
distance(const Iterator i1, const Iterator i2)
|
||||
{
|
||||
return i2 - i1;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost::detail::iterator_traits_
|
||||
|
||||
template <class Iterator>
|
||||
inline typename ::boost::detail::iterator_traits<Iterator>::difference_type
|
||||
distance(const Iterator& first, const Iterator& last)
|
||||
{
|
||||
typedef typename ::boost::detail::iterator_traits<Iterator>::iterator_category iterator_category;
|
||||
return iterator_traits_::distance_select<iterator_category>::distance(first, last);
|
||||
}
|
||||
# endif // workarounds
|
||||
|
||||
}} // namespace boost::detail
|
||||
|
||||
# undef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
|
||||
# undef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
|
||||
|
||||
#endif // ITERATOR_DWA122600_HPP_
|
224
include/boost/detail/named_template_params.hpp
Normal file
224
include/boost/detail/named_template_params.hpp
Normal file
@ -0,0 +1,224 @@
|
||||
// (C) Copyright Jeremy Siek 2001. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
|
||||
// Revision History:
|
||||
//
|
||||
// 27 June 2001 Jeremy Siek
|
||||
// Simplified the mechanism.
|
||||
// 08 Mar 2001 Jeremy Siek
|
||||
// Initial version.
|
||||
|
||||
#ifndef BOOST_DETAIL_NAMED_TEMPLATE_PARAMS_HPP
|
||||
#define BOOST_DETAIL_NAMED_TEMPLATE_PARAMS_HPP
|
||||
|
||||
#include <boost/type_traits/conversion_traits.hpp>
|
||||
#include <boost/type_traits/same_traits.hpp>
|
||||
#include <boost/type_traits/composite_traits.hpp> // for is_reference
|
||||
#include <boost/pending/ct_if.hpp>
|
||||
#if defined(__BORLANDC__)
|
||||
#include <boost/type_traits/ice.hpp>
|
||||
#endif
|
||||
|
||||
/*
|
||||
template <class List, class Tag>
|
||||
struct find_param;
|
||||
|
||||
This searches through a compile-time associative "List" of types
|
||||
to find the value (which is a type) associated with key specified
|
||||
by "Tag". The list is a lisp-style cons list using std::pair.
|
||||
The first_type of each pair must be a type that has a
|
||||
"type" and "tag" member, where "type" is the value and "tag"
|
||||
is the key that will match with the "Tag". The *_is classes
|
||||
in boost/iterator_adaptors.hpp (like value_type_is) are
|
||||
example of such types.
|
||||
|
||||
|
||||
struct named_template_param_base;
|
||||
template <class Arg, class Tag> struct wrap_param;
|
||||
|
||||
The named_template_param_base can be used to distinguish
|
||||
normal arguments from named arguments, the *_is classes
|
||||
inherit from named_template_param_base. The wrap_param
|
||||
class returns named arguments unchanged and returns
|
||||
normal arguments wrapped with the param_is type so
|
||||
that it will fit into the associative list.
|
||||
|
||||
|
||||
template <class Arg, class DefaultGen, class Info>
|
||||
class resolve_default;
|
||||
|
||||
This class figures out what the argument type of a parameter is
|
||||
based on the argument passed in (which might be the
|
||||
default_argument type), a default generator, and an Info type,
|
||||
|
||||
The DefaultGen type should have a single member class template
|
||||
named "bind" with one template parameter for the Info type. The
|
||||
bind class should have a single typedef named "type" that produces
|
||||
the default. See boost/iterator_adaptors.hpp for example usage.
|
||||
|
||||
The Info type is any type that might be useful in computing the
|
||||
default inside of the "bind" member class.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
// To differentiate an unnamed parameter from a traits generator
|
||||
// we use is_convertible<X, iter_traits_gen_base>.
|
||||
struct named_template_param_base { };
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct default_argument { };
|
||||
|
||||
struct dummy_default_gen {
|
||||
template <class Info>
|
||||
struct bind {
|
||||
typedef default_argument type;
|
||||
};
|
||||
};
|
||||
|
||||
// Specializations of this class template are used as a workaround
|
||||
// for MSVC. For other compilers this unspecialized version is
|
||||
// used (which doesn't really do anything).
|
||||
template <class Gen> struct default_generator {
|
||||
typedef Gen type;
|
||||
};
|
||||
|
||||
template <class T> struct is_default {
|
||||
enum { value = false };
|
||||
typedef type_traits::no_type type;
|
||||
};
|
||||
template <> struct is_default<default_argument> {
|
||||
enum { value = true };
|
||||
typedef type_traits::yes_type type;
|
||||
};
|
||||
|
||||
struct choose_default {
|
||||
template <class Arg, class DefaultGen, class Info>
|
||||
struct bind {
|
||||
typedef typename default_generator<DefaultGen>::type Gen;
|
||||
typedef typename Gen::template bind<Info>::type type;
|
||||
};
|
||||
};
|
||||
struct choose_arg {
|
||||
template <class Arg, class DefaultGen, class Info>
|
||||
struct bind {
|
||||
typedef Arg type;
|
||||
};
|
||||
};
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
template <class UseDefault>
|
||||
struct choose_arg_or_default { typedef choose_arg type; };
|
||||
template <>
|
||||
struct choose_arg_or_default<type_traits::yes_type> {
|
||||
typedef choose_default type;
|
||||
};
|
||||
#else
|
||||
template <bool UseDefault>
|
||||
struct choose_arg_or_default { typedef choose_arg type; };
|
||||
template <>
|
||||
struct choose_arg_or_default<true> {
|
||||
typedef choose_default type;
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class Arg, class DefaultGen, class Info>
|
||||
class resolve_default {
|
||||
#if defined(__BORLANDC__)
|
||||
typedef typename choose_arg_or_default<typename is_default<Arg>::type>::type Selector;
|
||||
#else
|
||||
// This usually works for Borland, but I'm seeing weird errors in
|
||||
// iterator_adaptor_test.cpp when using this method.
|
||||
enum { is_def = is_default<Arg>::value };
|
||||
typedef typename choose_arg_or_default<is_def>::type Selector;
|
||||
#endif
|
||||
public:
|
||||
typedef typename Selector
|
||||
::template bind<Arg, DefaultGen, Info>::type type;
|
||||
};
|
||||
|
||||
template <class X>
|
||||
struct is_named_param_list {
|
||||
enum { value = is_convertible<X, named_template_param_base>::value };
|
||||
};
|
||||
|
||||
struct choose_named_params {
|
||||
template <class Prev> struct bind { typedef Prev type; };
|
||||
};
|
||||
struct choose_default_arg {
|
||||
template <class Prev> struct bind {
|
||||
typedef detail::default_argument type;
|
||||
};
|
||||
};
|
||||
|
||||
template <bool Named> struct choose_default_dispatch { };
|
||||
template <> struct choose_default_dispatch<true> {
|
||||
typedef choose_named_params type;
|
||||
};
|
||||
template <> struct choose_default_dispatch<false> {
|
||||
typedef choose_default_arg type;
|
||||
};
|
||||
|
||||
|
||||
template <class PreviousArg>
|
||||
struct choose_default_argument {
|
||||
enum { is_named = is_named_param_list<PreviousArg>::value };
|
||||
typedef typename choose_default_dispatch<is_named>::type Selector;
|
||||
typedef typename Selector::template bind<PreviousArg>::type type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
struct list_end_type { };
|
||||
|
||||
namespace detail {
|
||||
template <class List>
|
||||
struct find_param_impl {
|
||||
template <class Tag> class bind {
|
||||
typedef typename List::first_type Param;
|
||||
typedef typename List::second_type Rest;
|
||||
typedef typename find_param_impl<Rest>::template bind<Tag>::type
|
||||
RestType;
|
||||
enum { is_same_tag = is_same<typename Param::tag, Tag>::value };
|
||||
public:
|
||||
typedef typename ct_if<is_same_tag,
|
||||
typename Param::type, RestType>::type type;
|
||||
};
|
||||
};
|
||||
template <>
|
||||
struct find_param_impl<list_end_type> {
|
||||
template <class Tag> struct bind {
|
||||
typedef default_argument type;
|
||||
};
|
||||
};
|
||||
|
||||
template <class T, class Tag>
|
||||
struct param_is {
|
||||
typedef T type;
|
||||
typedef Tag tag;
|
||||
};
|
||||
|
||||
} //namespace detail
|
||||
|
||||
template <class List, class Tag> struct find_param {
|
||||
typedef typename detail::find_param_impl<List>::template bind<Tag>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <class T, class Tag>
|
||||
struct wrap_param {
|
||||
enum { is_named_param =
|
||||
is_convertible<T, named_template_param_base>::value };
|
||||
typedef typename ct_if<is_named_param, T,
|
||||
detail::param_is<T, Tag> >::type type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_DETAIL_NAMED_TEMPLATE_PARAMS_HPP
|
200
include/boost/detail/numeric_traits.hpp
Normal file
200
include/boost/detail/numeric_traits.hpp
Normal file
@ -0,0 +1,200 @@
|
||||
// (C) Copyright David Abrahams 2001. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
//
|
||||
// Template class is_signed and its documentation is:
|
||||
// (C) Copyright Howard Hinnant 2001. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
//
|
||||
// Template class numeric_traits<Number> --
|
||||
//
|
||||
// Supplies:
|
||||
//
|
||||
// typedef difference_type -- a type used to represent the difference
|
||||
// between any two values of Number.
|
||||
//
|
||||
// Support:
|
||||
// 1. Not all specializations are supplied
|
||||
//
|
||||
// 2. Use of specializations that are not supplied will cause a
|
||||
// compile-time error
|
||||
//
|
||||
// 3. Users are free to specialize numeric_traits for any type.
|
||||
//
|
||||
// 4. Right now, specializations are only supplied for integer types.
|
||||
//
|
||||
// 5. On implementations which do not supply compile-time constants in
|
||||
// std::numeric_limits<>, only specializations for built-in integer types
|
||||
// are supplied.
|
||||
//
|
||||
// 6. Handling of numbers whose range of representation is at least as
|
||||
// great as boost::intmax_t can cause some differences to be
|
||||
// unrepresentable in difference_type:
|
||||
//
|
||||
// Number difference_type
|
||||
// ------ ---------------
|
||||
// signed Number
|
||||
// unsigned intmax_t
|
||||
//
|
||||
// template <class Number> typename numeric_traits<Number>::difference_type
|
||||
// numeric_distance(Number x, Number y)
|
||||
// computes (y - x), attempting to avoid overflows.
|
||||
//
|
||||
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
|
||||
// Revision History
|
||||
// 11 Feb 2001 - Use BOOST_STATIC_CONSTANT (David Abrahams)
|
||||
// 11 Feb 2001 - Rolled back ineffective Borland-specific code
|
||||
// (David Abrahams)
|
||||
// 10 Feb 2001 - Rolled in supposed Borland fixes from John Maddock, but
|
||||
// not seeing any improvement yet (David Abrahams)
|
||||
// 06 Feb 2001 - Factored if_true out into boost/detail/select_type.hpp
|
||||
// (David Abrahams)
|
||||
// 23 Jan 2001 - Fixed logic of difference_type selection, which was
|
||||
// completely wack. In the process, added digit_traits<>
|
||||
// to compute the number of digits in intmax_t even when
|
||||
// not supplied by numeric_limits<>. (David Abrahams)
|
||||
// 21 Jan 2001 - Created (David Abrahams)
|
||||
|
||||
#ifndef BOOST_NUMERIC_TRAITS_HPP_DWA20001901
|
||||
# define BOOST_NUMERIC_TRAITS_HPP_DWA20001901
|
||||
|
||||
# include <boost/config.hpp>
|
||||
# include <boost/cstdint.hpp>
|
||||
# include <boost/static_assert.hpp>
|
||||
# include <boost/type_traits.hpp>
|
||||
# include <boost/detail/select_type.hpp>
|
||||
# ifndef BOOST_NO_LIMITS
|
||||
# include <limits>
|
||||
# endif
|
||||
|
||||
namespace boost { namespace detail {
|
||||
|
||||
// Template class is_signed -- determine whether a numeric type is signed
|
||||
// Requires that T is constructable from the literals -1 and 0. Compile-time
|
||||
// error results if that requirement is not met (and thus signedness is not
|
||||
// likely to have meaning for that type).
|
||||
template <class Number>
|
||||
struct is_signed
|
||||
{
|
||||
#if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || defined(BOOST_MSVC)
|
||||
BOOST_STATIC_CONSTANT(bool, value = (Number(-1) < Number(0)));
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits<Number>::is_signed);
|
||||
#endif
|
||||
};
|
||||
|
||||
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
// digit_traits - compute the number of digits in a built-in integer
|
||||
// type. Needed for implementations on which numeric_limits is not specialized
|
||||
// for intmax_t (e.g. VC6).
|
||||
template <bool is_specialized> struct digit_traits_select;
|
||||
|
||||
// numeric_limits is specialized; just select that version of digits
|
||||
template <> struct digit_traits_select<true>
|
||||
{
|
||||
template <class T> struct traits
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, digits = std::numeric_limits<T>::digits);
|
||||
};
|
||||
};
|
||||
|
||||
// numeric_limits is not specialized; compute digits from sizeof(T)
|
||||
template <> struct digit_traits_select<false>
|
||||
{
|
||||
template <class T> struct traits
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(int, digits = (
|
||||
sizeof(T) * std::numeric_limits<unsigned char>::digits
|
||||
- (is_signed<T>::value ? 1 : 0))
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
// here's the "usable" template
|
||||
template <class T> struct digit_traits
|
||||
{
|
||||
typedef digit_traits_select<
|
||||
::std::numeric_limits<T>::is_specialized> selector;
|
||||
typedef typename selector::template traits<T> traits;
|
||||
BOOST_STATIC_CONSTANT(int, digits = traits::digits);
|
||||
};
|
||||
#endif
|
||||
|
||||
// Template class integer_traits<Integer> -- traits of various integer types
|
||||
// This should probably be rolled into boost::integer_traits one day, but I
|
||||
// need it to work without <limits>
|
||||
template <class Integer>
|
||||
struct integer_traits
|
||||
{
|
||||
# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
private:
|
||||
typedef Integer integer_type;
|
||||
typedef std::numeric_limits<integer_type> x;
|
||||
# ifdef BOOST_MSVC
|
||||
// for some reason, MSVC asserts when it shouldn't unless we make these
|
||||
// local definitions
|
||||
BOOST_STATIC_CONSTANT(bool, is_integer = x::is_integer);
|
||||
BOOST_STATIC_CONSTANT(bool, is_specialized = x::is_specialized);
|
||||
|
||||
BOOST_STATIC_ASSERT(is_integer);
|
||||
BOOST_STATIC_ASSERT(is_specialized);
|
||||
# endif
|
||||
public:
|
||||
typedef typename
|
||||
if_true<(int(x::is_signed)
|
||||
&& (!int(x::is_bounded)
|
||||
// digits is the number of no-sign bits
|
||||
|| (int(x::digits) + 1 >= digit_traits<boost::intmax_t>::digits)))>::template then<
|
||||
Integer,
|
||||
|
||||
typename if_true<(int(x::digits) + 1 < digit_traits<signed int>::digits)>::template then<
|
||||
signed int,
|
||||
|
||||
typename if_true<(int(x::digits) + 1 < digit_traits<signed long>::digits)>::template then<
|
||||
signed long,
|
||||
|
||||
// else
|
||||
intmax_t
|
||||
>::type>::type>::type difference_type;
|
||||
#else
|
||||
BOOST_STATIC_ASSERT(boost::is_integral<Integer>::value);
|
||||
|
||||
typedef typename
|
||||
if_true<(sizeof(Integer) >= sizeof(intmax_t))>::template then<
|
||||
|
||||
typename if_true<(is_signed<Integer>::value)>::template then<
|
||||
Integer,
|
||||
intmax_t
|
||||
>::type,
|
||||
|
||||
typename if_true<(sizeof(Integer) < sizeof(std::ptrdiff_t))>::template then<
|
||||
std::ptrdiff_t,
|
||||
intmax_t
|
||||
>::type
|
||||
>::type difference_type;
|
||||
# endif
|
||||
};
|
||||
|
||||
// Right now, only supports integers, but should be expanded.
|
||||
template <class Number>
|
||||
struct numeric_traits
|
||||
{
|
||||
typedef typename integer_traits<Number>::difference_type difference_type;
|
||||
};
|
||||
|
||||
template <class Number>
|
||||
typename numeric_traits<Number>::difference_type numeric_distance(Number x, Number y)
|
||||
{
|
||||
typedef typename numeric_traits<Number>::difference_type difference_type;
|
||||
return difference_type(y) - difference_type(x);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif // BOOST_NUMERIC_TRAITS_HPP_DWA20001901
|
37
include/boost/detail/select_type.hpp
Normal file
37
include/boost/detail/select_type.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
// (C) Copyright David Abrahams 2001. Permission to copy, use, modify,
|
||||
// sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org for most recent version including documentation.
|
||||
|
||||
// Revision History
|
||||
// 09 Feb 01 Applied John Maddock's Borland patch Moving <true>
|
||||
// specialization to unspecialized template (David Abrahams)
|
||||
// 06 Feb 01 Created (David Abrahams)
|
||||
|
||||
#ifndef SELECT_TYPE_DWA20010206_HPP
|
||||
# define SELECT_TYPE_DWA20010206_HPP
|
||||
|
||||
namespace boost { namespace detail {
|
||||
|
||||
// Template class if_true -- select among 2 types based on a bool constant expression
|
||||
// Usage:
|
||||
// typename if_true<(bool_const_expression)>::template then<true_type, false_type>::type
|
||||
|
||||
// HP aCC cannot deal with missing names for template value parameters
|
||||
template <bool b> struct if_true
|
||||
{
|
||||
template <class T, class F>
|
||||
struct then { typedef T type; };
|
||||
};
|
||||
|
||||
template <>
|
||||
struct if_true<false>
|
||||
{
|
||||
template <class T, class F>
|
||||
struct then { typedef F type; };
|
||||
};
|
||||
}}
|
||||
#endif // SELECT_TYPE_DWA20010206_HPP
|
@ -12,15 +12,44 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
/*
|
||||
There is a bug in the Borland compiler with regards to using
|
||||
integers to specialize templates. This made it hard to use ct_if in
|
||||
the graph library. Changing from 'ct_if' to 'ct_if_t' fixed the
|
||||
problem.
|
||||
*/
|
||||
|
||||
namespace boost {
|
||||
|
||||
struct ct_if_error { };
|
||||
|
||||
struct true_type { enum { value = true }; };
|
||||
struct false_type { enum { value = false }; };
|
||||
|
||||
template <class A, class B>
|
||||
struct ct_and { typedef false_type type; };
|
||||
template <> struct ct_and<true_type,true_type> { typedef true_type type; };
|
||||
|
||||
template <class A> struct ct_not { typedef ct_if_error type; };
|
||||
template <> struct ct_not<true_type> { typedef false_type type; };
|
||||
template <> struct ct_not<false_type> { typedef true_type type; };
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <int cond, class A, class B>
|
||||
struct ct_if { typedef A type; };
|
||||
struct ct_if { typedef ct_if_error type; };
|
||||
template <class A, class B>
|
||||
struct ct_if<1, A, B> { typedef A type; };
|
||||
template <class A, class B>
|
||||
struct ct_if<0, A, B> { typedef B type; };
|
||||
|
||||
template <class cond, class A, class B>
|
||||
struct ct_if_t { typedef ct_if_error type; };
|
||||
template <class A, class B>
|
||||
struct ct_if_t<true_type, A, B> { typedef A type; };
|
||||
template <class A, class B>
|
||||
struct ct_if_t<false_type, A, B> { typedef B type; };
|
||||
|
||||
#else
|
||||
|
||||
namespace detail {
|
||||
@ -32,7 +61,7 @@ namespace boost {
|
||||
|
||||
struct SelectFirstType {
|
||||
template<class A, class B>
|
||||
struct Template { typedef A type; };
|
||||
struct Template { typedef A type; };
|
||||
};
|
||||
|
||||
struct SelectSecondType {
|
||||
@ -59,6 +88,11 @@ namespace boost {
|
||||
typedef typename Selector::template Template<A, B>::type type;
|
||||
};
|
||||
|
||||
template <class cond, class A, class B>
|
||||
struct ct_if_t {
|
||||
typedef typename ct_if<cond::value, A, B>::type type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
19
include/boost/type.hpp
Normal file
19
include/boost/type.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
// (C) Copyright David Abrahams 2001. Permission to copy, use,
|
||||
// modify, sell and distribute this software is granted provided this
|
||||
// copyright notice appears in all copies. This software is provided
|
||||
// "as is" without express or implied warranty, and with no claim as
|
||||
// to its suitability for any purpose.
|
||||
|
||||
#ifndef BOOST_TYPE_DWA20010120_HPP
|
||||
# define BOOST_TYPE_DWA20010120_HPP
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Just a simple "type envelope". Useful in various contexts, mostly to work
|
||||
// around some MSVC deficiencies.
|
||||
template <class T>
|
||||
struct type {};
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_TYPE_DWA20010120_HPP
|
Reference in New Issue
Block a user