mirror of
https://github.com/boostorg/detail.git
synced 2025-06-27 21:11:07 +02:00
Compare commits
45 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
11f2862f05 | |||
2fe7fd95d2 | |||
0096bf2291 | |||
9ab05a600a | |||
1fbad0fe2c | |||
1fa91744d4 | |||
8715141657 | |||
d562044910 | |||
187c393d0c | |||
61ab827c49 | |||
9223a385a6 | |||
f7d6abb21e | |||
b2de7f6888 | |||
5d116e0057 | |||
d536934458 | |||
4cbe12240a | |||
190b0bf58b | |||
463f382482 | |||
b3edcaebb3 | |||
665f18d2b7 | |||
092c5f5b52 | |||
f980329354 | |||
ac460707c9 | |||
7e4ad9c654 | |||
11adf72ff6 | |||
7a092ba5f9 | |||
ab34b61206 | |||
b0b37ef724 | |||
69c7068028 | |||
124be84389 | |||
0caf4bb53e | |||
7f668adbcd | |||
d6fbac9ba7 | |||
8f71074339 | |||
1f52127735 | |||
48507564a9 | |||
8d549f45fd | |||
c1f144e5d4 | |||
53ba30e0c9 | |||
9aead1823b | |||
c14ee17601 | |||
2bca71488b | |||
1f335d30ba | |||
a38297a6cc | |||
72ca3d7d9f |
84
include/boost/blank.hpp
Normal file
84
include/boost/blank.hpp
Normal file
@ -0,0 +1,84 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost blank.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003
|
||||
// Eric Friedman
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
|
||||
#ifndef BOOST_BLANK_HPP
|
||||
#define BOOST_BLANK_HPP
|
||||
|
||||
#include "boost/blank_fwd.hpp"
|
||||
|
||||
#include <iosfwd> // for std::basic_ostream forward declare
|
||||
|
||||
#include "boost/detail/templated_streams.hpp"
|
||||
#include "boost/mpl/bool.hpp"
|
||||
#include "boost/type_traits/is_empty.hpp"
|
||||
#include "boost/type_traits/is_pod.hpp"
|
||||
#include "boost/type_traits/is_stateless.hpp"
|
||||
|
||||
namespace boost {
|
||||
|
||||
struct blank
|
||||
{
|
||||
};
|
||||
|
||||
// type traits specializations
|
||||
//
|
||||
|
||||
template <>
|
||||
struct is_pod< blank >
|
||||
: mpl::true_
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_empty< blank >
|
||||
: mpl::true_
|
||||
{
|
||||
};
|
||||
|
||||
template <>
|
||||
struct is_stateless< blank >
|
||||
: mpl::true_
|
||||
{
|
||||
};
|
||||
|
||||
// relational operators
|
||||
//
|
||||
|
||||
inline bool operator==(const blank&, const blank&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator<(const blank&, const blank&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// streaming support
|
||||
//
|
||||
BOOST_TEMPLATED_STREAM_TEMPLATE(E,T)
|
||||
inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
|
||||
BOOST_TEMPLATED_STREAM(ostream, E,T)& out
|
||||
, const blank&
|
||||
)
|
||||
{
|
||||
// (output nothing)
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_BLANK_HPP
|
26
include/boost/blank_fwd.hpp
Normal file
26
include/boost/blank_fwd.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost blank_fwd.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003
|
||||
// Eric Friedman
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
|
||||
#ifndef BOOST_BLANK_FWD_HPP
|
||||
#define BOOST_BLANK_FWD_HPP
|
||||
|
||||
namespace boost {
|
||||
|
||||
struct blank;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_BLANK_FWD_HPP
|
@ -1,11 +1,9 @@
|
||||
// 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.
|
||||
// Copyright Beman Dawes 2001.
|
||||
// See accompanying license for terms and conditions of use.
|
||||
|
||||
// See http://www.boost.org for updates and documentation.
|
||||
// See http://www.boost.org/libs/utility/cstdlib.html for documentation.
|
||||
|
||||
// Revision History
|
||||
// 26 Feb 01 Initial version (Beman Dawes)
|
||||
|
@ -3,13 +3,9 @@
|
||||
* Copyright (c) 2001
|
||||
* Dr John Maddock
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Dr John Maddock makes no representations
|
||||
* about the suitability of this software for any purpose.
|
||||
* It is provided "as is" without express or implied warranty.
|
||||
* Use, modification and distribution are 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)
|
||||
*
|
||||
*/
|
||||
|
||||
@ -18,6 +14,8 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
#include <assert.h>
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std{
|
||||
using ::ptrdiff_t;
|
||||
@ -49,7 +47,10 @@ void allocator_construct(T* p, const T& t)
|
||||
|
||||
template <class T>
|
||||
void allocator_destroy(T* p)
|
||||
{ p->~T(); }
|
||||
{
|
||||
(void)p; // warning suppression
|
||||
p->~T();
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
@ -57,7 +58,7 @@ void allocator_destroy(T* p)
|
||||
|
||||
#include <memory>
|
||||
|
||||
#define BOOST_DEFAULT_ALLOCATOR(T) std::allocator<T>
|
||||
#define BOOST_DEFAULT_ALLOCATOR(T) std::allocator< T >
|
||||
|
||||
namespace boost{ namespace detail{
|
||||
|
||||
@ -71,12 +72,12 @@ struct rebind_allocator
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#elif !defined(BOOST_NO_MEMBER_TEMPLATES)
|
||||
#elif !defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__SUNPRO_CC)
|
||||
|
||||
// no std::allocator, but the compiler supports the necessary syntax,
|
||||
// write our own allocator instead:
|
||||
|
||||
#define BOOST_DEFAULT_ALLOCATOR(T) ::boost::detail::allocator<T>
|
||||
#define BOOST_DEFAULT_ALLOCATOR(T) ::boost::detail::allocator< T >
|
||||
|
||||
namespace boost{ namespace detail{
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
// 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.
|
||||
// Copyright Beman Dawes 1995-2001.
|
||||
// See accompanying license for terms and conditions of use.
|
||||
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
// See http://www.boost.org/libs/test for documentation.
|
||||
|
||||
// Revision History
|
||||
// 13 Jun 01 report_exception() made inline. (John Maddock, Jesse Jones)
|
||||
|
71
include/boost/detail/is_incrementable.hpp
Executable file
71
include/boost/detail/is_incrementable.hpp
Executable file
@ -0,0 +1,71 @@
|
||||
// Copyright David Abrahams 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)
|
||||
#ifndef IS_INCREMENTABLE_DWA200415_HPP
|
||||
# define IS_INCREMENTABLE_DWA200415_HPP
|
||||
|
||||
# include <boost/type_traits/remove_cv.hpp>
|
||||
# include <boost/mpl/bool.hpp>
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost { namespace detail {
|
||||
|
||||
// is_incrementable<T> metafunction
|
||||
//
|
||||
// Requires: Given x of type T&, if the expression ++x is well-formed
|
||||
// it must have complete type; otherwise, it must neither be ambiguous
|
||||
// nor violate access.
|
||||
|
||||
// This namespace ensures that ADL doesn't mess things up.
|
||||
namespace is_incrementable_
|
||||
{
|
||||
struct tag {};
|
||||
|
||||
// any soaks up implicit conversions and makes the following
|
||||
// operator++ less-preferred than any other such operator which
|
||||
// might be found via ADL.
|
||||
struct any { template <class T> any(T const&); };
|
||||
tag operator++(any const&);
|
||||
|
||||
// two check overloads help us identify which operator++ was picked
|
||||
char (& check(tag) )[2];
|
||||
|
||||
template <class T>
|
||||
char check(T const&);
|
||||
|
||||
|
||||
template <class T>
|
||||
struct
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
impl
|
||||
# else
|
||||
is_incrementable
|
||||
# endif
|
||||
{
|
||||
static typename remove_cv<T>::type& x;
|
||||
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool
|
||||
, value = sizeof(is_incrementable_::check(++x)) == 1
|
||||
);
|
||||
|
||||
typedef mpl::bool_<(
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
::boost::detail::is_incrementable_::is_incrementable<T>::
|
||||
# endif
|
||||
value)> type;
|
||||
};
|
||||
}
|
||||
|
||||
# if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
|
||||
template <class T>
|
||||
struct is_incrementable : is_incrementable_::impl<T>
|
||||
{
|
||||
};
|
||||
# else
|
||||
using is_incrementable_::is_incrementable;
|
||||
# endif
|
||||
|
||||
}} // namespace boost::detail
|
||||
|
||||
#endif // IS_INCREMENTABLE_DWA200415_HPP
|
@ -1,4 +1,4 @@
|
||||
// (C) Copyright David Abrahams 2001. Permission to copy, use, modify,
|
||||
// (C) Copyright David Abrahams 2002. 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
|
||||
@ -20,11 +20,6 @@
|
||||
// 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
|
||||
@ -57,17 +52,7 @@
|
||||
# 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) && !defined(__SGI_STL_PORT)
|
||||
# include <xtree>
|
||||
# include <deque>
|
||||
# include <list>
|
||||
# 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
|
||||
@ -76,9 +61,9 @@
|
||||
// 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)
|
||||
# if defined(__SGI_STL_PORT)
|
||||
|
||||
# ifdef __STL_DEBUG
|
||||
# if (__SGI_STL_PORT <= 0x410) && !defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && defined(__STL_DEBUG)
|
||||
# define BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
|
||||
# endif
|
||||
|
||||
@ -86,298 +71,423 @@
|
||||
|
||||
# endif // STLPort <= 4.1b4 && no partial specialization
|
||||
|
||||
# if !defined(BOOST_NO_STD_ITERATOR_TRAITS) \
|
||||
&& !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
&& !defined(BOOST_MSVC_STD_ITERATOR)
|
||||
|
||||
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;
|
||||
|
||||
// Define a new template so it can be specialized
|
||||
template <class Iterator>
|
||||
struct iterator_traits
|
||||
: std::iterator_traits<Iterator>
|
||||
{};
|
||||
using std::distance;
|
||||
|
||||
}} // namespace boost::detail
|
||||
|
||||
# else
|
||||
|
||||
namespace iterator_traits_ {
|
||||
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
&& !defined(BOOST_MSVC_STD_ITERATOR)
|
||||
|
||||
// Workarounds for less-capable implementations
|
||||
template <bool is_ptr> struct iterator_traits_select;
|
||||
// This is the case where everything conforms except BOOST_NO_STD_ITERATOR_TRAITS
|
||||
|
||||
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;
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
|
||||
// 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; };
|
||||
};
|
||||
namespace boost { namespace detail {
|
||||
|
||||
// Rogue Wave Standard Library fools itself into thinking partial
|
||||
// specialization is missing on some platforms (e.g. Sun), so fails to
|
||||
// supply iterator_traits!
|
||||
template <class Iterator>
|
||||
struct iterator_category_select
|
||||
struct iterator_traits
|
||||
{
|
||||
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;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef typename Iterator::reference reference;
|
||||
typedef typename Iterator::pointer pointer;
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef typename Iterator::iterator_category iterator_category;
|
||||
};
|
||||
|
||||
# endif
|
||||
template <class T>
|
||||
struct iterator_traits<T*>
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef T& reference;
|
||||
typedef T* pointer;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct iterator_traits<T const*>
|
||||
{
|
||||
typedef T value_type;
|
||||
typedef T const& reference;
|
||||
typedef T const* pointer;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
};
|
||||
|
||||
}} // namespace boost::detail
|
||||
|
||||
# else
|
||||
|
||||
# include <boost/type_traits/remove_const.hpp>
|
||||
# include <boost/type_traits/detail/yes_no_type.hpp>
|
||||
# include <boost/type_traits/is_pointer.hpp>
|
||||
|
||||
# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
# include <boost/type_traits/remove_pointer.hpp>
|
||||
# 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;
|
||||
};
|
||||
};
|
||||
# include <boost/type_traits/is_base_and_derived.hpp>
|
||||
# endif
|
||||
|
||||
# if defined(BOOST_MSVC_STD_ITERATOR) && !defined(__SGI_STL_PORT)
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/mpl/aux_/has_xxx.hpp>
|
||||
# include <cstddef>
|
||||
|
||||
// should be the last #include
|
||||
# include "boost/type_traits/detail/bool_trait_def.hpp"
|
||||
|
||||
namespace boost { namespace detail {
|
||||
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type)
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(reference)
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(pointer)
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(difference_type)
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category)
|
||||
|
||||
// is_mutable_iterator --
|
||||
//
|
||||
// A metafunction returning true iff T is a mutable iterator type
|
||||
// with a nested value_type. Will only work portably with iterators
|
||||
// whose operator* returns a reference, but that seems to be OK for
|
||||
// the iterators supplied by Dinkumware. Some input iterators may
|
||||
// compile-time if they arrive here, and if the compiler is strict
|
||||
// about not taking the address of an rvalue.
|
||||
|
||||
// This one detects ordinary mutable iterators - the result of
|
||||
// operator* is convertible to the value_type.
|
||||
template <class T>
|
||||
type_traits::yes_type is_mutable_iterator_helper(T const*, BOOST_DEDUCED_TYPENAME T::value_type*);
|
||||
|
||||
// Since you can't take the address of an rvalue, the guts of
|
||||
// is_mutable_iterator_impl will fail if we use &*t directly. This
|
||||
// makes sure we can still work with non-lvalue iterators.
|
||||
template <class T> T* mutable_iterator_lvalue_helper(T& x);
|
||||
int mutable_iterator_lvalue_helper(...);
|
||||
|
||||
|
||||
// This one detects output iterators such as ostream_iterator which
|
||||
// return references to themselves.
|
||||
template <class T>
|
||||
type_traits::yes_type is_mutable_iterator_helper(T const*, T const*);
|
||||
|
||||
type_traits::no_type is_mutable_iterator_helper(...);
|
||||
|
||||
template <class T>
|
||||
struct is_mutable_iterator_impl
|
||||
{
|
||||
static T t;
|
||||
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool, value = sizeof(
|
||||
detail::is_mutable_iterator_helper(
|
||||
(T*)0
|
||||
, mutable_iterator_lvalue_helper(*t) // like &*t
|
||||
))
|
||||
== sizeof(type_traits::yes_type)
|
||||
);
|
||||
};
|
||||
|
||||
BOOST_TT_AUX_BOOL_TRAIT_DEF1(
|
||||
is_mutable_iterator,T,::boost::detail::is_mutable_iterator_impl<T>::value)
|
||||
|
||||
|
||||
// is_full_iterator_traits --
|
||||
//
|
||||
// A metafunction returning true iff T has all the requisite nested
|
||||
// types to satisfy the requirements for a fully-conforming
|
||||
// iterator_traits implementation.
|
||||
template <class T>
|
||||
struct is_full_iterator_traits_impl
|
||||
{
|
||||
enum { value =
|
||||
has_value_type<T>::value
|
||||
& has_reference<T>::value
|
||||
& has_pointer<T>::value
|
||||
& has_difference_type<T>::value
|
||||
& has_iterator_category<T>::value
|
||||
};
|
||||
};
|
||||
|
||||
BOOST_TT_AUX_BOOL_TRAIT_DEF1(
|
||||
is_full_iterator_traits,T,::boost::detail::is_full_iterator_traits_impl<T>::value)
|
||||
|
||||
|
||||
# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(_Iterator_category)
|
||||
|
||||
// is_stlport_40_debug_iterator --
|
||||
//
|
||||
// A metafunction returning true iff T has all the requisite nested
|
||||
// types to satisfy the requirements of an STLPort 4.0 debug iterator
|
||||
// iterator_traits implementation.
|
||||
template <class T>
|
||||
struct is_stlport_40_debug_iterator_impl
|
||||
{
|
||||
enum { value =
|
||||
has_value_type<T>::value
|
||||
& has_reference<T>::value
|
||||
& has_pointer<T>::value
|
||||
& has_difference_type<T>::value
|
||||
& has__Iterator_category<T>::value
|
||||
};
|
||||
};
|
||||
|
||||
BOOST_TT_AUX_BOOL_TRAIT_DEF1(
|
||||
is_stlport_40_debug_iterator,T,::boost::detail::is_stlport_40_debug_iterator_impl<T>::value)
|
||||
|
||||
template <class T>
|
||||
struct stlport_40_debug_iterator_traits
|
||||
{
|
||||
typedef typename T::value_type value_type;
|
||||
typedef typename T::reference reference;
|
||||
typedef typename T::pointer pointer;
|
||||
typedef typename T::difference_type difference_type;
|
||||
typedef typename T::_Iterator_category iterator_category;
|
||||
};
|
||||
# endif // BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
|
||||
|
||||
template <class T> struct pointer_iterator_traits;
|
||||
|
||||
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template <class T>
|
||||
struct pointer_iterator_traits<T*>
|
||||
{
|
||||
typedef remove_const<T>::type value_type;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
};
|
||||
# else
|
||||
|
||||
// In case of no template partial specialization, and if T is a
|
||||
// pointer, iterator_traits<T>::value_type can still be computed. For
|
||||
// some basic types, remove_pointer is manually defined in
|
||||
// type_traits/broken_compiler_spec.hpp. For others, do it yourself.
|
||||
|
||||
template<class P> class please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee;
|
||||
|
||||
template<class P>
|
||||
struct pointer_value_type
|
||||
: mpl::if_<
|
||||
is_same<P, typename remove_pointer<P>::type>
|
||||
, please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee<P>
|
||||
, typename remove_const<
|
||||
typename remove_pointer<P>::type
|
||||
>::type
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
template<class P>
|
||||
struct pointer_reference
|
||||
: mpl::if_<
|
||||
is_same<P, typename remove_pointer<P>::type>
|
||||
, please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee<P>
|
||||
, typename remove_pointer<P>::type&
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct pointer_iterator_traits
|
||||
{
|
||||
typedef T pointer;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
typedef typename pointer_value_type<T>::type value_type;
|
||||
typedef typename pointer_reference<T>::type reference;
|
||||
};
|
||||
|
||||
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
// 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 standard_iterator_traits
|
||||
{
|
||||
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;
|
||||
};
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef typename Iterator::pointer pointer;
|
||||
typedef typename Iterator::reference reference;
|
||||
typedef typename Iterator::iterator_category iterator_category;
|
||||
};
|
||||
|
||||
template <> struct msvc_traits_select<msvc_stdlib_mutable_iterator>
|
||||
template <class Iterator>
|
||||
struct msvc_stdlib_mutable_traits
|
||||
: std::iterator_traits<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;
|
||||
};
|
||||
typedef typename std::iterator_traits<Iterator>::distance_type difference_type;
|
||||
typedef value_type* pointer;
|
||||
typedef value_type& reference;
|
||||
};
|
||||
|
||||
template <> struct msvc_traits_select<msvc_stdlib_const_iterator>
|
||||
template <class Iterator>
|
||||
struct msvc_stdlib_const_traits
|
||||
: std::iterator_traits<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;
|
||||
};
|
||||
typedef typename std::iterator_traits<Iterator>::distance_type difference_type;
|
||||
typedef const value_type* pointer;
|
||||
typedef const value_type& reference;
|
||||
};
|
||||
|
||||
template <> struct msvc_traits_select<msvc_stdlib_ostream_iterator>
|
||||
# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
|
||||
template <class Iterator>
|
||||
struct is_bad_output_iterator
|
||||
: is_base_and_derived<
|
||||
std::iterator<std::output_iterator_tag,void,void,void,void>
|
||||
, 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>*);
|
||||
|
||||
// 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(...);
|
||||
|
||||
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>
|
||||
struct bad_output_iterator_traits
|
||||
{
|
||||
template <class Iterator>
|
||||
struct traits
|
||||
{
|
||||
# if defined(BOOST_MSVC_STD_ITERATOR) && !defined(__SGI_STL_PORT)
|
||||
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::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;
|
||||
typedef void value_type;
|
||||
typedef void difference_type;
|
||||
typedef std::output_iterator_tag iterator_category;
|
||||
typedef void pointer;
|
||||
typedef void 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;
|
||||
|
||||
// If we're looking at an MSVC6 (old Dinkumware) ``standard''
|
||||
// iterator, this will generate an appropriate traits class.
|
||||
template <class Iterator>
|
||||
struct msvc_stdlib_iterator_traits
|
||||
: mpl::if_<
|
||||
is_mutable_iterator<Iterator>
|
||||
, msvc_stdlib_mutable_traits<Iterator>
|
||||
, msvc_stdlib_const_traits<Iterator>
|
||||
>::type
|
||||
{};
|
||||
|
||||
template <class Iterator>
|
||||
struct non_pointer_iterator_traits
|
||||
: mpl::if_<
|
||||
// if the iterator contains all the right nested types...
|
||||
is_full_iterator_traits<Iterator>
|
||||
// Use a standard iterator_traits implementation
|
||||
, standard_iterator_traits<Iterator>
|
||||
# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
|
||||
// Check for STLPort 4.0 broken _Iterator_category type
|
||||
, mpl::if_<
|
||||
is_stlport_40_debug_iterator<Iterator>
|
||||
, stlport_40_debug_iterator_traits<Iterator>
|
||||
# endif
|
||||
};
|
||||
// Otherwise, assume it's a Dinkum iterator
|
||||
, msvc_stdlib_iterator_traits<Iterator>
|
||||
# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
|
||||
>::type
|
||||
# endif
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace boost::detail::iterator_traits_
|
||||
template <class Iterator>
|
||||
struct iterator_traits_aux
|
||||
: mpl::if_<
|
||||
is_pointer<Iterator>
|
||||
, pointer_iterator_traits<Iterator>
|
||||
, non_pointer_iterator_traits<Iterator>
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
template <class Iterator>
|
||||
struct iterator_traits
|
||||
: iterator_traits_::iterator_traits_select<is_pointer<Iterator>::value>::template traits<Iterator>
|
||||
{
|
||||
// Explicit forwarding from base class needed to keep MSVC6 happy
|
||||
// under some circumstances.
|
||||
private:
|
||||
typedef typename iterator_traits_::iterator_traits_select<
|
||||
is_pointer<remove_cv<Iterator>::type>::value>::template traits<Iterator> traits;
|
||||
# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
|
||||
typedef
|
||||
typename mpl::if_<
|
||||
is_bad_output_iterator<Iterator>
|
||||
, bad_output_iterator_traits
|
||||
, iterator_traits_aux<Iterator>
|
||||
>::type base;
|
||||
# else
|
||||
typedef iterator_traits_aux<Iterator> base;
|
||||
# endif
|
||||
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;
|
||||
typedef typename base::value_type value_type;
|
||||
typedef typename base::pointer pointer;
|
||||
typedef typename base::reference reference;
|
||||
typedef typename base::difference_type difference_type;
|
||||
typedef typename base::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;
|
||||
}
|
||||
// This specialization cuts off ETI (Early Template Instantiation) for MSVC.
|
||||
template <> struct iterator_traits<int>
|
||||
{
|
||||
typedef int value_type;
|
||||
typedef int pointer;
|
||||
typedef int reference;
|
||||
typedef int difference_type;
|
||||
typedef int iterator_category;
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
# endif // workarounds
|
||||
|
||||
namespace boost { namespace detail {
|
||||
|
||||
namespace iterator_traits_
|
||||
{
|
||||
template <class Iterator, class Difference>
|
||||
struct distance_select
|
||||
{
|
||||
static Difference execute(Iterator i1, const Iterator i2, ...)
|
||||
{
|
||||
Difference result = 0;
|
||||
while (i1 != i2)
|
||||
{
|
||||
++i1;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static Difference execute(Iterator i1, const Iterator i2, std::random_access_iterator_tag*)
|
||||
{
|
||||
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)
|
||||
inline typename iterator_traits<Iterator>::difference_type
|
||||
distance(Iterator first, Iterator last)
|
||||
{
|
||||
typedef typename iterator_traits<Iterator>::difference_type diff_t;
|
||||
typedef typename ::boost::detail::iterator_traits<Iterator>::iterator_category iterator_category;
|
||||
return iterator_traits_::distance_select<iterator_category>::distance(first, last);
|
||||
|
||||
return iterator_traits_::distance_select<Iterator,diff_t>::execute(
|
||||
first, last, (iterator_category*)0);
|
||||
}
|
||||
# endif // workarounds
|
||||
|
||||
}} // namespace boost::detail
|
||||
}}
|
||||
|
||||
# endif
|
||||
|
||||
|
||||
# undef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
|
||||
# undef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
|
||||
|
76
include/boost/detail/lightweight_test.hpp
Normal file
76
include/boost/detail/lightweight_test.hpp
Normal file
@ -0,0 +1,76 @@
|
||||
#ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
|
||||
#define BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// boost/detail/lightweight_test.hpp - lightweight test library
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
//
|
||||
// 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_TEST(expression)
|
||||
// BOOST_ERROR(message)
|
||||
//
|
||||
// int boost::report_errors()
|
||||
//
|
||||
|
||||
#include <boost/current_function.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline int & test_errors()
|
||||
{
|
||||
static int x = 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
|
||||
{
|
||||
std::cerr << file << "(" << line << "): test '" << expr << "' failed in function '" << function << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
|
||||
inline void error_impl(char const * msg, char const * file, int line, char const * function)
|
||||
{
|
||||
std::cerr << file << "(" << line << "): " << msg << " in function '" << function << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
inline int report_errors()
|
||||
{
|
||||
int errors = detail::test_errors();
|
||||
|
||||
if(errors == 0)
|
||||
{
|
||||
std::cerr << "No errors detected." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << errors << " error" << (errors == 1? "": "s") << " detected." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
|
||||
#define BOOST_ERROR(msg) ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
|
||||
|
||||
#endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
|
189
include/boost/detail/quick_allocator.hpp
Normal file
189
include/boost/detail/quick_allocator.hpp
Normal file
@ -0,0 +1,189 @@
|
||||
#ifndef BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
|
||||
#define BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// detail/quick_allocator.hpp
|
||||
//
|
||||
// Copyright (c) 2003 David Abrahams
|
||||
// Copyright (c) 2003 Peter Dimov
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include <boost/detail/lightweight_mutex.hpp>
|
||||
#include <boost/type_traits/type_with_alignment.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
#include <new> // ::operator new, ::operator delete
|
||||
#include <cstddef> // std::size_t
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<unsigned size, unsigned align_> union freeblock
|
||||
{
|
||||
typedef typename boost::type_with_alignment<align_>::type aligner_type;
|
||||
aligner_type aligner;
|
||||
char bytes[size];
|
||||
freeblock * next;
|
||||
};
|
||||
|
||||
template<unsigned size, unsigned align_> struct allocator_impl
|
||||
{
|
||||
typedef freeblock<size, align_> block;
|
||||
|
||||
// It may seem odd to use such small pages.
|
||||
//
|
||||
// However, on a typical Windows implementation that uses
|
||||
// the OS allocator, "normal size" pages interact with the
|
||||
// "ordinary" operator new, slowing it down dramatically.
|
||||
//
|
||||
// 512 byte pages are handled by the small object allocator,
|
||||
// and don't interfere with ::new.
|
||||
//
|
||||
// The other alternative is to use much bigger pages (1M.)
|
||||
//
|
||||
// It is surprisingly easy to hit pathological behavior by
|
||||
// varying the page size. g++ 2.96 on Red Hat Linux 7.2,
|
||||
// for example, passionately dislikes 496. 512 seems OK.
|
||||
|
||||
#if defined(BOOST_QA_PAGE_SIZE)
|
||||
|
||||
enum { items_per_page = BOOST_QA_PAGE_SIZE / size };
|
||||
|
||||
#else
|
||||
|
||||
enum { items_per_page = 512 / size }; // 1048560 / size
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
static lightweight_mutex mutex;
|
||||
#endif
|
||||
|
||||
static block * free;
|
||||
static block * page;
|
||||
static unsigned last;
|
||||
|
||||
static inline void * alloc()
|
||||
{
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
lightweight_mutex::scoped_lock lock(mutex);
|
||||
#endif
|
||||
if(block * x = free)
|
||||
{
|
||||
free = x->next;
|
||||
return x;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(last == items_per_page)
|
||||
{
|
||||
// "Listen to me carefully: there is no memory leak"
|
||||
// -- Scott Meyers, Eff C++ 2nd Ed Item 10
|
||||
page = ::new block[items_per_page];
|
||||
last = 0;
|
||||
}
|
||||
|
||||
return &page[last++];
|
||||
}
|
||||
}
|
||||
|
||||
static inline void * alloc(std::size_t n)
|
||||
{
|
||||
if(n != size) // class-specific new called for a derived object
|
||||
{
|
||||
return ::operator new(n);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
lightweight_mutex::scoped_lock lock(mutex);
|
||||
#endif
|
||||
if(block * x = free)
|
||||
{
|
||||
free = x->next;
|
||||
return x;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(last == items_per_page)
|
||||
{
|
||||
page = ::new block[items_per_page];
|
||||
last = 0;
|
||||
}
|
||||
|
||||
return &page[last++];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void dealloc(void * pv)
|
||||
{
|
||||
if(pv != 0) // 18.4.1.1/13
|
||||
{
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
lightweight_mutex::scoped_lock lock(mutex);
|
||||
#endif
|
||||
block * pb = static_cast<block *>(pv);
|
||||
pb->next = free;
|
||||
free = pb;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void dealloc(void * pv, std::size_t n)
|
||||
{
|
||||
if(n != size) // class-specific delete called for a derived object
|
||||
{
|
||||
::operator delete(pv);
|
||||
}
|
||||
else if(pv != 0) // 18.4.1.1/13
|
||||
{
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
lightweight_mutex::scoped_lock lock(mutex);
|
||||
#endif
|
||||
block * pb = static_cast<block *>(pv);
|
||||
pb->next = free;
|
||||
free = pb;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
template<unsigned size, unsigned align_>
|
||||
lightweight_mutex allocator_impl<size, align_>::mutex;
|
||||
#endif
|
||||
|
||||
template<unsigned size, unsigned align_>
|
||||
freeblock<size, align_> * allocator_impl<size, align_>::free = 0;
|
||||
|
||||
template<unsigned size, unsigned align_>
|
||||
freeblock<size, align_> * allocator_impl<size, align_>::page = 0;
|
||||
|
||||
template<unsigned size, unsigned align_>
|
||||
unsigned allocator_impl<size, align_>::last = allocator_impl<size, align_>::items_per_page;
|
||||
|
||||
template<class T>
|
||||
struct quick_allocator: public allocator_impl< sizeof(T), boost::alignment_of<T>::value >
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
|
145
include/boost/detail/reference_content.hpp
Normal file
145
include/boost/detail/reference_content.hpp
Normal file
@ -0,0 +1,145 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost detail/reference_content.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003
|
||||
// Eric Friedman
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
|
||||
#ifndef BOOST_DETAIL_REFERENCE_CONTENT_HPP
|
||||
#define BOOST_DETAIL_REFERENCE_CONTENT_HPP
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
# include "boost/mpl/bool.hpp"
|
||||
# include "boost/type_traits/has_nothrow_copy.hpp"
|
||||
#else
|
||||
# include "boost/mpl/if.hpp"
|
||||
# include "boost/type_traits/is_reference.hpp"
|
||||
#endif
|
||||
|
||||
#include "boost/mpl/void.hpp"
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) class template reference_content
|
||||
//
|
||||
// Non-Assignable wrapper for references.
|
||||
//
|
||||
template <typename RefT>
|
||||
class reference_content
|
||||
{
|
||||
private: // representation
|
||||
|
||||
RefT content_;
|
||||
|
||||
public: // structors
|
||||
|
||||
~reference_content()
|
||||
{
|
||||
}
|
||||
|
||||
reference_content(RefT r)
|
||||
: content_( r )
|
||||
{
|
||||
}
|
||||
|
||||
reference_content(const reference_content& operand)
|
||||
: content_( operand.content_ )
|
||||
{
|
||||
}
|
||||
|
||||
private: // non-Assignable
|
||||
|
||||
reference_content& operator=(const reference_content&);
|
||||
|
||||
public: // queries
|
||||
|
||||
RefT get() const
|
||||
{
|
||||
return content_;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) metafunction make_reference_content
|
||||
//
|
||||
// Wraps with reference_content if specified type is reference.
|
||||
//
|
||||
|
||||
template <typename T = mpl::void_> struct make_reference_content;
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
template <typename T>
|
||||
struct make_reference_content
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct make_reference_content< T& >
|
||||
{
|
||||
typedef reference_content<T&> type;
|
||||
};
|
||||
|
||||
#else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
template <typename T>
|
||||
struct make_reference_content
|
||||
: mpl::if_<
|
||||
is_reference<T>
|
||||
, reference_content<T>
|
||||
, T
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
|
||||
|
||||
template <>
|
||||
struct make_reference_content< mpl::void_ >
|
||||
{
|
||||
template <typename T>
|
||||
struct apply
|
||||
: make_reference_content<T>
|
||||
{
|
||||
};
|
||||
|
||||
typedef mpl::void_ type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// reference_content<T&> type traits specializations
|
||||
//
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
template <typename T>
|
||||
struct has_nothrow_copy<
|
||||
::boost::detail::reference_content< T& >
|
||||
>
|
||||
: mpl::true_
|
||||
{
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_DETAIL_REFERENCE_CONTENT_HPP
|
78
include/boost/detail/templated_streams.hpp
Normal file
78
include/boost/detail/templated_streams.hpp
Normal file
@ -0,0 +1,78 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// boost detail/templated_streams.hpp header file
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2003
|
||||
// Eric Friedman
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both the copyright notice and this permission notice appear in
|
||||
// supporting documentation. No representations are made about the
|
||||
// suitability of this software for any purpose. It is provided "as is"
|
||||
// without express or implied warranty.
|
||||
|
||||
#ifndef BOOST_DETAIL_TEMPLATED_STREAMS_HPP
|
||||
#define BOOST_DETAIL_TEMPLATED_STREAMS_HPP
|
||||
|
||||
#include "boost/config.hpp"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// (detail) BOOST_TEMPLATED_STREAM_* macros
|
||||
//
|
||||
// Provides workaround platforms without stream class templates.
|
||||
//
|
||||
|
||||
#if !defined(BOOST_NO_STD_LOCALE)
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_TEMPLATE(E,T) \
|
||||
template < typename E , typename T >
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_TEMPLATE_ALLOC(E,T,A) \
|
||||
template < typename E , typename T , typename A >
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ARGS(E,T) \
|
||||
typename E , typename T
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ARGS_ALLOC(E,T,A) \
|
||||
typename E , typename T , typename A
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_COMMA ,
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ELEM(E) E
|
||||
#define BOOST_TEMPLATED_STREAM_TRAITS(T) T
|
||||
#define BOOST_TEMPLATED_STREAM_ALLOC(A) A
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM(X,E,T) \
|
||||
BOOST_JOIN(std::basic_,X)< E , T >
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_WITH_ALLOC(X,E,T,A) \
|
||||
BOOST_JOIN(std::basic_,X)< E , T , A >
|
||||
|
||||
#else // defined(BOOST_NO_STD_LOCALE)
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_TEMPLATE(E,T) /**/
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_TEMPLATE_ALLOC(E,T,A) /**/
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ARGS(E,T) /**/
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ARGS_ALLOC(E,T,A) /**/
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_COMMA /**/
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_ELEM(E) char
|
||||
#define BOOST_TEMPLATED_STREAM_TRAITS(T) std::char_traits<char>
|
||||
#define BOOST_TEMPLATED_STREAM_ALLOC(A) std::allocator<char>
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM(X,E,T) \
|
||||
std::X
|
||||
|
||||
#define BOOST_TEMPLATED_STREAM_WITH_ALLOC(X,E,T,A) \
|
||||
std::X
|
||||
|
||||
#endif // BOOST_NO_STD_LOCALE
|
||||
|
||||
#endif // BOOST_DETAIL_TEMPLATED_STREAMS_HPP
|
39
include/boost/indirect_reference.hpp
Executable file
39
include/boost/indirect_reference.hpp
Executable file
@ -0,0 +1,39 @@
|
||||
// Copyright David Abrahams 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)
|
||||
#ifndef INDIRECT_REFERENCE_DWA200415_HPP
|
||||
# define INDIRECT_REFERENCE_DWA200415_HPP
|
||||
|
||||
// dereferenceable_traits provides access to the value_type and
|
||||
// reference of a Dereferenceable type.
|
||||
|
||||
# include <boost/detail/is_incrementable.hpp>
|
||||
# include <boost/iterator/iterator_traits.hpp>
|
||||
# include <boost/type_traits/remove_cv.hpp>
|
||||
# include <boost/mpl/apply_if.hpp>
|
||||
# include <boost/pointee.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <class P>
|
||||
struct smart_ptr_reference
|
||||
{
|
||||
typedef typename boost::pointee<P>::type& type;
|
||||
};
|
||||
}
|
||||
|
||||
template <class P>
|
||||
struct indirect_reference
|
||||
: mpl::apply_if<
|
||||
detail::is_incrementable<P>
|
||||
, iterator_reference<P>
|
||||
, detail::smart_ptr_reference<P>
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // INDIRECT_REFERENCE_DWA200415_HPP
|
24
include/boost/non_type.hpp
Normal file
24
include/boost/non_type.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
// (C) Copyright Gennaro Prota 2003. 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_NON_TYPE_HPP_GP_20030417
|
||||
#define BOOST_NON_TYPE_HPP_GP_20030417
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Just a simple "envelope" for non-type template parameters. Useful
|
||||
// to work around some MSVC deficiencies.
|
||||
|
||||
template <typename T, T n>
|
||||
struct non_type { };
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // include guard
|
@ -36,12 +36,23 @@ namespace boost {
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <int cond, class A, class B>
|
||||
// agurt, 15/sep/02: in certain cases Borland has problems with
|
||||
// choosing the right 'ct_if' specialization even though 'cond'
|
||||
// _does_ equal '1'; the easiest way to fix it is to make first
|
||||
// 'ct_if' non-type template parameter boolean.
|
||||
#if !defined(__BORLANDC__)
|
||||
template <bool cond, class A, class B>
|
||||
struct ct_if { typedef ct_if_error type; };
|
||||
template <class A, class B>
|
||||
struct ct_if<1, A, B> { typedef A type; };
|
||||
struct ct_if<true, A, B> { typedef A type; };
|
||||
template <class A, class B>
|
||||
struct ct_if<0, A, B> { typedef B type; };
|
||||
struct ct_if<false, A, B> { typedef B type; };
|
||||
#else
|
||||
template <bool cond, class A, class B>
|
||||
struct ct_if { typedef A type; };
|
||||
template <class A, class B>
|
||||
struct ct_if<false, A, B> { typedef B type; };
|
||||
#endif
|
||||
|
||||
template <class cond, class A, class B>
|
||||
struct ct_if_t { typedef ct_if_error type; };
|
||||
|
@ -1,17 +1,11 @@
|
||||
// Boost.Signals library
|
||||
//
|
||||
// Copyright (C) 2001 Doug Gregor (gregod@cs.rpi.edu)
|
||||
//
|
||||
// Permission to copy, use, sell and distribute this software is granted
|
||||
// provided this copyright notice appears in all copies.
|
||||
// Permission to modify the code and to distribute modified code is granted
|
||||
// provided this copyright notice appears in all copies, and a notice
|
||||
// that the code was modified is included with the copyright notice.
|
||||
//
|
||||
// This software is provided "as is" without express or implied warranty,
|
||||
// and with no claim as to its suitability for any purpose.
|
||||
|
||||
// For more information, see http://www.boost.org
|
||||
|
||||
// Copyright Doug Gregor 2001-2003. 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/signals
|
||||
|
||||
#ifndef BOOST_VISIT_EACH_HPP
|
||||
#define BOOST_VISIT_EACH_HPP
|
||||
|
Reference in New Issue
Block a user