From ee352dee03d6cb77108180833e3097a9d7bd27c5 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Mon, 18 Sep 2000 08:24:47 +0000 Subject: [PATCH 01/12] pending stuff from Boost Graph Library [SVN r7704] --- include/boost/pending/cstddef.hpp | 12 ++++++ include/boost/pending/ct_if.hpp | 67 +++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 include/boost/pending/cstddef.hpp create mode 100644 include/boost/pending/ct_if.hpp diff --git a/include/boost/pending/cstddef.hpp b/include/boost/pending/cstddef.hpp new file mode 100644 index 0000000..279bec0 --- /dev/null +++ b/include/boost/pending/cstddef.hpp @@ -0,0 +1,12 @@ +// -*- C++ -*- forwarding header. + +#ifndef BOOST_CSTDDEF_HPP +#define BOOST_CSTDDEF_HPP + +#if defined(__sgi) && !defined(__GNUC__) +# include +#else +# include +#endif + +#endif diff --git a/include/boost/pending/ct_if.hpp b/include/boost/pending/ct_if.hpp new file mode 100644 index 0000000..a6f3059 --- /dev/null +++ b/include/boost/pending/ct_if.hpp @@ -0,0 +1,67 @@ +// (C) Copyright Jeremy Siek 2000. 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. + +// The ct_if implementation that avoids partial specialization is +// based on the IF class by Ulrich W. Eisenecker and Krzysztof +// Czarnecki. + +#ifndef BOOST_CT_IF_HPP +#define BOOST_CT_IF_HPP + +#include + +namespace boost { + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + template + struct ct_if { typedef A type; }; + template + struct ct_if<0, A, B> { typedef B type; }; + +#else + + namespace detail { + + template struct IF; + template struct SlectSelector; + struct SelectFirstType; + struct SelectSecondType; + + struct SelectFirstType { + template + struct Template { typedef A type; }; + }; + + struct SelectSecondType { + template + struct Template { typedef B type; }; + }; + + template + struct SlectSelector { + typedef SelectFirstType type; + }; + + template <> + struct SlectSelector<0> { + typedef SelectSecondType type; + }; + + } // namespace detail + + template + struct ct_if + { + typedef typename detail::SlectSelector::type Selector; + typedef typename Selector::template Template::type type; + }; + +#endif + +} // namespace boost + +#endif // BOOST_CT_IF_HPP + From 7ad2ddb3bcf1f0b24364eafdf6138d3e096f13d1 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Mon, 25 Sep 2000 21:19:29 +0000 Subject: [PATCH 02/12] removed tabs [SVN r7835] --- include/boost/pending/ct_if.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/pending/ct_if.hpp b/include/boost/pending/ct_if.hpp index a6f3059..669ad54 100644 --- a/include/boost/pending/ct_if.hpp +++ b/include/boost/pending/ct_if.hpp @@ -32,7 +32,7 @@ namespace boost { struct SelectFirstType { template - struct Template { typedef A type; }; + struct Template { typedef A type; }; }; struct SelectSecondType { From 304cce63f590842090505c357500badf10ce1d6a Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Tue, 17 Oct 2000 00:16:05 +0000 Subject: [PATCH 03/12] ported the graph library to borland [SVN r7965] --- include/boost/pending/ct_if.hpp | 36 ++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/include/boost/pending/ct_if.hpp b/include/boost/pending/ct_if.hpp index 669ad54..1655cfa 100644 --- a/include/boost/pending/ct_if.hpp +++ b/include/boost/pending/ct_if.hpp @@ -12,15 +12,44 @@ #include +/* + 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 + struct ct_and { typedef false_type type; }; + template <> struct ct_and { typedef true_type type; }; + + template struct ct_not { typedef ct_if_error type; }; + template <> struct ct_not { typedef false_type type; }; + template <> struct ct_not { typedef true_type type; }; + #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template - struct ct_if { typedef A type; }; + struct ct_if { typedef ct_if_error type; }; + template + struct ct_if<1, A, B> { typedef A type; }; template struct ct_if<0, A, B> { typedef B type; }; + template + struct ct_if_t { typedef ct_if_error type; }; + template + struct ct_if_t { typedef A type; }; + template + struct ct_if_t { typedef B type; }; + #else namespace detail { @@ -59,6 +88,11 @@ namespace boost { typedef typename Selector::template Template::type type; }; + template + struct ct_if_t { + typedef typename ct_if::type type; + }; + #endif } // namespace boost From 357349a423f68a9ed353618df0d4b2fc39295a17 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Mon, 16 Sep 2002 04:10:29 +0000 Subject: [PATCH 04/12] Borland fix [SVN r15360] --- include/boost/pending/ct_if.hpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/include/boost/pending/ct_if.hpp b/include/boost/pending/ct_if.hpp index 1655cfa..5fbb045 100644 --- a/include/boost/pending/ct_if.hpp +++ b/include/boost/pending/ct_if.hpp @@ -36,12 +36,23 @@ namespace boost { #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template +// 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 struct ct_if { typedef ct_if_error type; }; template - struct ct_if<1, A, B> { typedef A type; }; + struct ct_if { typedef A type; }; template - struct ct_if<0, A, B> { typedef B type; }; + struct ct_if { typedef B type; }; +#else + template + struct ct_if { typedef A type; }; + template + struct ct_if { typedef B type; }; +#endif template struct ct_if_t { typedef ct_if_error type; }; From ff18de3b35efc1660eab6579a3aca8af007a63cf Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Sun, 18 Apr 2004 09:15:08 +0000 Subject: [PATCH 05/12] new file (needed by dynamic_bitset) [SVN r22651] --- include/boost/pending/integer_log2.hpp | 96 ++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 include/boost/pending/integer_log2.hpp diff --git a/include/boost/pending/integer_log2.hpp b/include/boost/pending/integer_log2.hpp new file mode 100644 index 0000000..49b97a2 --- /dev/null +++ b/include/boost/pending/integer_log2.hpp @@ -0,0 +1,96 @@ +// ------------------------------------- +// integer_log2.hpp +// +// Gives the integer part of the logarithm, in base 2, of a +// given number. Behavior is undefined if the argument is <= 0. +// +// +// (C) Copyright Gennaro Prota 2003 - 2004. +// +// 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) +// +// ------------------------------------------------------ + + + +#ifndef BOOST_INTEGER_LOG2_HPP_GP_20030301 +#define BOOST_INTEGER_LOG2_HPP_GP_20030301 + +#include +#include "boost/limits.hpp" +#include "boost/config.hpp" + + +namespace boost { + namespace detail { + + template + int integer_log2_impl(T x, int n) { + + int result = 0; + + while (x != 1) { + + const T t = x >> n; + if (t) { + result += n; + x = t; + } + n /= 2; + + } + + return result; + } + + + + // helper to find the maximum power of two + // less than p (more involved than necessary, + // to avoid PTS) + // + template + struct max_pow2_less { + + enum { c = 2*n < p }; + + BOOST_STATIC_CONSTANT(int, value = + c ? (max_pow2_less< c*p, 2*c*n>::value) : n); + + }; + + template <> + struct max_pow2_less<0, 0> { + + BOOST_STATIC_CONSTANT(int, value = 0); + }; + + } // detail + + + // --------- + // integer_log2 + // --------------- + // + template + int integer_log2(T x) { + + assert(x > 0); + + const int n = detail::max_pow2_less< + std::numeric_limits :: digits, 4 + > :: value; + + return detail::integer_log2_impl(x, n); + + } + + + +} + + + +#endif // include guard From 70c7ae271c64a8f53288e84279017d46461c2cfa Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Sun, 9 May 2004 08:58:03 +0000 Subject: [PATCH 06/12] added Borland workaround [SVN r22770] --- include/boost/pending/integer_log2.hpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/include/boost/pending/integer_log2.hpp b/include/boost/pending/integer_log2.hpp index 49b97a2..fd8e446 100644 --- a/include/boost/pending/integer_log2.hpp +++ b/include/boost/pending/integer_log2.hpp @@ -19,6 +19,7 @@ #define BOOST_INTEGER_LOG2_HPP_GP_20030301 #include +#include // actually used for Borland only #include "boost/limits.hpp" #include "boost/config.hpp" @@ -67,6 +68,22 @@ namespace boost { BOOST_STATIC_CONSTANT(int, value = 0); }; + // this template is here just for Borland :( + // we could simply rely on numeric_limits but sometimes + // Borland tries to use numeric_limits, because + // of its usual const-related problems in argument deduction + // - gps + template + struct width { + +#ifdef __BORLANDC__ + BOOST_STATIC_CONSTANT(int, value = sizeof(T) * CHAR_BIT); +#else + BOOST_STATIC_CONSTANT(int, value = (std::numeric_limits::digits)); +#endif + + }; + } // detail @@ -80,8 +97,8 @@ namespace boost { assert(x > 0); const int n = detail::max_pow2_less< - std::numeric_limits :: digits, 4 - > :: value; + detail::width :: value, 4 + > :: value; return detail::integer_log2_impl(x, n); From f71f747400d20cafead3ef0f96579a4953f8fc44 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 26 Jul 2004 00:32:12 +0000 Subject: [PATCH 07/12] Converted to Boost Software License, Version 1.0 [SVN r24055] --- include/boost/pending/ct_if.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/pending/ct_if.hpp b/include/boost/pending/ct_if.hpp index 5fbb045..29fdbc4 100644 --- a/include/boost/pending/ct_if.hpp +++ b/include/boost/pending/ct_if.hpp @@ -1,7 +1,7 @@ -// (C) Copyright Jeremy Siek 2000. 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. +// (C) Copyright Jeremy Siek 2000. +// 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) // The ct_if implementation that avoids partial specialization is // based on the IF class by Ulrich W. Eisenecker and Krzysztof From a76279f48c1b8065b3507c3867790324e01c93b0 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Wed, 20 Oct 2004 13:07:46 +0000 Subject: [PATCH 08/12] added copyrights [SVN r25809] --- include/boost/pending/cstddef.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/pending/cstddef.hpp b/include/boost/pending/cstddef.hpp index 279bec0..440629e 100644 --- a/include/boost/pending/cstddef.hpp +++ b/include/boost/pending/cstddef.hpp @@ -1,4 +1,8 @@ // -*- C++ -*- forwarding header. +// (C) Copyright Jeremy Siek 2004 +// 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) #ifndef BOOST_CSTDDEF_HPP #define BOOST_CSTDDEF_HPP From 5328370ab6d885a412e6903a68763e7f5363cca7 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 30 Jan 2005 15:47:46 +0000 Subject: [PATCH 09/12] Bring type traits into line with TR1 [SVN r26937] --- include/boost/pending/ct_if.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/boost/pending/ct_if.hpp b/include/boost/pending/ct_if.hpp index 29fdbc4..2f8540d 100644 --- a/include/boost/pending/ct_if.hpp +++ b/include/boost/pending/ct_if.hpp @@ -19,13 +19,12 @@ problem. */ +#include // true_type and false_type + namespace boost { struct ct_if_error { }; - struct true_type { enum { value = true }; }; - struct false_type { enum { value = false }; }; - template struct ct_and { typedef false_type type; }; template <> struct ct_and { typedef true_type type; }; From 775d25573bac4b009dd393db12eaeb5a8e8e1130 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 25 Nov 2007 18:07:19 +0000 Subject: [PATCH 10/12] Full merge from trunk at revision 41356 of entire boost-root tree. [SVN r41369] --- include/boost/pending/ct_if.hpp | 104 +++++-------------------- include/boost/pending/integer_log2.hpp | 9 ++- 2 files changed, 24 insertions(+), 89 deletions(-) diff --git a/include/boost/pending/ct_if.hpp b/include/boost/pending/ct_if.hpp index 2f8540d..a9b801e 100644 --- a/include/boost/pending/ct_if.hpp +++ b/include/boost/pending/ct_if.hpp @@ -3,107 +3,39 @@ // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// The ct_if implementation that avoids partial specialization is -// based on the IF class by Ulrich W. Eisenecker and Krzysztof -// Czarnecki. +// This header replaces the implementation of ct_if that preceded the +// introduction of Boost.MPL with a facade that defers to that reviewed and +// accepted library. + +// Author: Ronald Garcia +// Date: 20 October, 2006 + #ifndef BOOST_CT_IF_HPP #define BOOST_CT_IF_HPP -#include -/* - 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. -*/ +// A stub implementation in terms of Boost.MPL -#include // true_type and false_type +#include +#include +#include +// true_type and false_type are used by applications of ct_if +#include namespace boost { - struct ct_if_error { }; - template - struct ct_and { typedef false_type type; }; - template <> struct ct_and { typedef true_type type; }; + struct ct_and : boost::mpl::and_ {}; - template struct ct_not { typedef ct_if_error type; }; - template <> struct ct_not { typedef false_type type; }; - template <> struct ct_not { typedef true_type type; }; + template + struct ct_not : mpl::not_ {}; -#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 - struct ct_if { typedef ct_if_error type; }; - template - struct ct_if { typedef A type; }; - template - struct ct_if { typedef B type; }; -#else - template - struct ct_if { typedef A type; }; - template - struct ct_if { typedef B type; }; -#endif + struct ct_if : mpl::if_c {}; template - struct ct_if_t { typedef ct_if_error type; }; - template - struct ct_if_t { typedef A type; }; - template - struct ct_if_t { typedef B type; }; - -#else - - namespace detail { - - template struct IF; - template struct SlectSelector; - struct SelectFirstType; - struct SelectSecondType; - - struct SelectFirstType { - template - struct Template { typedef A type; }; - }; - - struct SelectSecondType { - template - struct Template { typedef B type; }; - }; - - template - struct SlectSelector { - typedef SelectFirstType type; - }; - - template <> - struct SlectSelector<0> { - typedef SelectSecondType type; - }; - - } // namespace detail - - template - struct ct_if - { - typedef typename detail::SlectSelector::type Selector; - typedef typename Selector::template Template::type type; - }; - - template - struct ct_if_t { - typedef typename ct_if::type type; - }; - -#endif + struct ct_if_t : mpl::if_ {}; } // namespace boost diff --git a/include/boost/pending/integer_log2.hpp b/include/boost/pending/integer_log2.hpp index fd8e446..15fd8b5 100644 --- a/include/boost/pending/integer_log2.hpp +++ b/include/boost/pending/integer_log2.hpp @@ -12,14 +12,17 @@ // http://www.boost.org/LICENSE_1_0.txt) // // ------------------------------------------------------ - +// +// $Id$ #ifndef BOOST_INTEGER_LOG2_HPP_GP_20030301 #define BOOST_INTEGER_LOG2_HPP_GP_20030301 -#include -#include // actually used for Borland only +#include +#ifdef __BORLANDC__ +#include +#endif #include "boost/limits.hpp" #include "boost/config.hpp" From 78b945269620d716c1e273eb277e37bdf002f48d Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Sun, 24 Aug 2008 18:16:24 +0000 Subject: [PATCH 11/12] boost/pending/: ported revision 48251 ("integer_log2.hpp and lowest_bit.hpp, in boost/pending/: little comment cleanup (svn anchors, etc.); added a static_cast<> to silence (harmless) MSVC++ warnings") from trunk [SVN r48353] --- include/boost/pending/integer_log2.hpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/include/boost/pending/integer_log2.hpp b/include/boost/pending/integer_log2.hpp index 15fd8b5..f4bc846 100644 --- a/include/boost/pending/integer_log2.hpp +++ b/include/boost/pending/integer_log2.hpp @@ -1,20 +1,16 @@ -// ------------------------------------- +// ----------------------------------------------------------- // integer_log2.hpp // // Gives the integer part of the logarithm, in base 2, of a // given number. Behavior is undefined if the argument is <= 0. // -// -// (C) Copyright Gennaro Prota 2003 - 2004. +// Copyright (c) 2003-2004, 2008 Gennaro Prota // // 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) // -// ------------------------------------------------------ -// -// $Id$ - +// ----------------------------------------------------------- #ifndef BOOST_INTEGER_LOG2_HPP_GP_20030301 #define BOOST_INTEGER_LOG2_HPP_GP_20030301 @@ -37,7 +33,7 @@ namespace boost { while (x != 1) { - const T t = x >> n; + const T t = static_cast(x >> n); if (t) { result += n; x = t; From afa395b517070ef2a8efb798750c6eace32784d4 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Tue, 29 Dec 2009 03:50:53 +0000 Subject: [PATCH 12/12] Merged changes from trunk that are going into 1.42.0 [SVN r58554] --- include/boost/pending/ct_if.hpp | 43 --------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 include/boost/pending/ct_if.hpp diff --git a/include/boost/pending/ct_if.hpp b/include/boost/pending/ct_if.hpp deleted file mode 100644 index a9b801e..0000000 --- a/include/boost/pending/ct_if.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// (C) Copyright Jeremy Siek 2000. -// 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) - -// This header replaces the implementation of ct_if that preceded the -// introduction of Boost.MPL with a facade that defers to that reviewed and -// accepted library. - -// Author: Ronald Garcia -// Date: 20 October, 2006 - - -#ifndef BOOST_CT_IF_HPP -#define BOOST_CT_IF_HPP - - -// A stub implementation in terms of Boost.MPL - -#include -#include -#include -// true_type and false_type are used by applications of ct_if -#include - -namespace boost { - - template - struct ct_and : boost::mpl::and_ {}; - - template - struct ct_not : mpl::not_ {}; - - template - struct ct_if : mpl::if_c {}; - - template - struct ct_if_t : mpl::if_ {}; - -} // namespace boost - -#endif // BOOST_CT_IF_HPP -