forked from boostorg/integer
Full merge from trunk at revision 41356 of entire boost-root tree.
[SVN r41369]
This commit is contained in:
committed by
Glen Fernandes
parent
5328370ab6
commit
775d25573b
@ -3,107 +3,39 @@
|
|||||||
// 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)
|
||||||
|
|
||||||
// The ct_if implementation that avoids partial specialization is
|
// This header replaces the implementation of ct_if that preceded the
|
||||||
// based on the IF class by Ulrich W. Eisenecker and Krzysztof
|
// introduction of Boost.MPL with a facade that defers to that reviewed and
|
||||||
// Czarnecki.
|
// accepted library.
|
||||||
|
|
||||||
|
// 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/type_traits/integral_constant.hpp> // true_type and false_type
|
#include <boost/mpl/if.hpp>
|
||||||
|
#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 { typedef false_type type; };
|
struct ct_and : boost::mpl::and_<A,B> {};
|
||||||
template <> struct ct_and<true_type,true_type> { typedef true_type type; };
|
|
||||||
|
|
||||||
template <class A> struct ct_not { typedef ct_if_error type; };
|
template <class A>
|
||||||
template <> struct ct_not<true_type> { typedef false_type type; };
|
struct ct_not : mpl::not_<A> {};
|
||||||
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 { typedef ct_if_error type; };
|
struct ct_if : mpl::if_c<cond,A,B> {};
|
||||||
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 { typedef ct_if_error type; };
|
struct ct_if_t : mpl::if_<cond,A,B> {};
|
||||||
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,14 +12,17 @@
|
|||||||
// 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 <cassert>
|
#include <assert.h>
|
||||||
#include <climits> // actually used for Borland only
|
#ifdef __BORLANDC__
|
||||||
|
#include <climits>
|
||||||
|
#endif
|
||||||
#include "boost/limits.hpp"
|
#include "boost/limits.hpp"
|
||||||
#include "boost/config.hpp"
|
#include "boost/config.hpp"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user