From 33abcf7250bd434a510a62ba11b83f7ae0bf4a78 Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Mon, 30 Apr 2001 13:36:05 +0000 Subject: [PATCH] use BOOST_STATIC_CONSTANT define static member constants add wchar_t specialization [SVN r9997] --- include/boost/integer_traits.hpp | 43 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/include/boost/integer_traits.hpp b/include/boost/integer_traits.hpp index ba4ef27..8ec2302 100644 --- a/include/boost/integer_traits.hpp +++ b/include/boost/integer_traits.hpp @@ -21,8 +21,11 @@ #include #include -// This is an implementation detail and not part of the interface +// These are an implementation detail and not part of the interface #include +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +#include +#endif namespace boost { @@ -30,11 +33,7 @@ template class integer_traits : public std::numeric_limits { public: -#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION - static const bool is_integral = false; -#else - enum { is_integral = false }; -#endif + BOOST_STATIC_CONSTANT(bool, is_integral = false); }; namespace detail { @@ -42,18 +41,20 @@ template class integer_traits_base { public: -#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION - static const bool is_integral = true; - static const T const_min = min_val; - static const T const_max = max_val; -#else - enum { - is_integral = true, - const_min = min_val, - const_max = max_val - }; -#endif + BOOST_STATIC_CONSTANT(bool, is_integral = true); + BOOST_STATIC_CONSTANT(T, const_min = min_val); + BOOST_STATIC_CONSTANT(T, const_max = max_val); }; + +#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION +// The definition is required even for integral static constants +template +const T integer_traits_base::const_min; + +template +const T integer_traits_base::const_max; +#endif + } // namespace detail template<> @@ -80,7 +81,13 @@ class integer_traits public detail::integer_traits_base { }; -// What about wchar_t ? +#ifndef BOOST_NO_INTRINSIC_WCHAR_T +template<> +class integer_traits + : public std::numeric_limits, + public detail::integer_traits_base +{ }; +#endif // BOOST_NO_INTRINSIC_WCHAR_T template<> class integer_traits