mirror of
https://github.com/boostorg/detail.git
synced 2025-06-28 13:31:05 +02:00
Compare commits
15 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
4076d5bda0 | |||
de549910c0 | |||
49858c1ac4 | |||
ec6dfefa6e | |||
1df1d181c0 | |||
dc34adabef | |||
8aebcc4fbd | |||
2551c9baf0 | |||
71ec49242e | |||
0dc54e7b18 | |||
4039b44fce | |||
2f7218cdc4 | |||
37cd3c6dd2 | |||
71a268689d | |||
4dda81e93a |
@ -1,4 +1,4 @@
|
|||||||
/* Copyright 2003-2007 Joaqu<71>n M L<>pez Mu<4D>oz.
|
/* Copyright 2003-2005 Joaqu<71>n M L<>pez Mu<4D>oz.
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@ -30,21 +30,13 @@ namespace detail{
|
|||||||
namespace allocator{
|
namespace allocator{
|
||||||
|
|
||||||
/* partial_std_allocator_wrapper inherits the functionality of a std
|
/* partial_std_allocator_wrapper inherits the functionality of a std
|
||||||
* allocator while providing a templatized ctor and other bits missing
|
* allocator while providing a templatized ctor.
|
||||||
* in some stdlib implementation or another.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
class partial_std_allocator_wrapper:public std::allocator<Type>
|
class partial_std_allocator_wrapper:public std::allocator<Type>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/* Oddly enough, STLport does not define std::allocator<void>::value_type
|
|
||||||
* when configured to work without partial template specialization.
|
|
||||||
* No harm in supplying the definition here unconditionally.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef Type value_type;
|
|
||||||
|
|
||||||
partial_std_allocator_wrapper(){};
|
partial_std_allocator_wrapper(){};
|
||||||
|
|
||||||
template<typename Other>
|
template<typename Other>
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
// boost/identifier.hpp ----------------------------------------------------//
|
|
||||||
|
|
||||||
// Copyright Beman Dawes 2006
|
|
||||||
|
|
||||||
// Distributed under 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)
|
|
||||||
|
|
||||||
// See documentation at http://www.boost.org/libs/utility
|
|
||||||
|
|
||||||
#ifndef BOOST_IDENTIFIER_HPP
|
|
||||||
#define BOOST_IDENTIFIER_HPP
|
|
||||||
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
|
||||||
#include <boost/type_traits/is_base_of.hpp>
|
|
||||||
#include <iosfwd>
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
// class template identifier ---------------------------------------------//
|
|
||||||
|
|
||||||
// Always used as a base class so that different instantiations result in
|
|
||||||
// different class types even if instantiated with the same value type T.
|
|
||||||
|
|
||||||
// Expected usage is that T is often an integer type, best passed by
|
|
||||||
// value. There is no reason why T can't be a possibly larger class such as
|
|
||||||
// std::string, best passed by const reference.
|
|
||||||
|
|
||||||
// This implementation uses pass by value, based on expected common uses.
|
|
||||||
|
|
||||||
template <typename T, typename D>
|
|
||||||
class identifier
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef T value_type;
|
|
||||||
|
|
||||||
const value_type value() const { return m_value; }
|
|
||||||
void assign( value_type v ) { m_value = v; }
|
|
||||||
|
|
||||||
bool operator==( const D & rhs ) const { return m_value == rhs.m_value; }
|
|
||||||
bool operator!=( const D & rhs ) const { return m_value != rhs.m_value; }
|
|
||||||
bool operator< ( const D & rhs ) const { return m_value < rhs.m_value; }
|
|
||||||
bool operator<=( const D & rhs ) const { return m_value <= rhs.m_value; }
|
|
||||||
bool operator> ( const D & rhs ) const { return m_value > rhs.m_value; }
|
|
||||||
bool operator>=( const D & rhs ) const { return m_value >= rhs.m_value; }
|
|
||||||
|
|
||||||
typedef void (*unspecified_bool_type)(D); // without the D, unspecified_bool_type
|
|
||||||
static void unspecified_bool_true(D){} // conversion allows relational operators
|
|
||||||
// between different identifier types
|
|
||||||
|
|
||||||
operator unspecified_bool_type() const { return m_value == value_type() ? 0 : unspecified_bool_true; }
|
|
||||||
bool operator!() const { return m_value == value_type(); }
|
|
||||||
|
|
||||||
// constructors are protected so that class can only be used as a base class
|
|
||||||
protected:
|
|
||||||
identifier() {}
|
|
||||||
explicit identifier( value_type v ) : m_value(v) {}
|
|
||||||
|
|
||||||
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 // 1300 == VC++ 7.0 bug workaround
|
|
||||||
private:
|
|
||||||
#endif
|
|
||||||
T m_value;
|
|
||||||
};
|
|
||||||
|
|
||||||
//#ifndef BOOST_NO_SFINAE
|
|
||||||
|
|
||||||
// template <class Ostream, class Id>
|
|
||||||
// typename enable_if< is_base_of< identifier< typename Id::value_type, Id >, Id >,
|
|
||||||
// Ostream & >::type operator<<( Ostream & os, const Id & id )
|
|
||||||
// {
|
|
||||||
// return os << id.value();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// template <class Istream, class Id>
|
|
||||||
// typename enable_if< is_base_of< identifier< typename Id::value_type, Id >, Id >,
|
|
||||||
// Istream & >::type operator>>( Istream & is, Id & id )
|
|
||||||
// {
|
|
||||||
// typename Id::value_type v;
|
|
||||||
// is >> v;
|
|
||||||
// id.value( v );
|
|
||||||
// return is;
|
|
||||||
// }
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace boost
|
|
||||||
|
|
||||||
#endif // BOOST_IDENTIFIER_HPP
|
|
@ -398,7 +398,7 @@ struct reference_to_pointer_impl
|
|||||||
|
|
||||||
typedef mpl::bool_<value> type;
|
typedef mpl::bool_<value> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct is_reference_to_pointer
|
struct is_reference_to_pointer
|
||||||
: mpl::eval_if<is_reference<T>, reference_to_pointer_impl<T>, mpl::false_>::type
|
: mpl::eval_if<is_reference<T>, reference_to_pointer_impl<T>, mpl::false_>::type
|
||||||
|
@ -47,11 +47,6 @@ extern "C" long __cdecl InterlockedExchangeAdd( long*, long );
|
|||||||
# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
|
# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
|
||||||
# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
|
# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
|
||||||
|
|
||||||
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \
|
|
||||||
((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long*)(dest),(long)(exchange),(long)(compare)))
|
|
||||||
# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \
|
|
||||||
((void*)BOOST_INTERLOCKED_EXCHANGE((long*)(dest),(long)(exchange)))
|
|
||||||
|
|
||||||
#elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )
|
#elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )
|
||||||
|
|
||||||
extern "C" long __cdecl _InterlockedIncrement( long volatile * );
|
extern "C" long __cdecl _InterlockedIncrement( long volatile * );
|
||||||
|
@ -3,39 +3,107 @@
|
|||||||
// accompanying file LICENSE_1_0.txt or copy at
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// This header replaces the implementation of ct_if that preceded the
|
// The ct_if implementation that avoids partial specialization is
|
||||||
// introduction of Boost.MPL with a facade that defers to that reviewed and
|
// based on the IF class by Ulrich W. Eisenecker and Krzysztof
|
||||||
// accepted library.
|
// Czarnecki.
|
||||||
|
|
||||||
// Author: Ronald Garcia
|
|
||||||
// Date: 20 October, 2006
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BOOST_CT_IF_HPP
|
#ifndef BOOST_CT_IF_HPP
|
||||||
#define BOOST_CT_IF_HPP
|
#define BOOST_CT_IF_HPP
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
// A stub implementation in terms of Boost.MPL
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/type_traits/integral_constant.hpp> // true_type and false_type
|
||||||
#include <boost/mpl/not.hpp>
|
|
||||||
#include <boost/mpl/and.hpp>
|
|
||||||
// true_type and false_type are used by applications of ct_if
|
|
||||||
#include <boost/type_traits/integral_constant.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
|
struct ct_if_error { };
|
||||||
|
|
||||||
template <class A, class B>
|
template <class A, class B>
|
||||||
struct ct_and : boost::mpl::and_<A,B> {};
|
struct ct_and { typedef false_type type; };
|
||||||
|
template <> struct ct_and<true_type,true_type> { typedef true_type type; };
|
||||||
|
|
||||||
template <class A>
|
template <class A> struct ct_not { typedef ct_if_error type; };
|
||||||
struct ct_not : mpl::not_<A> {};
|
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
|
||||||
|
|
||||||
|
// 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>
|
template <bool cond, class A, class B>
|
||||||
struct ct_if : mpl::if_c<cond,A,B> {};
|
struct ct_if { typedef ct_if_error type; };
|
||||||
|
template <class A, class B>
|
||||||
|
struct ct_if<true, A, B> { typedef A type; };
|
||||||
|
template <class A, class B>
|
||||||
|
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>
|
template <class cond, class A, class B>
|
||||||
struct ct_if_t : mpl::if_<cond,A,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 {
|
||||||
|
|
||||||
|
template <int condition, class A, class B> struct IF;
|
||||||
|
template <int condition> struct SlectSelector;
|
||||||
|
struct SelectFirstType;
|
||||||
|
struct SelectSecondType;
|
||||||
|
|
||||||
|
struct SelectFirstType {
|
||||||
|
template<class A, class B>
|
||||||
|
struct Template { typedef A type; };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SelectSecondType {
|
||||||
|
template<class A, class B>
|
||||||
|
struct Template { typedef B type; };
|
||||||
|
};
|
||||||
|
|
||||||
|
template<int condition>
|
||||||
|
struct SlectSelector {
|
||||||
|
typedef SelectFirstType type;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct SlectSelector<0> {
|
||||||
|
typedef SelectSecondType type;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
template<int condition, class A, class B>
|
||||||
|
struct ct_if
|
||||||
|
{
|
||||||
|
typedef typename detail::SlectSelector<condition>::type Selector;
|
||||||
|
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
|
} // namespace boost
|
||||||
|
|
||||||
|
@ -12,17 +12,14 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef BOOST_INTEGER_LOG2_HPP_GP_20030301
|
#ifndef BOOST_INTEGER_LOG2_HPP_GP_20030301
|
||||||
#define BOOST_INTEGER_LOG2_HPP_GP_20030301
|
#define BOOST_INTEGER_LOG2_HPP_GP_20030301
|
||||||
|
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
#ifdef __BORLANDC__
|
#include <climits> // actually used for Borland only
|
||||||
#include <climits>
|
|
||||||
#endif
|
|
||||||
#include "boost/limits.hpp"
|
#include "boost/limits.hpp"
|
||||||
#include "boost/config.hpp"
|
#include "boost/config.hpp"
|
||||||
|
|
||||||
|
@ -139,8 +139,8 @@ std::codecvt_base::result utf8_codecvt_facet::do_out(
|
|||||||
int shift_exponent = (cont_octet_count) * 6;
|
int shift_exponent = (cont_octet_count) * 6;
|
||||||
|
|
||||||
// Process the first character
|
// Process the first character
|
||||||
*to++ = static_cast<char>(octet1_modifier_table[cont_octet_count] +
|
*to++ = octet1_modifier_table[cont_octet_count] +
|
||||||
(unsigned char)(*from / (1 << shift_exponent)));
|
(unsigned char)(*from / (1 << shift_exponent));
|
||||||
|
|
||||||
// Process the continuation characters
|
// Process the continuation characters
|
||||||
// Invariants: At the start of the loop:
|
// Invariants: At the start of the loop:
|
||||||
@ -150,7 +150,7 @@ std::codecvt_base::result utf8_codecvt_facet::do_out(
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
while (i != cont_octet_count && to != to_end) {
|
while (i != cont_octet_count && to != to_end) {
|
||||||
shift_exponent -= 6;
|
shift_exponent -= 6;
|
||||||
*to++ = static_cast<char>(0x80 + ((*from / (1 << shift_exponent)) % (1 << 6)));
|
*to++ = 0x80 + ((*from / (1 << shift_exponent)) % (1 << 6));
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
// If we filled up the out buffer before encoding the character
|
// If we filled up the out buffer before encoding the character
|
||||||
@ -199,7 +199,7 @@ int utf8_codecvt_facet::do_length(
|
|||||||
last_octet_count = (get_octet_count(*from_next));
|
last_octet_count = (get_octet_count(*from_next));
|
||||||
++char_count;
|
++char_count;
|
||||||
}
|
}
|
||||||
return static_cast<int>(from_next-from_end);
|
return from_next-from_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int utf8_codecvt_facet::get_octet_count(
|
unsigned int utf8_codecvt_facet::get_octet_count(
|
||||||
|
Reference in New Issue
Block a user