From 3f5e466c7efd917328bb1bd7f2387d387f9a0888 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Mon, 18 Sep 2000 08:24:47 +0000 Subject: [PATCH 01/29] pending stuff from Boost Graph Library [SVN r7704] --- .gitattributes | 96 +++++++++++++++++++++++++++++++ include/boost/pending/cstddef.hpp | 12 ++++ include/boost/pending/ct_if.hpp | 67 +++++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 .gitattributes create mode 100644 include/boost/pending/cstddef.hpp create mode 100644 include/boost/pending/ct_if.hpp diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3e84d7c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,96 @@ +* text=auto !eol svneol=native#text/plain +*.gitattributes text svneol=native#text/plain + +# Scriptish formats +*.bat text svneol=native#text/plain +*.bsh text svneol=native#text/x-beanshell +*.cgi text svneol=native#text/plain +*.cmd text svneol=native#text/plain +*.js text svneol=native#text/javascript +*.php text svneol=native#text/x-php +*.pl text svneol=native#text/x-perl +*.pm text svneol=native#text/x-perl +*.py text svneol=native#text/x-python +*.sh eol=lf svneol=LF#text/x-sh +configure eol=lf svneol=LF#text/x-sh + +# Image formats +*.bmp binary svneol=unset#image/bmp +*.gif binary svneol=unset#image/gif +*.ico binary svneol=unset#image/ico +*.jpeg binary svneol=unset#image/jpeg +*.jpg binary svneol=unset#image/jpeg +*.png binary svneol=unset#image/png +*.tif binary svneol=unset#image/tiff +*.tiff binary svneol=unset#image/tiff +*.svg text svneol=native#image/svg%2Bxml + +# Data formats +*.pdf binary svneol=unset#application/pdf +*.avi binary svneol=unset#video/avi +*.doc binary svneol=unset#application/msword +*.dsp text svneol=crlf#text/plain +*.dsw text svneol=crlf#text/plain +*.eps binary svneol=unset#application/postscript +*.gz binary svneol=unset#application/gzip +*.mov binary svneol=unset#video/quicktime +*.mp3 binary svneol=unset#audio/mpeg +*.ppt binary svneol=unset#application/vnd.ms-powerpoint +*.ps binary svneol=unset#application/postscript +*.psd binary svneol=unset#application/photoshop +*.rdf binary svneol=unset#text/rdf +*.rss text svneol=unset#text/xml +*.rtf binary svneol=unset#text/rtf +*.sln text svneol=native#text/plain +*.swf binary svneol=unset#application/x-shockwave-flash +*.tgz binary svneol=unset#application/gzip +*.vcproj text svneol=native#text/xml +*.vcxproj text svneol=native#text/xml +*.vsprops text svneol=native#text/xml +*.wav binary svneol=unset#audio/wav +*.xls binary svneol=unset#application/vnd.ms-excel +*.zip binary svneol=unset#application/zip + +# Text formats +.htaccess text svneol=native#text/plain +*.bbk text svneol=native#text/xml +*.cmake text svneol=native#text/plain +*.css text svneol=native#text/css +*.dtd text svneol=native#text/xml +*.htm text svneol=native#text/html +*.html text svneol=native#text/html +*.ini text svneol=native#text/plain +*.log text svneol=native#text/plain +*.mak text svneol=native#text/plain +*.qbk text svneol=native#text/plain +*.rst text svneol=native#text/plain +*.sql text svneol=native#text/x-sql +*.txt text svneol=native#text/plain +*.xhtml text svneol=native#text/xhtml%2Bxml +*.xml text svneol=native#text/xml +*.xsd text svneol=native#text/xml +*.xsl text svneol=native#text/xml +*.xslt text svneol=native#text/xml +*.xul text svneol=native#text/xul +*.yml text svneol=native#text/plain +boost-no-inspect text svneol=native#text/plain +CHANGES text svneol=native#text/plain +COPYING text svneol=native#text/plain +INSTALL text svneol=native#text/plain +Jamfile text svneol=native#text/plain +Jamroot text svneol=native#text/plain +Jamfile.v2 text svneol=native#text/plain +Jamrules text svneol=native#text/plain +Makefile* text svneol=native#text/plain +README text svneol=native#text/plain +TODO text svneol=native#text/plain + +# Code formats +*.c text svneol=native#text/plain +*.cpp text svneol=native#text/plain +*.h text svneol=native#text/plain +*.hpp text svneol=native#text/plain +*.ipp text svneol=native#text/plain +*.tpp text svneol=native#text/plain +*.jam text svneol=native#text/plain +*.java text svneol=native#text/plain 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 9b9d2241a7656f1b3e99291ca158f10f619d9416 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Mon, 25 Sep 2000 21:19:29 +0000 Subject: [PATCH 02/29] 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 de2904c9a1f9dced3968194445aa60b74c1a832b Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Tue, 17 Oct 2000 00:16:05 +0000 Subject: [PATCH 03/29] 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 4d24f82e6e39013e409d03d92000a851c138a964 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 21 Jan 2001 00:16:10 +0000 Subject: [PATCH 04/29] Initial Checkin [SVN r8661] --- include/boost/type.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 include/boost/type.hpp diff --git a/include/boost/type.hpp b/include/boost/type.hpp new file mode 100644 index 0000000..a6d17f6 --- /dev/null +++ b/include/boost/type.hpp @@ -0,0 +1,19 @@ +// (C) Copyright David Abrahams 2001. Permission to copy, use, +// modify, sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. + +#ifndef BOOST_TYPE_DWA20010120_HPP +# define BOOST_TYPE_DWA20010120_HPP + +namespace boost { + + // Just a simple "type envelope". Useful in various contexts, mostly to work + // around some MSVC deficiencies. + template + struct type {}; + +} + +#endif // BOOST_TYPE_DWA20010120_HPP From 5963c3d44daae29b8b2c974438a9ab7dbfa0ea13 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 21 Jan 2001 05:18:41 +0000 Subject: [PATCH 05/29] Initial checkin [SVN r8664] --- include/boost/detail/iterator.hpp | 207 ++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 include/boost/detail/iterator.hpp diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp new file mode 100644 index 0000000..8652b8f --- /dev/null +++ b/include/boost/detail/iterator.hpp @@ -0,0 +1,207 @@ +// (C) Copyright David Abrahams 2001. Permission to copy, use, modify, +// sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. + +// Boost versions of +// +// std::iterator_traits<>::iterator_category +// std::iterator_traits<>::difference_type +// std::distance() +// +// ...for all compilers and iterators + +#ifndef ITERATOR_DWA122600_HPP_ +# define ITERATOR_DWA122600_HPP_ + +# include +# include +# include +# include + +// STLPort 4.0 and betas have a bug when debugging is enabled and there is no +// partial specialization: instead of an iterator_category typedef, the standard +// container iterators have _Iterator_category. +// +// Also, whether debugging is enabled or not, there is a broken specialization +// of std::iterator which has no +// typedefs but iterator_category. +// the proper typedef. +# if defined(__SGI_STL_PORT) && (__SGI_STL_PORT <= 0x410) && !defined(__STL_CLASS_PARTIAL_SPECIALIZATION) + +# ifdef __STL_DEBUG +# define BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +# endif + +# define BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION + +# endif // STLPort <= 4.1b4 && no partial specialization + +# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +# include +# include +# include +# include +# include +# include +# include +# include +# include +# endif + +namespace boost { namespace detail { +# if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +using std::iterator_traits; +using std::distance; +# else +// Workarounds for less-capable implementations +template struct iterator_traits_select; +template <> struct iterator_traits_select +{ + template + struct traits + { + typedef std::ptrdiff_t difference_type; + typedef std::random_access_iterator_tag iterator_category; + }; +}; + + +# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +no_result bad_category_helper(...); +template yes_result bad_category_helper(std::_DBG_iter*); + +template struct bad_category_select; +template <> +struct bad_category_select +{ + template + struct category { typedef typename Iterator::_Iterator_category type; }; +}; +template <> +struct bad_category_select +{ + template + struct category { typedef typename Iterator::iterator_category type; }; +}; + +template +struct iterator_category_select +{ + private: + static Iterator p; + enum { has_bad_category + = sizeof(bad_category_helper(&p)) == sizeof(yes_result) }; + typedef bad_category_select category_select; + public: + typedef typename category_select::template category::type type; +}; + +# endif + +# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION +template struct bad_difference_select; +template <> +struct bad_difference_select +{ + template + struct difference { typedef void type; }; +}; +template <> +struct bad_difference_select +{ + template + struct difference { typedef typename Iterator::difference_type type; }; +}; +yes_result bad_output_iterator_helper(std::iterator*); +no_result bad_output_iterator_helper(...); +# endif + +template <> struct iterator_traits_select +{ + template + struct traits +# if defined(BOOST_NO_STD_ITERATOR_TRAITS) + { +# if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) + typedef typename Iterator::distance_type difference_type; +# elif !defined(BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION) + typedef typename Iterator::difference_type difference_type; +# else + private: + // static Iterator *p; + typedef bad_difference_select< + is_convertible* + >::value> difference_type_select; + public: + typedef typename difference_type_select::template difference::type difference_type; +# endif + +# if !defined(BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF) + typedef typename Iterator::iterator_category iterator_category; +# else + typedef typename iterator_category_select::type iterator_category; +# endif + }; +# else + { + typedef typename std::iterator_traits::difference_type difference_type; + typedef typename std::iterator_traits::iterator_category iterator_category; + }; +# endif +}; + +template +struct iterator_traits +{ + private: + typedef iterator_traits_select::type>::value> select; + typedef typename select::template traits traits; + public: + typedef typename traits::difference_type difference_type; + typedef typename traits::iterator_category iterator_category; +}; + +template +struct distance_select { + template + static typename ::boost::detail::iterator_traits::difference_type + distance(Iterator i1, const Iterator i2) + { + typename ::boost::detail::iterator_traits::difference_type result = 0; + while (i1 != i2) + { + ++i1; + ++result; + } + return result; + } +}; + +template <> +struct distance_select { + template + static typename ::boost::detail::iterator_traits::difference_type + distance(const Iterator i1, const Iterator i2) + { + return i2 - i1; + } +}; + +template +inline typename ::boost::detail::iterator_traits::difference_type +distance(const Iterator& first, const Iterator& last) +{ + typedef typename ::boost::detail::iterator_traits::iterator_category iterator_category; + return distance_select::distance(first, last); +} +# endif // workarounds + +}} + +# undef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF +# undef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION + +#endif // ITERATOR_DWA122600_HPP_ From 708fd64f4ede3ae679176d08ac62eb696337123d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 21 Jan 2001 16:18:41 +0000 Subject: [PATCH 06/29] tweak a comment [SVN r8680] --- include/boost/detail/iterator.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 8652b8f..17b3344 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -27,7 +27,6 @@ // Also, whether debugging is enabled or not, there is a broken specialization // of std::iterator which has no // typedefs but iterator_category. -// the proper typedef. # if defined(__SGI_STL_PORT) && (__SGI_STL_PORT <= 0x410) && !defined(__STL_CLASS_PARTIAL_SPECIALIZATION) # ifdef __STL_DEBUG From 37d08acea167734a19332961e8987a223b06ca5c Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 22 Jan 2001 04:08:29 +0000 Subject: [PATCH 07/29] Initial checkin [SVN r8702] --- include/boost/detail/numeric_traits.hpp | 164 ++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 include/boost/detail/numeric_traits.hpp diff --git a/include/boost/detail/numeric_traits.hpp b/include/boost/detail/numeric_traits.hpp new file mode 100644 index 0000000..0a96f06 --- /dev/null +++ b/include/boost/detail/numeric_traits.hpp @@ -0,0 +1,164 @@ +// (C) Copyright David Abrahams 2001. Permission to copy, use, modify, +// sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +// +// Template class is_signed and its documentation is: +// (C) Copyright Howard Hinnant 2001. Permission to copy, use, modify, +// sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +// +// Template class numeric_traits -- +// +// Supplies: +// +// typedef difference_type -- a type used to represent the difference +// between any two values of Number. +// +// Support: +// 1. Not all specializations are supplied +// +// 2. Use of specializations that are not supplied will cause a +// compile-time error +// +// 3. Users are free to specialize numeric_traits for any type. +// +// 4. Right now, specializations are only supplied for integer types. +// +// 5. On implementations which do not supply compile-time constants in +// std::numeric_limits<>, only specializations for built-in integer types +// are supplied. +// +// 6. Handling of numbers whose range of representation is at least as +// great as boost::intmax_t can cause some differences to be +// unrepresentable in difference_type: +// +// Number difference_type +// ------ --------------- +// signed Number +// unsigned intmax_t +// +// template typename numeric_traits::difference_type +// numeric_distance(Number x, Number y) +// computes (y - x), attempting to avoid overflows. +// + +// See http://www.boost.org for most recent version including documentation. + +// Revision History +// 21 Jan 2001 - Created + +#ifndef BOOST_NUMERIC_TRAITS_HPP_DWA20001901 +# define BOOST_NUMERIC_TRAITS_HPP_DWA20001901 + +# include +# include +# include +# include +# ifndef BOOST_NO_LIMITS +# include +# endif + +namespace boost { namespace detail { + + // Template class if_true -- select among 2 types based on a bool constant expression + // Usage: + // typename if_true<(bool_const_expression)>::template then::type + template struct if_true; + + template <> + struct if_true + { + template + struct then { typedef T1 type; }; + }; + + template <> + struct if_true + { + template + struct then { typedef T2 type; }; + }; + + // Template class is_signed -- determine whether a numeric type is signed + // Requires that T is constructable from the literals -1 and 0. Compile-time + // error results if that requirement is not met (and thus signedness is not + // likely to have meaning for that type). + template + struct is_signed + { + enum { value = (Number(-1) < Number(0)) }; + }; + + // Template class integer_traits -- traits of various integer types + // This should probably be rolled into boost::integer_traits one day, but I +// need it to work without + template + struct integer_traits + { +# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + private: + typedef Integer integer_type; + typedef std::numeric_limits x; +# ifdef BOOST_MSVC + enum { is_integer = x::is_integer }; +# endif + public: +# ifndef BOOST_MSVC // for some reason, this asserts when it shouldn't + BOOST_STATIC_ASSERT(x::is_integer); +# else + BOOST_STATIC_ASSERT(is_integer); +# endif + typedef typename + if_true= std::numeric_limits::digits)>::template then< + Integer, + + typename if_true<(x::digits < std::numeric_limits::digits)>::template then< + signed int, + + typename if_true<(x::digits < std::numeric_limits::digits)>::template then< + signed long, + + // else + intmax_t + >::type>::type>::type difference_type; +# else + BOOST_STATIC_ASSERT(boost::is_integral::value); + + typedef typename + if_true<(sizeof(Integer) >= sizeof(intmax_t))>::template then< + + typename if_true::value>::template then< + Integer, + intmax_t + >::type, + + typename if_true<(sizeof(Integer) < sizeof(std::ptrdiff_t))>::template then< + std::ptrdiff_t, + intmax_t + >::type + >::type difference_type; +# endif + }; + + // Right now, only supports integers, but should be expanded. + template + struct numeric_traits + { + typedef typename integer_traits::difference_type difference_type; + }; + + template + typename numeric_traits::difference_type numeric_distance(Number x, Number y) + { + typedef typename numeric_traits::difference_type difference_type; + return difference_type(y) - difference_type(x); + } +}} + +#endif // BOOST_NUMERIC_TRAITS_HPP_DWA20001901 From 4bfd4da65005c70ac90b632d771cd2d494fdf580 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 24 Jan 2001 01:44:05 +0000 Subject: [PATCH 08/29] Fixed logic of difference_type selection, which was completely wack. In the process, added digit_traits<> to compute the number of digits in intmax_t even when not supplied by numeric_limits<>. [SVN r8747] --- include/boost/detail/numeric_traits.hpp | 66 ++++++++++++++++++++----- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/include/boost/detail/numeric_traits.hpp b/include/boost/detail/numeric_traits.hpp index 0a96f06..9701ec6 100644 --- a/include/boost/detail/numeric_traits.hpp +++ b/include/boost/detail/numeric_traits.hpp @@ -49,6 +49,10 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 23 Jan 2001 - Fixed logic of difference_type selection, which was +// completely wack. In the process, added digit_traits<> +// to compute the number of digits in intmax_t even when +// not supplied by numeric_limits<>. // 21 Jan 2001 - Created #ifndef BOOST_NUMERIC_TRAITS_HPP_DWA20001901 @@ -93,6 +97,43 @@ namespace boost { namespace detail { enum { value = (Number(-1) < Number(0)) }; }; +# ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + // digit_traits - compute the number of digits in a built-in integer + // type. Needed for implementations on which numeric_limits is not specialized + // for intmax_t (e.g. VC6). + template struct digit_traits_select; + + // numeric_limits is specialized; just select that version of digits + template <> struct digit_traits_select + { + template struct traits + { + enum { digits = std::numeric_limits::digits }; + }; + }; + + // numeric_limits is not specialized; compute digits from sizeof(T) + template <> struct digit_traits_select + { + template struct traits + { + enum { digits = sizeof(T) * std::numeric_limits::digits + - (is_signed::value ? 1 : 0) + }; + }; + }; + + // here's the "usable" template + template struct digit_traits + { + enum { + digits = digit_traits_select< + std::numeric_limits::is_specialized + >::template traits::digits + }; + }; +#endif + // Template class integer_traits -- traits of various integer types // This should probably be rolled into boost::integer_traits one day, but I // need it to work without @@ -104,24 +145,27 @@ namespace boost { namespace detail { typedef Integer integer_type; typedef std::numeric_limits x; # ifdef BOOST_MSVC - enum { is_integer = x::is_integer }; + // for some reason, MSVC asserts when it shouldn't unless we make these + // local definitions + enum { + is_integer = x::is_integer, + is_specialized = x::is_specialized + }; + BOOST_STATIC_ASSERT(is_integer); + BOOST_STATIC_ASSERT(is_specialized); # endif public: -# ifndef BOOST_MSVC // for some reason, this asserts when it shouldn't - BOOST_STATIC_ASSERT(x::is_integer); -# else - BOOST_STATIC_ASSERT(is_integer); -# endif typedef typename - if_true= std::numeric_limits::digits)>::template then< + if_true<(x::is_signed + && (!x::is_bounded + // digits is the number of no-sign bits + || (x::digits + 1 >= digit_traits::digits)))>::template then< Integer, - typename if_true<(x::digits < std::numeric_limits::digits)>::template then< + typename if_true<(x::digits + 1 < digit_traits::digits)>::template then< signed int, - typename if_true<(x::digits < std::numeric_limits::digits)>::template then< + typename if_true<(x::digits + 1 < digit_traits::digits)>::template then< signed long, // else From 82af891892ac1ccbebb313e02342617fbdfcd89d Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Tue, 6 Feb 2001 01:21:11 +0000 Subject: [PATCH 09/29] ported to KAI C++ [SVN r8955] --- include/boost/detail/numeric_traits.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/boost/detail/numeric_traits.hpp b/include/boost/detail/numeric_traits.hpp index 9701ec6..f87893c 100644 --- a/include/boost/detail/numeric_traits.hpp +++ b/include/boost/detail/numeric_traits.hpp @@ -94,7 +94,11 @@ namespace boost { namespace detail { template struct is_signed { - enum { value = (Number(-1) < Number(0)) }; +#if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || defined(BOOST_MSVC) + enum { value = (Number(-1) < Number(0)) }; +#else + enum { value = std::numeric_limits::is_signed }; +#endif }; # ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS @@ -156,16 +160,16 @@ namespace boost { namespace detail { # endif public: typedef typename - if_true<(x::is_signed - && (!x::is_bounded + if_true<(!int(x::is_signed) + && (!int(x::is_bounded) // digits is the number of no-sign bits - || (x::digits + 1 >= digit_traits::digits)))>::template then< + || (int(x::digits) + 1 >= digit_traits::digits)))>::template then< Integer, - typename if_true<(x::digits + 1 < digit_traits::digits)>::template then< + typename if_true<(int(x::digits) + 1 < digit_traits::digits)>::template then< signed int, - typename if_true<(x::digits + 1 < digit_traits::digits)>::template then< + typename if_true<(int(x::digits) + 1 < digit_traits::digits)>::template then< signed long, // else From 3cbecf5ddd02de8f081e88b2310cb7343e965f4f Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Tue, 6 Feb 2001 22:56:37 +0000 Subject: [PATCH 10/29] fix bool logic bug introduced by Jeremy's compilation fixes [SVN r8988] --- include/boost/detail/numeric_traits.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/detail/numeric_traits.hpp b/include/boost/detail/numeric_traits.hpp index f87893c..4444766 100644 --- a/include/boost/detail/numeric_traits.hpp +++ b/include/boost/detail/numeric_traits.hpp @@ -160,7 +160,7 @@ namespace boost { namespace detail { # endif public: typedef typename - if_true<(!int(x::is_signed) + if_true<(int(x::is_signed) && (!int(x::is_bounded) // digits is the number of no-sign bits || (int(x::digits) + 1 >= digit_traits::digits)))>::template then< From 8b60ca8d0a180b25963e4d39b82fa76822d8ad0e Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 7 Feb 2001 04:49:32 +0000 Subject: [PATCH 11/29] Factored if_true out into boost/detail/select_type.hpp [SVN r8991] --- include/boost/detail/numeric_traits.hpp | 26 +++++-------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/include/boost/detail/numeric_traits.hpp b/include/boost/detail/numeric_traits.hpp index 4444766..1a65520 100644 --- a/include/boost/detail/numeric_traits.hpp +++ b/include/boost/detail/numeric_traits.hpp @@ -49,11 +49,13 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 06 Feb 2001 - Factored if_true out into boost/detail/select_type.hpp +// (David Abrahams) // 23 Jan 2001 - Fixed logic of difference_type selection, which was // completely wack. In the process, added digit_traits<> // to compute the number of digits in intmax_t even when -// not supplied by numeric_limits<>. -// 21 Jan 2001 - Created +// not supplied by numeric_limits<>. (David Abrahams) +// 21 Jan 2001 - Created (David Abrahams) #ifndef BOOST_NUMERIC_TRAITS_HPP_DWA20001901 # define BOOST_NUMERIC_TRAITS_HPP_DWA20001901 @@ -62,31 +64,13 @@ # include # include # include +# include # ifndef BOOST_NO_LIMITS # include # endif namespace boost { namespace detail { - // Template class if_true -- select among 2 types based on a bool constant expression - // Usage: - // typename if_true<(bool_const_expression)>::template then::type - template struct if_true; - - template <> - struct if_true - { - template - struct then { typedef T1 type; }; - }; - - template <> - struct if_true - { - template - struct then { typedef T2 type; }; - }; - // Template class is_signed -- determine whether a numeric type is signed // Requires that T is constructable from the literals -1 and 0. Compile-time // error results if that requirement is not met (and thus signedness is not From 8ffb174556e0646898bd68fc4786c20f6b27777c Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 7 Feb 2001 04:51:12 +0000 Subject: [PATCH 12/29] Initial Checkin [SVN r8992] --- include/boost/detail/select_type.hpp | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 include/boost/detail/select_type.hpp diff --git a/include/boost/detail/select_type.hpp b/include/boost/detail/select_type.hpp new file mode 100644 index 0000000..2f65571 --- /dev/null +++ b/include/boost/detail/select_type.hpp @@ -0,0 +1,36 @@ +// (C) Copyright David Abrahams 2001. Permission to copy, use, modify, +// sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +// +// See http://www.boost.org for most recent version including documentation. + +// Revision History +// 06 Feb 2001 - Created (David Abrahams) + +#ifndef SELECT_TYPE_DWA20010206_HPP +# define SELECT_TYPE_DWA20010206_HPP + +namespace boost { namespace detail { + + // Template class if_true -- select among 2 types based on a bool constant expression + // Usage: + // typename if_true<(bool_const_expression)>::template then::type + template struct if_true; + + template <> + struct if_true + { + template + struct then { typedef T type; }; + }; + + template <> + struct if_true + { + template + struct then { typedef F type; }; + }; +}} +#endif // SELECT_TYPE_DWA20010206_HPP From ddccb755f4c04bb23c709ca6aa07ec918bda87ea Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 7 Feb 2001 04:52:58 +0000 Subject: [PATCH 13/29] Removed useless #includes of standard library headers [SVN r8993] --- include/boost/detail/iterator.hpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 17b3344..5c4ea17 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -11,6 +11,13 @@ // std::distance() // // ...for all compilers and iterators +// + +// See http://www.boost.org for most recent version including documentation. + +// Revision History +// 06 Feb 2001 - Removed useless #includes of standard library headers +// (David Abrahams) #ifndef ITERATOR_DWA122600_HPP_ # define ITERATOR_DWA122600_HPP_ @@ -37,18 +44,6 @@ # endif // STLPort <= 4.1b4 && no partial specialization -# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF -# include -# include -# include -# include -# include -# include -# include -# include -# include -# endif - namespace boost { namespace detail { # if !defined(BOOST_NO_STD_ITERATOR_TRAITS) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) using std::iterator_traits; From a7ae27dc5b96828b2f68a969991040ae259b4266 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 7 Feb 2001 16:43:57 +0000 Subject: [PATCH 14/29] Added support for more of the traits members where possible, making this useful as a replacement for std::iterator_traits when used as a default template parameter. [SVN r9002] --- include/boost/detail/iterator.hpp | 60 +++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 5c4ea17..4376006 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -12,10 +12,20 @@ // // ...for all compilers and iterators // +// Additionally, if partial specialization is supported or X is not a pointer +// std::iterator_traits::value_type +// +// And if partial specialization is supported or (X is not a pointer and the +// library isn't the VC6 standard library), +// std::iterator_traits::pointer +// std::iterator_traits::reference // See http://www.boost.org for most recent version including documentation. // Revision History +// 07 Feb 2001 - Support for more of the traits members where possible, making +// this useful as a replacement for std::iterator_traits when +// used as a default template parameter. // 06 Feb 2001 - Removed useless #includes of standard library headers // (David Abrahams) @@ -49,8 +59,10 @@ namespace boost { namespace detail { using std::iterator_traits; using std::distance; # else + // Workarounds for less-capable implementations template struct iterator_traits_select; + template <> struct iterator_traits_select { template @@ -95,23 +107,33 @@ struct iterator_category_select # endif # ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION -template struct bad_difference_select; +template struct bad_output_iterator_select; template <> -struct bad_difference_select +struct bad_output_iterator_select { template - struct difference { typedef void type; }; + struct non_category_traits { + typedef void value_type; + typedef void difference_type; + typedef void pointer; + typedef void reference; + }; }; template <> -struct bad_difference_select +struct bad_output_iterator_select { template - struct difference { typedef typename Iterator::difference_type type; }; + 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; + }; }; -yes_result bad_output_iterator_helper(std::iterator*); -no_result bad_output_iterator_helper(...); # endif +template struct undefined; + template <> struct iterator_traits_select { template @@ -120,17 +142,24 @@ template <> struct iterator_traits_select { # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) typedef typename Iterator::distance_type difference_type; + typedef typename Iterator::value_type value_type; # elif !defined(BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION) typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; # else - private: - // static Iterator *p; - typedef bad_difference_select< + typedef bad_output_iterator_select< is_convertible* - >::value> difference_type_select; + >::value> non_category_traits_select; + typedef non_category_traits_select::template non_category_traits non_category_traits; public: - typedef typename difference_type_select::template difference::type difference_type; + typedef typename non_category_traits::value_type value_type; + typedef typename non_category_traits::difference_type difference_type; + typedef typename non_category_traits::pointer pointer; + typedef typename non_category_traits::reference reference; # endif # if !defined(BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF) @@ -149,11 +178,14 @@ template <> struct iterator_traits_select template struct iterator_traits + : iterator_traits_select::type>::value>::template traits { private: - typedef iterator_traits_select::type>::value> select; - typedef typename select::template traits traits; + typedef typename iterator_traits_select< + is_pointer::type>::value>::template traits traits; public: + // Why do I need to define these typedefs? It keeps MSVC happy somehow. + // Why don't I need to define the other typedefs? Who knows?!? typedef typename traits::difference_type difference_type; typedef typename traits::iterator_category iterator_category; }; From 9ac4d90d826bf8ebbebb1b79fe033065116790b2 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 8 Feb 2001 04:44:19 +0000 Subject: [PATCH 15/29] *** empty log message *** [SVN r9029] --- include/boost/detail/numeric_traits.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/detail/numeric_traits.hpp b/include/boost/detail/numeric_traits.hpp index 1a65520..b8123af 100644 --- a/include/boost/detail/numeric_traits.hpp +++ b/include/boost/detail/numeric_traits.hpp @@ -115,9 +115,9 @@ namespace boost { namespace detail { template struct digit_traits { enum { - digits = digit_traits_select< + digits = digit_traits_select<( std::numeric_limits::is_specialized - >::template traits::digits + )>::template traits::digits }; }; #endif From cd1eecd245bcf3b06fc90111a2419247af1310d3 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 9 Feb 2001 03:30:12 +0000 Subject: [PATCH 16/29] Add parens to appease Borland [SVN r9043] --- include/boost/detail/numeric_traits.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/detail/numeric_traits.hpp b/include/boost/detail/numeric_traits.hpp index b8123af..c404aed 100644 --- a/include/boost/detail/numeric_traits.hpp +++ b/include/boost/detail/numeric_traits.hpp @@ -165,7 +165,7 @@ namespace boost { namespace detail { typedef typename if_true<(sizeof(Integer) >= sizeof(intmax_t))>::template then< - typename if_true::value>::template then< + typename if_true<(is_signed::value)>::template then< Integer, intmax_t >::type, From 2947fb7051bc9e8de3a615fec88fa0a1425ea569 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 9 Feb 2001 15:23:55 +0000 Subject: [PATCH 17/29] Applied John Maddock's Borland patch Moving specialization to unspecialized template [SVN r9058] --- include/boost/detail/select_type.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/detail/select_type.hpp b/include/boost/detail/select_type.hpp index 2f65571..4f1347c 100644 --- a/include/boost/detail/select_type.hpp +++ b/include/boost/detail/select_type.hpp @@ -7,7 +7,9 @@ // See http://www.boost.org for most recent version including documentation. // Revision History -// 06 Feb 2001 - Created (David Abrahams) +// 09 Feb 01 Applied John Maddock's Borland patch Moving +// specialization to unspecialized template (David Abrahams) +// 06 Feb 01 Created (David Abrahams) #ifndef SELECT_TYPE_DWA20010206_HPP # define SELECT_TYPE_DWA20010206_HPP @@ -17,10 +19,8 @@ namespace boost { namespace detail { // Template class if_true -- select among 2 types based on a bool constant expression // Usage: // typename if_true<(bool_const_expression)>::template then::type - template struct if_true; - - template <> - struct if_true + template + struct if_true { template struct then { typedef T type; }; From 08a2ab3fe66d8baee3204a557c4ef0e7b7dcefa3 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 10 Feb 2001 00:05:17 +0000 Subject: [PATCH 18/29] Always have a definition for each traits member, even if it can't be properly deduced. These will be incomplete types in some cases (undefined), but it helps suppress MSVC errors elsewhere [SVN r9064] --- include/boost/detail/iterator.hpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 4376006..eb8f692 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -23,6 +23,10 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 09 Feb 2001 - Always have a definition for each traits member, even if it +// can't be properly deduced. These will be incomplete types in +// some cases (undefined), but it helps suppress MSVC errors +// elsewhere (David Abrahams) // 07 Feb 2001 - Support for more of the traits members where possible, making // this useful as a replacement for std::iterator_traits when // used as a default template parameter. @@ -63,6 +67,7 @@ using std::distance; // Workarounds for less-capable implementations template struct iterator_traits_select; +template struct undefined; template <> struct iterator_traits_select { template @@ -70,6 +75,14 @@ template <> struct iterator_traits_select { typedef std::ptrdiff_t difference_type; typedef std::random_access_iterator_tag iterator_category; +#ifdef BOOST_MSVC +// Keeps MSVC happy under certain circumstances. It seems class template default +// arguments are partly instantiated even when not used when the class template +// is the return type of a function template. + typedef undefined value_type; + typedef undefined pointer; + typedef undefined reference; +#endif }; }; @@ -132,8 +145,6 @@ struct bad_output_iterator_select }; # endif -template struct undefined; - template <> struct iterator_traits_select { template @@ -143,6 +154,10 @@ template <> struct iterator_traits_select # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) typedef typename Iterator::distance_type difference_type; typedef typename Iterator::value_type value_type; +#ifdef BOOST_MSVC // Keeps MSVC happy under certain circumstances + typedef undefined pointer; + typedef undefined reference; +#endif # elif !defined(BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION) typedef typename Iterator::difference_type difference_type; typedef typename Iterator::value_type value_type; From d0f656c4dadfc2c434457d0ac3b30f56cb2aa5ef Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 10 Feb 2001 20:14:20 +0000 Subject: [PATCH 19/29] Rolled in supposed Borland fixes from John Maddock, but not seeing any improvement yet [SVN r9091] --- include/boost/detail/numeric_traits.hpp | 51 ++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/include/boost/detail/numeric_traits.hpp b/include/boost/detail/numeric_traits.hpp index c404aed..16cfa4d 100644 --- a/include/boost/detail/numeric_traits.hpp +++ b/include/boost/detail/numeric_traits.hpp @@ -49,6 +49,8 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 10 Feb 2001 - Rolled in supposed Borland fixes from John Maddock, but +// not seeing any improvement yet (David Abrahams) // 06 Feb 2001 - Factored if_true out into boost/detail/select_type.hpp // (David Abrahams) // 23 Jan 2001 - Fixed logic of difference_type selection, which was @@ -114,13 +116,42 @@ namespace boost { namespace detail { // here's the "usable" template template struct digit_traits { + typedef digit_traits_select< + ::std::numeric_limits::is_specialized> selector; + typedef typename selector::template traits traits; enum { - digits = digit_traits_select<( - std::numeric_limits::is_specialized - )>::template traits::digits + digits = traits::digits }; }; -#endif +#endif + +#ifdef __BORLANDC__ // // This code from John Maddock, but doesn't seem to make any difference +template +struct select_diff +{ + typedef std::ptrdiff_t difference_type; +}; +template +struct select_diff +{ + typedef T difference_type; +}; +template +struct select_diff +{ + typedef intmax_t difference_type; +}; +template +struct select_diff +{ + typedef std::ptrdiff_t difference_type; +}; +template +struct select_diff +{ + typedef intmax_t difference_type; +}; +#endif // Template class integer_traits -- traits of various integer types // This should probably be rolled into boost::integer_traits one day, but I @@ -159,9 +190,17 @@ namespace boost { namespace detail { // else intmax_t >::type>::type>::type difference_type; -# else +# elif defined(__BORLANDC__) // This code from John Maddock, but doesn't seem to make any difference BOOST_STATIC_ASSERT(boost::is_integral::value); - + typedef select_diff::value), + (sizeof(Integer) >= sizeof(intmax_t)), + (sizeof(Integer) < sizeof(std::ptrdiff_t))> t; + typedef typename t::difference_type difference_type; + +#else + BOOST_STATIC_ASSERT(boost::is_integral::value); + typedef typename if_true<(sizeof(Integer) >= sizeof(intmax_t))>::template then< From dc1186e73fd01122298cc7a101d4830bead56a69 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 11 Feb 2001 16:11:24 +0000 Subject: [PATCH 20/29] Rolled back ineffective Borland-specific code [SVN r9115] --- include/boost/detail/numeric_traits.hpp | 40 ++----------------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/include/boost/detail/numeric_traits.hpp b/include/boost/detail/numeric_traits.hpp index 16cfa4d..e794bbd 100644 --- a/include/boost/detail/numeric_traits.hpp +++ b/include/boost/detail/numeric_traits.hpp @@ -49,6 +49,8 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 11 Feb 2001 - Rolled back ineffective Borland-specific code +// (David Abrahams) // 10 Feb 2001 - Rolled in supposed Borland fixes from John Maddock, but // not seeing any improvement yet (David Abrahams) // 06 Feb 2001 - Factored if_true out into boost/detail/select_type.hpp @@ -125,37 +127,9 @@ namespace boost { namespace detail { }; #endif -#ifdef __BORLANDC__ // // This code from John Maddock, but doesn't seem to make any difference -template -struct select_diff -{ - typedef std::ptrdiff_t difference_type; -}; -template -struct select_diff -{ - typedef T difference_type; -}; -template -struct select_diff -{ - typedef intmax_t difference_type; -}; -template -struct select_diff -{ - typedef std::ptrdiff_t difference_type; -}; -template -struct select_diff -{ - typedef intmax_t difference_type; -}; -#endif - // Template class integer_traits -- traits of various integer types // This should probably be rolled into boost::integer_traits one day, but I -// need it to work without + // need it to work without template struct integer_traits { @@ -190,14 +164,6 @@ struct select_diff // else intmax_t >::type>::type>::type difference_type; -# elif defined(__BORLANDC__) // This code from John Maddock, but doesn't seem to make any difference - BOOST_STATIC_ASSERT(boost::is_integral::value); - typedef select_diff::value), - (sizeof(Integer) >= sizeof(intmax_t)), - (sizeof(Integer) < sizeof(std::ptrdiff_t))> t; - typedef typename t::difference_type difference_type; - #else BOOST_STATIC_ASSERT(boost::is_integral::value); From 3cb4fe87a9efb4cb922e47f5cf2108d70ab28f9a Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 11 Feb 2001 16:12:13 +0000 Subject: [PATCH 21/29] Rolled unspecialized template back in [SVN r9116] --- include/boost/detail/select_type.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/boost/detail/select_type.hpp b/include/boost/detail/select_type.hpp index 4f1347c..2a95a98 100644 --- a/include/boost/detail/select_type.hpp +++ b/include/boost/detail/select_type.hpp @@ -19,8 +19,7 @@ namespace boost { namespace detail { // Template class if_true -- select among 2 types based on a bool constant expression // Usage: // typename if_true<(bool_const_expression)>::template then::type - template - struct if_true + template struct if_true { template struct then { typedef T type; }; From 7523daa90519044249a2ef4adcaddfe70203b924 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 11 Feb 2001 19:39:11 +0000 Subject: [PATCH 22/29] Use BOOST_STATIC_CONSTANT [SVN r9133] --- include/boost/detail/numeric_traits.hpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/include/boost/detail/numeric_traits.hpp b/include/boost/detail/numeric_traits.hpp index e794bbd..785a61e 100644 --- a/include/boost/detail/numeric_traits.hpp +++ b/include/boost/detail/numeric_traits.hpp @@ -49,6 +49,7 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 11 Feb 2001 - Use BOOST_STATIC_CONSTANT (David Abrahams) // 11 Feb 2001 - Rolled back ineffective Borland-specific code // (David Abrahams) // 10 Feb 2001 - Rolled in supposed Borland fixes from John Maddock, but @@ -83,9 +84,9 @@ namespace boost { namespace detail { struct is_signed { #if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || defined(BOOST_MSVC) - enum { value = (Number(-1) < Number(0)) }; + BOOST_STATIC_CONSTANT(bool, value = (Number(-1) < Number(0))); #else - enum { value = std::numeric_limits::is_signed }; + BOOST_STATIC_CONSTANT(bool, value = std::numeric_limits::is_signed); #endif }; @@ -100,7 +101,7 @@ namespace boost { namespace detail { { template struct traits { - enum { digits = std::numeric_limits::digits }; + BOOST_STATIC_CONSTANT(int, digits = std::numeric_limits::digits); }; }; @@ -109,9 +110,10 @@ namespace boost { namespace detail { { template struct traits { - enum { digits = sizeof(T) * std::numeric_limits::digits - - (is_signed::value ? 1 : 0) - }; + BOOST_STATIC_CONSTANT(int, digits = ( + sizeof(T) * std::numeric_limits::digits + - (is_signed::value ? 1 : 0)) + ); }; }; @@ -121,9 +123,7 @@ namespace boost { namespace detail { typedef digit_traits_select< ::std::numeric_limits::is_specialized> selector; typedef typename selector::template traits traits; - enum { - digits = traits::digits - }; + BOOST_STATIC_CONSTANT(int, digits = traits::digits); }; #endif @@ -140,10 +140,9 @@ namespace boost { namespace detail { # ifdef BOOST_MSVC // for some reason, MSVC asserts when it shouldn't unless we make these // local definitions - enum { - is_integer = x::is_integer, - is_specialized = x::is_specialized - }; + BOOST_STATIC_CONSTANT(bool, is_integer = x::is_integer); + BOOST_STATIC_CONSTANT(bool, is_specialized = x::is_specialized); + BOOST_STATIC_ASSERT(is_integer); BOOST_STATIC_ASSERT(is_specialized); # endif From 1e0e965f074d5f48582cc61f4e5d68ea045ca5ed Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 11 Feb 2001 19:44:54 +0000 Subject: [PATCH 23/29] Clean away code which can never be used [SVN r9134] --- include/boost/detail/iterator.hpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index eb8f692..9c21037 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -23,6 +23,7 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 11 Feb 2001 - Clean away code which can never be used (David Abrahams) // 09 Feb 2001 - Always have a definition for each traits member, even if it // can't be properly deduced. These will be incomplete types in // some cases (undefined), but it helps suppress MSVC errors @@ -149,7 +150,6 @@ template <> struct iterator_traits_select { template struct traits -# if defined(BOOST_NO_STD_ITERATOR_TRAITS) { # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) typedef typename Iterator::distance_type difference_type; @@ -183,12 +183,6 @@ template <> struct iterator_traits_select typedef typename iterator_category_select::type iterator_category; # endif }; -# else - { - typedef typename std::iterator_traits::difference_type difference_type; - typedef typename std::iterator_traits::iterator_category iterator_category; - }; -# endif }; template From 2f6f7af430da510c2058e1736c0b156fb5154210 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 13 Feb 2001 23:30:25 +0000 Subject: [PATCH 24/29] Make it work with standard conforming iterators under raw VC6. [SVN r9197] --- include/boost/detail/iterator.hpp | 63 ++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 9c21037..7b73d68 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -23,6 +23,10 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 13 Feb 2001 - Make it work with nearly all standard-conforming iterators +// under raw VC6. The one category remaining which will fail is +// that of iterators derived from std::iterator but not +// boost::iterator and which redefine difference_type. // 11 Feb 2001 - Clean away code which can never be used (David Abrahams) // 09 Feb 2001 - Always have a definition for each traits member, even if it // can't be properly deduced. These will be incomplete types in @@ -39,6 +43,7 @@ # include # include +# include # include # include @@ -146,18 +151,64 @@ struct bad_output_iterator_select }; # endif +# if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) +template struct msvc_traits_select; + +template <> struct msvc_traits_select +{ + template + struct traits_ // calling this "traits" will confuse VC. + { + typedef typename Iterator::distance_type difference_type; + typedef typename Iterator::value_type value_type; + typedef undefined pointer; + typedef undefined reference; + }; +}; + +template <> struct msvc_traits_select +{ + template + struct traits_ + { + typedef typename Iterator::difference_type difference_type; + typedef typename Iterator::value_type value_type; + typedef typename Iterator::pointer pointer; + typedef typename Iterator::reference reference; + }; +}; + +template +yes_result is_std_iterator_helper(const volatile std::iterator*); +no_result is_std_iterator_helper(...); + +template +yes_result is_boost_iterator_helper(const volatile boost::iterator*); +no_result is_boost_iterator_helper(...); + +template +struct has_msvc_std_iterator_traits +{ + BOOST_STATIC_CONSTANT(bool, value = + (sizeof(is_std_iterator_helper((T*)0)) == sizeof(yes_result) + && sizeof(is_boost_iterator_helper((T*)0)) == sizeof(no_result))); +}; +# endif + template <> struct iterator_traits_select { template struct traits { # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) - typedef typename Iterator::distance_type difference_type; - typedef typename Iterator::value_type value_type; -#ifdef BOOST_MSVC // Keeps MSVC happy under certain circumstances - typedef undefined pointer; - typedef undefined reference; -#endif + typedef msvc_traits_select<( + has_msvc_std_iterator_traits::value + )>::template traits_ 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; From 5044712ff632a068cd51c0157bf07b3002deb99e Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 18 Feb 2001 11:43:01 +0000 Subject: [PATCH 25/29] type_traits: regression failure fixes from type traits changes... [SVN r9249] --- include/boost/detail/iterator.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 7b73d68..0d9ceff 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -70,6 +70,9 @@ using std::iterator_traits; using std::distance; # else +typedef char yes_result; +typedef double no_result; + // Workarounds for less-capable implementations template struct iterator_traits_select; From 58bff4af875715fda2127a0a9ebe08645181031e Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 19 Feb 2001 22:51:32 +0000 Subject: [PATCH 26/29] Improved workarounds for stock MSVC6; use yes_type and no_type from type_traits.hpp; stopped trying to remove_cv before detecting is_pointer, in honor of the new type_traits semantics. [SVN r9282] --- include/boost/detail/iterator.hpp | 133 ++++++++++++++++++++++-------- 1 file changed, 100 insertions(+), 33 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 0d9ceff..29b4346 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -23,6 +23,10 @@ // See http://www.boost.org for most recent version including documentation. // Revision History +// 19 Feb 2001 - Improved workarounds for stock MSVC6; use yes_type and +// no_type from type_traits.hpp; stopped trying to remove_cv +// before detecting is_pointer, in honor of the new type_traits +// semantics. (David Abrahams) // 13 Feb 2001 - Make it work with nearly all standard-conforming iterators // under raw VC6. The one category remaining which will fail is // that of iterators derived from std::iterator but not @@ -47,6 +51,13 @@ # include # include +# if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) +# include +# include +# include +# endif + + // STLPort 4.0 and betas have a bug when debugging is enabled and there is no // partial specialization: instead of an iterator_category typedef, the standard // container iterators have _Iterator_category. @@ -70,9 +81,6 @@ using std::iterator_traits; using std::distance; # else -typedef char yes_result; -typedef double no_result; - // Workarounds for less-capable implementations template struct iterator_traits_select; @@ -84,12 +92,12 @@ template <> struct iterator_traits_select { typedef std::ptrdiff_t difference_type; typedef std::random_access_iterator_tag iterator_category; + typedef Ptr pointer; #ifdef BOOST_MSVC // Keeps MSVC happy under certain circumstances. It seems class template default // arguments are partly instantiated even when not used when the class template // is the return type of a function template. typedef undefined value_type; - typedef undefined pointer; typedef undefined reference; #endif }; @@ -97,8 +105,8 @@ template <> struct iterator_traits_select # ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF -no_result bad_category_helper(...); -template yes_result bad_category_helper(std::_DBG_iter*); +no_type bad_category_helper(...); +template yes_type bad_category_helper(std::_DBG_iter*); template struct bad_category_select; template <> @@ -120,7 +128,7 @@ struct iterator_category_select private: static Iterator p; enum { has_bad_category - = sizeof(bad_category_helper(&p)) == sizeof(yes_result) }; + = sizeof(bad_category_helper(&p)) == sizeof(yes_type) }; typedef bad_category_select category_select; public: typedef typename category_select::template category::type type; @@ -155,24 +163,22 @@ struct bad_output_iterator_select # endif # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) -template struct msvc_traits_select; -template <> struct msvc_traits_select +// 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 struct msvc_traits_select; + +template <> struct msvc_traits_select { template struct traits_ // calling this "traits" will confuse VC. - { - typedef typename Iterator::distance_type difference_type; - typedef typename Iterator::value_type value_type; - typedef undefined pointer; - typedef undefined reference; - }; -}; - -template <> struct msvc_traits_select -{ - template - struct traits_ { typedef typename Iterator::difference_type difference_type; typedef typename Iterator::value_type value_type; @@ -181,20 +187,81 @@ template <> struct msvc_traits_select }; }; -template -yes_result is_std_iterator_helper(const volatile std::iterator*); -no_result is_std_iterator_helper(...); +template <> struct msvc_traits_select +{ + template + struct traits_ + { + typedef typename Iterator::distance_type difference_type; + typedef typename Iterator::value_type value_type; + typedef value_type* pointer; + typedef value_type& reference; + }; +}; +template <> struct msvc_traits_select +{ + template + struct traits_ + { + typedef typename Iterator::distance_type difference_type; + typedef typename Iterator::value_type value_type; + typedef const value_type* pointer; + typedef const value_type& reference; + }; +}; + +template <> struct msvc_traits_select +{ + template + 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? +template +yes_type is_std_iterator_helper(const volatile std::iterator*); +no_type is_std_iterator_helper(...); + +// Is the iterator derived from boost::iterator? template -yes_result is_boost_iterator_helper(const volatile boost::iterator*); -no_result is_boost_iterator_helper(...); +yes_type is_boost_iterator_helper(const volatile boost::iterator*); +no_type is_boost_iterator_helper(...); + +// Is the iterator one of the known mutable container iterators? +template +yes_type is_mutable_iterator_helper(const volatile std::_Tree::iterator*); +template +yes_type is_mutable_iterator_helper(const volatile std::list::iterator*); +template +yes_type is_mutable_iterator_helper(const volatile std::deque::iterator*); +no_type is_mutable_iterator_helper(...); + +// Is the iterator an ostream_iterator? +template +yes_type is_ostream_iterator_helper(const volatile std::ostream_iterator*); +no_type is_ostream_iterator_helper(...); template -struct has_msvc_std_iterator_traits -{ - BOOST_STATIC_CONSTANT(bool, value = - (sizeof(is_std_iterator_helper((T*)0)) == sizeof(yes_result) - && sizeof(is_boost_iterator_helper((T*)0)) == sizeof(no_result))); +struct msvc_iterator_classification { + enum { + 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 @@ -205,7 +272,7 @@ template <> struct iterator_traits_select { # if defined(BOOST_MSVC) && !defined(__SGI_STL_PORT) typedef msvc_traits_select<( - has_msvc_std_iterator_traits::value + msvc_iterator_classification::value )>::template traits_ inner_traits; typedef typename inner_traits::difference_type difference_type; @@ -241,7 +308,7 @@ template <> struct iterator_traits_select template struct iterator_traits - : iterator_traits_select::type>::value>::template traits + : iterator_traits_select::value>::template traits { private: typedef typename iterator_traits_select< From 03b1bb7a1e27ba0a6b9821d119fc9b1545aad0de Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 19 Feb 2001 22:58:12 +0000 Subject: [PATCH 27/29] Updated documentation [SVN r9283] --- include/boost/detail/iterator.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/boost/detail/iterator.hpp b/include/boost/detail/iterator.hpp index 29b4346..df8bf36 100644 --- a/include/boost/detail/iterator.hpp +++ b/include/boost/detail/iterator.hpp @@ -12,13 +12,18 @@ // // ...for all compilers and iterators // -// Additionally, if partial specialization is supported or X is not a pointer +// Additionally, if X is a pointer +// std::iterator_traits::pointer + +// Otherwise, if partial specialization is supported or X is not a pointer // std::iterator_traits::value_type -// -// And if partial specialization is supported or (X is not a pointer and the -// library isn't the VC6 standard library), // std::iterator_traits::pointer // std::iterator_traits::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. From 7c911250606c441ebf8d3717a2e510432280aa5f Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 28 Feb 2001 21:39:56 +0000 Subject: [PATCH 28/29] Boost Test Library initial commit [SVN r9364] --- include/boost/detail/catch_exceptions.hpp | 133 ++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 include/boost/detail/catch_exceptions.hpp diff --git a/include/boost/detail/catch_exceptions.hpp b/include/boost/detail/catch_exceptions.hpp new file mode 100644 index 0000000..a7e79a3 --- /dev/null +++ b/include/boost/detail/catch_exceptions.hpp @@ -0,0 +1,133 @@ +// boost/catch_exceptions.hpp -----------------------------------------------// + +// (C) Copyright Beman Dawes 1995-2001. Permission to copy, use, modify, sell +// and distribute this software is granted provided this copyright notice +// appears in all copies. This software is provided "as is" without express or +// implied warranty, and with no claim as to its suitability for any purpose. + +// See http://www.boost.org for updates, documentation, and revision history. + +// Revision History +// 26 Feb 01 Numerous changes suggested during formal review. (Beman) +// 25 Jan 01 catch_exceptions.hpp code factored out of cpp_main.cpp. +// 22 Jan 01 Remove test_tools dependencies to reduce coupling. +// 5 Nov 00 Initial boost version (Beman Dawes) + +#ifndef BOOST_CATCH_EXCEPTIONS_HPP +#define BOOST_CATCH_EXCEPTIONS_HPP + +// header dependencies are deliberately restricted to the standard library +// to reduce coupling to other boost libraries. +#include // for string +#include // for bad_alloc +#include // for bad_cast, bad_typeid +#include // for exception, bad_exception +#include // for std exception hierarchy +#include // for exit codes +# if __GNUC__ != 2 || __GNUC_MINOR__ > 95 +# include // for ostream +# else +# include // workaround GNU missing ostream header +# endif + + +namespace boost +{ + + namespace detail + { + // A separate reporting function was requested during formal review. + void report_exception( std::ostream & os, + const char * name, const char * info ) + { os << "\n** uncaught exception: " << name << " " << info << std::endl; } + } + + // catch_exceptions ------------------------------------------------------// + + template< class Generator > // Generator is function object returning int + int catch_exceptions( Generator function_object, + std::ostream & out, std::ostream & err ) + { + int result = 0; // quiet compiler warnings + bool exception_thrown = true; // avoid setting result for each excptn type + + try + { + result = function_object(); + exception_thrown = false; + } + + // As a result of hard experience with strangely interleaved output + // under some compilers, there is a lot of use of endl in the code below + // where a simple '\n' might appear to do. + + // The rules for catch & arguments are a bit different from function + // arguments (ISO 15.3 paragraphs 18 & 19). Apparently const isn't + // required, but it doesn't hurt and some programmers ask for it. + + catch ( const char * ex ) + { detail::report_exception( out, "", ex ); } + catch ( const std::string & ex ) + { detail::report_exception( out, "", ex.c_str() ); } + + // std:: exceptions + catch ( const std::bad_alloc & ex ) + { detail::report_exception( out, "std::bad_alloc:", ex.what() ); } + +# if !defined(__BORLANDC__) || __BORLANDC__ > 0x0551 + catch ( const std::bad_cast & ex ) + { detail::report_exception( out, "std::bad_cast:", ex.what() ); } + catch ( const std::bad_typeid & ex ) + { detail::report_exception( out, "std::bad_typeid:", ex.what() ); } +# else + catch ( const std::bad_cast & ex ) + { detail::report_exception( out, "std::bad_cast", "" ); } + catch ( const std::bad_typeid & ex ) + { detail::report_exception( out, "std::bad_typeid", "" ); } +# endif + + catch ( const std::bad_exception & ex ) + { detail::report_exception( out, "std::bad_exception:", ex.what() ); } + catch ( const std::domain_error & ex ) + { detail::report_exception( out, "std::domain_error:", ex.what() ); } + catch ( const std::invalid_argument & ex ) + { detail::report_exception( out, "std::invalid_argument:", ex.what() ); } + catch ( const std::length_error & ex ) + { detail::report_exception( out, "std::length_error:", ex.what() ); } + catch ( const std::out_of_range & ex ) + { detail::report_exception( out, "std::out_of_range:", ex.what() ); } + catch ( const std::range_error & ex ) + { detail::report_exception( out, "std::range_error:", ex.what() ); } + catch ( const std::overflow_error & ex ) + { detail::report_exception( out, "std::overflow_error:", ex.what() ); } + catch ( const std::underflow_error & ex ) + { detail::report_exception( out, "std::underflow_error:", ex.what() ); } + catch ( const std::logic_error & ex ) + { detail::report_exception( out, "std::logic_error:", ex.what() ); } + catch ( const std::runtime_error & ex ) + { detail::report_exception( out, "std::runtime_error:", ex.what() ); } + catch ( const std::exception & ex ) + { detail::report_exception( out, "std::exception:", ex.what() ); } + + catch ( ... ) + { detail::report_exception( out, "unknown exception", "" ); } + + if ( exception_thrown ) result = boost::exit_exception_failure; + + if ( result != 0 && result != exit_success ) + { + out << std::endl << "**** returning with error code " + << result << std::endl; + err + << "********** errors detected; see stdout for details ***********" + << std::endl; + } + else { out << std::flush << "no errors detected" << std::endl; } + + return result; + } // catch_exceptions + +} // boost + +#endif // BOOST_CATCH_EXCEPTIONS_HPP + From 6b15777c8f5da5af8b48107ca15da61c33469d61 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Thu, 1 Mar 2001 15:45:41 +0000 Subject: [PATCH 29/29] Initial commit [SVN r9370] --- include/boost/cstdlib.hpp | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 include/boost/cstdlib.hpp diff --git a/include/boost/cstdlib.hpp b/include/boost/cstdlib.hpp new file mode 100644 index 0000000..39419b4 --- /dev/null +++ b/include/boost/cstdlib.hpp @@ -0,0 +1,42 @@ +// boost/cstdlib.hpp header ------------------------------------------------// + +// (C) Copyright Beman Dawes 2001. Permission to copy, use, modify, sell +// and distribute this software is granted provided this copyright notice +// appears in all copies. This software is provided "as is" without express or +// implied warranty, and with no claim as to its suitability for any purpose. + +// See http://www.boost.org for updates and documentation. + +// Revision History +// 26 Feb 01 Initial version (Beman Dawes) + +#ifndef BOOST_CSTDLIB_HPP +#define BOOST_CSTDLIB_HPP + +#include + +namespace boost +{ + // The intent is to propose the following for addition to namespace std + // in the C++ Standard Library, and to then deprecate EXIT_SUCCESS and + // EXIT_FAILURE. As an implementation detail, this header defines the + // new constants in terms of EXIT_SUCCESS and EXIT_FAILURE. In a new + // standard, the constants would be implementation-defined, although it + // might be worthwhile to "suggest" (which a standard is allowed to do) + // values of 0 and 1 respectively. + + // Rationale for having multiple failure values: some environments may + // wish to distinguish between different classes of errors. + // Rationale for choice of values: programs often use values < 100 for + // their own error reporting. Values > 255 are sometimes reserved for + // system detected errors. 200/201 were suggested to minimize conflict. + + const int exit_success = EXIT_SUCCESS; // implementation-defined value + const int exit_failure = EXIT_FAILURE; // implementation-defined value + const int exit_exception_failure = 200; // otherwise uncaught exception + const int exit_test_failure = 201; // report_error or + // report_critical_error called. +} + +#endif +