From b7a2b8d4cc228b256d48f86130845e39bc0e96fe Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 30 Jul 2000 10:33:54 +0000 Subject: [PATCH 001/138] This commit was manufactured by cvs2svn to create branch 'conversion'. [SVN r7663] From ba5b91daef5bed45e10a62ca4855645210a8dd9e Mon Sep 17 00:00:00 2001 From: nobody Date: Wed, 2 Aug 2000 10:31:49 +0000 Subject: [PATCH 002/138] This commit was manufactured by cvs2svn to create tag 'conversion-merge-1'. [SVN r7674] From fe11e65a4a664795e93a6dae7ab1e0dca8af29e7 Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 21 Sep 2000 03:34:33 +0000 Subject: [PATCH 003/138] This commit was manufactured by cvs2svn to create branch 'regex-sub'. [SVN r7754] From 15b1fc3b5876f6994848e90ed5fc3e2aed62c4f3 Mon Sep 17 00:00:00 2001 From: nobody Date: Sat, 27 Jan 2001 17:35:01 +0000 Subject: [PATCH 004/138] This commit was manufactured by cvs2svn to create branch 'unlabeled-1.1.2'. [SVN r8787] --- cast.htm | 145 -------------- cast_test.cpp | 153 --------------- include/boost/cast.hpp | 342 --------------------------------- include/boost/lexical_cast.hpp | 67 ------- index.htm | 39 ---- lexical_cast_test.cpp | 149 -------------- test.hpp | 312 ------------------------------ 7 files changed, 1207 deletions(-) delete mode 100644 cast.htm delete mode 100644 cast_test.cpp delete mode 100644 include/boost/cast.hpp delete mode 100644 include/boost/lexical_cast.hpp delete mode 100644 index.htm delete mode 100644 lexical_cast_test.cpp delete mode 100644 test.hpp diff --git a/cast.htm b/cast.htm deleted file mode 100644 index d64473b..0000000 --- a/cast.htm +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - -Header boost/cast.hpp Documentation - - - - -

c++boost.gif (8819 bytes)Header -boost/cast.hpp

-

Cast Functions

-

The header boost/cast.hpp -provides polymorphic_cast, polymorphic_downcast, -and numeric_cast function templates designed -to complement the C++ built-in casts.

-

The program cast_test.cpp can be used to -verify these function templates work as expected.

-

Polymorphic casts

-

Pointers to polymorphic objects (objects of classes which define at least one -virtual function) are sometimes downcast or crosscast.  Downcasting means -casting from a base class to a derived class.  Crosscasting means casting -across an inheritance hierarchy diagram, such as from one base to the other in a -Y diagram hierarchy.

-

Such casts can be done with old-style casts, but this approach is never to be -recommended.  Old-style casts are sorely lacking in type safety, suffer -poor readability, and are difficult to locate with search tools.

-

The C++ built-in static_cast can be used for efficiently downcasting -pointers to polymorphic objects, but provides no error detection for the case -where the pointer being cast actually points to the wrong derived class. The polymorphic_downcast -template retains the efficiency of static_cast for non-debug -compilations, but for debug compilations adds safety via an assert() that a dynamic_cast -succeeds.  

-

The C++ built-in dynamic_cast can be used for downcasts and crosscasts -of pointers to polymorphic objects, but error notification in the form of a -returned value of 0 is inconvenient to test, or worse yet, easy to forget to -test.  The polymorphic_cast template performs a dynamic_cast, -and throws an exception if the dynamic_cast returns 0.

-

A polymorphic_downcast is preferred when debug-mode tests will cover -100% of the object types possibly cast and when non-debug-mode efficiency is an -issue. If these two conditions are not present, polymorphic_cast is -preferred.  It must also be used for crosscasts.  It does an assert( -dynamic_cast<Derived>(x) == x ) where x is the base pointer, ensuring that -not only is a non-zero pointer returned, but also that it correct in the -presence of multiple inheritance. Warning:: Because polymorphic_downcast -uses assert(), it violates the one definition rule (ODR) if NDEBUG is inconsistently -defined across translation units.  [See ISO Std 3.2]

-

The C++ built-in dynamic_cast must be used to cast references rather -than pointers.  It is also the only cast that can be used to check whether -a given interface is supported; in that case a return of 0 isn't an error -condition.

-

polymorphic_cast and polymorphic_downcast synopsis

-
-
namespace boost {
-
-template <class Derived, class Base>
-inline Derived polymorphic_cast(Base* x);
-// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )
-// Returns: dynamic_cast<Derived>(x)
-
-template <class Derived, class Base>
-inline Derived polymorphic_downcast(Base* x);
-// Effects: assert( dynamic_cast<Derived>(x) == x );
-// Returns: static_cast<Derived>(x)
-
-}
-
-

polymorphic_downcast example

-
-
#include <boost/cast.hpp>
-...
-class Fruit { public: virtual ~Fruit(){}; ... };
-class Banana : public Fruit { ... };
-...
-void f( Fruit * fruit ) {
-// ... logic which leads us to believe it is a Banana
-  Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
-  ...
-
-

numeric_cast

-

A static_cast or implicit conversion will not -detect failure to preserve range for numeric casts. The numeric_cast function -templates are similar to static_cast and certain (dubious) -implicit conversions in this respect, except that they detect loss of numeric -range. An exception is thrown when a runtime value-preservation check fails.

-

The requirements on the argument and result types are:

-
-
    -
  • Both argument and result types are CopyConstructible [ISO Std 20.1.3].
  • -
  • Both argument and result types are Numeric, defined by std::numeric_limits<>::is_specialized - being true.
  • -
  • The argument can be converted to the result type using static_cast.
  • -
-
-

numeric_cast synopsis

-
-
namespace boost {
-
-class bad_numeric_cast : public std::bad_cast {...};
-
-template<typename Target, typename Source>
-  inline Target numeric_cast(Source arg);
-    // Throws:  bad_numeric_cast unless, in converting arg from Source to Target,
-    //          there is no loss of negative range, and no underflow, and no
-    //          overflow, as determined by std::numeric_limits
-    // Returns: static_cast<Target>(arg)
-
-}
-
-

numeric_cast example

-
-
#include <boost/cast.hpp>
-using namespace boost::cast;
-
-void ariane(double vx)
-{
-    ...
-    unsigned short dx = numeric_cast<unsigned short>(vx);
-    ...
-}
-
-

numeric_cast rationale

-

The form of the throws condition is specified so that != is not a required -operation.

-

History

-

polymorphic_cast was suggested by Bjarne Stroustrup in "The C++ -Programming Language".
-polymorphic_downcast was contributed by Dave -Abrahams.
-numeric_cast
was contributed by Kevlin -Henney.

-
-

Revised  06 January, 2001

-

© Copyright boost.org 1999. Permission to copy, use, modify, sell and -distribute this document is granted provided this copyright notice appears in -all copies. This document is provided "as is" without express or -implied warranty, and with no claim as to its suitability for any purpose.

- - - - diff --git a/cast_test.cpp b/cast_test.cpp deleted file mode 100644 index e3ca7ea..0000000 --- a/cast_test.cpp +++ /dev/null @@ -1,153 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright boost.org 1999. 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 -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - -namespace -{ - struct Base - { - virtual char kind() { return 'B'; } - }; - - struct Base2 - { - virtual char kind2() { return '2'; } - }; - - struct Derived : public Base, Base2 - { - virtual char kind() { return 'D'; } - }; -} - - -int main( int argc, char * argv[] ) -{ - cout << "Usage: test_casts [n], where n omitted or is:\n" - " 1 = execute #1 assert failure (#ifndef NDEBUG)\n" - " 2 = execute #2 assert failure (#ifndef NDEBUG)\n" - "Example: test_casts 2\n\n"; - -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test polymorphic_cast ---------------------------------------------------// - - // tests which should succeed - Base * base = new Derived; - Base2 * base2 = 0; - Derived * derived = 0; - derived = polymorphic_downcast( base ); // downcast - assert( derived->kind() == 'D' ); - - derived = 0; - derived = polymorphic_cast( base ); // downcast, throw on error - assert( derived->kind() == 'D' ); - - base2 = polymorphic_cast( base ); // crosscast - assert( base2->kind2() == '2' ); - - // tests which should result in errors being detected - int err_count = 0; - base = new Base; - - if ( argc > 1 && *argv[1] == '1' ) - { derived = polymorphic_downcast( base ); } // #1 assert failure - - bool caught_exception = false; - try { derived = polymorphic_cast( base ); } - catch (std::bad_cast) - { cout<<"caught bad_cast\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - // the following is just so generated code can be inspected - if ( derived->kind() == 'B' ) ++err_count; - -// test implicit_cast and numeric_cast -------------------------------------// - - // tests which should succeed - long small_value = 1; - long small_negative_value = -1; - long large_value = LONG_MAX; - long large_negative_value = LONG_MIN; - signed char c = 0; - - c = large_value; // see if compiler generates warning - - c = numeric_cast( small_value ); - assert( c == 1 ); - c = 0; - c = numeric_cast( small_value ); - assert( c == 1 ); - c = 0; - c = numeric_cast( small_negative_value ); - assert( c == -1 ); - - // These tests courtesy of Joe R NWP Swatosh - assert( 0.0f == numeric_cast( 0.0 ) ); - assert( 0.0 == numeric_cast( 0.0 ) ); - - // tests which should result in errors being detected - - caught_exception = false; - try { c = numeric_cast( large_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #1\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - caught_exception = false; - try { c = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #2\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - unsigned long ul; - caught_exception = false; - try { ul = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #3\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - caught_exception = false; - try { ul = numeric_cast( small_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #4\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - caught_exception = false; - try { numeric_cast( DBL_MAX ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #5\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - cout << err_count << " errors detected\nTest " - << (err_count==0 ? "passed\n" : "failed\n"); - return err_count; -} // main diff --git a/include/boost/cast.hpp b/include/boost/cast.hpp deleted file mode 100644 index 031cc5d..0000000 --- a/include/boost/cast.hpp +++ /dev/null @@ -1,342 +0,0 @@ -// boost cast.hpp header file ----------------------------------------------// - -// (C) Copyright boost.org 1999. 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 -// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never -// worked with stock GCC; trying to get it to do that broke -// vc-stlport. -// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp. -// Removed unused BOOST_EXPLICIT_TARGET macro. Moved -// boost::detail::type to boost/type.hpp. Made it compile with -// stock gcc again (Dave Abrahams) -// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal -// Review (Beman Dawes) -// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams) -// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC -// (Dave Abrahams) -// 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams) -// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes) -// 27 Jun 00 More MSVC6 workarounds -// 15 Jun 00 Add workarounds for MSVC6 -// 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov) -// 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar) -// 29 Dec 99 Change using declarations so usages in other namespaces work -// correctly (Dave Abrahams) -// 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors -// as suggested Darin Adler and improved by Valentin Bonnard. -// 2 Sep 99 Remove controversial asserts, simplify, rename. -// 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast, -// place in nested namespace. -// 3 Aug 99 Initial version - -#ifndef BOOST_CAST_HPP -#define BOOST_CAST_HPP - -# include -# include -# include -# include -# ifndef BOOST_NO_LIMITS -# include -# endif - -// It has been demonstrated numerous times that MSVC 6.0 fails silently at link -// time if you use a template function which has template parameters that don't -// appear in the function's argument list. -// -// TODO: Add this to config.hpp? -# if defined(BOOST_MSVC) && BOOST_MSVC <= 1200 // 1200 = VC6 -# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type* = 0 -# else -# define BOOST_EXPLICIT_DEFAULT_TARGET -# endif - -namespace boost -{ -// See the documentation for descriptions of how to choose between -// static_cast<>, dynamic_cast<>, polymorphic_cast<> and polymorphic_downcast<> - -// polymorphic_cast --------------------------------------------------------// - - // Runtime checked polymorphic downcasts and crosscasts. - // Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup, - // section 15.8 exercise 1, page 425. - - template - inline Target polymorphic_cast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) - { - Target tmp = dynamic_cast(x); - if ( tmp == 0 ) throw std::bad_cast(); - return tmp; - } - -// polymorphic_downcast ----------------------------------------------------// - - // assert() checked polymorphic downcast. Crosscasts prohibited. - - // WARNING: Because this cast uses assert(), it violates the One Definition - // Rule if NDEBUG is inconsistently defined across translation units. - - // Contributed by Dave Abrahams - - template - inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) - { - assert( dynamic_cast(x) == x ); // detect logic error - return static_cast(x); - } - -// implicit_cast -----------------------------------------------------------// -// -// Removed due to uncertain purpose. Use either numeric_cast (see below) -// or static_cast according to the need. - -// numeric_cast and related exception --------------------------------------// - -// Contributed by Kevlin Henney - -// bad_numeric_cast --------------------------------------------------------// - - // exception used to indicate runtime numeric_cast failure - class bad_numeric_cast : public std::bad_cast - { - public: - // constructors, destructors and assignment operator defaulted - - // function inlined for brevity and consistency with rest of library - virtual const char *what() const throw() - { - return "bad numeric cast: loss of range in numeric_cast"; - } - }; - -// numeric_cast ------------------------------------------------------------// - -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - - namespace detail - { - template struct numeric_min_select; - - template<> - struct numeric_min_select - { - template - struct limits : std::numeric_limits - { - static inline T min() -# ifndef __GNUC__ // bug workaround courtesy Jens Maurer - { - return std::numeric_limits::min() >= 0 - // unary minus causes integral promotion, thus the static_cast<> - ? static_cast(-std::numeric_limits::max()) - : std::numeric_limits::min(); - } -# else - ; -# endif - }; - }; - -# ifdef __GNUC__ // bug workaround courtesy Jens Maurer - template<> template - inline T numeric_min_select::limits::min() - { - return std::numeric_limits::min() >= 0 - // unary minus causes integral promotion, thus the static_cast<> - ? static_cast(-std::numeric_limits::max()) - : std::numeric_limits::min(); - } -# endif - - template<> - struct numeric_min_select - { - template - struct limits : std::numeric_limits {}; - }; - - // Move to namespace boost in utility.hpp? - template - struct fixed_numeric_limits - : public numeric_min_select< - std::numeric_limits::is_signed - >::template limits - { - }; - } // namespace detail - -// less_than_type_min - - // x_is_signed should be numeric_limits::is_signed - // y_is_signed should be numeric_limits::is_signed - // y_min should be numeric_limits::min() - // - // check(x, y_min) returns true iff x < y_min without invoking comparisons - // between signed and unsigned values. - // - // "poor man's partial specialization" is in use here. - template - struct less_than_type_min - { - template - static bool check(X x, Y y_min) - { return x < y_min; } - }; - - template <> - struct less_than_type_min - { - template - static bool check(X, Y) - { return false; } - }; - - template <> - struct less_than_type_min - { - template - static bool check(X x, Y) - { return x < 0; } - }; - - // greater_than_type_max - - // same_sign should be: - // numeric_limits::is_signed == numeric_limits::is_signed - // y_max should be numeric_limits::max() - // - // check(x, y_max) returns true iff x > y_max without invoking comparisons - // between signed and unsigned values. - // - // "poor man's partial specialization" is in use here. - template - struct greater_than_type_max; - - template<> - struct greater_than_type_max - { - template - static inline bool check(X x, Y y_max) - { return x > y_max; } - }; - - template <> - struct greater_than_type_max - { - // What does the standard say about this? I think it's right, and it - // will work with every compiler I know of. - template - static inline bool check(X x, Y) - { return x >= 0 && static_cast(static_cast(x)) != x; } - }; - - template<> - struct greater_than_type_max - { - template - static inline bool check(X x, Y y_max) - { return x > y_max; } - }; - - template <> - struct greater_than_type_max - { - // What does the standard say about this? I think it's right, and it - // will work with every compiler I know of. - template - static inline bool check(X x, Y) - { return static_cast(static_cast(x)) != x; } - }; - -#else // use #pragma hacks if available - - namespace detail - { -# if BOOST_MSVC -# pragma warning(push) -# pragma warning(disable : 4018) -# pragma warning(disable : 4146) -#elif defined(__BORLANDC__) -# pragma option push -w-8041 -# endif - -# ifndef BOOST_NO_LIMITS - // Move to namespace boost in utility.hpp? - template - struct fixed_numeric_limits : public std::numeric_limits - { - static inline T min() - { - return std::numeric_limits::is_signed && std::numeric_limits::min() >= 0 - ? T(-std::numeric_limits::max()) : std::numeric_limits::min(); - } - }; -# endif // BOOST_NO_LIMITS - -# if BOOST_MSVC -# pragma warning(pop) -#elif defined(__BORLANDC__) -# pragma option pop -# endif - } // namespace detail - -#endif - - template - inline Target numeric_cast(Source arg BOOST_EXPLICIT_DEFAULT_TARGET) - { -#ifndef BOOST_NO_LIMITS - // typedefs abbreviating respective trait classes - typedef std::numeric_limits arg_traits; - typedef detail::fixed_numeric_limits result_traits; -#endif - -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - // typedefs that act as compile time assertions - // (to be replaced by boost compile time assertions - // as and when they become available and are stable) - typedef bool argument_must_be_numeric[arg_traits::is_specialized]; - typedef bool result_must_be_numeric[result_traits::is_specialized]; - - const bool arg_is_signed = arg_traits::is_signed; - const bool result_is_signed = result_traits::is_signed; - const bool same_sign = arg_is_signed == result_is_signed; - - if (less_than_type_min::check(arg, result_traits::min()) - || greater_than_type_max::check(arg, result_traits::max()) - ) - -#else // We need to use #pragma hacks if available - -# if BOOST_MSVC -# pragma warning(push) -# pragma warning(disable : 4018) -#elif defined(__BORLANDC__) -#pragma option push -w-8012 -# endif - if ((arg < 0 && !result_traits::is_signed) // loss of negative range - || (arg_traits::is_signed && arg < result_traits::min()) // underflow - || arg > result_traits::max()) // overflow -# if BOOST_MSVC -# pragma warning(pop) -#elif defined(__BORLANDC__) -#pragma option pop -# endif -#endif - { - throw bad_numeric_cast(); - } - return static_cast(arg); - } // numeric_cast - -# undef BOOST_EXPLICIT_DEFAULT_TARGET - -} // namespace boost - -#endif // BOOST_CAST_HPP diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp deleted file mode 100644 index 5096e1b..0000000 --- a/include/boost/lexical_cast.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// boost lexical_cast.hpp header -------------------------------------------// - -// See http://www.boost.org for most recent version including documentation. - -#ifndef BOOST_LEXICAL_CAST_INCLUDED -#define BOOST_LEXICAL_CAST_INCLUDED - -// what: lexical_cast custom keyword cast -// who: contributed by Kevlin Henney, with alternative naming, behaviors -// and fixes contributed by Dave Abrahams, Daryle Walker and other -// Boosters on the list -// when: November 2000 -// where: tested with MSVC 6.0, BCC 5.5, and g++ 2.91 - -#include -# ifndef BOOST_NO_STRINGSTREAM -# include -# else -# include -# endif -#include - -namespace boost -{ - // exception used to indicate runtime lexical_cast failure - class bad_lexical_cast : public std::bad_cast - { - public: - // constructors, destructors, and assignment operator defaulted - - // function inlined for brevity and consistency with rest of library - virtual const char * what() const throw() - { - return "bad lexical cast: " - "source type value could not be interpreted as target"; - } - }; - - template - Target lexical_cast(Source arg) - { -# ifndef BOOST_NO_STRINGSTREAM - std::stringstream interpreter; -# else - std::strstream interpreter; // for out-of-the-box g++ 2.95.2 -# endif - Target result; - - if(!(interpreter << arg) || !(interpreter >> result) || - !(interpreter >> std::ws).eof()) - throw bad_lexical_cast(); - - return result; - } -} - -// Copyright Kevlin Henney, 2000. All rights reserved. -// -// Permission to use, copy, modify, and distribute this software for any -// purpose is hereby granted without fee, provided that this copyright and -// permissions notice appear in all copies and derivatives, and that no -// charge may be made for the software and its documentation except to cover -// cost of distribution. -// -// This software is provided "as is" without express or implied warranty. - -#endif diff --git a/index.htm b/index.htm deleted file mode 100644 index 079576c..0000000 --- a/index.htm +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - -Boost Conversion Library - - - - -

Boost -Conversion Library

- -

The Conversion Library improves program safety and clarity by performing -otherwise messy conversions.  It includes cast-style function templates designed to complement the C++ -Standard's built-in casts.

-

To reduce coupling, particularly to standard library IOStreams, the Boost -Conversion Library is -supplied by several headers:

-
    -
  • The boost/cast header provides polymorphic_cast<> - and polymorphic_downcast<> to perform safe casting between - polymorphic types, and numeric_cast<> to perform safe casting - between numeric types.
    -
  • -
  • The boost/lexical_cast header provides lexical_cast<> - general literal text conversions, such as an int represented as - a string, or vice-versa.
  • -
-
-

Revised 06 January, 2001 -

- - - - diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp deleted file mode 100644 index c19cf08..0000000 --- a/lexical_cast_test.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// boost lexical_cast_test.cpp program -------------------------------------// - -// See http://www.boost.org for most recent version including documentation. - -// what: lexical_cast custom keyword cast tests -// who: contributed by Kevlin Henney -// when: October 2000 -// where: tested with MSVC 6.0 and BCC 5.5 - -#include -#include "test.hpp" -#include -#include -#include - -using namespace boost; -using namespace std; - -typedef test::test test_case; -typedef const test_case * test_case_iterator; - -extern const test_case_iterator begin, end; - -int main() -{ - test::tester test_suite(begin, end); - return test_suite() ? EXIT_SUCCESS : EXIT_FAILURE; -} - -void test_to_string() -{ - test::check_equal( - lexical_cast(2001), "2001", - "2001 -> \"2001\""); - test::check_equal( - lexical_cast(2001.0), "2001", - "2001.0 ->\"2001\""); - test::check_equal( - lexical_cast(complex(2000,1)), "(2000,1)", - "complex(2000,1) -> \"(2000,1)\""); -} - -void test_to_int() -{ - test::check_equal( - lexical_cast("2001"), 2001, - "\"2001\" -> 2001"); - test::check_equal( - lexical_cast(" 2001"), 2001, - "\" 2001\" -> 2001"); - test::check_equal( - lexical_cast("2001 "), 2001, - "\"2001 \" -> 2001"); - TEST_CHECK_THROW( - lexical_cast("Two thousand and one"), - bad_lexical_cast, - "\"Two thousand and one\""); - TEST_CHECK_THROW( - lexical_cast("2001: A Space Odyssey"), - bad_lexical_cast, - "\"2001: A Space Odyssey\""); - TEST_CHECK_THROW( - lexical_cast(200.1), - bad_lexical_cast, - "200.1"); - TEST_CHECK_THROW( - lexical_cast("200e1"), - bad_lexical_cast, - "\"200e1\""); -} - -void test_to_char() -{ - test::check_equal( - lexical_cast("2"), '2', - "\"2\" -> '2'"); - test::check_equal( - lexical_cast(" 2"), '2', - "\" 2\" -> '2'"); - test::check_equal( - lexical_cast("2 "), '2', - "\"2 \" -> '2'"); - test::check_equal( - lexical_cast(2), '2', - "2 -> '2'"); - TEST_CHECK_THROW( - lexical_cast("2001"), - bad_lexical_cast, - "\"2001\""); - TEST_CHECK_THROW( - lexical_cast(2001), - bad_lexical_cast, - "2001"); -} - -void test_to_double() -{ - test::check_equal( - lexical_cast("1e6"), 1e6, - "\"1e6\" -> 1e6"); - test::check_equal( - lexical_cast("1e-2"), 1e-2, - "\"1e-2\" -> 1e-2"); -} - -void test_to_bool() -{ - test::check_equal( - lexical_cast(1), true, - "1 -> true"); - test::check_equal( - lexical_cast('0'), false, - "'0' -> false"); - TEST_CHECK_THROW( - lexical_cast(2001), - bad_lexical_cast, - "2001"); - TEST_CHECK_THROW( - lexical_cast(2), - bad_lexical_cast, - "2"); - TEST_CHECK_THROW( - lexical_cast("true thousand and one"), - bad_lexical_cast, - "\"true thousand and one\""); -} - -const test_case test_cases[] = -{ - { "lexical_cast", test_to_string }, - { "lexical_cast", test_to_int }, - { "lexical_cast", test_to_char }, - { "lexical_cast", test_to_double }, - { "lexical_cast", test_to_bool } -}; - -const test_case_iterator begin = test_cases; -const test_case_iterator end = - test_cases + (sizeof test_cases / sizeof *test_cases); - -// Copyright Kevlin Henney, 2000. All rights reserved. -// -// Permission to use, copy, modify, and distribute this software for any -// purpose is hereby granted without fee, provided that this copyright and -// permissions notice appear in all copies and derivatives, and that no -// charge may be made for the software and its documentation except to cover -// cost of distribution. -// -// This software is provided "as is" without express or implied warranty. diff --git a/test.hpp b/test.hpp deleted file mode 100644 index d286b8c..0000000 --- a/test.hpp +++ /dev/null @@ -1,312 +0,0 @@ -// what: simple unit test framework -// who: developed by Kevlin Henney -// when: November 2000 -// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.91 -// -// ChangeLog: -// 20 Jan 2001 - Fixed a warning for MSVC (Dave Abrahams) - -#ifndef TEST_INCLUDED -#define TEST_INCLUDED - -#include -#include -#include // for out-of-the-box g++ -#include - -namespace test // test tuple comprises name and nullary function (object) -{ - template - struct test - { - string_type name; - function_type action; - - static test make(string_type name, function_type action) - { - test result; // MSVC aggreggate initializer bugs - result.name = name; - result.action = action; - return result; - } - }; -} - -namespace test // failure exception used to indicate checked test failures -{ - class failure : public std::exception - { - public: // struction (default cases are OK) - - failure(const std::string & why) - : reason(why) - { - } - - // std::~string has no exception-specification (could throw anything), - // but we need to be compatible with std::~exception's empty one - // see std::15.4p13 and std::15.4p3 - ~failure() throw() - { - } - - public: // usage - - virtual const char * what() const throw() - { - return reason.c_str(); - } - - private: // representation - - std::string reason; - - }; -} - -namespace test // not_implemented exception used to mark unimplemented tests -{ - class not_implemented : public std::exception - { - public: // usage (default ctor and dtor are OK) - - virtual const char * what() const throw() - { - return "not implemented"; - } - - }; -} - -namespace test // test utilities -{ - inline void check(bool condition, const std::string & description) - { - if(!condition) - { - throw failure(description); - } - } - - inline void check_true(bool value, const std::string & description) - { - check(value, "expected true: " + description); - } - - inline void check_false(bool value, const std::string & description) - { - check(!value, "expected false: " + description); - } - - template - void check_equal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs == rhs, "expected equal values: " + description); - } - - template - void check_unequal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs != rhs, "expected unequal values: " + description); - } - - inline void check_null(const void* ptr, const std::string & description) - { - check(!ptr, "expected null pointer: " + description); - } - - inline void check_non_null(const void* ptr, const std::string & description) - { - check(ptr != 0, "expected non-null pointer: " + description); - } -} - -#define TEST_CHECK_THROW(expression, exception, description) \ - try \ - { \ - expression; \ - throw ::test::failure(description); \ - } \ - catch(exception &) \ - { \ - } - -namespace test // memory tracking (enabled if test new and delete linked in) -{ - class allocations - { - public: // singleton access - - static allocations & instance() - { - static allocations singleton; - return singleton; - } - - public: // logging - - void clear() - { - alloc_count = dealloc_count = 0; - } - - void allocation() - { - ++alloc_count; - } - - void deallocation() - { - ++dealloc_count; - } - - public: // reporting - - unsigned long allocated() const - { - return alloc_count; - } - - unsigned long deallocated() const - { - return dealloc_count; - } - - bool balanced() const - { - return alloc_count == dealloc_count; - } - - private: // structors (default dtor is fine) - - allocations() - : alloc_count(0), dealloc_count(0) - { - } - - private: // prevention - - allocations(const allocations &); - allocations & operator=(const allocations &); - - private: // state - - unsigned long alloc_count, dealloc_count; - - }; -} - -namespace test // tester is the driver class for a sequence of tests -{ - template - class tester - { - public: // structors (default destructor is OK) - - tester(test_iterator first_test, test_iterator after_last_test) - : begin(first_test), end(after_last_test) - { - } - - public: // usage - - bool operator()(); // returns true if all tests passed - - private: // representation - - test_iterator begin, end; - - private: // prevention - - tester(const tester &); - tester &operator=(const tester &); - - }; - - template - bool tester::operator()() - { - using namespace std; - - unsigned long passed = 0, failed = 0, unimplemented = 0; - - for(test_iterator current = begin; current != end; ++current) - { - cerr << "[" << current->name << "] " << flush; - string result = "passed"; // optimistic - - try - { - allocations::instance().clear(); - current->action(); - - if(!allocations::instance().balanced()) - { - unsigned long allocated = allocations::instance().allocated(); - unsigned long deallocated = allocations::instance().deallocated(); - ostrstream report; - report << "new/delete (" - << allocated << " allocated, " - << deallocated << " deallocated)" - << ends; - const char * text = report.str(); - report.freeze(false); - throw failure(text); - } - - ++passed; - } - catch(const failure & caught) - { - (result = "failed: ") += caught.what(); - ++failed; - } - catch(const not_implemented &) - { - result = "not implemented"; - ++unimplemented; - } - catch(const exception & caught) - { - (result = "exception: ") += caught.what(); - ++failed; - } - catch(...) - { - result = "failed with unknown exception"; - ++failed; - } - - cerr << result << endl; - } - - cerr << passed + failed << " tests: " - << passed << " passed, " - << failed << " failed"; - - if(unimplemented) - { - cerr << " (" << unimplemented << " not implemented)"; - } - - cerr << endl; - - return failed == 0; - } -} - -#endif - -// Copyright Kevlin Henney, 2000. All rights reserved. -// -// Permission to use, copy, modify, and distribute this software for any -// purpose is hereby granted without fee, provided that this copyright and -// permissions notice appear in all copies and derivatives, and that no -// charge may be made for the software and its documentation except to cover -// cost of distribution. -// -// This software is provided "as is" without express or implied warranty. From f9f1ca0d10fa1ef8a56277aa14d1492779223c1e Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Mon, 5 Mar 2001 20:01:01 +0000 Subject: [PATCH 005/138] Join ralf_grosse_kunstleve with HEAD [SVN r9444] --- lexical_cast.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lexical_cast.htm b/lexical_cast.htm index 2a4af6d..13a20f0 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -127,7 +127,7 @@ void log_errno(int yoko)

Synopsis

-Library features defined in "boost/lexical_cast.hpp": +Library features defined in "boost/lexical_cast.hpp":

From 2ced4e32a47e0339ad6e011414565b9d4c0fb59c Mon Sep 17 00:00:00 2001
From: nobody 
Date: Sat, 4 Aug 2001 14:31:38 +0000
Subject: [PATCH 006/138] This commit was manufactured by cvs2svn to create
 branch 'split-config'.

[SVN r10742]

From 56b9a696bc6f666b80ed2a895caa4257a56259a2 Mon Sep 17 00:00:00 2001
From: nobody 
Date: Fri, 22 Mar 2002 12:16:42 +0000
Subject: [PATCH 007/138] This commit was manufactured by cvs2svn to create
 branch 'compiler_supported_error_messages'.

[SVN r13249]

From b3e887447b2b23c9ac50c2eb9f57b34e72953048 Mon Sep 17 00:00:00 2001
From: nobody 
Date: Mon, 12 Aug 2002 13:35:54 +0000
Subject: [PATCH 008/138] This commit was manufactured by cvs2svn to create
 branch 'python-v2-dev'.

[SVN r14785]

From 60b527f7b885a6f29d06ba64736df0087a35ec00 Mon Sep 17 00:00:00 2001
From: nobody 
Date: Thu, 5 Jun 2003 05:15:05 +0000
Subject: [PATCH 009/138] This commit was manufactured by cvs2svn to create
 branch 'mpl_v2_2'.

[SVN r18675]
---
 cast.htm                    | 150 -----------------
 cast_test.cpp               | 154 ------------------
 index.htm                   |  39 -----
 lexical_cast.htm            | 223 --------------------------
 lexical_cast_test.cpp       | 290 ---------------------------------
 test.hpp                    | 312 ------------------------------------
 test/Jamfile                |  34 ----
 test/implicit_cast.cpp      |  34 ----
 test/implicit_cast_fail.cpp |  23 ---
 9 files changed, 1259 deletions(-)
 delete mode 100644 cast.htm
 delete mode 100644 cast_test.cpp
 delete mode 100644 index.htm
 delete mode 100644 lexical_cast.htm
 delete mode 100644 lexical_cast_test.cpp
 delete mode 100644 test.hpp
 delete mode 100644 test/Jamfile
 delete mode 100644 test/implicit_cast.cpp
 delete mode 100644 test/implicit_cast_fail.cpp

diff --git a/cast.htm b/cast.htm
deleted file mode 100644
index 9122c01..0000000
--- a/cast.htm
+++ /dev/null
@@ -1,150 +0,0 @@
-
-
-
-
-
-
-
-
-Header boost/cast.hpp Documentation
-
-
-
-
-

c++boost.gif (8819 bytes)Header -boost/cast.hpp

- -

Cast Functions

- -

The header boost/cast.hpp -provides polymorphic_cast, polymorphic_downcast, -and numeric_cast function templates designed -to complement the C++ built-in casts.

- -

The program cast_test.cpp can be used to -verify these function templates work as expected.

-

Polymorphic casts

-

Pointers to polymorphic objects (objects of classes which define at least one -virtual function) are sometimes downcast or crosscast. Downcasting means -casting from a base class to a derived class. Crosscasting means casting -across an inheritance hierarchy diagram, such as from one base to the other in a -Y diagram hierarchy.

-

Such casts can be done with old-style casts, but this approach is never to be -recommended. Old-style casts are sorely lacking in type safety, suffer -poor readability, and are difficult to locate with search tools.

-

The C++ built-in static_cast can be used for efficiently downcasting -pointers to polymorphic objects, but provides no error detection for the case -where the pointer being cast actually points to the wrong derived class. The polymorphic_downcast -template retains the efficiency of static_cast for non-debug -compilations, but for debug compilations adds safety via an assert() that a dynamic_cast -succeeds.

-

The C++ built-in dynamic_cast can be used for downcasts and crosscasts -of pointers to polymorphic objects, but error notification in the form of a -returned value of 0 is inconvenient to test, or worse yet, easy to forget to -test. The polymorphic_cast template performs a dynamic_cast, -and throws an exception if the dynamic_cast returns 0.

-

A polymorphic_downcast is preferred when debug-mode tests will cover -100% of the object types possibly cast and when non-debug-mode efficiency is an -issue. If these two conditions are not present, polymorphic_cast is -preferred. It must also be used for crosscasts. It does an assert( -dynamic_cast<Derived>(x) == x ) where x is the base pointer, ensuring that -not only is a non-zero pointer returned, but also that it correct in the -presence of multiple inheritance. Warning:: Because polymorphic_downcast -uses assert(), it violates the one definition rule (ODR) if NDEBUG is inconsistently -defined across translation units. [See ISO Std 3.2]

-

The C++ built-in dynamic_cast must be used to cast references rather -than pointers. It is also the only cast that can be used to check whether -a given interface is supported; in that case a return of 0 isn't an error -condition.

-

polymorphic_cast and polymorphic_downcast synopsis

-
-
namespace boost {
-
-template <class Derived, class Base>
-inline Derived polymorphic_cast(Base* x);
-// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )
-// Returns: dynamic_cast<Derived>(x)
-
-template <class Derived, class Base>
-inline Derived polymorphic_downcast(Base* x);
-// Effects: assert( dynamic_cast<Derived>(x) == x );
-// Returns: static_cast<Derived>(x)
-
-}
-
-

polymorphic_downcast example

-
-
#include <boost/cast.hpp>
-...
-class Fruit { public: virtual ~Fruit(){}; ... };
-class Banana : public Fruit { ... };
-...
-void f( Fruit * fruit ) {
-// ... logic which leads us to believe it is a Banana
-  Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
-  ...
-
-

numeric_cast

-

A static_cast or implicit conversion will not -detect failure to preserve range for numeric casts. The numeric_cast function -templates are similar to static_cast and certain (dubious) -implicit conversions in this respect, except that they detect loss of numeric -range. An exception is thrown when a runtime value-preservation check fails.

-

The requirements on the argument and result types are:

-
-
    -
  • Both argument and result types are CopyConstructible [ISO Std 20.1.3].
  • -
  • Both argument and result types are Numeric, defined by std::numeric_limits<>::is_specialized - being true.
  • -
  • The argument can be converted to the result type using static_cast.
  • -
-
-

numeric_cast synopsis

-
-
namespace boost {
-
-class bad_numeric_cast : public std::bad_cast {...};
-
-template<typename Target, typename Source>
-  inline Target numeric_cast(Source arg);
-    // Throws:  bad_numeric_cast unless, in converting arg from Source to Target,
-    //          there is no loss of negative range, and no underflow, and no
-    //          overflow, as determined by std::numeric_limits
-    // Returns: static_cast<Target>(arg)
-
-}
-
-

numeric_cast example

-
-
#include <boost/cast.hpp>
-using namespace boost::cast;
-
-void ariane(double vx)
-{
-    ...
-    unsigned short dx = numeric_cast<unsigned short>(vx);
-    ...
-}
-
-

numeric_cast rationale

-

The form of the throws condition is specified so that != is not a required -operation.

-

History

-

polymorphic_cast was suggested by Bjarne Stroustrup in "The C++ -Programming Language".
-polymorphic_downcast was contributed by Dave -Abrahams.
-numeric_cast
was contributed by Kevlin -Henney.

-
-

Revised 06 January, 2001

-

© Copyright boost.org 1999. Permission to copy, use, modify, sell and -distribute this document is granted provided this copyright notice appears in -all copies. This document is provided "as is" without express or -implied warranty, and with no claim as to its suitability for any purpose.

- - - - diff --git a/cast_test.cpp b/cast_test.cpp deleted file mode 100644 index 091cfe6..0000000 --- a/cast_test.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright boost.org 1999. 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 -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include // for DBL_MAX (Peter Schmid) -#include - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - -namespace -{ - struct Base - { - virtual char kind() { return 'B'; } - }; - - struct Base2 - { - virtual char kind2() { return '2'; } - }; - - struct Derived : public Base, Base2 - { - virtual char kind() { return 'D'; } - }; -} - - -int main( int argc, char * argv[] ) -{ - cout << "Usage: test_casts [n], where n omitted or is:\n" - " 1 = execute #1 assert failure (#ifndef NDEBUG)\n" - " 2 = execute #2 assert failure (#ifndef NDEBUG)\n" - "Example: test_casts 2\n\n"; - -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test polymorphic_cast ---------------------------------------------------// - - // tests which should succeed - Base * base = new Derived; - Base2 * base2 = 0; - Derived * derived = 0; - derived = polymorphic_downcast( base ); // downcast - assert( derived->kind() == 'D' ); - - derived = 0; - derived = polymorphic_cast( base ); // downcast, throw on error - assert( derived->kind() == 'D' ); - - base2 = polymorphic_cast( base ); // crosscast - assert( base2->kind2() == '2' ); - - // tests which should result in errors being detected - int err_count = 0; - base = new Base; - - if ( argc > 1 && *argv[1] == '1' ) - { derived = polymorphic_downcast( base ); } // #1 assert failure - - bool caught_exception = false; - try { derived = polymorphic_cast( base ); } - catch (std::bad_cast) - { cout<<"caught bad_cast\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - // the following is just so generated code can be inspected - if ( derived->kind() == 'B' ) ++err_count; - -// test implicit_cast and numeric_cast -------------------------------------// - - // tests which should succeed - long small_value = 1; - long small_negative_value = -1; - long large_value = LONG_MAX; - long large_negative_value = LONG_MIN; - signed char c = 0; - - c = large_value; // see if compiler generates warning - - c = numeric_cast( small_value ); - assert( c == 1 ); - c = 0; - c = numeric_cast( small_value ); - assert( c == 1 ); - c = 0; - c = numeric_cast( small_negative_value ); - assert( c == -1 ); - - // These tests courtesy of Joe R NWP Swatosh - assert( 0.0f == numeric_cast( 0.0 ) ); - assert( 0.0 == numeric_cast( 0.0 ) ); - - // tests which should result in errors being detected - - caught_exception = false; - try { c = numeric_cast( large_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #1\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - caught_exception = false; - try { c = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #2\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - unsigned long ul; - caught_exception = false; - try { ul = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #3\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - caught_exception = false; - try { ul = numeric_cast( small_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #4\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - caught_exception = false; - try { numeric_cast( DBL_MAX ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #5\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - cout << err_count << " errors detected\nTest " - << (err_count==0 ? "passed\n" : "failed\n"); - return err_count; -} // main diff --git a/index.htm b/index.htm deleted file mode 100644 index 079576c..0000000 --- a/index.htm +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - -Boost Conversion Library - - - - -

Boost -Conversion Library

- -

The Conversion Library improves program safety and clarity by performing -otherwise messy conversions.  It includes cast-style function templates designed to complement the C++ -Standard's built-in casts.

-

To reduce coupling, particularly to standard library IOStreams, the Boost -Conversion Library is -supplied by several headers:

-
    -
  • The boost/cast header provides polymorphic_cast<> - and polymorphic_downcast<> to perform safe casting between - polymorphic types, and numeric_cast<> to perform safe casting - between numeric types.
    -
  • -
  • The boost/lexical_cast header provides lexical_cast<> - general literal text conversions, such as an int represented as - a string, or vice-versa.
  • -
-
-

Revised 06 January, 2001 -

- - - - diff --git a/lexical_cast.htm b/lexical_cast.htm deleted file mode 100644 index 1215a52..0000000 --- a/lexical_cast.htm +++ /dev/null @@ -1,223 +0,0 @@ - - - - - lexical_cast - - - - -

c++boost.gif (8819 bytes)Header - boost/lexical_cast.hpp

- -
-

Motivation

- Sometimes a value must be converted to a literal text form, such as an int - represented as a string, or vice-versa, when a string - is interpreted as an int. Such examples are common when converting - between data types internal to a program and representation external to a - program, such as windows and configuration files. -

- The standard C and C++ libraries offer a number of facilities for performing - such conversions. However, they vary with their ease of use, extensibility, and - safety. -

- For instance, there are a number of limitations with the family of standard C - functions typified by atoi: -

    -
  • - Conversion is supported in one direction only: from text to internal data type. - Converting the other way using the C library requires either the inconvenience - and compromised safety of the sprintf function, or the loss of - portability associated with non-standard functions such as itoa. -
  • -
  • - The range of types supported is only a subset of the built-in numeric types, - namely int, long, and double. -
  • -
  • - The range of types cannot be extended in a uniform manner. For instance, - conversion from string representation to complex or rational. -
  • -
- The standard C functions typified by strtol have the same basic - limitations, but offer finer control over the conversion process. However, for - the common case such control is often either not required or not used. The scanf - family of functions offer even greater control, but also lack safety and ease - of use. -

- The standard C++ library offers stringstream for the kind of - in-core formatting being discussed. It offers a great deal of control over the - formatting and conversion of I/O to and from arbitrary types through text. - However, for simple conversions direct use of stringstream can be - either clumsy (with the introduction of extra local variables and the loss of - infix-expression convenience) or obscure (where stringstream - objects are created as temporary objects in an expression). Facets provide a - comprehensive concept and facility for controlling textual representation, but - their perceived complexity and high entry level requires an extreme degree of - involvement for simple conversions, and excludes all but a few programmers. -

- The lexical_cast function template offers a convenient and - consistent form for supporting common conversions to and from arbitrary types - when they are represented as text. The simplification it offers is in - expression-level convenience for such conversions. For more involved - conversions, such as where precision or formatting need tighter control than is - offered by the default behavior of lexical_cast, the conventional - stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast - may offer more reasonable behavior than lexical_cast. -

- For a good discussion of the options and issues involved in string-based - formatting, including comparison of stringstream, lexical_cast, - and others, see Herb Sutter's article, - The String Formatters of Manor Farm. -

-


-

Examples

- The following example treats command line arguments as a sequence of numeric - data:
-
-int main(int argc, char * argv[])
-{
-    using boost::lexical_cast;
-    using boost::bad_lexical_cast;
-
-    std::vector<short> args;
-
-    while(*++argv)
-    {
-        try
-        {
-            args.push_back(lexical_cast<short>(*argv));
-        }
-        catch(bad_lexical_cast &)
-        {
-            args.push_back(0);
-        }
-    }
-    ...
-}
-
-
The following example uses numeric data in a string expression:
-
-void log_message(const std::string &);
-
-void log_errno(int yoko)
-{
-    log_message("Error " + boost::lexical_cast<std::string>(yoko) + ": " + strerror(yoko));
-}
-
-
-
-

Synopsis

- Library features defined in "boost/lexical_cast.hpp": -
-
-namespace boost
-{
-    class bad_lexical_cast;
-    template<typename Target, typename Source>
-      Target lexical_cast(Source arg);
-}
-
-
Unit test defined in "lexical_cast_test.cpp". -

-


-

lexical_cast

-
-
-template<typename Target, typename Source>
-  Target lexical_cast(Source arg);
-
-
Returns the result of streaming arg into a - standard library string-based stream and then out as a Target object. - Where Target is either std::string - or std::wstring, stream extraction takes the whole content - of the string, including spaces, rather than relying on the default - operator>> behavior. - If the conversion is unsuccessful, a - bad_lexical_cast exception is thrown. -

- The requirements on the argument and result types are: -

    -
  • - Source is OutputStreamable, meaning that an operator<< - is defined that takes a std::ostream or std::wostream object on the - left hand side and an instance of the argument type on the right. -
  • -
  • - Target is InputStreamable, meaning that an operator>> - is defined that takes a std::istream or std::wistream object on the left hand side - and an instance of the result type on the right. -
  • -
  • - Both Source and Target are CopyConstructible [20.1.3]. -
  • -
  • - Target is DefaultConstructible, meaning that it is possible - to default-initialize an object of that type [8.5, 20.1.4]. -
  • -
- The character type of the underlying stream is assumed to be char unless - either the Source or the Target requires wide-character - streaming, in which case the underlying stream uses wchar_t. - Source types that require wide-character streaming are wchar_t, - wchar_t *, and std::wstring. Target types that - require wide-character streaming are wchar_t and std::wstring. -

- Where a higher degree of control is required over conversions, std::stringstream - and std::wstringstream offer a more appropriate path. Where non-stream-based conversions are - required, lexical_cast - is the wrong tool for the job and is not special-cased for such scenarios. -

-


-

bad_lexical_cast

-
-
-class bad_lexical_cast : public std::bad_cast
-{
-public:
-    ... // same member function interface as std::exception
-};
-
-
Exception used to indicate runtime lexical_cast - failure. -
-

Changes

-
    -
  • The previous version of lexical_cast used the default stream precision for reading - and writing floating-point numbers. For numerics that have a corresponding specialization of - std::numeric_limits, the current version now chooses a precision to match. -
  • The previous version of lexical_cast did not support conversion to or from any - wide-character-based types. For compilers with full language and library support for wide characters, - lexical_cast now supports conversions from wchar_t, wchar_t *, - and std::wstring and to wchar_t and std::wstring. -
  • The previous version of lexical_cast assumed that the conventional stream extractor - operators were sufficient for reading values. However, string I/O is asymmetric, with the result - that spaces play the role of I/O separators rather than string content. The current version fixes - this error for std::string and, where supported, std::wstring: - lexical_cast<std::string>("Hello, World") succeeds instead of failing with - a bad_lexical_cast exception. -
  • The previous version of lexical_cast allowed unsafe and meaningless conversions to - pointers. The current version now throws a bad_lexical_cast for conversions to pointers: - lexical_cast<char *>("Goodbye, World") now throws an exception instead of - causing undefined behavior. -
-

-


-
© Copyright Kevlin Henney, 2000–2003
- - diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp deleted file mode 100644 index 9072821..0000000 --- a/lexical_cast_test.cpp +++ /dev/null @@ -1,290 +0,0 @@ -// Unit test for boost::lexical_cast. -// -// See http://www.boost.org for most recent version, including documentation. -// -// Copyright Terje Slettebø and Kevlin Henney, 2003. -// -// Permission to use, copy, modify, and distribute this software for any -// purpose is hereby granted without fee, provided that this copyright and -// permissions notice appear in all copies and derivatives. -// -// This software is provided "as is" without express or implied warranty. - -#include - -#if defined(__INTEL_COMPILER) -#pragma warning(disable: 193 383 488 981 1418 1419) -#elif defined(BOOST_MSVC) -#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) -#endif - -#include -#include -#include - -#if defined(BOOST_NO_STRINGSTREAM) || \ - defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) || \ - defined(BOOST_NO_INTRINSIC_WCHAR_T) -#define DISABLE_WIDE_CHAR_SUPPORT -#endif - -using namespace boost; - -void test_conversion_to_char(); -void test_conversion_to_int(); -void test_conversion_to_double(); -void test_conversion_to_bool(); -void test_conversion_to_string(); -void test_conversion_from_to_wchar_t_alias(); -void test_conversion_to_pointer(); -void test_conversion_from_wchar_t(); -void test_conversion_to_wchar_t(); -void test_conversion_from_wstring(); -void test_conversion_to_wstring(); - -unit_test_framework::test_suite *init_unit_test_suite(int, char **) -{ - unit_test_framework::test_suite *suite = - BOOST_TEST_SUITE("lexical_cast unit test"); - suite->add(BOOST_TEST_CASE(test_conversion_to_char)); - suite->add(BOOST_TEST_CASE(test_conversion_to_int)); - suite->add(BOOST_TEST_CASE(test_conversion_to_double)); - suite->add(BOOST_TEST_CASE(test_conversion_to_bool)); - suite->add(BOOST_TEST_CASE(test_conversion_from_to_wchar_t_alias)); - suite->add(BOOST_TEST_CASE(test_conversion_to_pointer)); - suite->add(BOOST_TEST_CASE(test_conversion_to_string)); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_from_wstring)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wstring)); - #endif - return suite; -} - -void test_conversion_to_char() -{ - BOOST_CHECK_EQUAL('A', lexical_cast('A')); - BOOST_CHECK_EQUAL(' ', lexical_cast(' ')); - BOOST_CHECK_EQUAL('1', lexical_cast(1)); - BOOST_CHECK_EQUAL('0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL('1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL('1', lexical_cast(true)); - BOOST_CHECK_EQUAL('0', lexical_cast(false)); - BOOST_CHECK_EQUAL('A', lexical_cast("A")); - BOOST_CHECK_EQUAL(' ', lexical_cast(" ")); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL('A', lexical_cast(std::string("A"))); - BOOST_CHECK_EQUAL(' ', lexical_cast(std::string(" "))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), boost::bad_lexical_cast); -} - -void test_conversion_to_int() -{ - BOOST_CHECK_EQUAL(1,lexical_cast('1')); - BOOST_CHECK_EQUAL(0,lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'),boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1,lexical_cast(1)); - BOOST_CHECK_EQUAL( - std::numeric_limits::max(), - lexical_cast(std::numeric_limits::max())); - BOOST_CHECK_EQUAL(1,lexical_cast(1.0)); - - BOOST_CHECK_THROW(lexical_cast(1.23), boost::bad_lexical_cast); - - BOOST_CHECK_THROW(lexical_cast(1e20), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1, lexical_cast(true)); - BOOST_CHECK_EQUAL(0, lexical_cast(false)); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_THROW( - lexical_cast(" 123"), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_EQUAL(123,lexical_cast(std::string("123"))); - BOOST_CHECK_THROW( - lexical_cast(std::string(" 123")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), boost::bad_lexical_cast); -} - -void test_conversion_to_double() -{ - BOOST_CHECK_EQUAL(1.0, lexical_cast('1')); - BOOST_CHECK_THROW(lexical_cast('A'), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1.0, lexical_cast(1)); - BOOST_CHECK_EQUAL(1.23, lexical_cast(1.23)); - BOOST_CHECK_CLOSE( - std::numeric_limits::max() / 2, - lexical_cast(std::numeric_limits::max() / 2), - std::numeric_limits::epsilon()); - BOOST_CHECK_EQUAL(1.0, lexical_cast(true)); - BOOST_CHECK_EQUAL(0.0, lexical_cast(false)); - BOOST_CHECK_EQUAL(1.23, lexical_cast("1.23")); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1.23, lexical_cast(std::string("1.23"))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), boost::bad_lexical_cast); -} - -void test_conversion_to_bool() -{ - BOOST_CHECK_EQUAL(true, lexical_cast('1')); - BOOST_CHECK_EQUAL(false, lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1)); - BOOST_CHECK_EQUAL(false, lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1.0)); - BOOST_CHECK_EQUAL(false, lexical_cast(0.0)); - BOOST_CHECK_EQUAL(true, lexical_cast(true)); - BOOST_CHECK_EQUAL(false, lexical_cast(false)); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_EQUAL(true, lexical_cast(std::string("1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::string("0"))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), boost::bad_lexical_cast); -} - -void test_conversion_to_string() -{ - BOOST_CHECK_EQUAL("A", lexical_cast('A')); - BOOST_CHECK_EQUAL(" ", lexical_cast(' ')); - BOOST_CHECK_EQUAL("123", lexical_cast(123)); - BOOST_CHECK_EQUAL("1.23", lexical_cast(1.23)); - BOOST_CHECK_EQUAL("1.111111111", lexical_cast(1.111111111)); - BOOST_CHECK_EQUAL("1",lexical_cast(true)); - BOOST_CHECK_EQUAL("0",lexical_cast(false)); - BOOST_CHECK_EQUAL("Test", lexical_cast("Test")); - BOOST_CHECK_EQUAL(" ", lexical_cast(" ")); - BOOST_CHECK_EQUAL("", lexical_cast("")); - BOOST_CHECK_EQUAL("Test", lexical_cast(std::string("Test"))); - BOOST_CHECK_EQUAL(" ", lexical_cast(std::string(" "))); - BOOST_CHECK_EQUAL("", lexical_cast(std::string(""))); -} - -void test_conversion_from_to_wchar_t_alias() -{ - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_EQUAL(std::string("123"), - lexical_cast(static_cast(123))); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123u)); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123ul)); -} - -void test_conversion_to_pointer() -{ - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - #endif -} - -void test_conversion_from_wchar_t() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_EQUAL(1, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), boost::bad_lexical_cast); - - BOOST_CHECK_EQUAL(123, lexical_cast(L"123")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); - - BOOST_CHECK_EQUAL(1.0, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), boost::bad_lexical_cast); - - BOOST_CHECK_EQUAL(1.23, lexical_cast(L"1.23")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); - - BOOST_CHECK_EQUAL(true, lexical_cast(L'1')); - BOOST_CHECK_EQUAL(false, lexical_cast(L'0')); - BOOST_CHECK_THROW(lexical_cast(L'A'), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(L"1")); - BOOST_CHECK_EQUAL(false, lexical_cast(L"0")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); - #endif -} - -void test_conversion_to_wchar_t() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_EQUAL(L'1', lexical_cast(1)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(L'1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0.0)); - BOOST_CHECK_EQUAL(L'1', lexical_cast(true)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(false)); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L'A')); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L' ')); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L"A")); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L" ")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(L'A', lexical_cast(std::wstring(L"A"))); - BOOST_CHECK_EQUAL(L' ', lexical_cast(std::wstring(L" "))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), boost::bad_lexical_cast); - #endif -} - -void test_conversion_from_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_EQUAL(123, lexical_cast(std::wstring(L"123"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), boost::bad_lexical_cast); - - BOOST_CHECK_EQUAL(true, lexical_cast(std::wstring(L"1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::wstring(L"0"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), boost::bad_lexical_cast); - #endif -} - -void test_conversion_to_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK(L"123" == lexical_cast(123)); - BOOST_CHECK(L"1.23" == lexical_cast(1.23)); - BOOST_CHECK(L"1.111111111" == lexical_cast(1.111111111)); - BOOST_CHECK(L"1" == lexical_cast(true)); - BOOST_CHECK(L"0" == lexical_cast(false)); - BOOST_CHECK(L"A" == lexical_cast(L'A')); - BOOST_CHECK(L" " == lexical_cast(L' ')); - BOOST_CHECK(L"Test" == lexical_cast(L"Test")); - BOOST_CHECK(L" " == lexical_cast(L" ")); - BOOST_CHECK(L"" == lexical_cast(L"")); - BOOST_CHECK(L"Test" == lexical_cast(std::wstring(L"Test"))); - BOOST_CHECK(L" " == lexical_cast(std::wstring(L" "))); - BOOST_CHECK(L"" == lexical_cast(std::wstring(L""))); - #endif -} diff --git a/test.hpp b/test.hpp deleted file mode 100644 index 42870b9..0000000 --- a/test.hpp +++ /dev/null @@ -1,312 +0,0 @@ -// what: simple unit test framework -// who: developed by Kevlin Henney -// when: November 2000 -// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.91 -// -// ChangeLog: -// 20 Jan 2001 - Fixed a warning for MSVC (Dave Abrahams) - -#ifndef TEST_INCLUDED -#define TEST_INCLUDED - -#include -#include -#include // for out-of-the-box g++ -#include - -namespace test // test tuple comprises name and nullary function (object) -{ - template - struct test - { - string_type name; - function_type action; - - static test make(string_type name, function_type action) - { - test result; // MSVC aggreggate initializer bugs - result.name = name; - result.action = action; - return result; - } - }; -} - -namespace test // failure exception used to indicate checked test failures -{ - class failure : public std::exception - { - public: // struction (default cases are OK) - - failure(const std::string & why) - : reason(why) - { - } - - // std::~string has no exception-specification (could throw anything), - // but we need to be compatible with std::~exception's empty one - // see std::15.4p13 and std::15.4p3 - ~failure() throw() - { - } - - public: // usage - - virtual const char * what() const throw() - { - return reason.c_str(); - } - - private: // representation - - std::string reason; - - }; -} - -namespace test // not_implemented exception used to mark unimplemented tests -{ - class not_implemented : public std::exception - { - public: // usage (default ctor and dtor are OK) - - virtual const char * what() const throw() - { - return "not implemented"; - } - - }; -} - -namespace test // test utilities -{ - inline void check(bool condition, const std::string & description) - { - if(!condition) - { - throw failure(description); - } - } - - inline void check_true(bool value, const std::string & description) - { - check(value, "expected true: " + description); - } - - inline void check_false(bool value, const std::string & description) - { - check(!value, "expected false: " + description); - } - - template - void check_equal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs == rhs, "expected equal values: " + description); - } - - template - void check_unequal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs != rhs, "expected unequal values: " + description); - } - - inline void check_null(const void* ptr, const std::string & description) - { - check(!ptr, "expected null pointer: " + description); - } - - inline void check_non_null(const void* ptr, const std::string & description) - { - check(ptr != 0, "expected non-null pointer: " + description); - } -} - -#define TEST_CHECK_THROW(expression, exception, description) \ - try \ - { \ - expression; \ - throw ::test::failure(description); \ - } \ - catch(exception &) \ - { \ - } - -namespace test // memory tracking (enabled if test new and delete linked in) -{ - class allocations - { - public: // singleton access - - static allocations & instance() - { - static allocations singleton; - return singleton; - } - - public: // logging - - void clear() - { - alloc_count = dealloc_count = 0; - } - - void allocation() - { - ++alloc_count; - } - - void deallocation() - { - ++dealloc_count; - } - - public: // reporting - - unsigned long allocated() const - { - return alloc_count; - } - - unsigned long deallocated() const - { - return dealloc_count; - } - - bool balanced() const - { - return alloc_count == dealloc_count; - } - - private: // structors (default dtor is fine) - - allocations() - : alloc_count(0), dealloc_count(0) - { - } - - private: // prevention - - allocations(const allocations &); - allocations & operator=(const allocations &); - - private: // state - - unsigned long alloc_count, dealloc_count; - - }; -} - -namespace test // tester is the driver class for a sequence of tests -{ - template - class tester - { - public: // structors (default destructor is OK) - - tester(test_iterator first_test, test_iterator after_last_test) - : begin(first_test), end(after_last_test) - { - } - - public: // usage - - bool operator()(); // returns true if all tests passed - - private: // representation - - test_iterator begin, end; - - private: // prevention - - tester(const tester &); - tester &operator=(const tester &); - - }; - - template - bool tester::operator()() - { - using namespace std; - - unsigned long passed = 0, failed = 0, unimplemented = 0; - - for(test_iterator current = begin; current != end; ++current) - { - cerr << "[" << current->name << "] " << flush; - string result = "passed"; // optimistic - - try - { - allocations::instance().clear(); - current->action(); - - if(!allocations::instance().balanced()) - { - unsigned long allocated = allocations::instance().allocated(); - unsigned long deallocated = allocations::instance().deallocated(); - ostrstream report; - report << "new/delete (" - << allocated << " allocated, " - << deallocated << " deallocated)" - << ends; - const char * text = report.str(); - report.freeze(false); - throw failure(text); - } - - ++passed; - } - catch(const failure & caught) - { - (result = "failed: ") += caught.what(); - ++failed; - } - catch(const not_implemented &) - { - result = "not implemented"; - ++unimplemented; - } - catch(const exception & caught) - { - (result = "exception: ") += caught.what(); - ++failed; - } - catch(...) - { - result = "failed with unknown exception"; - ++failed; - } - - cerr << result << endl; - } - - cerr << passed + failed << " tests: " - << passed << " passed, " - << failed << " failed"; - - if(unimplemented) - { - cerr << " (" << unimplemented << " not implemented)"; - } - - cerr << endl; - - return failed == 0; - } -} - -#endif - -// Copyright Kevlin Henney, 2000. All rights reserved. -// -// Permission to use, copy, modify, and distribute this software for any -// purpose is hereby granted without fee, provided that this copyright and -// permissions notice appear in all copies and derivatives, and that no -// charge may be made for the software and its documentation except to cover -// cost of distribution. -// -// This software is provided "as is" without express or implied warranty. diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100644 index 2a274a9..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,34 +0,0 @@ -# Signals library - -# Copyright (C) 2001-2003 Douglas Gregor - -# Permission to copy, use, sell and distribute this software is granted -# provided this copyright notice appears in all copies. Permission to modify -# the code and to distribute modified code is granted provided this copyright -# notice appears in all copies, and a notice that the code was modified is -# included with the copyright notice. This software is provided "as is" -# without express or implied warranty, and with no claim as to its suitability -# for any purpose. - -# For more information, see http://www.boost.org/ - - -# Testing Jamfile autogenerated from XML source -subproject libs/conversion/test ; - -# bring in rules for testing -SEARCH on testing.jam = $(BOOST_BUILD_PATH) ; -include testing.jam ; - -# Make tests run by default. -DEPENDS all : test ; - -{ - test-suite conversion - : [ run implicit_cast.cpp ] - [ compile-fail implicit_cast_fail.cpp ] - [ run ../cast_test.cpp ] - [ run ../lexical_cast_test.cpp ] - ; -} - \ No newline at end of file diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp deleted file mode 100644 index 39aee56..0000000 --- a/test/implicit_cast.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright David Abrahams 2003. 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. - -#include -#include -#include - -using boost::implicit_cast; -using boost::type; - -template -type check_return(T) { return type(); } - -struct foo -{ - foo(char const*) {} - operator long() const { return 0; } -}; - -typedef type long_type; -typedef type foo_type; - -int main() -{ - type x = check_return(boost::implicit_cast(1)); - assert(boost::implicit_cast(1) == 1L); - - type f = check_return(boost::implicit_cast("hello")); - type z = check_return(boost::implicit_cast(foo("hello"))); - return 0; -} diff --git a/test/implicit_cast_fail.cpp b/test/implicit_cast_fail.cpp deleted file mode 100644 index 9805256..0000000 --- a/test/implicit_cast_fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright David Abrahams 2003. 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. - -#include -#include - -#define BOOST_INCLUDE_MAIN -#include - -using boost::implicit_cast; - -struct foo -{ - explicit foo(char const*) {} -}; - -int test_main(int, char*[]) -{ - foo x = implicit_cast("foobar"); -} From f4f8fc77d9d830174517117dc6da92cd70fc0036 Mon Sep 17 00:00:00 2001 From: nobody Date: Sat, 16 Aug 2003 01:05:44 +0000 Subject: [PATCH 010/138] This commit was manufactured by cvs2svn to create tag 'merged_to_RC_1_30_0'. [SVN r19627] --- include/boost/lexical_cast.hpp | 44 ++++++++++++++++---- lexical_cast_test.cpp | 75 ++++++++++++---------------------- 2 files changed, 60 insertions(+), 59 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 924d6ac..a247649 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1,23 +1,24 @@ #ifndef BOOST_LEXICAL_CAST_INCLUDED #define BOOST_LEXICAL_CAST_INCLUDED -// boost lexical_cast.hpp header --------------------------------------------// - -// See http://www.boost.org/libs/conversion for documentation. +// Boost lexical_cast.hpp header -------------------------------------------// +// +// See http://www.boost.org for most recent version including documentation. // See end of this header for rights and permissions. // // what: lexical_cast custom keyword cast // who: contributed by Kevlin Henney, // enhanced with contributions from Terje Slettebø, // with additional fixes and suggestions from Gennaro Prota, -// Dave Abrahams, Daryle Walker, and other Boosters on the list +// Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, +// and other Boosters // when: November 2000, March 2003 #include #include #include #include -#include +#include #ifdef BOOST_NO_STRINGSTREAM #include @@ -25,6 +26,18 @@ #include #endif +#if defined(BOOST_NO_STRINGSTREAM) || \ + defined(BOOST_NO_STD_WSTRING) || \ + defined(BOOST_NO_STD_LOCALE) || \ + defined(BOOST_NO_CWCHAR) || \ + defined(BOOST_MSVC) && (BOOST_MSVC <= 1200) +#define DISABLE_WIDE_CHAR_SUPPORT +#endif + +#ifdef BOOST_NO_INTRINSIC_WCHAR_T +#include +#endif + namespace boost { // exception used to indicate runtime lexical_cast failure @@ -69,7 +82,7 @@ namespace boost typedef char type; }; - #ifndef BOOST_NO_STRINGSTREAM + #ifndef DISABLE_WIDE_CHAR_SUPPORT template<> struct stream_char { @@ -140,11 +153,21 @@ namespace boost stream >> output && (stream >> std::ws).eof(); } - template - bool operator>>(std::basic_string &output) + bool operator>>(std::string &output) { - return std::getline(stream, output, char_type()).eof(); + #if defined(BOOST_NO_STRINGSTREAM) + stream << '\0'; + #endif + output = stream.str(); + return true; } + #ifndef DISABLE_WIDE_CHAR_SUPPORT + bool operator>>(std::wstring &output) + { + output = stream.str(); + return true; + } + #endif private: typedef typename widest_char< typename stream_char::type, @@ -152,6 +175,8 @@ namespace boost #if defined(BOOST_NO_STRINGSTREAM) std::strstream stream; + #elif defined(BOOST_NO_STD_LOCALE) + std::stringstream stream; #else std::basic_stringstream stream; #endif @@ -178,4 +203,5 @@ namespace boost // // This software is provided "as is" without express or implied warranty. +#undef DISABLE_WIDE_CHAR_SUPPORT #endif diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 1d3c631..a3df60d 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -13,7 +13,7 @@ #include #if defined(__INTEL_COMPILER) -#pragma warning(disable: 383 488 981 1418 1419) +#pragma warning(disable: 193 383 488 981 1418 1419) #elif defined(BOOST_MSVC) #pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) #endif @@ -22,11 +22,11 @@ #include #include -// If BOOST_NO_STRINGSTREAM is defined wide character support is unavailable, -// and all wide character tests are disabled. - -#ifdef BOOST_NO_STRINGSTREAM -#define NO_WIDE_CHAR_SUPPORT +#if defined(BOOST_NO_STRINGSTREAM) || \ + defined(BOOST_NO_STD_WSTRING) || \ + defined(BOOST_NO_STD_LOCALE) || \ + defined(BOOST_NO_INTRINSIC_WCHAR_T) +#define DISABLE_WIDE_CHAR_SUPPORT #endif using namespace boost; @@ -36,6 +36,7 @@ void test_conversion_to_int(); void test_conversion_to_double(); void test_conversion_to_bool(); void test_conversion_to_string(); +void test_conversion_from_to_wchar_t_alias(); void test_conversion_to_pointer(); void test_conversion_from_wchar_t(); void test_conversion_to_wchar_t(); @@ -50,9 +51,10 @@ unit_test_framework::test_suite *init_unit_test_suite(int, char **) suite->add(BOOST_TEST_CASE(test_conversion_to_int)); suite->add(BOOST_TEST_CASE(test_conversion_to_double)); suite->add(BOOST_TEST_CASE(test_conversion_to_bool)); + suite->add(BOOST_TEST_CASE(test_conversion_from_to_wchar_t_alias)); suite->add(BOOST_TEST_CASE(test_conversion_to_pointer)); suite->add(BOOST_TEST_CASE(test_conversion_to_string)); - #ifndef NO_WIDE_CHAR_SUPPORT + #ifndef DISABLE_WIDE_CHAR_SUPPORT suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t)); suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t)); suite->add(BOOST_TEST_CASE(test_conversion_from_wstring)); @@ -75,10 +77,6 @@ void test_conversion_to_char() BOOST_CHECK_EQUAL(' ', lexical_cast(" ")); BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL('A', lexical_cast("A")); - BOOST_CHECK_EQUAL(' ', lexical_cast(" ")); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); BOOST_CHECK_EQUAL('A', lexical_cast(std::string("A"))); BOOST_CHECK_EQUAL(' ', lexical_cast(std::string(" "))); BOOST_CHECK_THROW( @@ -109,8 +107,6 @@ void test_conversion_to_int() BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); BOOST_CHECK_EQUAL(123,lexical_cast(std::string("123"))); BOOST_CHECK_THROW( lexical_cast(std::string(" 123")), boost::bad_lexical_cast); @@ -135,9 +131,6 @@ void test_conversion_to_double() BOOST_CHECK_EQUAL(1.23, lexical_cast("1.23")); BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1.23, lexical_cast("1.23")); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); BOOST_CHECK_EQUAL(1.23, lexical_cast(std::string("1.23"))); BOOST_CHECK_THROW( lexical_cast(std::string("")), boost::bad_lexical_cast); @@ -163,8 +156,6 @@ void test_conversion_to_bool() BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); BOOST_CHECK_EQUAL(true, lexical_cast("1")); BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); BOOST_CHECK_EQUAL(true, lexical_cast(std::string("1"))); BOOST_CHECK_EQUAL(false, lexical_cast(std::string("0"))); BOOST_CHECK_THROW( @@ -175,7 +166,6 @@ void test_conversion_to_bool() void test_conversion_to_string() { - // *** All the following gives compilation error (ambiguity) on MSVC 6 BOOST_CHECK_EQUAL("A", lexical_cast('A')); BOOST_CHECK_EQUAL(" ", lexical_cast(' ')); BOOST_CHECK_EQUAL("123", lexical_cast(123)); @@ -186,31 +176,36 @@ void test_conversion_to_string() BOOST_CHECK_EQUAL("Test", lexical_cast("Test")); BOOST_CHECK_EQUAL(" ", lexical_cast(" ")); BOOST_CHECK_EQUAL("", lexical_cast("")); - BOOST_CHECK_EQUAL("Test", lexical_cast("Test")); - BOOST_CHECK_EQUAL(" ", lexical_cast(" ")); - BOOST_CHECK_EQUAL("", lexical_cast("")); BOOST_CHECK_EQUAL("Test", lexical_cast(std::string("Test"))); BOOST_CHECK_EQUAL(" ", lexical_cast(std::string(" "))); BOOST_CHECK_EQUAL("", lexical_cast(std::string(""))); } +void test_conversion_from_to_wchar_t_alias() +{ + BOOST_CHECK_EQUAL(123u, lexical_cast("123")); + BOOST_CHECK_EQUAL(123u, lexical_cast("123")); + BOOST_CHECK_EQUAL(123u, lexical_cast("123")); + BOOST_CHECK_EQUAL(std::string("123"), + lexical_cast(static_cast(123))); + BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123u)); + BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123ul)); +} + void test_conversion_to_pointer() { BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - #ifndef NO_WIDE_CHAR_SUPPORT + #ifndef DISABLE_WIDE_CHAR_SUPPORT BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); #endif } void test_conversion_from_wchar_t() { - #ifndef NO_WIDE_CHAR_SUPPORT + #ifndef DISABLE_WIDE_CHAR_SUPPORT BOOST_CHECK_EQUAL(1, lexical_cast(L'1')); BOOST_CHECK_THROW(lexical_cast(L'A'), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(123, lexical_cast(L"123")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); BOOST_CHECK_EQUAL(123, lexical_cast(L"123")); BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); @@ -218,9 +213,6 @@ void test_conversion_from_wchar_t() BOOST_CHECK_EQUAL(1.0, lexical_cast(L'1')); BOOST_CHECK_THROW(lexical_cast(L'A'), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1.23, lexical_cast(L"1.23")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); BOOST_CHECK_EQUAL(1.23, lexical_cast(L"1.23")); BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); @@ -232,16 +224,12 @@ void test_conversion_from_wchar_t() BOOST_CHECK_EQUAL(false, lexical_cast(L"0")); BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(L"1")); - BOOST_CHECK_EQUAL(false, lexical_cast(L"0")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); #endif } void test_conversion_to_wchar_t() { - #ifndef NO_WIDE_CHAR_SUPPORT + #ifndef DISABLE_WIDE_CHAR_SUPPORT BOOST_CHECK_EQUAL(L'1', lexical_cast(1)); BOOST_CHECK_EQUAL(L'0', lexical_cast(0)); BOOST_CHECK_THROW(lexical_cast(123), boost::bad_lexical_cast); @@ -255,10 +243,6 @@ void test_conversion_to_wchar_t() BOOST_CHECK_EQUAL(L' ', lexical_cast(L" ")); BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L"A")); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L" ")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); BOOST_CHECK_EQUAL(L'A', lexical_cast(std::wstring(L"A"))); BOOST_CHECK_EQUAL(L' ', lexical_cast(std::wstring(L" "))); BOOST_CHECK_THROW( @@ -270,19 +254,13 @@ void test_conversion_to_wchar_t() void test_conversion_from_wstring() { - #ifndef NO_WIDE_CHAR_SUPPORT + #ifndef DISABLE_WIDE_CHAR_SUPPORT BOOST_CHECK_EQUAL(123, lexical_cast(std::wstring(L"123"))); BOOST_CHECK_THROW( lexical_cast(std::wstring(L"")), boost::bad_lexical_cast); BOOST_CHECK_THROW( lexical_cast(std::wstring(L"Test")), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1.23, lexical_cast(std::wstring(L"1.23"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(std::wstring(L"1"))); BOOST_CHECK_EQUAL(false, lexical_cast(std::wstring(L"0"))); BOOST_CHECK_THROW( @@ -294,7 +272,7 @@ void test_conversion_from_wstring() void test_conversion_to_wstring() { - #ifndef NO_WIDE_CHAR_SUPPORT + #ifndef DISABLE_WIDE_CHAR_SUPPORT BOOST_CHECK(L"123" == lexical_cast(123)); BOOST_CHECK(L"1.23" == lexical_cast(1.23)); BOOST_CHECK(L"1.111111111" == lexical_cast(1.111111111)); @@ -305,9 +283,6 @@ void test_conversion_to_wstring() BOOST_CHECK(L"Test" == lexical_cast(L"Test")); BOOST_CHECK(L" " == lexical_cast(L" ")); BOOST_CHECK(L"" == lexical_cast(L"")); - BOOST_CHECK(L"Test" == lexical_cast(L"Test")); - BOOST_CHECK(L" " == lexical_cast(L" ")); - BOOST_CHECK(L"" == lexical_cast(L"")); BOOST_CHECK(L"Test" == lexical_cast(std::wstring(L"Test"))); BOOST_CHECK(L" " == lexical_cast(std::wstring(L" "))); BOOST_CHECK(L"" == lexical_cast(std::wstring(L""))); From 4e6017820533e5946ab772282fca50a4f4395e15 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 30 Dec 2003 12:10:04 +0000 Subject: [PATCH 011/138] This commit was manufactured by cvs2svn to create branch 'RC_1_31_0'. [SVN r21427] From 90bf2b81ddbc1dccd37a31e6a539f703cf3cc91b Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 23 Feb 2004 07:33:35 +0000 Subject: [PATCH 012/138] This commit was manufactured by cvs2svn to create tag 'merged_to_RC_1_31_0'. [SVN r22369] From 434e84db6696e278fe3944dcb2d6313181509577 Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 23 Jul 2004 02:16:28 +0000 Subject: [PATCH 013/138] This commit was manufactured by cvs2svn to create branch 'SPIRIT_1_6'. [SVN r23968] --- cast.htm | 202 ----------------------- cast_test.cpp | 154 ------------------ index.html | 39 ----- lexical_cast.htm | 223 -------------------------- lexical_cast_test.cpp | 290 --------------------------------- test.hpp | 312 ------------------------------------ test/Jamfile | 33 ---- test/Jamfile.v2 | 25 --- test/implicit_cast.cpp | 34 ---- test/implicit_cast_fail.cpp | 23 --- 10 files changed, 1335 deletions(-) delete mode 100644 cast.htm delete mode 100644 cast_test.cpp delete mode 100644 index.html delete mode 100644 lexical_cast.htm delete mode 100644 lexical_cast_test.cpp delete mode 100644 test.hpp delete mode 100644 test/Jamfile delete mode 100644 test/Jamfile.v2 delete mode 100644 test/implicit_cast.cpp delete mode 100644 test/implicit_cast_fail.cpp diff --git a/cast.htm b/cast.htm deleted file mode 100644 index ce596a5..0000000 --- a/cast.htm +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - Header boost/cast.hpp Documentation - - - -

c++boost.gif (8819 bytes)Header boost/cast.hpp

- -

Cast Functions

- -

The header boost/cast.hpp provides - polymorphic_cast, polymorphic_downcast, and numeric_cast function templates designed to - complement the C++ built-in casts.

- -

The program cast_test.cpp can be used to - verify these function templates work as expected.

- -

Polymorphic casts

- -

Pointers to polymorphic objects (objects of classes which define at - least one virtual function) are sometimes downcast or crosscast. - Downcasting means casting from a base class to a derived class. - Crosscasting means casting across an inheritance hierarchy diagram, such - as from one base to the other in a Y diagram hierarchy.

- -

Such casts can be done with old-style casts, but this approach is - never to be recommended. Old-style casts are sorely lacking in type - safety, suffer poor readability, and are difficult to locate with search - tools.

- -

The C++ built-in static_cast can be used for efficiently - downcasting pointers to polymorphic objects, but provides no error - detection for the case where the pointer being cast actually points to - the wrong derived class. The polymorphic_downcast template retains - the efficiency of static_cast for non-debug compilations, but for - debug compilations adds safety via an assert() that a dynamic_cast - succeeds.

- -

The C++ built-in dynamic_cast can be used for downcasts and - crosscasts of pointers to polymorphic objects, but error notification in - the form of a returned value of 0 is inconvenient to test, or worse yet, - easy to forget to test. The throwing form of dynamic_cast, which - works on references, can be used on pointers through the ugly expression - &dynamic_cast<T&>(*p), which causes undefined - behavior if p is 0. The polymorphic_cast - template performs a dynamic_cast on a pointer, and throws an - exception if the dynamic_cast returns 0.

- -

A polymorphic_downcast is preferred when debug-mode tests will - cover 100% of the object types possibly cast and when non-debug-mode - efficiency is an issue. If these two conditions are not present, - polymorphic_cast is preferred. It must also be used for - crosscasts. It does an assert( dynamic_cast<Derived>(x) == x ) - where x is the base pointer, ensuring that not only is a non-zero pointer - returned, but also that it correct in the presence of multiple - inheritance. Warning:: Because polymorphic_downcast uses - assert(), it violates the one definition rule (ODR) if NDEBUG is - inconsistently defined across translation units. [See ISO Std 3.2]

- -

The C++ built-in dynamic_cast must be used to cast references - rather than pointers. It is also the only cast that can be used to check - whether a given interface is supported; in that case a return of 0 isn't - an error condition.

- -

polymorphic_cast and polymorphic_downcast synopsis

- -
-
-namespace boost {
-
-template <class Derived, class Base>
-inline Derived polymorphic_cast(Base* x);
-// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )
-// Returns: dynamic_cast<Derived>(x)
-
-template <class Derived, class Base>
-inline Derived polymorphic_downcast(Base* x);
-// Effects: assert( dynamic_cast<Derived>(x) == x );
-// Returns: static_cast<Derived>(x)
-
-}
-
-
- -

polymorphic_downcast example

- -
-
-#include <boost/cast.hpp>
-...
-class Fruit { public: virtual ~Fruit(){}; ... };
-class Banana : public Fruit { ... };
-...
-void f( Fruit * fruit ) {
-// ... logic which leads us to believe it is a Banana
-  Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
-  ...
-
-
- -

numeric_cast

- -

A static_cast or implicit conversion will not detect failure to - preserve range for numeric casts. The numeric_cast function - templates are similar to static_cast and certain (dubious) - implicit conversions in this respect, except that they detect loss of - numeric range. An exception is thrown when a runtime value-preservation - check fails.

- -

The requirements on the argument and result types are:

- -
-
    -
  • Both argument and result types are CopyConstructible [ISO Std - 20.1.3].
  • - -
  • Both argument and result types are Numeric, defined by - std::numeric_limits<>::is_specialized being - true.
  • - -
  • The argument can be converted to the result type using - static_cast.
  • -
-
- -

numeric_cast synopsis

- -
-
-namespace boost {
-
-class bad_numeric_cast : public std::bad_cast {...};
-
-template<typename Target, typename Source>
-  inline Target numeric_cast(Source arg);
-    // Throws:  bad_numeric_cast unless, in converting arg from Source to Target,
-    //          there is no loss of negative range, and no underflow, and no
-    //          overflow, as determined by std::numeric_limits
-    // Returns: static_cast<Target>(arg)
-
-}
-
-
- -

numeric_cast example

- -
-
-#include <boost/cast.hpp>
-using namespace boost::cast;
-
-void ariane(double vx)
-{
-    ...
-    unsigned short dx = numeric_cast<unsigned short>(vx);
-    ...
-}
-
-
- -

numeric_cast rationale

- -

The form of the throws condition is specified so that != is not a - required operation.

- -

History

- -

polymorphic_cast was suggested by Bjarne Stroustrup in "The C++ - Programming Language".
- polymorphic_downcast was contributed by Dave Abrahams.
- numeric_cast
was contributed by Kevlin Henney.

-
- -

Revised - 06 January, 2001 -

- -

© Copyright boost.org 1999. Permission to copy, use, modify, sell - and distribute this document is granted provided this copyright notice - appears in all copies. This document is provided "as is" without express - or implied warranty, and with no claim as to its suitability for any - purpose.

- - - diff --git a/cast_test.cpp b/cast_test.cpp deleted file mode 100644 index 091cfe6..0000000 --- a/cast_test.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright boost.org 1999. 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 -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include // for DBL_MAX (Peter Schmid) -#include - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - -namespace -{ - struct Base - { - virtual char kind() { return 'B'; } - }; - - struct Base2 - { - virtual char kind2() { return '2'; } - }; - - struct Derived : public Base, Base2 - { - virtual char kind() { return 'D'; } - }; -} - - -int main( int argc, char * argv[] ) -{ - cout << "Usage: test_casts [n], where n omitted or is:\n" - " 1 = execute #1 assert failure (#ifndef NDEBUG)\n" - " 2 = execute #2 assert failure (#ifndef NDEBUG)\n" - "Example: test_casts 2\n\n"; - -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test polymorphic_cast ---------------------------------------------------// - - // tests which should succeed - Base * base = new Derived; - Base2 * base2 = 0; - Derived * derived = 0; - derived = polymorphic_downcast( base ); // downcast - assert( derived->kind() == 'D' ); - - derived = 0; - derived = polymorphic_cast( base ); // downcast, throw on error - assert( derived->kind() == 'D' ); - - base2 = polymorphic_cast( base ); // crosscast - assert( base2->kind2() == '2' ); - - // tests which should result in errors being detected - int err_count = 0; - base = new Base; - - if ( argc > 1 && *argv[1] == '1' ) - { derived = polymorphic_downcast( base ); } // #1 assert failure - - bool caught_exception = false; - try { derived = polymorphic_cast( base ); } - catch (std::bad_cast) - { cout<<"caught bad_cast\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - // the following is just so generated code can be inspected - if ( derived->kind() == 'B' ) ++err_count; - -// test implicit_cast and numeric_cast -------------------------------------// - - // tests which should succeed - long small_value = 1; - long small_negative_value = -1; - long large_value = LONG_MAX; - long large_negative_value = LONG_MIN; - signed char c = 0; - - c = large_value; // see if compiler generates warning - - c = numeric_cast( small_value ); - assert( c == 1 ); - c = 0; - c = numeric_cast( small_value ); - assert( c == 1 ); - c = 0; - c = numeric_cast( small_negative_value ); - assert( c == -1 ); - - // These tests courtesy of Joe R NWP Swatosh - assert( 0.0f == numeric_cast( 0.0 ) ); - assert( 0.0 == numeric_cast( 0.0 ) ); - - // tests which should result in errors being detected - - caught_exception = false; - try { c = numeric_cast( large_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #1\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - caught_exception = false; - try { c = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #2\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - unsigned long ul; - caught_exception = false; - try { ul = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #3\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - caught_exception = false; - try { ul = numeric_cast( small_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #4\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - caught_exception = false; - try { numeric_cast( DBL_MAX ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #5\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - - cout << err_count << " errors detected\nTest " - << (err_count==0 ? "passed\n" : "failed\n"); - return err_count; -} // main diff --git a/index.html b/index.html deleted file mode 100644 index 079576c..0000000 --- a/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - -Boost Conversion Library - - - - -

Boost -Conversion Library

- -

The Conversion Library improves program safety and clarity by performing -otherwise messy conversions.  It includes cast-style function templates designed to complement the C++ -Standard's built-in casts.

-

To reduce coupling, particularly to standard library IOStreams, the Boost -Conversion Library is -supplied by several headers:

-
    -
  • The boost/cast header provides polymorphic_cast<> - and polymorphic_downcast<> to perform safe casting between - polymorphic types, and numeric_cast<> to perform safe casting - between numeric types.
    -
  • -
  • The boost/lexical_cast header provides lexical_cast<> - general literal text conversions, such as an int represented as - a string, or vice-versa.
  • -
-
-

Revised 06 January, 2001 -

- - - - diff --git a/lexical_cast.htm b/lexical_cast.htm deleted file mode 100644 index 1215a52..0000000 --- a/lexical_cast.htm +++ /dev/null @@ -1,223 +0,0 @@ - - - - - lexical_cast - - - - -

c++boost.gif (8819 bytes)Header - boost/lexical_cast.hpp

- -
-

Motivation

- Sometimes a value must be converted to a literal text form, such as an int - represented as a string, or vice-versa, when a string - is interpreted as an int. Such examples are common when converting - between data types internal to a program and representation external to a - program, such as windows and configuration files. -

- The standard C and C++ libraries offer a number of facilities for performing - such conversions. However, they vary with their ease of use, extensibility, and - safety. -

- For instance, there are a number of limitations with the family of standard C - functions typified by atoi: -

    -
  • - Conversion is supported in one direction only: from text to internal data type. - Converting the other way using the C library requires either the inconvenience - and compromised safety of the sprintf function, or the loss of - portability associated with non-standard functions such as itoa. -
  • -
  • - The range of types supported is only a subset of the built-in numeric types, - namely int, long, and double. -
  • -
  • - The range of types cannot be extended in a uniform manner. For instance, - conversion from string representation to complex or rational. -
  • -
- The standard C functions typified by strtol have the same basic - limitations, but offer finer control over the conversion process. However, for - the common case such control is often either not required or not used. The scanf - family of functions offer even greater control, but also lack safety and ease - of use. -

- The standard C++ library offers stringstream for the kind of - in-core formatting being discussed. It offers a great deal of control over the - formatting and conversion of I/O to and from arbitrary types through text. - However, for simple conversions direct use of stringstream can be - either clumsy (with the introduction of extra local variables and the loss of - infix-expression convenience) or obscure (where stringstream - objects are created as temporary objects in an expression). Facets provide a - comprehensive concept and facility for controlling textual representation, but - their perceived complexity and high entry level requires an extreme degree of - involvement for simple conversions, and excludes all but a few programmers. -

- The lexical_cast function template offers a convenient and - consistent form for supporting common conversions to and from arbitrary types - when they are represented as text. The simplification it offers is in - expression-level convenience for such conversions. For more involved - conversions, such as where precision or formatting need tighter control than is - offered by the default behavior of lexical_cast, the conventional - stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast - may offer more reasonable behavior than lexical_cast. -

- For a good discussion of the options and issues involved in string-based - formatting, including comparison of stringstream, lexical_cast, - and others, see Herb Sutter's article, - The String Formatters of Manor Farm. -

-


-

Examples

- The following example treats command line arguments as a sequence of numeric - data:
-
-int main(int argc, char * argv[])
-{
-    using boost::lexical_cast;
-    using boost::bad_lexical_cast;
-
-    std::vector<short> args;
-
-    while(*++argv)
-    {
-        try
-        {
-            args.push_back(lexical_cast<short>(*argv));
-        }
-        catch(bad_lexical_cast &)
-        {
-            args.push_back(0);
-        }
-    }
-    ...
-}
-
-
The following example uses numeric data in a string expression:
-
-void log_message(const std::string &);
-
-void log_errno(int yoko)
-{
-    log_message("Error " + boost::lexical_cast<std::string>(yoko) + ": " + strerror(yoko));
-}
-
-
-
-

Synopsis

- Library features defined in "boost/lexical_cast.hpp": -
-
-namespace boost
-{
-    class bad_lexical_cast;
-    template<typename Target, typename Source>
-      Target lexical_cast(Source arg);
-}
-
-
Unit test defined in "lexical_cast_test.cpp". -

-


-

lexical_cast

-
-
-template<typename Target, typename Source>
-  Target lexical_cast(Source arg);
-
-
Returns the result of streaming arg into a - standard library string-based stream and then out as a Target object. - Where Target is either std::string - or std::wstring, stream extraction takes the whole content - of the string, including spaces, rather than relying on the default - operator>> behavior. - If the conversion is unsuccessful, a - bad_lexical_cast exception is thrown. -

- The requirements on the argument and result types are: -

    -
  • - Source is OutputStreamable, meaning that an operator<< - is defined that takes a std::ostream or std::wostream object on the - left hand side and an instance of the argument type on the right. -
  • -
  • - Target is InputStreamable, meaning that an operator>> - is defined that takes a std::istream or std::wistream object on the left hand side - and an instance of the result type on the right. -
  • -
  • - Both Source and Target are CopyConstructible [20.1.3]. -
  • -
  • - Target is DefaultConstructible, meaning that it is possible - to default-initialize an object of that type [8.5, 20.1.4]. -
  • -
- The character type of the underlying stream is assumed to be char unless - either the Source or the Target requires wide-character - streaming, in which case the underlying stream uses wchar_t. - Source types that require wide-character streaming are wchar_t, - wchar_t *, and std::wstring. Target types that - require wide-character streaming are wchar_t and std::wstring. -

- Where a higher degree of control is required over conversions, std::stringstream - and std::wstringstream offer a more appropriate path. Where non-stream-based conversions are - required, lexical_cast - is the wrong tool for the job and is not special-cased for such scenarios. -

-


-

bad_lexical_cast

-
-
-class bad_lexical_cast : public std::bad_cast
-{
-public:
-    ... // same member function interface as std::exception
-};
-
-
Exception used to indicate runtime lexical_cast - failure. -
-

Changes

-
    -
  • The previous version of lexical_cast used the default stream precision for reading - and writing floating-point numbers. For numerics that have a corresponding specialization of - std::numeric_limits, the current version now chooses a precision to match. -
  • The previous version of lexical_cast did not support conversion to or from any - wide-character-based types. For compilers with full language and library support for wide characters, - lexical_cast now supports conversions from wchar_t, wchar_t *, - and std::wstring and to wchar_t and std::wstring. -
  • The previous version of lexical_cast assumed that the conventional stream extractor - operators were sufficient for reading values. However, string I/O is asymmetric, with the result - that spaces play the role of I/O separators rather than string content. The current version fixes - this error for std::string and, where supported, std::wstring: - lexical_cast<std::string>("Hello, World") succeeds instead of failing with - a bad_lexical_cast exception. -
  • The previous version of lexical_cast allowed unsafe and meaningless conversions to - pointers. The current version now throws a bad_lexical_cast for conversions to pointers: - lexical_cast<char *>("Goodbye, World") now throws an exception instead of - causing undefined behavior. -
-

-


-
© Copyright Kevlin Henney, 2000–2003
- - diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp deleted file mode 100644 index a1a4669..0000000 --- a/lexical_cast_test.cpp +++ /dev/null @@ -1,290 +0,0 @@ -// Unit test for boost::lexical_cast. -// -// See http://www.boost.org for most recent version, including documentation. -// -// Copyright Terje Slettebø and Kevlin Henney, 2003. -// -// Permission to use, copy, modify, and distribute this software for any -// purpose is hereby granted without fee, provided that this copyright and -// permissions notice appear in all copies and derivatives. -// -// This software is provided "as is" without express or implied warranty. - -#include - -#if defined(__INTEL_COMPILER) -#pragma warning(disable: 193 383 488 981 1418 1419) -#elif defined(BOOST_MSVC) -#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) -#endif - -#include -#include -#include - -#if defined(BOOST_NO_STRINGSTREAM) || \ - defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) || \ - defined(BOOST_NO_INTRINSIC_WCHAR_T) -#define DISABLE_WIDE_CHAR_SUPPORT -#endif - -using namespace boost; - -void test_conversion_to_char(); -void test_conversion_to_int(); -void test_conversion_to_double(); -void test_conversion_to_bool(); -void test_conversion_to_string(); -void test_conversion_from_to_wchar_t_alias(); -void test_conversion_to_pointer(); -void test_conversion_from_wchar_t(); -void test_conversion_to_wchar_t(); -void test_conversion_from_wstring(); -void test_conversion_to_wstring(); - -unit_test_framework::test_suite *init_unit_test_suite(int, char **) -{ - unit_test_framework::test_suite *suite = - BOOST_TEST_SUITE("lexical_cast unit test"); - suite->add(BOOST_TEST_CASE(test_conversion_to_char)); - suite->add(BOOST_TEST_CASE(test_conversion_to_int)); - suite->add(BOOST_TEST_CASE(test_conversion_to_double)); - suite->add(BOOST_TEST_CASE(test_conversion_to_bool)); - suite->add(BOOST_TEST_CASE(test_conversion_from_to_wchar_t_alias)); - suite->add(BOOST_TEST_CASE(test_conversion_to_pointer)); - suite->add(BOOST_TEST_CASE(test_conversion_to_string)); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_from_wstring)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wstring)); - #endif - return suite; -} - -void test_conversion_to_char() -{ - BOOST_CHECK_EQUAL('A', lexical_cast('A')); - BOOST_CHECK_EQUAL(' ', lexical_cast(' ')); - BOOST_CHECK_EQUAL('1', lexical_cast(1)); - BOOST_CHECK_EQUAL('0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL('1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL('1', lexical_cast(true)); - BOOST_CHECK_EQUAL('0', lexical_cast(false)); - BOOST_CHECK_EQUAL('A', lexical_cast("A")); - BOOST_CHECK_EQUAL(' ', lexical_cast(" ")); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL('A', lexical_cast(std::string("A"))); - BOOST_CHECK_EQUAL(' ', lexical_cast(std::string(" "))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), boost::bad_lexical_cast); -} - -void test_conversion_to_int() -{ - BOOST_CHECK_EQUAL(1,lexical_cast('1')); - BOOST_CHECK_EQUAL(0,lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'),boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1,lexical_cast(1)); - BOOST_CHECK_EQUAL( - (std::numeric_limits::max)(), - lexical_cast((std::numeric_limits::max)())); - BOOST_CHECK_EQUAL(1,lexical_cast(1.0)); - - BOOST_CHECK_THROW(lexical_cast(1.23), boost::bad_lexical_cast); - - BOOST_CHECK_THROW(lexical_cast(1e20), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1, lexical_cast(true)); - BOOST_CHECK_EQUAL(0, lexical_cast(false)); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_THROW( - lexical_cast(" 123"), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_EQUAL(123,lexical_cast(std::string("123"))); - BOOST_CHECK_THROW( - lexical_cast(std::string(" 123")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), boost::bad_lexical_cast); -} - -void test_conversion_to_double() -{ - BOOST_CHECK_EQUAL(1.0, lexical_cast('1')); - BOOST_CHECK_THROW(lexical_cast('A'), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1.0, lexical_cast(1)); - BOOST_CHECK_EQUAL(1.23, lexical_cast(1.23)); - BOOST_CHECK_CLOSE( - (std::numeric_limits::max)() / 2, - lexical_cast((std::numeric_limits::max)() / 2), - std::numeric_limits::epsilon()); - BOOST_CHECK_EQUAL(1.0, lexical_cast(true)); - BOOST_CHECK_EQUAL(0.0, lexical_cast(false)); - BOOST_CHECK_EQUAL(1.23, lexical_cast("1.23")); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(1.23, lexical_cast(std::string("1.23"))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), boost::bad_lexical_cast); -} - -void test_conversion_to_bool() -{ - BOOST_CHECK_EQUAL(true, lexical_cast('1')); - BOOST_CHECK_EQUAL(false, lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1)); - BOOST_CHECK_EQUAL(false, lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1.0)); - BOOST_CHECK_EQUAL(false, lexical_cast(0.0)); - BOOST_CHECK_EQUAL(true, lexical_cast(true)); - BOOST_CHECK_EQUAL(false, lexical_cast(false)); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_THROW(lexical_cast(""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_EQUAL(true, lexical_cast(std::string("1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::string("0"))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), boost::bad_lexical_cast); -} - -void test_conversion_to_string() -{ - BOOST_CHECK_EQUAL("A", lexical_cast('A')); - BOOST_CHECK_EQUAL(" ", lexical_cast(' ')); - BOOST_CHECK_EQUAL("123", lexical_cast(123)); - BOOST_CHECK_EQUAL("1.23", lexical_cast(1.23)); - BOOST_CHECK_EQUAL("1.111111111", lexical_cast(1.111111111)); - BOOST_CHECK_EQUAL("1",lexical_cast(true)); - BOOST_CHECK_EQUAL("0",lexical_cast(false)); - BOOST_CHECK_EQUAL("Test", lexical_cast("Test")); - BOOST_CHECK_EQUAL(" ", lexical_cast(" ")); - BOOST_CHECK_EQUAL("", lexical_cast("")); - BOOST_CHECK_EQUAL("Test", lexical_cast(std::string("Test"))); - BOOST_CHECK_EQUAL(" ", lexical_cast(std::string(" "))); - BOOST_CHECK_EQUAL("", lexical_cast(std::string(""))); -} - -void test_conversion_from_to_wchar_t_alias() -{ - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(std::string("123"), - lexical_cast(static_cast(123))); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123u)); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123ul)); -} - -void test_conversion_to_pointer() -{ - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_THROW(lexical_cast("Test"), boost::bad_lexical_cast); - #endif -} - -void test_conversion_from_wchar_t() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_EQUAL(1, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), boost::bad_lexical_cast); - - BOOST_CHECK_EQUAL(123, lexical_cast(L"123")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); - - BOOST_CHECK_EQUAL(1.0, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), boost::bad_lexical_cast); - - BOOST_CHECK_EQUAL(1.23, lexical_cast(L"1.23")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); - - BOOST_CHECK_EQUAL(true, lexical_cast(L'1')); - BOOST_CHECK_EQUAL(false, lexical_cast(L'0')); - BOOST_CHECK_THROW(lexical_cast(L'A'), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(L"1")); - BOOST_CHECK_EQUAL(false, lexical_cast(L"0")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); - #endif -} - -void test_conversion_to_wchar_t() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_EQUAL(L'1', lexical_cast(1)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(L'1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0.0)); - BOOST_CHECK_EQUAL(L'1', lexical_cast(true)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(false)); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L'A')); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L' ')); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L"A")); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L" ")); - BOOST_CHECK_THROW(lexical_cast(L""), boost::bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), boost::bad_lexical_cast); - BOOST_CHECK_EQUAL(L'A', lexical_cast(std::wstring(L"A"))); - BOOST_CHECK_EQUAL(L' ', lexical_cast(std::wstring(L" "))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), boost::bad_lexical_cast); - #endif -} - -void test_conversion_from_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_EQUAL(123, lexical_cast(std::wstring(L"123"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), boost::bad_lexical_cast); - - BOOST_CHECK_EQUAL(true, lexical_cast(std::wstring(L"1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::wstring(L"0"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), boost::bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), boost::bad_lexical_cast); - #endif -} - -void test_conversion_to_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK(L"123" == lexical_cast(123)); - BOOST_CHECK(L"1.23" == lexical_cast(1.23)); - BOOST_CHECK(L"1.111111111" == lexical_cast(1.111111111)); - BOOST_CHECK(L"1" == lexical_cast(true)); - BOOST_CHECK(L"0" == lexical_cast(false)); - BOOST_CHECK(L"A" == lexical_cast(L'A')); - BOOST_CHECK(L" " == lexical_cast(L' ')); - BOOST_CHECK(L"Test" == lexical_cast(L"Test")); - BOOST_CHECK(L" " == lexical_cast(L" ")); - BOOST_CHECK(L"" == lexical_cast(L"")); - BOOST_CHECK(L"Test" == lexical_cast(std::wstring(L"Test"))); - BOOST_CHECK(L" " == lexical_cast(std::wstring(L" "))); - BOOST_CHECK(L"" == lexical_cast(std::wstring(L""))); - #endif -} diff --git a/test.hpp b/test.hpp deleted file mode 100644 index 42870b9..0000000 --- a/test.hpp +++ /dev/null @@ -1,312 +0,0 @@ -// what: simple unit test framework -// who: developed by Kevlin Henney -// when: November 2000 -// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.91 -// -// ChangeLog: -// 20 Jan 2001 - Fixed a warning for MSVC (Dave Abrahams) - -#ifndef TEST_INCLUDED -#define TEST_INCLUDED - -#include -#include -#include // for out-of-the-box g++ -#include - -namespace test // test tuple comprises name and nullary function (object) -{ - template - struct test - { - string_type name; - function_type action; - - static test make(string_type name, function_type action) - { - test result; // MSVC aggreggate initializer bugs - result.name = name; - result.action = action; - return result; - } - }; -} - -namespace test // failure exception used to indicate checked test failures -{ - class failure : public std::exception - { - public: // struction (default cases are OK) - - failure(const std::string & why) - : reason(why) - { - } - - // std::~string has no exception-specification (could throw anything), - // but we need to be compatible with std::~exception's empty one - // see std::15.4p13 and std::15.4p3 - ~failure() throw() - { - } - - public: // usage - - virtual const char * what() const throw() - { - return reason.c_str(); - } - - private: // representation - - std::string reason; - - }; -} - -namespace test // not_implemented exception used to mark unimplemented tests -{ - class not_implemented : public std::exception - { - public: // usage (default ctor and dtor are OK) - - virtual const char * what() const throw() - { - return "not implemented"; - } - - }; -} - -namespace test // test utilities -{ - inline void check(bool condition, const std::string & description) - { - if(!condition) - { - throw failure(description); - } - } - - inline void check_true(bool value, const std::string & description) - { - check(value, "expected true: " + description); - } - - inline void check_false(bool value, const std::string & description) - { - check(!value, "expected false: " + description); - } - - template - void check_equal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs == rhs, "expected equal values: " + description); - } - - template - void check_unequal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs != rhs, "expected unequal values: " + description); - } - - inline void check_null(const void* ptr, const std::string & description) - { - check(!ptr, "expected null pointer: " + description); - } - - inline void check_non_null(const void* ptr, const std::string & description) - { - check(ptr != 0, "expected non-null pointer: " + description); - } -} - -#define TEST_CHECK_THROW(expression, exception, description) \ - try \ - { \ - expression; \ - throw ::test::failure(description); \ - } \ - catch(exception &) \ - { \ - } - -namespace test // memory tracking (enabled if test new and delete linked in) -{ - class allocations - { - public: // singleton access - - static allocations & instance() - { - static allocations singleton; - return singleton; - } - - public: // logging - - void clear() - { - alloc_count = dealloc_count = 0; - } - - void allocation() - { - ++alloc_count; - } - - void deallocation() - { - ++dealloc_count; - } - - public: // reporting - - unsigned long allocated() const - { - return alloc_count; - } - - unsigned long deallocated() const - { - return dealloc_count; - } - - bool balanced() const - { - return alloc_count == dealloc_count; - } - - private: // structors (default dtor is fine) - - allocations() - : alloc_count(0), dealloc_count(0) - { - } - - private: // prevention - - allocations(const allocations &); - allocations & operator=(const allocations &); - - private: // state - - unsigned long alloc_count, dealloc_count; - - }; -} - -namespace test // tester is the driver class for a sequence of tests -{ - template - class tester - { - public: // structors (default destructor is OK) - - tester(test_iterator first_test, test_iterator after_last_test) - : begin(first_test), end(after_last_test) - { - } - - public: // usage - - bool operator()(); // returns true if all tests passed - - private: // representation - - test_iterator begin, end; - - private: // prevention - - tester(const tester &); - tester &operator=(const tester &); - - }; - - template - bool tester::operator()() - { - using namespace std; - - unsigned long passed = 0, failed = 0, unimplemented = 0; - - for(test_iterator current = begin; current != end; ++current) - { - cerr << "[" << current->name << "] " << flush; - string result = "passed"; // optimistic - - try - { - allocations::instance().clear(); - current->action(); - - if(!allocations::instance().balanced()) - { - unsigned long allocated = allocations::instance().allocated(); - unsigned long deallocated = allocations::instance().deallocated(); - ostrstream report; - report << "new/delete (" - << allocated << " allocated, " - << deallocated << " deallocated)" - << ends; - const char * text = report.str(); - report.freeze(false); - throw failure(text); - } - - ++passed; - } - catch(const failure & caught) - { - (result = "failed: ") += caught.what(); - ++failed; - } - catch(const not_implemented &) - { - result = "not implemented"; - ++unimplemented; - } - catch(const exception & caught) - { - (result = "exception: ") += caught.what(); - ++failed; - } - catch(...) - { - result = "failed with unknown exception"; - ++failed; - } - - cerr << result << endl; - } - - cerr << passed + failed << " tests: " - << passed << " passed, " - << failed << " failed"; - - if(unimplemented) - { - cerr << " (" << unimplemented << " not implemented)"; - } - - cerr << endl; - - return failed == 0; - } -} - -#endif - -// Copyright Kevlin Henney, 2000. All rights reserved. -// -// Permission to use, copy, modify, and distribute this software for any -// purpose is hereby granted without fee, provided that this copyright and -// permissions notice appear in all copies and derivatives, and that no -// charge may be made for the software and its documentation except to cover -// cost of distribution. -// -// This software is provided "as is" without express or implied warranty. diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100644 index 576a34a..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,33 +0,0 @@ -# Signals library - -# Copyright (C) 2001-2003 Douglas Gregor - -# Permission to copy, use, sell and distribute this software is granted -# provided this copyright notice appears in all copies. Permission to modify -# the code and to distribute modified code is granted provided this copyright -# notice appears in all copies, and a notice that the code was modified is -# included with the copyright notice. This software is provided "as is" -# without express or implied warranty, and with no claim as to its suitability -# for any purpose. - -# For more information, see http://www.boost.org/ - - -# Testing Jamfile autogenerated from XML source -subproject libs/conversion/test ; - -# bring in rules for testing -import testing ; - -# Make tests run by default. -DEPENDS all : test ; - -{ - test-suite conversion - : [ run implicit_cast.cpp ] - [ compile-fail implicit_cast_fail.cpp ] - [ run ../cast_test.cpp ] - [ run ../lexical_cast_test.cpp ] - ; -} - \ No newline at end of file diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 deleted file mode 100644 index 0aaa3d9..0000000 --- a/test/Jamfile.v2 +++ /dev/null @@ -1,25 +0,0 @@ -# Signals library - -# Copyright (C) 2001-2003 Douglas Gregor - -# Permission to copy, use, sell and distribute this software is granted -# provided this copyright notice appears in all copies. Permission to modify -# the code and to distribute modified code is granted provided this copyright -# notice appears in all copies, and a notice that the code was modified is -# included with the copyright notice. This software is provided "as is" -# without express or implied warranty, and with no claim as to its suitability -# for any purpose. - -# For more information, see http://www.boost.org/ - -# bring in rules for testing -import testing ; - -test-suite conversion - : [ run implicit_cast.cpp ] - [ compile-fail implicit_cast_fail.cpp ] - [ run ../cast_test.cpp ] - [ run ../lexical_cast_test.cpp ] - ; - - \ No newline at end of file diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp deleted file mode 100644 index 39aee56..0000000 --- a/test/implicit_cast.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright David Abrahams 2003. 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. - -#include -#include -#include - -using boost::implicit_cast; -using boost::type; - -template -type check_return(T) { return type(); } - -struct foo -{ - foo(char const*) {} - operator long() const { return 0; } -}; - -typedef type long_type; -typedef type foo_type; - -int main() -{ - type x = check_return(boost::implicit_cast(1)); - assert(boost::implicit_cast(1) == 1L); - - type f = check_return(boost::implicit_cast("hello")); - type z = check_return(boost::implicit_cast(foo("hello"))); - return 0; -} diff --git a/test/implicit_cast_fail.cpp b/test/implicit_cast_fail.cpp deleted file mode 100644 index 9805256..0000000 --- a/test/implicit_cast_fail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright David Abrahams 2003. 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. - -#include -#include - -#define BOOST_INCLUDE_MAIN -#include - -using boost::implicit_cast; - -struct foo -{ - explicit foo(char const*) {} -}; - -int test_main(int, char*[]) -{ - foo x = implicit_cast("foobar"); -} From 57bd7fa97d2ba091996e885a24e0e42e7c3437b8 Mon Sep 17 00:00:00 2001 From: nobody Date: Wed, 20 Oct 2004 08:26:42 +0000 Subject: [PATCH 014/138] This commit was manufactured by cvs2svn to create tag 'merged_to_RC_'. [SVN r25796] From dfca010fb34b5bc22c3bf8c426615778f9442954 Mon Sep 17 00:00:00 2001 From: nobody Date: Wed, 20 Oct 2004 08:26:43 +0000 Subject: [PATCH 015/138] This commit was manufactured by cvs2svn to create branch 'RC_1_32_0'. [SVN r25797] From c10b46b6f4717be4a2fe49907e40445864892e2e Mon Sep 17 00:00:00 2001 From: nobody Date: Mon, 29 Nov 2004 07:29:20 +0000 Subject: [PATCH 016/138] This commit was manufactured by cvs2svn to create branch 'SPIRIT_MINIBOOST'. [SVN r26343] From 43257b9478820e0a6739b409ce19eccfe2fc6e74 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Tue, 30 Nov 2004 07:52:25 +0000 Subject: [PATCH 017/138] Removed part of the Boost files from the SPIRIT_MINIBOOST branch. [SVN r26368] --- include/boost/cast.hpp | 384 -------------------------------- include/boost/implicit_cast.hpp | 35 --- include/boost/lexical_cast.hpp | 203 ----------------- 3 files changed, 622 deletions(-) delete mode 100644 include/boost/cast.hpp delete mode 100755 include/boost/implicit_cast.hpp delete mode 100644 include/boost/lexical_cast.hpp diff --git a/include/boost/cast.hpp b/include/boost/cast.hpp deleted file mode 100644 index 267b9d0..0000000 --- a/include/boost/cast.hpp +++ /dev/null @@ -1,384 +0,0 @@ -// boost cast.hpp header file ----------------------------------------------// - -// (C) Copyright Kevlin Henney and Dave Abrahams 1999. -// Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/conversion for Documentation. - -// Revision History -// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included -// instead (the workaround did not -// actually compile when BOOST_NO_LIMITS was defined in -// any case, so we loose nothing). (John Maddock) -// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never -// worked with stock GCC; trying to get it to do that broke -// vc-stlport. -// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp. -// Removed unused BOOST_EXPLICIT_TARGET macro. Moved -// boost::detail::type to boost/type.hpp. Made it compile with -// stock gcc again (Dave Abrahams) -// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal -// Review (Beman Dawes) -// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams) -// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC -// (Dave Abrahams) -// 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams) -// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes) -// 27 Jun 00 More MSVC6 workarounds -// 15 Jun 00 Add workarounds for MSVC6 -// 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov) -// 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar) -// 29 Dec 99 Change using declarations so usages in other namespaces work -// correctly (Dave Abrahams) -// 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors -// as suggested Darin Adler and improved by Valentin Bonnard. -// 2 Sep 99 Remove controversial asserts, simplify, rename. -// 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast, -// place in nested namespace. -// 3 Aug 99 Initial version - -#ifndef BOOST_CAST_HPP -#define BOOST_CAST_HPP - -# include -# include -# include -# include -# include -# include - -// It has been demonstrated numerous times that MSVC 6.0 fails silently at link -// time if you use a template function which has template parameters that don't -// appear in the function's argument list. -// -// TODO: Add this to config.hpp? -# if defined(BOOST_MSVC) && BOOST_MSVC <= 1200 // 1200 = VC6 -# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type* = 0 -# else -# define BOOST_EXPLICIT_DEFAULT_TARGET -# endif - -namespace boost -{ -// See the documentation for descriptions of how to choose between -// static_cast<>, dynamic_cast<>, polymorphic_cast<> and polymorphic_downcast<> - -// polymorphic_cast --------------------------------------------------------// - - // Runtime checked polymorphic downcasts and crosscasts. - // Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup, - // section 15.8 exercise 1, page 425. - - template - inline Target polymorphic_cast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) - { - Target tmp = dynamic_cast(x); - if ( tmp == 0 ) throw std::bad_cast(); - return tmp; - } - -// polymorphic_downcast ----------------------------------------------------// - - // assert() checked polymorphic downcast. Crosscasts prohibited. - - // WARNING: Because this cast uses assert(), it violates the One Definition - // Rule if NDEBUG is inconsistently defined across translation units. - - // Contributed by Dave Abrahams - - template - inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) - { - assert( dynamic_cast(x) == x ); // detect logic error - return static_cast(x); - } - -// implicit_cast -----------------------------------------------------------// -// -// Removed due to uncertain purpose. Use either numeric_cast (see below) -// or static_cast according to the need. - -// numeric_cast and related exception --------------------------------------// - -// Contributed by Kevlin Henney - -// bad_numeric_cast --------------------------------------------------------// - - // exception used to indicate runtime numeric_cast failure - class bad_numeric_cast : public std::bad_cast - { - public: - // constructors, destructors and assignment operator defaulted - - // function inlined for brevity and consistency with rest of library - virtual const char *what() const throw() - { - return "bad numeric cast: loss of range in numeric_cast"; - } - }; - -// numeric_cast ------------------------------------------------------------// - -#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || defined(BOOST_SGI_CPP_LIMITS) - - namespace detail - { - template - struct signed_numeric_limits : std::numeric_limits - { - static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION () - { - return (std::numeric_limits::min)() >= 0 - // unary minus causes integral promotion, thus the static_cast<> - ? static_cast(-(std::numeric_limits::max)()) - : (std::numeric_limits::min)(); - }; - }; - - // Move to namespace boost in utility.hpp? - template - struct fixed_numeric_limits_base - : public if_true< std::numeric_limits::is_signed > - ::BOOST_NESTED_TEMPLATE then< signed_numeric_limits, - std::numeric_limits - >::type - {}; - - template - struct fixed_numeric_limits - : fixed_numeric_limits_base::is_specialized)> - {}; - -# ifdef BOOST_HAS_LONG_LONG - // cover implementations which supply no specialization for long - // long / unsigned long long. Not intended to be full - // numeric_limits replacements, but good enough for numeric_cast<> - template <> - struct fixed_numeric_limits_base< ::boost::long_long_type, false> - { - BOOST_STATIC_CONSTANT(bool, is_specialized = true); - BOOST_STATIC_CONSTANT(bool, is_signed = true); - static ::boost::long_long_type max BOOST_PREVENT_MACRO_SUBSTITUTION () - { -# ifdef LONGLONG_MAX - return LONGLONG_MAX; -# else - return 9223372036854775807LL; // hope this is portable -# endif - } - - static ::boost::long_long_type min BOOST_PREVENT_MACRO_SUBSTITUTION () - { -# ifdef LONGLONG_MIN - return LONGLONG_MIN; -# else - return -( 9223372036854775807LL )-1; // hope this is portable -# endif - } - }; - - template <> - struct fixed_numeric_limits_base< ::boost::ulong_long_type, false> - { - BOOST_STATIC_CONSTANT(bool, is_specialized = true); - BOOST_STATIC_CONSTANT(bool, is_signed = false); - static ::boost::ulong_long_type max BOOST_PREVENT_MACRO_SUBSTITUTION () - { -# ifdef ULONGLONG_MAX - return ULONGLONG_MAX; -# else - return 0xffffffffffffffffULL; // hope this is portable -# endif - } - - static ::boost::ulong_long_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; } - }; -# endif - } // namespace detail - -// less_than_type_min - - // x_is_signed should be numeric_limits::is_signed - // y_is_signed should be numeric_limits::is_signed - // y_min should be numeric_limits::min() - // - // check(x, y_min) returns true iff x < y_min without invoking comparisons - // between signed and unsigned values. - // - // "poor man's partial specialization" is in use here. - template - struct less_than_type_min - { - template - static bool check(X x, Y y_min) - { return x < y_min; } - }; - - template <> - struct less_than_type_min - { - template - static bool check(X, Y) - { return false; } - }; - - template <> - struct less_than_type_min - { - template - static bool check(X x, Y) - { return x < 0; } - }; - - // greater_than_type_max - - // same_sign should be: - // numeric_limits::is_signed == numeric_limits::is_signed - // y_max should be numeric_limits::max() - // - // check(x, y_max) returns true iff x > y_max without invoking comparisons - // between signed and unsigned values. - // - // "poor man's partial specialization" is in use here. - template - struct greater_than_type_max; - - template<> - struct greater_than_type_max - { - template - static inline bool check(X x, Y y_max) - { return x > y_max; } - }; - - template <> - struct greater_than_type_max - { - // What does the standard say about this? I think it's right, and it - // will work with every compiler I know of. - template - static inline bool check(X x, Y) - { return x >= 0 && static_cast(static_cast(x)) != x; } - -# if defined(BOOST_MSVC) && BOOST_MSVC <= 1200 - // MSVC6 can't static_cast unsigned __int64 -> floating types -# define BOOST_UINT64_CAST(src_type) \ - static inline bool check(src_type x, unsigned __int64) \ - { \ - if (x < 0) return false; \ - unsigned __int64 y = static_cast(x); \ - bool odd = y & 0x1; \ - __int64 div2 = static_cast<__int64>(y >> 1); \ - return ((static_cast(div2) * 2.0) + odd) != x; \ - } - - BOOST_UINT64_CAST(long double); - BOOST_UINT64_CAST(double); - BOOST_UINT64_CAST(float); -# undef BOOST_UINT64_CAST -# endif - }; - - template<> - struct greater_than_type_max - { - template - static inline bool check(X x, Y y_max) - { return x > y_max; } - }; - - template <> - struct greater_than_type_max - { - // What does the standard say about this? I think it's right, and it - // will work with every compiler I know of. - template - static inline bool check(X x, Y) - { return static_cast(static_cast(x)) != x; } - }; - -#else // use #pragma hacks if available - - namespace detail - { -# if BOOST_MSVC -# pragma warning(push) -# pragma warning(disable : 4018) -# pragma warning(disable : 4146) -#elif defined(__BORLANDC__) -# pragma option push -w-8041 -# endif - - // Move to namespace boost in utility.hpp? - template - struct fixed_numeric_limits : public std::numeric_limits - { - static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION () - { - return std::numeric_limits::is_signed && (std::numeric_limits::min)() >= 0 - ? T(-(std::numeric_limits::max)()) : (std::numeric_limits::min)(); - } - }; - -# if BOOST_MSVC -# pragma warning(pop) -#elif defined(__BORLANDC__) -# pragma option pop -# endif - } // namespace detail - -#endif - - template - inline Target numeric_cast(Source arg BOOST_EXPLICIT_DEFAULT_TARGET) - { - // typedefs abbreviating respective trait classes - typedef detail::fixed_numeric_limits arg_traits; - typedef detail::fixed_numeric_limits result_traits; - -#if defined(BOOST_STRICT_CONFIG) \ - || (!defined(__HP_aCC) || __HP_aCC > 33900) \ - && (!defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) \ - || defined(BOOST_SGI_CPP_LIMITS)) - // typedefs that act as compile time assertions - // (to be replaced by boost compile time assertions - // as and when they become available and are stable) - typedef bool argument_must_be_numeric[arg_traits::is_specialized]; - typedef bool result_must_be_numeric[result_traits::is_specialized]; - - const bool arg_is_signed = arg_traits::is_signed; - const bool result_is_signed = result_traits::is_signed; - const bool same_sign = arg_is_signed == result_is_signed; - - if (less_than_type_min::check(arg, (result_traits::min)()) - || greater_than_type_max::check(arg, (result_traits::max)()) - ) - -#else // We need to use #pragma hacks if available - -# if BOOST_MSVC -# pragma warning(push) -# pragma warning(disable : 4018) -#elif defined(__BORLANDC__) -#pragma option push -w-8012 -# endif - if ((arg < 0 && !result_traits::is_signed) // loss of negative range - || (arg_traits::is_signed && arg < (result_traits::min)()) // underflow - || arg > (result_traits::max)()) // overflow -# if BOOST_MSVC -# pragma warning(pop) -#elif defined(__BORLANDC__) -#pragma option pop -# endif -#endif - { - throw bad_numeric_cast(); - } - return static_cast(arg); - } // numeric_cast - -# undef BOOST_EXPLICIT_DEFAULT_TARGET - -} // namespace boost - -#endif // BOOST_CAST_HPP diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp deleted file mode 100755 index 2593cb4..0000000 --- a/include/boost/implicit_cast.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright David Abrahams 2003. -// 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 IMPLICIT_CAST_DWA200356_HPP -# define IMPLICIT_CAST_DWA200356_HPP - -# include - -namespace boost { - -// implementation originally suggested by C. Green in -// http://lists.boost.org/MailArchives/boost/msg00886.php - -// The use of identity creates a non-deduced form, so that the -// explicit template argument must be supplied -template -inline T implicit_cast (typename mpl::identity::type x) { - return x; -} - -// incomplete return type now is here -//template -//void implicit_cast (...); - -// Macro for when you need a constant expression (Gennaro Prota) -#define BOOST_IMPLICIT_CAST(dst_type, expr) \ - ( sizeof( implicit_cast(expr) ) \ - , \ - static_cast(expr) \ - ) - -} // namespace boost - -#endif // IMPLICIT_CAST_DWA200356_HPP diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp deleted file mode 100644 index 079ca68..0000000 --- a/include/boost/lexical_cast.hpp +++ /dev/null @@ -1,203 +0,0 @@ -#ifndef BOOST_LEXICAL_CAST_INCLUDED -#define BOOST_LEXICAL_CAST_INCLUDED - -// Boost lexical_cast.hpp header -------------------------------------------// -// -// See http://www.boost.org for most recent version including documentation. -// See end of this header for rights and permissions. -// -// what: lexical_cast custom keyword cast -// who: contributed by Kevlin Henney, -// enhanced with contributions from Terje Slettebø, -// with additional fixes and suggestions from Gennaro Prota, -// Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, -// and other Boosters -// when: November 2000, March 2003 - -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_NO_STRINGSTREAM -#include -#else -#include -#endif - -#if defined(BOOST_NO_STRINGSTREAM) || \ - defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) || \ - defined(BOOST_NO_INTRINSIC_WCHAR_T) -#define DISABLE_WIDE_CHAR_SUPPORT -#endif - -namespace boost -{ - // exception used to indicate runtime lexical_cast failure - class bad_lexical_cast : public std::bad_cast - { - public: - bad_lexical_cast() : - source(&typeid(void)), target(&typeid(void)) - { - } - bad_lexical_cast( - const std::type_info &s, - const std::type_info &t) : - source(&s), target(&t) - { - } - const std::type_info &source_type() const - { - return *source; - } - const std::type_info &target_type() const - { - return *target; - } - virtual const char *what() const throw() - { - return "bad lexical cast: " - "source type value could not be interpreted as target"; - } - virtual ~bad_lexical_cast() throw() - { - } - private: - const std::type_info *source; - const std::type_info *target; - }; - - namespace detail // selectors for choosing stream character type - { - template - struct stream_char - { - typedef char type; - }; - - #ifndef DISABLE_WIDE_CHAR_SUPPORT - template<> - struct stream_char - { - typedef wchar_t type; - }; - - template<> - struct stream_char - { - typedef wchar_t type; - }; - - template<> - struct stream_char - { - typedef wchar_t type; - }; - - template<> - struct stream_char - { - typedef wchar_t type; - }; - #endif - - template - struct widest_char - { - typedef TargetChar type; - }; - - template<> - struct widest_char - { - typedef wchar_t type; - }; - } - - namespace detail // stream wrapper for handling lexical conversions - { - template - class lexical_stream - { - public: - lexical_stream() - { - stream.unsetf(std::ios::skipws); - - if(std::numeric_limits::is_specialized) - stream.precision(std::numeric_limits::digits10 + 1); - else if(std::numeric_limits::is_specialized) - stream.precision(std::numeric_limits::digits10 + 1); - } - ~lexical_stream() - { - #if defined(BOOST_NO_STRINGSTREAM) - stream.freeze(false); - #endif - } - bool operator<<(const Source &input) - { - return !(stream << input).fail(); - } - template - bool operator>>(InputStreamable &output) - { - return !is_pointer::value && - stream >> output && - (stream >> std::ws).eof(); - } - bool operator>>(std::string &output) - { - #if defined(BOOST_NO_STRINGSTREAM) - stream << '\0'; - #endif - output = stream.str(); - return true; - } - #ifndef DISABLE_WIDE_CHAR_SUPPORT - bool operator>>(std::wstring &output) - { - output = stream.str(); - return true; - } - #endif - private: - typedef typename widest_char< - typename stream_char::type, - typename stream_char::type>::type char_type; - - #if defined(BOOST_NO_STRINGSTREAM) - std::strstream stream; - #elif defined(BOOST_NO_STD_LOCALE) - std::stringstream stream; - #else - std::basic_stringstream stream; - #endif - }; - } - - template - Target lexical_cast(Source arg) - { - detail::lexical_stream interpreter; - Target result; - - if(!(interpreter << arg && interpreter >> result)) - throw_exception(bad_lexical_cast(typeid(Target), typeid(Source))); - return result; - } -} - -// Copyright Kevlin Henney, 2000-2003. All rights reserved. -// -// 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) - -#undef DISABLE_WIDE_CHAR_SUPPORT -#endif - From 166924ca12c2898eccc050b364d5703e1678b0cc Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 28 Jul 2005 18:22:24 +0000 Subject: [PATCH 018/138] This commit was manufactured by cvs2svn to create branch 'RC_1_33_0'. [SVN r30300] From f587f503667d72861330d7c2ef3c7019996131f3 Mon Sep 17 00:00:00 2001 From: Jonathan Turkanis Date: Tue, 2 Aug 2005 20:47:34 +0000 Subject: [PATCH 019/138] fixed broken links [SVN r30386] --- lexical_cast.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lexical_cast.htm b/lexical_cast.htm index 16ce762..0ec5553 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -77,7 +77,7 @@ conversions, such as where precision or formatting need tighter control than is offered by the default behavior of lexical_cast, the conventional stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast + numeric to numeric, numeric_cast may offer more reasonable behavior than lexical_cast.

For a good discussion of the options and issues involved in string-based From cb041dd66c263231205a0894ef0130191ea62671 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 29 Aug 2005 12:44:09 +0000 Subject: [PATCH 020/138] Reconfigure lexical_cast to work wide character strings and VC++ when not using /Zc:wchar_t. [SVN r30724] --- include/boost/lexical_cast.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 8e07fda..926b95e 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -30,8 +30,7 @@ #if defined(BOOST_NO_STRINGSTREAM) || \ defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) || \ - defined(BOOST_NO_INTRINSIC_WCHAR_T) + defined(BOOST_NO_STD_LOCALE) #define DISABLE_WIDE_CHAR_SUPPORT #endif @@ -81,11 +80,13 @@ namespace boost }; #ifndef DISABLE_WIDE_CHAR_SUPPORT +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) template<> struct stream_char { typedef wchar_t type; }; +#endif template<> struct stream_char From 3b484a6aae9185f4b87dc27cbc86745b0bb676d7 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Mon, 29 Aug 2005 12:45:35 +0000 Subject: [PATCH 021/138] Reconfigure lexical_cast to work with wide character strings and VC++ even when not using /Zc:wchar_t. [SVN r30725] --- lexical_cast_test.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 1eecc57..1e7f7ed 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -24,8 +24,7 @@ #if defined(BOOST_NO_STRINGSTREAM) || \ defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) || \ - defined(BOOST_NO_INTRINSIC_WCHAR_T) + defined(BOOST_NO_STD_LOCALE) #define DISABLE_WIDE_CHAR_SUPPORT #endif @@ -203,34 +202,40 @@ void test_conversion_to_pointer() void test_conversion_from_wchar_t() { - #ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef DISABLE_WIDE_CHAR_SUPPORT +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) BOOST_CHECK_EQUAL(1, lexical_cast(L'1')); BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); +#endif BOOST_CHECK_EQUAL(123, lexical_cast(L"123")); BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) BOOST_CHECK_EQUAL(1.0, lexical_cast(L'1')); BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); +#endif BOOST_CHECK_EQUAL(1.23, lexical_cast(L"1.23")); BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) BOOST_CHECK_EQUAL(true, lexical_cast(L'1')); BOOST_CHECK_EQUAL(false, lexical_cast(L'0')); BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); +#endif BOOST_CHECK_EQUAL(true, lexical_cast(L"1")); BOOST_CHECK_EQUAL(false, lexical_cast(L"0")); BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - #endif +#endif } void test_conversion_to_wchar_t() { - #ifndef DISABLE_WIDE_CHAR_SUPPORT +#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) BOOST_CHECK_EQUAL(L'1', lexical_cast(1)); BOOST_CHECK_EQUAL(L'0', lexical_cast(0)); BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); @@ -279,8 +284,10 @@ void test_conversion_to_wstring() BOOST_CHECK(L"1.111111111" == lexical_cast(1.111111111)); BOOST_CHECK(L"1" == lexical_cast(true)); BOOST_CHECK(L"0" == lexical_cast(false)); +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) BOOST_CHECK(L"A" == lexical_cast(L'A')); BOOST_CHECK(L" " == lexical_cast(L' ')); +#endif BOOST_CHECK(L"Test" == lexical_cast(L"Test")); BOOST_CHECK(L" " == lexical_cast(L" ")); BOOST_CHECK(L"" == lexical_cast(L"")); From a60c1f44a6c71f979b6c929c39b3fbe58518086e Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 13 Sep 2005 14:20:32 +0000 Subject: [PATCH 022/138] This commit was manufactured by cvs2svn to create branch 'thread_rewrite'. [SVN r30953] --- cast.htm | 140 ---------------- cast_test.cpp | 91 ---------- index.html | 38 ----- lexical_cast.htm | 239 --------------------------- lexical_cast_test.cpp | 319 ------------------------------------ numeric_cast_test.cpp | 100 ----------- test.hpp | 308 ---------------------------------- test/Jamfile | 33 ---- test/Jamfile.v2 | 26 --- test/implicit_cast.cpp | 33 ---- test/implicit_cast_fail.cpp | 22 --- 11 files changed, 1349 deletions(-) delete mode 100644 cast.htm delete mode 100644 cast_test.cpp delete mode 100644 index.html delete mode 100644 lexical_cast.htm delete mode 100644 lexical_cast_test.cpp delete mode 100644 numeric_cast_test.cpp delete mode 100644 test.hpp delete mode 100644 test/Jamfile delete mode 100644 test/Jamfile.v2 delete mode 100644 test/implicit_cast.cpp delete mode 100644 test/implicit_cast_fail.cpp diff --git a/cast.htm b/cast.htm deleted file mode 100644 index 587d08a..0000000 --- a/cast.htm +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - Header boost/cast.hpp Documentation - - - -

boost.png (6897 bytes)Header boost/cast.hpp

- -

Cast Functions

- -

The header boost/cast.hpp provides - polymorphic_cast and polymorphic_downcast function templates designed to - complement the C++ built-in casts.

- -

The program cast_test.cpp can be used to - verify these function templates work as expected.

- -

Polymorphic casts

- -

Pointers to polymorphic objects (objects of classes which define at - least one virtual function) are sometimes downcast or crosscast. - Downcasting means casting from a base class to a derived class. - Crosscasting means casting across an inheritance hierarchy diagram, such - as from one base to the other in a Y diagram hierarchy.

- -

Such casts can be done with old-style casts, but this approach is - never to be recommended. Old-style casts are sorely lacking in type - safety, suffer poor readability, and are difficult to locate with search - tools.

- -

The C++ built-in static_cast can be used for efficiently - downcasting pointers to polymorphic objects, but provides no error - detection for the case where the pointer being cast actually points to - the wrong derived class. The polymorphic_downcast template retains - the efficiency of static_cast for non-debug compilations, but for - debug compilations adds safety via an assert() that a dynamic_cast - succeeds.

- -

The C++ built-in dynamic_cast can be used for downcasts and - crosscasts of pointers to polymorphic objects, but error notification in - the form of a returned value of 0 is inconvenient to test, or worse yet, - easy to forget to test. The throwing form of dynamic_cast, which - works on references, can be used on pointers through the ugly expression - &dynamic_cast<T&>(*p), which causes undefined - behavior if p is 0. The polymorphic_cast - template performs a dynamic_cast on a pointer, and throws an - exception if the dynamic_cast returns 0.

- -

A polymorphic_downcast should be used for - downcasts that you are certain should succeed. Error checking is - only performed in translation units where NDEBUG is - not defined, via -

  assert( dynamic_cast<Derived>(x) == x )
-
where x is the source pointer. This approach - ensures that not only is a non-zero pointer returned, but also - that it is correct in the presence of multiple inheritance. - Attempts to crosscast using polymorphic_downcast will - fail to compile. - Warning: Because polymorphic_downcast uses assert(), it - violates the One Definition Rule (ODR) if NDEBUG is inconsistently - defined across translation units. [See ISO Std 3.2] -

- For crosscasts, or when the success of a cast can only be known at - runtime, or when efficiency is not important, - polymorphic_cast is preferred.

- -

The C++ built-in dynamic_cast must be used to cast references - rather than pointers. It is also the only cast that can be used to check - whether a given interface is supported; in that case a return of 0 isn't - an error condition.

- -

polymorphic_cast and polymorphic_downcast synopsis

- -
-
namespace boost {
-
-template <class Derived, class Base>
-inline Derived polymorphic_cast(Base* x);
-// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )
-// Returns: dynamic_cast<Derived>(x)
-
-template <class Derived, class Base>
-inline Derived polymorphic_downcast(Base* x);
-// Effects: assert( dynamic_cast<Derived>(x) == x );
-// Returns: static_cast<Derived>(x)
-
-}
-
-
- -

polymorphic_downcast example

- -
-
#include <boost/cast.hpp>
-...
-class Fruit { public: virtual ~Fruit(){}; ... };
-class Banana : public Fruit { ... };
-...
-void f( Fruit * fruit ) {
-// ... logic which leads us to believe it is a Banana
-  Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
-  ...
-
-
- -

History

- -

polymorphic_cast was suggested by Bjarne Stroustrup in "The C++ - Programming Language".
- polymorphic_downcast was contributed by Dave Abrahams.
- An old - numeric_cast
that was contributed by Kevlin Henney is now superseeded by the Boost Numeric Conversion Library

-
- -

Revised - June 23, 2005

- -

© Copyright boost.org 1999. Permission to copy, use, modify, sell - and distribute this document is granted provided this copyright notice - appears in all copies. This document is provided "as is" without express - or implied warranty, and with no claim as to its suitability for any - purpose.

- - \ No newline at end of file diff --git a/cast_test.cpp b/cast_test.cpp deleted file mode 100644 index ad6b18f..0000000 --- a/cast_test.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright Beman Dawes, Dave Abrahams 1999. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version including documentation. - -// Revision History -// 28 Set 04 factored out numeric_cast<> test (Fernando Cacciola) -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include // for DBL_MAX (Peter Schmid) -#include - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - -namespace -{ - struct Base - { - virtual char kind() { return 'B'; } - }; - - struct Base2 - { - virtual char kind2() { return '2'; } - }; - - struct Derived : public Base, Base2 - { - virtual char kind() { return 'D'; } - }; -} - - -int main( int argc, char * argv[] ) -{ -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test polymorphic_cast ---------------------------------------------------// - - // tests which should succeed - Base * base = new Derived; - Base2 * base2 = 0; - Derived * derived = 0; - derived = polymorphic_downcast( base ); // downcast - assert( derived->kind() == 'D' ); - - derived = 0; - derived = polymorphic_cast( base ); // downcast, throw on error - assert( derived->kind() == 'D' ); - - base2 = polymorphic_cast( base ); // crosscast - assert( base2->kind2() == '2' ); - - // tests which should result in errors being detected - int err_count = 0; - base = new Base; - - if ( argc > 1 && *argv[1] == '1' ) - { derived = polymorphic_downcast( base ); } // #1 assert failure - - bool caught_exception = false; - try { derived = polymorphic_cast( base ); } - catch (std::bad_cast) - { cout<<"caught bad_cast\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - // the following is just so generated code can be inspected - if ( derived->kind() == 'B' ) ++err_count; - - cout << err_count << " errors detected\nTest " - << (err_count==0 ? "passed\n" : "failed\n"); - return err_count; -} // main diff --git a/index.html b/index.html deleted file mode 100644 index cf8527f..0000000 --- a/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - -Boost Conversion Library - - - - -

Boost -Conversion Library

- -

The Conversion Library improves program safety and clarity by performing -otherwise messy conversions.  It includes cast-style function templates designed to complement the C++ -Standard's built-in casts.

-

To reduce coupling, particularly to standard library IOStreams, the Boost -Conversion Library is -supplied by several headers:

-
    -
  • The boost/cast header provides polymorphic_cast<> - and polymorphic_downcast<> to perform safe casting between - polymorphic types.
    -
  • -
  • The boost/lexical_cast header provides lexical_cast<> - general literal text conversions, such as an int represented as - a string, or vice-versa.
  • -
-
-

Revised June 23, 2005 -

- - - - \ No newline at end of file diff --git a/lexical_cast.htm b/lexical_cast.htm deleted file mode 100644 index 0ec5553..0000000 --- a/lexical_cast.htm +++ /dev/null @@ -1,239 +0,0 @@ - - - - - lexical_cast - - - - -

boost.png (6897 bytes)Header - boost/lexical_cast.hpp

- -
-

Motivation

- Sometimes a value must be converted to a literal text form, such as an int - represented as a string, or vice-versa, when a string - is interpreted as an int. Such examples are common when converting - between data types internal to a program and representation external to a - program, such as windows and configuration files. -

- The standard C and C++ libraries offer a number of facilities for performing - such conversions. However, they vary with their ease of use, extensibility, and - safety. -

- For instance, there are a number of limitations with the family of standard C - functions typified by atoi: -

    -
  • - Conversion is supported in one direction only: from text to internal data type. - Converting the other way using the C library requires either the inconvenience - and compromised safety of the sprintf function, or the loss of - portability associated with non-standard functions such as itoa. -
  • -
  • - The range of types supported is only a subset of the built-in numeric types, - namely int, long, and double. -
  • -
  • - The range of types cannot be extended in a uniform manner. For instance, - conversion from string representation to complex or rational. -
  • -
- The standard C functions typified by strtol have the same basic - limitations, but offer finer control over the conversion process. However, for - the common case such control is often either not required or not used. The scanf - family of functions offer even greater control, but also lack safety and ease - of use. -

- The standard C++ library offers stringstream for the kind of - in-core formatting being discussed. It offers a great deal of control over the - formatting and conversion of I/O to and from arbitrary types through text. - However, for simple conversions direct use of stringstream can be - either clumsy (with the introduction of extra local variables and the loss of - infix-expression convenience) or obscure (where stringstream - objects are created as temporary objects in an expression). Facets provide a - comprehensive concept and facility for controlling textual representation, but - their perceived complexity and high entry level requires an extreme degree of - involvement for simple conversions, and excludes all but a few programmers. -

- The lexical_cast function template offers a convenient and - consistent form for supporting common conversions to and from arbitrary types - when they are represented as text. The simplification it offers is in - expression-level convenience for such conversions. For more involved - conversions, such as where precision or formatting need tighter control than is - offered by the default behavior of lexical_cast, the conventional - stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast - may offer more reasonable behavior than lexical_cast. -

- For a good discussion of the options and issues involved in string-based - formatting, including comparison of stringstream, lexical_cast, - and others, see Herb Sutter's article, - The String Formatters of Manor Farm. -

-


-

Examples

- The following example treats command line arguments as a sequence of numeric - data:
-
-int main(int argc, char * argv[])
-{
-    using boost::lexical_cast;
-    using boost::bad_lexical_cast;
-
-    std::vector<short> args;
-
-    while(*++argv)
-    {
-        try
-        {
-            args.push_back(lexical_cast<short>(*argv));
-        }
-        catch(bad_lexical_cast &)
-        {
-            args.push_back(0);
-        }
-    }
-    ...
-}
-
-
The following example uses numeric data in a string expression:
-
-void log_message(const std::string &);
-
-void log_errno(int yoko)
-{
-    log_message("Error " + boost::lexical_cast<std::string>(yoko) + ": " + strerror(yoko));
-}
-
-
-
-

Synopsis

- Library features defined in "boost/lexical_cast.hpp": -
-
-namespace boost
-{
-    class bad_lexical_cast;
-    template<typename Target, typename Source>
-      Target lexical_cast(Source arg);
-}
-
-
Unit test defined in "lexical_cast_test.cpp". -

-


-

lexical_cast

-
-
-template<typename Target, typename Source>
-  Target lexical_cast(Source arg);
-
-
Returns the result of streaming arg into a - standard library string-based stream and then out as a Target object. - Where Target is either std::string - or std::wstring, stream extraction takes the whole content - of the string, including spaces, rather than relying on the default - operator>> behavior. - If the conversion is unsuccessful, a - bad_lexical_cast exception is thrown. -

- The requirements on the argument and result types are: -

    -
  • - Source is OutputStreamable, meaning that an operator<< - is defined that takes a std::ostream or std::wostream object on the - left hand side and an instance of the argument type on the right. -
  • -
  • - Target is InputStreamable, meaning that an operator>> - is defined that takes a std::istream or std::wistream object on the left hand side - and an instance of the result type on the right. -
  • -
  • - Both Source and Target are CopyConstructible [20.1.3]. -
  • -
  • - Target is DefaultConstructible, meaning that it is possible - to default-initialize an object of that type [8.5, 20.1.4]. -
  • -
- The character type of the underlying stream is assumed to be char unless - either the Source or the Target requires wide-character - streaming, in which case the underlying stream uses wchar_t. - Source types that require wide-character streaming are wchar_t, - wchar_t *, and std::wstring. Target types that - require wide-character streaming are wchar_t and std::wstring. -

- Where a higher degree of control is required over conversions, std::stringstream - and std::wstringstream offer a more appropriate path. Where non-stream-based conversions are - required, lexical_cast - is the wrong tool for the job and is not special-cased for such scenarios. -

-


-

bad_lexical_cast

-
-
-class bad_lexical_cast : public std::bad_cast
-{
-public:
-    ... // same member function interface as std::exception
-};
-
-
Exception used to indicate runtime lexical_cast - failure. -
- -

Changes

-

June 2005:

-
    -
  • Call-by-const reference for the parameters. This requires partial specialization - of class templates, so it doesn't work for MSVC 6, and it uses the original - pass by value there.
    -
  • -
  • The MSVC 6 support is deprecated, and will be removed in a future Boost - version.
  • -
-

Earlier:

- -
    -
  • The previous version of lexical_cast used the default stream - precision for reading and writing floating-point numbers. For numerics that - have a corresponding specialization of std::numeric_limits, the - current version now chooses a precision to match.
    -
  • The previous version of lexical_cast did not support conversion - to or from any wide-character-based types. For compilers with full language - and library support for wide characters, lexical_cast now supports - conversions from wchar_t, wchar_t *, and std::wstring - and to wchar_t and std::wstring.
    -
  • The previous version of lexical_cast assumed that the conventional - stream extractor operators were sufficient for reading values. However, string - I/O is asymmetric, with the result that spaces play the role of I/O separators - rather than string content. The current version fixes this error for std::string - and, where supported, std::wstring: lexical_cast<std::string>("Hello, - World") succeeds instead of failing with a bad_lexical_cast - exception.
    -
  • The previous version of lexical_cast allowed unsafe and meaningless - conversions to pointers. The current version now throws a bad_lexical_cast - for conversions to pointers: lexical_cast<char *>("Goodbye, World") - now throws an exception instead of causing undefined behavior. -
-

-


- -
© Copyright Kevlin Henney, 2000–2005
- - diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp deleted file mode 100644 index 1e7f7ed..0000000 --- a/lexical_cast_test.cpp +++ /dev/null @@ -1,319 +0,0 @@ -// Unit test for boost::lexical_cast. -// -// See http://www.boost.org for most recent version, including documentation. -// -// Copyright Terje Slettebø and Kevlin Henney, 2005. -// -// 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). -// -// Note: The unit test no longer compile on MSVC 6, but lexical_cast itself works for it. - -#include - -#if defined(__INTEL_COMPILER) -#pragma warning(disable: 193 383 488 981 1418 1419) -#elif defined(BOOST_MSVC) -#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) -#endif - -#include -#include -#include - -#if defined(BOOST_NO_STRINGSTREAM) || \ - defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) -#define DISABLE_WIDE_CHAR_SUPPORT -#endif - -using namespace boost; - -void test_conversion_to_char(); -void test_conversion_to_int(); -void test_conversion_to_double(); -void test_conversion_to_bool(); -void test_conversion_to_string(); -void test_conversion_from_to_wchar_t_alias(); -void test_conversion_to_pointer(); -void test_conversion_from_wchar_t(); -void test_conversion_to_wchar_t(); -void test_conversion_from_wstring(); -void test_conversion_to_wstring(); -void test_bad_lexical_cast(); -void test_no_whitespace_stripping(); - -unit_test_framework::test_suite *init_unit_test_suite(int, char **) -{ - unit_test_framework::test_suite *suite = - BOOST_TEST_SUITE("lexical_cast unit test"); - suite->add(BOOST_TEST_CASE(test_conversion_to_char)); - suite->add(BOOST_TEST_CASE(test_conversion_to_int)); - suite->add(BOOST_TEST_CASE(test_conversion_to_double)); - suite->add(BOOST_TEST_CASE(test_conversion_to_bool)); - suite->add(BOOST_TEST_CASE(test_conversion_from_to_wchar_t_alias)); - suite->add(BOOST_TEST_CASE(test_conversion_to_pointer)); - suite->add(BOOST_TEST_CASE(test_conversion_to_string)); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_from_wstring)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wstring)); - #endif - suite->add(BOOST_TEST_CASE(test_bad_lexical_cast)); - suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping)); - return suite; -} - -void test_conversion_to_char() -{ - BOOST_CHECK_EQUAL('A', lexical_cast('A')); - BOOST_CHECK_EQUAL(' ', lexical_cast(' ')); - BOOST_CHECK_EQUAL('1', lexical_cast(1)); - BOOST_CHECK_EQUAL('0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL('1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL('1', lexical_cast(true)); - BOOST_CHECK_EQUAL('0', lexical_cast(false)); - BOOST_CHECK_EQUAL('A', lexical_cast("A")); - BOOST_CHECK_EQUAL(' ', lexical_cast(" ")); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL('A', lexical_cast(std::string("A"))); - BOOST_CHECK_EQUAL(' ', lexical_cast(std::string(" "))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_int() -{ - BOOST_CHECK_EQUAL(1, lexical_cast('1')); - BOOST_CHECK_EQUAL(0, lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_EQUAL(1, lexical_cast(1)); - BOOST_CHECK_EQUAL( - (std::numeric_limits::max)(), - lexical_cast((std::numeric_limits::max)())); - BOOST_CHECK_EQUAL(1, lexical_cast(1.0)); - - BOOST_CHECK_THROW(lexical_cast(1.23), bad_lexical_cast); - - BOOST_CHECK_THROW(lexical_cast(1e20), bad_lexical_cast); - BOOST_CHECK_EQUAL(1, lexical_cast(true)); - BOOST_CHECK_EQUAL(0, lexical_cast(false)); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_THROW( - lexical_cast(" 123"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_EQUAL(123, lexical_cast(std::string("123"))); - BOOST_CHECK_THROW( - lexical_cast(std::string(" 123")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_double() -{ - BOOST_CHECK_CLOSE(1.0, lexical_cast('1'), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_CLOSE(1.0, lexical_cast(1), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.23, lexical_cast(1.23), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.234567890, 1.234567890, std::numeric_limits::epsilon()); - BOOST_CHECK_CLOSE(1.0, lexical_cast(true), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(0.0, lexical_cast(false), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.23, lexical_cast("1.23"), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_CLOSE(1.23, lexical_cast(std::string("1.23")), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_bool() -{ - BOOST_CHECK_EQUAL(true, lexical_cast('1')); - BOOST_CHECK_EQUAL(false, lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1)); - BOOST_CHECK_EQUAL(false, lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1.0)); - BOOST_CHECK_EQUAL(false, lexical_cast(0.0)); - BOOST_CHECK_EQUAL(true, lexical_cast(true)); - BOOST_CHECK_EQUAL(false, lexical_cast(false)); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_EQUAL(true, lexical_cast(std::string("1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::string("0"))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_string() -{ - BOOST_CHECK_EQUAL("A", lexical_cast('A')); - BOOST_CHECK_EQUAL(" ", lexical_cast(' ')); - BOOST_CHECK_EQUAL("123", lexical_cast(123)); - BOOST_CHECK_EQUAL("1.23", lexical_cast(1.23)); - BOOST_CHECK_EQUAL("1.111111111", lexical_cast(1.111111111)); - BOOST_CHECK_EQUAL("1", lexical_cast(true)); - BOOST_CHECK_EQUAL("0", lexical_cast(false)); - BOOST_CHECK_EQUAL("Test", lexical_cast("Test")); - BOOST_CHECK_EQUAL(" ", lexical_cast(" ")); - BOOST_CHECK_EQUAL("", lexical_cast("")); - BOOST_CHECK_EQUAL("Test", lexical_cast(std::string("Test"))); - BOOST_CHECK_EQUAL(" ", lexical_cast(std::string(" "))); - BOOST_CHECK_EQUAL("", lexical_cast(std::string(""))); -} - -void test_conversion_from_to_wchar_t_alias() -{ - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(std::string("123"), - lexical_cast(static_cast(123))); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123u)); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123ul)); -} - -void test_conversion_to_pointer() -{ - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #endif -} - -void test_conversion_from_wchar_t() -{ -#ifndef DISABLE_WIDE_CHAR_SUPPORT -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(1, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - - BOOST_CHECK_EQUAL(123, lexical_cast(L"123")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(1.0, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - - BOOST_CHECK_EQUAL(1.23, lexical_cast(L"1.23")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(true, lexical_cast(L'1')); - BOOST_CHECK_EQUAL(false, lexical_cast(L'0')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - BOOST_CHECK_EQUAL(true, lexical_cast(L"1")); - BOOST_CHECK_EQUAL(false, lexical_cast(L"0")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); -#endif -} - -void test_conversion_to_wchar_t() -{ -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(L'1', lexical_cast(1)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL(L'1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0.0)); - BOOST_CHECK_EQUAL(L'1', lexical_cast(true)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(false)); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L'A')); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L' ')); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L"A")); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L" ")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(L'A', lexical_cast(std::wstring(L"A"))); - BOOST_CHECK_EQUAL(L' ', lexical_cast(std::wstring(L" "))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - #endif -} - -void test_conversion_from_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_EQUAL(123, lexical_cast(std::wstring(L"123"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - - BOOST_CHECK_EQUAL(true, lexical_cast(std::wstring(L"1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::wstring(L"0"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - #endif -} - -void test_conversion_to_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK(L"123" == lexical_cast(123)); - BOOST_CHECK(L"1.23" == lexical_cast(1.23)); - BOOST_CHECK(L"1.111111111" == lexical_cast(1.111111111)); - BOOST_CHECK(L"1" == lexical_cast(true)); - BOOST_CHECK(L"0" == lexical_cast(false)); -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK(L"A" == lexical_cast(L'A')); - BOOST_CHECK(L" " == lexical_cast(L' ')); -#endif - BOOST_CHECK(L"Test" == lexical_cast(L"Test")); - BOOST_CHECK(L" " == lexical_cast(L" ")); - BOOST_CHECK(L"" == lexical_cast(L"")); - BOOST_CHECK(L"Test" == lexical_cast(std::wstring(L"Test"))); - BOOST_CHECK(L" " == lexical_cast(std::wstring(L" "))); - BOOST_CHECK(L"" == lexical_cast(std::wstring(L""))); - #endif -} - -void test_bad_lexical_cast() -{ - try - { - lexical_cast(std::string("Test")); - - BOOST_CHECK(false); // Exception expected - } - catch(const bad_lexical_cast &e) - { - BOOST_CHECK(e.source_type() == typeid(std::string)); - BOOST_CHECK(e.target_type() == typeid(int)); - } -} - -void test_no_whitespace_stripping() -{ - BOOST_CHECK_THROW(lexical_cast(" 123"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("123 "), bad_lexical_cast); -} diff --git a/numeric_cast_test.cpp b/numeric_cast_test.cpp deleted file mode 100644 index 0b5bcde..0000000 --- a/numeric_cast_test.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright Beman Dawes, Dave Abrahams 1999. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version including documentation. - -// Revision History -// 28 Set 04 factored out numeric_cast<> test (Fernando Cacciola) -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include // for DBL_MAX (Peter Schmid) -#include - -#include "boost/test/minimal.hpp" - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - - -int test_main( int argc, char * argv[] ) -{ - -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test implicit_cast and numeric_cast -------------------------------------// - - // tests which should succeed - long small_value = 1; - long small_negative_value = -1; - long large_value = LONG_MAX; - long large_negative_value = LONG_MIN; - signed char c = 0; - - c = large_value; // see if compiler generates warning - - c = numeric_cast( small_value ); - BOOST_CHECK( c == 1 ); - c = 0; - c = numeric_cast( small_value ); - BOOST_CHECK( c == 1 ); - c = 0; - c = numeric_cast( small_negative_value ); - BOOST_CHECK( c == -1 ); - - // These tests courtesy of Joe R NWP Swatosh - BOOST_CHECK( 0.0f == numeric_cast( 0.0 ) ); - BOOST_CHECK( 0.0 == numeric_cast( 0.0 ) ); - - // tests which should result in errors being detected - - bool caught_exception = false; - try { c = numeric_cast( large_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #1\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { c = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #2\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - unsigned long ul; - caught_exception = false; - try { ul = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #3\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { ul = numeric_cast( small_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #4\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { numeric_cast( DBL_MAX ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #5\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - return 0 ; -} diff --git a/test.hpp b/test.hpp deleted file mode 100644 index 4c7eecb..0000000 --- a/test.hpp +++ /dev/null @@ -1,308 +0,0 @@ -// what: simple unit test framework -// who: developed by Kevlin Henney -// when: November 2000 -// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.91 -// -// ChangeLog: -// 20 Jan 2001 - Fixed a warning for MSVC (Dave Abrahams) - -#ifndef TEST_INCLUDED -#define TEST_INCLUDED - -#include -#include -#include // for out-of-the-box g++ -#include - -namespace test // test tuple comprises name and nullary function (object) -{ - template - struct test - { - string_type name; - function_type action; - - static test make(string_type name, function_type action) - { - test result; // MSVC aggreggate initializer bugs - result.name = name; - result.action = action; - return result; - } - }; -} - -namespace test // failure exception used to indicate checked test failures -{ - class failure : public std::exception - { - public: // struction (default cases are OK) - - failure(const std::string & why) - : reason(why) - { - } - - // std::~string has no exception-specification (could throw anything), - // but we need to be compatible with std::~exception's empty one - // see std::15.4p13 and std::15.4p3 - ~failure() throw() - { - } - - public: // usage - - virtual const char * what() const throw() - { - return reason.c_str(); - } - - private: // representation - - std::string reason; - - }; -} - -namespace test // not_implemented exception used to mark unimplemented tests -{ - class not_implemented : public std::exception - { - public: // usage (default ctor and dtor are OK) - - virtual const char * what() const throw() - { - return "not implemented"; - } - - }; -} - -namespace test // test utilities -{ - inline void check(bool condition, const std::string & description) - { - if(!condition) - { - throw failure(description); - } - } - - inline void check_true(bool value, const std::string & description) - { - check(value, "expected true: " + description); - } - - inline void check_false(bool value, const std::string & description) - { - check(!value, "expected false: " + description); - } - - template - void check_equal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs == rhs, "expected equal values: " + description); - } - - template - void check_unequal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs != rhs, "expected unequal values: " + description); - } - - inline void check_null(const void* ptr, const std::string & description) - { - check(!ptr, "expected null pointer: " + description); - } - - inline void check_non_null(const void* ptr, const std::string & description) - { - check(ptr != 0, "expected non-null pointer: " + description); - } -} - -#define TEST_CHECK_THROW(expression, exception, description) \ - try \ - { \ - expression; \ - throw ::test::failure(description); \ - } \ - catch(exception &) \ - { \ - } - -namespace test // memory tracking (enabled if test new and delete linked in) -{ - class allocations - { - public: // singleton access - - static allocations & instance() - { - static allocations singleton; - return singleton; - } - - public: // logging - - void clear() - { - alloc_count = dealloc_count = 0; - } - - void allocation() - { - ++alloc_count; - } - - void deallocation() - { - ++dealloc_count; - } - - public: // reporting - - unsigned long allocated() const - { - return alloc_count; - } - - unsigned long deallocated() const - { - return dealloc_count; - } - - bool balanced() const - { - return alloc_count == dealloc_count; - } - - private: // structors (default dtor is fine) - - allocations() - : alloc_count(0), dealloc_count(0) - { - } - - private: // prevention - - allocations(const allocations &); - allocations & operator=(const allocations &); - - private: // state - - unsigned long alloc_count, dealloc_count; - - }; -} - -namespace test // tester is the driver class for a sequence of tests -{ - template - class tester - { - public: // structors (default destructor is OK) - - tester(test_iterator first_test, test_iterator after_last_test) - : begin(first_test), end(after_last_test) - { - } - - public: // usage - - bool operator()(); // returns true if all tests passed - - private: // representation - - test_iterator begin, end; - - private: // prevention - - tester(const tester &); - tester &operator=(const tester &); - - }; - - template - bool tester::operator()() - { - using namespace std; - - unsigned long passed = 0, failed = 0, unimplemented = 0; - - for(test_iterator current = begin; current != end; ++current) - { - cerr << "[" << current->name << "] " << flush; - string result = "passed"; // optimistic - - try - { - allocations::instance().clear(); - current->action(); - - if(!allocations::instance().balanced()) - { - unsigned long allocated = allocations::instance().allocated(); - unsigned long deallocated = allocations::instance().deallocated(); - ostrstream report; - report << "new/delete (" - << allocated << " allocated, " - << deallocated << " deallocated)" - << ends; - const char * text = report.str(); - report.freeze(false); - throw failure(text); - } - - ++passed; - } - catch(const failure & caught) - { - (result = "failed: ") += caught.what(); - ++failed; - } - catch(const not_implemented &) - { - result = "not implemented"; - ++unimplemented; - } - catch(const exception & caught) - { - (result = "exception: ") += caught.what(); - ++failed; - } - catch(...) - { - result = "failed with unknown exception"; - ++failed; - } - - cerr << result << endl; - } - - cerr << passed + failed << " tests: " - << passed << " passed, " - << failed << " failed"; - - if(unimplemented) - { - cerr << " (" << unimplemented << " not implemented)"; - } - - cerr << endl; - - return failed == 0; - } -} - -#endif - -// Copyright Kevlin Henney, 2000. All rights reserved. -// -// 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) diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100644 index 73bc860..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,33 +0,0 @@ -# Signals library - -# Copyright (C) 2001-2003 Douglas Gregor - -# Permission to copy, use, sell and distribute this software is granted -# provided this copyright notice appears in all copies. Permission to modify -# the code and to distribute modified code is granted provided this copyright -# notice appears in all copies, and a notice that the code was modified is -# included with the copyright notice. This software is provided "as is" -# without express or implied warranty, and with no claim as to its suitability -# for any purpose. - -# For more information, see http://www.boost.org/ - - -# Testing Jamfile autogenerated from XML source -subproject libs/conversion/test ; - -# bring in rules for testing -import testing ; - -# Make tests run by default. -DEPENDS all : test ; - -{ - test-suite conversion - : [ run implicit_cast.cpp ] - [ compile-fail implicit_cast_fail.cpp ] - [ run ../cast_test.cpp ] - [ run ../lexical_cast_test.cpp ] - ; -} - diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 deleted file mode 100644 index 56f3a3f..0000000 --- a/test/Jamfile.v2 +++ /dev/null @@ -1,26 +0,0 @@ -# Signals library - -# Copyright (C) 2001-2003 Douglas Gregor - -# Permission to copy, use, sell and distribute this software is granted -# provided this copyright notice appears in all copies. Permission to modify -# the code and to distribute modified code is granted provided this copyright -# notice appears in all copies, and a notice that the code was modified is -# included with the copyright notice. This software is provided "as is" -# without express or implied warranty, and with no claim as to its suitability -# for any purpose. - -# For more information, see http://www.boost.org/ - -# bring in rules for testing -import testing ; - -test-suite conversion - : [ run implicit_cast.cpp ] - [ compile-fail implicit_cast_fail.cpp ] - [ run ../cast_test.cpp ] - [ run ../numeric_cast_test.cpp ] - [ run ../lexical_cast_test.cpp ] - ; - - \ No newline at end of file diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp deleted file mode 100644 index 564c9eb..0000000 --- a/test/implicit_cast.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright David Abrahams 2003. -// 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) - -#include -#include -#include - -using boost::implicit_cast; -using boost::type; - -template -type check_return(T) { return type(); } - -struct foo -{ - foo(char const*) {} - operator long() const { return 0; } -}; - -typedef type long_type; -typedef type foo_type; - -int main() -{ - type x = check_return(boost::implicit_cast(1)); - assert(boost::implicit_cast(1) == 1L); - - type f = check_return(boost::implicit_cast("hello")); - type z = check_return(boost::implicit_cast(foo("hello"))); - return 0; -} diff --git a/test/implicit_cast_fail.cpp b/test/implicit_cast_fail.cpp deleted file mode 100644 index 80143da..0000000 --- a/test/implicit_cast_fail.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright David Abrahams 2003. -// 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) - -#include -#include - -#define BOOST_INCLUDE_MAIN -#include - -using boost::implicit_cast; - -struct foo -{ - explicit foo(char const*) {} -}; - -int test_main(int, char*[]) -{ - foo x = implicit_cast("foobar"); -} From 350501529e63e79004fb1172d2416d24e5ba504b Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 1 Dec 2005 13:06:58 +0000 Subject: [PATCH 023/138] This commit was manufactured by cvs2svn to create tag 'merged_to_RC_1_33_0'. [SVN r31853] From 74fc01da7e20f21b3e6af3651ab03cc1e736e913 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 21 Mar 2006 02:26:31 +0000 Subject: [PATCH 024/138] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r33417] From 06e7d986d297f1affe58bcd0e5e6a8c3c69808d0 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Mon, 17 Jul 2006 03:08:48 +0000 Subject: [PATCH 025/138] fixed library name, copyright notice, removed a tab char and a space-only line; NOTE: is the copyright notice autogenerated? [SVN r34573] --- test/Jamfile | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/test/Jamfile b/test/Jamfile index 8af8d65..b0c960c 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,17 +1,10 @@ -# Signals library +# Conversion library # Copyright (C) 2001-2003 Douglas Gregor -# Permission to copy, use, sell and distribute this software is granted -# provided this copyright notice appears in all copies. Permission to modify -# the code and to distribute modified code is granted provided this copyright -# notice appears in all copies, and a notice that the code was modified is -# included with the copyright notice. This software is provided "as is" -# without express or implied warranty, and with no claim as to its suitability -# for any purpose. - -# For more information, see http://www.boost.org/ - +# 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) # Testing Jamfile autogenerated from XML source subproject libs/conversion/test ; @@ -27,8 +20,8 @@ DEPENDS all : test ; : [ run implicit_cast.cpp ] [ compile-fail implicit_cast_fail.cpp ] [ run ../cast_test.cpp ] - [ run ../numeric_cast_test.cpp ] + [ run ../numeric_cast_test.cpp ] [ run ../lexical_cast_test.cpp ../../test/build/boost_unit_test_framework ] ; } - + From abf3aa23de68b44e8437d6f5eac74400afee5d05 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Mon, 17 Jul 2006 04:17:11 +0000 Subject: [PATCH 026/138] removed erroneous macro version [SVN r34578] --- include/boost/implicit_cast.hpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp index 2593cb4..7043085 100755 --- a/include/boost/implicit_cast.hpp +++ b/include/boost/implicit_cast.hpp @@ -23,12 +23,6 @@ inline T implicit_cast (typename mpl::identity::type x) { //template //void implicit_cast (...); -// Macro for when you need a constant expression (Gennaro Prota) -#define BOOST_IMPLICIT_CAST(dst_type, expr) \ - ( sizeof( implicit_cast(expr) ) \ - , \ - static_cast(expr) \ - ) } // namespace boost From 78f1acc5ff51e34216cf9105e63b88b0fbfd2338 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 6 Nov 2006 17:10:46 +0000 Subject: [PATCH 027/138] Remove obsolete Boost.Build v1 files. [SVN r35880] --- test/Jamfile | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 test/Jamfile diff --git a/test/Jamfile b/test/Jamfile deleted file mode 100644 index b0c960c..0000000 --- a/test/Jamfile +++ /dev/null @@ -1,27 +0,0 @@ -# Conversion library - -# Copyright (C) 2001-2003 Douglas Gregor - -# 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) - -# Testing Jamfile autogenerated from XML source -subproject libs/conversion/test ; - -# bring in rules for testing -import testing ; - -# Make tests run by default. -DEPENDS all : test ; - -{ - test-suite conversion - : [ run implicit_cast.cpp ] - [ compile-fail implicit_cast_fail.cpp ] - [ run ../cast_test.cpp ] - [ run ../numeric_cast_test.cpp ] - [ run ../lexical_cast_test.cpp ../../test/build/boost_unit_test_framework ] - ; -} - From bfeb60c400c09da36114c07698fe634c811df377 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 10 Nov 2006 19:59:52 +0000 Subject: [PATCH 028/138] Merge from HEAD. Allow building of shared versions of some Boost.Test libraries. Adjust tests to use always use static linking to Boost.Test, since linking to the shared version requires test changes. Patch from Juergen Hunold. [SVN r35990] --- test/Jamfile.v2 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 58ae133..0e59404 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -20,7 +20,8 @@ test-suite conversion [ compile-fail implicit_cast_fail.cpp ] [ run ../cast_test.cpp ] [ run ../numeric_cast_test.cpp ] - [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework ] + [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_loopback_test.cpp ../../test/build//boost_unit_test_framework/static ] ; - \ No newline at end of file + From 37d07617d13154d9ab8281a027686441fb1ad553 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 10 Nov 2006 21:03:16 +0000 Subject: [PATCH 029/138] Fix [SVN r35993] --- test/Jamfile.v2 | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 0e59404..56a03d8 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -21,7 +21,6 @@ test-suite conversion [ run ../cast_test.cpp ] [ run ../numeric_cast_test.cpp ] [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_loopback_test.cpp ../../test/build//boost_unit_test_framework/static ] ; From 2a28a0150be246d324858591497e0e2df29b56fb Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 20 Mar 2007 19:06:03 +0000 Subject: [PATCH 030/138] This commit was manufactured by cvs2svn to create tag 'RC_1_34_0_freeze'. [SVN r37245] From f0843002933e336c7ea582730f39892fd047ce08 Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 7 Jun 2007 20:53:46 +0000 Subject: [PATCH 031/138] This commit was manufactured by cvs2svn to create tag 'merged_to_RC_1_34_0'. [SVN r37938] --- test/Jamfile.v2 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 58ae133..0e59404 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -20,7 +20,8 @@ test-suite conversion [ compile-fail implicit_cast_fail.cpp ] [ run ../cast_test.cpp ] [ run ../numeric_cast_test.cpp ] - [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework ] + [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_loopback_test.cpp ../../test/build//boost_unit_test_framework/static ] ; - \ No newline at end of file + From ce0601049955fe4350f198119dfd31c575b8a59f Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 19 Jun 2007 01:09:14 +0000 Subject: [PATCH 032/138] This commit was manufactured by cvs2svn to create tag 'SPIRIT_1_6_4_MINIBOOST'. [SVN r38030] --- cast.htm | 140 ---------------- cast_test.cpp | 91 ---------- include/boost/cast.hpp | 107 ------------ index.html | 38 ----- lexical_cast.htm | 234 -------------------------- lexical_cast_test.cpp | 320 ------------------------------------ numeric_cast_test.cpp | 100 ----------- test.hpp | 308 ---------------------------------- test/Jamfile.v2 | 26 --- test/implicit_cast.cpp | 32 ---- test/implicit_cast_fail.cpp | 22 --- 11 files changed, 1418 deletions(-) delete mode 100644 cast.htm delete mode 100644 cast_test.cpp delete mode 100644 include/boost/cast.hpp delete mode 100644 index.html delete mode 100644 lexical_cast.htm delete mode 100644 lexical_cast_test.cpp delete mode 100644 numeric_cast_test.cpp delete mode 100644 test.hpp delete mode 100644 test/Jamfile.v2 delete mode 100644 test/implicit_cast.cpp delete mode 100644 test/implicit_cast_fail.cpp diff --git a/cast.htm b/cast.htm deleted file mode 100644 index 587d08a..0000000 --- a/cast.htm +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - Header boost/cast.hpp Documentation - - - -

boost.png (6897 bytes)Header boost/cast.hpp

- -

Cast Functions

- -

The header boost/cast.hpp provides - polymorphic_cast and polymorphic_downcast function templates designed to - complement the C++ built-in casts.

- -

The program cast_test.cpp can be used to - verify these function templates work as expected.

- -

Polymorphic casts

- -

Pointers to polymorphic objects (objects of classes which define at - least one virtual function) are sometimes downcast or crosscast. - Downcasting means casting from a base class to a derived class. - Crosscasting means casting across an inheritance hierarchy diagram, such - as from one base to the other in a Y diagram hierarchy.

- -

Such casts can be done with old-style casts, but this approach is - never to be recommended. Old-style casts are sorely lacking in type - safety, suffer poor readability, and are difficult to locate with search - tools.

- -

The C++ built-in static_cast can be used for efficiently - downcasting pointers to polymorphic objects, but provides no error - detection for the case where the pointer being cast actually points to - the wrong derived class. The polymorphic_downcast template retains - the efficiency of static_cast for non-debug compilations, but for - debug compilations adds safety via an assert() that a dynamic_cast - succeeds.

- -

The C++ built-in dynamic_cast can be used for downcasts and - crosscasts of pointers to polymorphic objects, but error notification in - the form of a returned value of 0 is inconvenient to test, or worse yet, - easy to forget to test. The throwing form of dynamic_cast, which - works on references, can be used on pointers through the ugly expression - &dynamic_cast<T&>(*p), which causes undefined - behavior if p is 0. The polymorphic_cast - template performs a dynamic_cast on a pointer, and throws an - exception if the dynamic_cast returns 0.

- -

A polymorphic_downcast should be used for - downcasts that you are certain should succeed. Error checking is - only performed in translation units where NDEBUG is - not defined, via -

  assert( dynamic_cast<Derived>(x) == x )
-
where x is the source pointer. This approach - ensures that not only is a non-zero pointer returned, but also - that it is correct in the presence of multiple inheritance. - Attempts to crosscast using polymorphic_downcast will - fail to compile. - Warning: Because polymorphic_downcast uses assert(), it - violates the One Definition Rule (ODR) if NDEBUG is inconsistently - defined across translation units. [See ISO Std 3.2] -

- For crosscasts, or when the success of a cast can only be known at - runtime, or when efficiency is not important, - polymorphic_cast is preferred.

- -

The C++ built-in dynamic_cast must be used to cast references - rather than pointers. It is also the only cast that can be used to check - whether a given interface is supported; in that case a return of 0 isn't - an error condition.

- -

polymorphic_cast and polymorphic_downcast synopsis

- -
-
namespace boost {
-
-template <class Derived, class Base>
-inline Derived polymorphic_cast(Base* x);
-// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )
-// Returns: dynamic_cast<Derived>(x)
-
-template <class Derived, class Base>
-inline Derived polymorphic_downcast(Base* x);
-// Effects: assert( dynamic_cast<Derived>(x) == x );
-// Returns: static_cast<Derived>(x)
-
-}
-
-
- -

polymorphic_downcast example

- -
-
#include <boost/cast.hpp>
-...
-class Fruit { public: virtual ~Fruit(){}; ... };
-class Banana : public Fruit { ... };
-...
-void f( Fruit * fruit ) {
-// ... logic which leads us to believe it is a Banana
-  Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
-  ...
-
-
- -

History

- -

polymorphic_cast was suggested by Bjarne Stroustrup in "The C++ - Programming Language".
- polymorphic_downcast was contributed by Dave Abrahams.
- An old - numeric_cast
that was contributed by Kevlin Henney is now superseeded by the Boost Numeric Conversion Library

-
- -

Revised - June 23, 2005

- -

© Copyright boost.org 1999. Permission to copy, use, modify, sell - and distribute this document is granted provided this copyright notice - appears in all copies. This document is provided "as is" without express - or implied warranty, and with no claim as to its suitability for any - purpose.

- - \ No newline at end of file diff --git a/cast_test.cpp b/cast_test.cpp deleted file mode 100644 index ad6b18f..0000000 --- a/cast_test.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright Beman Dawes, Dave Abrahams 1999. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version including documentation. - -// Revision History -// 28 Set 04 factored out numeric_cast<> test (Fernando Cacciola) -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include // for DBL_MAX (Peter Schmid) -#include - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - -namespace -{ - struct Base - { - virtual char kind() { return 'B'; } - }; - - struct Base2 - { - virtual char kind2() { return '2'; } - }; - - struct Derived : public Base, Base2 - { - virtual char kind() { return 'D'; } - }; -} - - -int main( int argc, char * argv[] ) -{ -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test polymorphic_cast ---------------------------------------------------// - - // tests which should succeed - Base * base = new Derived; - Base2 * base2 = 0; - Derived * derived = 0; - derived = polymorphic_downcast( base ); // downcast - assert( derived->kind() == 'D' ); - - derived = 0; - derived = polymorphic_cast( base ); // downcast, throw on error - assert( derived->kind() == 'D' ); - - base2 = polymorphic_cast( base ); // crosscast - assert( base2->kind2() == '2' ); - - // tests which should result in errors being detected - int err_count = 0; - base = new Base; - - if ( argc > 1 && *argv[1] == '1' ) - { derived = polymorphic_downcast( base ); } // #1 assert failure - - bool caught_exception = false; - try { derived = polymorphic_cast( base ); } - catch (std::bad_cast) - { cout<<"caught bad_cast\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - // the following is just so generated code can be inspected - if ( derived->kind() == 'B' ) ++err_count; - - cout << err_count << " errors detected\nTest " - << (err_count==0 ? "passed\n" : "failed\n"); - return err_count; -} // main diff --git a/include/boost/cast.hpp b/include/boost/cast.hpp deleted file mode 100644 index 2615d18..0000000 --- a/include/boost/cast.hpp +++ /dev/null @@ -1,107 +0,0 @@ -// boost cast.hpp header file ----------------------------------------------// - -// (C) Copyright Kevlin Henney and Dave Abrahams 1999. -// Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/conversion for Documentation. - -// Revision History -// 23 JUn 05 numeric_cast removed and redirected to the new verion (Fernando Cacciola) -// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included -// instead (the workaround did not -// actually compile when BOOST_NO_LIMITS was defined in -// any case, so we loose nothing). (John Maddock) -// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never -// worked with stock GCC; trying to get it to do that broke -// vc-stlport. -// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp. -// Removed unused BOOST_EXPLICIT_TARGET macro. Moved -// boost::detail::type to boost/type.hpp. Made it compile with -// stock gcc again (Dave Abrahams) -// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal -// Review (Beman Dawes) -// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams) -// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC -// (Dave Abrahams) -// 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams) -// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes) -// 27 Jun 00 More MSVC6 workarounds -// 15 Jun 00 Add workarounds for MSVC6 -// 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov) -// 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar) -// 29 Dec 99 Change using declarations so usages in other namespaces work -// correctly (Dave Abrahams) -// 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors -// as suggested Darin Adler and improved by Valentin Bonnard. -// 2 Sep 99 Remove controversial asserts, simplify, rename. -// 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast, -// place in nested namespace. -// 3 Aug 99 Initial version - -#ifndef BOOST_CAST_HPP -#define BOOST_CAST_HPP - -# include -# include -# include -# include -# include -# include - -// It has been demonstrated numerous times that MSVC 6.0 fails silently at link -// time if you use a template function which has template parameters that don't -// appear in the function's argument list. -// -// TODO: Add this to config.hpp? -# if defined(BOOST_MSVC) && BOOST_MSVC < 1300 -# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type* = 0 -# else -# define BOOST_EXPLICIT_DEFAULT_TARGET -# endif - -namespace boost -{ -// See the documentation for descriptions of how to choose between -// static_cast<>, dynamic_cast<>, polymorphic_cast<> and polymorphic_downcast<> - -// polymorphic_cast --------------------------------------------------------// - - // Runtime checked polymorphic downcasts and crosscasts. - // Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup, - // section 15.8 exercise 1, page 425. - - template - inline Target polymorphic_cast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) - { - Target tmp = dynamic_cast(x); - if ( tmp == 0 ) throw std::bad_cast(); - return tmp; - } - -// polymorphic_downcast ----------------------------------------------------// - - // BOOST_ASSERT() checked polymorphic downcast. Crosscasts prohibited. - - // WARNING: Because this cast uses BOOST_ASSERT(), it violates - // the One Definition Rule if used in multiple translation units - // where BOOST_DISABLE_ASSERTS, BOOST_ENABLE_ASSERT_HANDLER - // NDEBUG are defined inconsistently. - - // Contributed by Dave Abrahams - - template - inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) - { - BOOST_ASSERT( dynamic_cast(x) == x ); // detect logic error - return static_cast(x); - } - -# undef BOOST_EXPLICIT_DEFAULT_TARGET - -} // namespace boost - -# include - -#endif // BOOST_CAST_HPP diff --git a/index.html b/index.html deleted file mode 100644 index cf8527f..0000000 --- a/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - -Boost Conversion Library - - - - -

Boost -Conversion Library

- -

The Conversion Library improves program safety and clarity by performing -otherwise messy conversions.  It includes cast-style function templates designed to complement the C++ -Standard's built-in casts.

-

To reduce coupling, particularly to standard library IOStreams, the Boost -Conversion Library is -supplied by several headers:

-
    -
  • The boost/cast header provides polymorphic_cast<> - and polymorphic_downcast<> to perform safe casting between - polymorphic types.
    -
  • -
  • The boost/lexical_cast header provides lexical_cast<> - general literal text conversions, such as an int represented as - a string, or vice-versa.
  • -
-
-

Revised June 23, 2005 -

- - - - \ No newline at end of file diff --git a/lexical_cast.htm b/lexical_cast.htm deleted file mode 100644 index 949b70c..0000000 --- a/lexical_cast.htm +++ /dev/null @@ -1,234 +0,0 @@ - - - - - lexical_cast - - - - -

boost.png (6897 bytes)Header - boost/lexical_cast.hpp

- -
-

Motivation

- Sometimes a value must be converted to a literal text form, such as an int - represented as a string, or vice-versa, when a string - is interpreted as an int. Such examples are common when converting - between data types internal to a program and representation external to a - program, such as windows and configuration files. -

- The standard C and C++ libraries offer a number of facilities for performing - such conversions. However, they vary with their ease of use, extensibility, and - safety. -

- For instance, there are a number of limitations with the family of standard C - functions typified by atoi: -

    -
  • - Conversion is supported in one direction only: from text to internal data type. - Converting the other way using the C library requires either the inconvenience - and compromised safety of the sprintf function, or the loss of - portability associated with non-standard functions such as itoa. -
  • -
  • - The range of types supported is only a subset of the built-in numeric types, - namely int, long, and double. -
  • -
  • - The range of types cannot be extended in a uniform manner. For instance, - conversion from string representation to complex or rational. -
  • -
- The standard C functions typified by strtol have the same basic - limitations, but offer finer control over the conversion process. However, for - the common case such control is often either not required or not used. The scanf - family of functions offer even greater control, but also lack safety and ease - of use. -

- The standard C++ library offers stringstream for the kind of - in-core formatting being discussed. It offers a great deal of control over the - formatting and conversion of I/O to and from arbitrary types through text. - However, for simple conversions direct use of stringstream can be - either clumsy (with the introduction of extra local variables and the loss of - infix-expression convenience) or obscure (where stringstream - objects are created as temporary objects in an expression). Facets provide a - comprehensive concept and facility for controlling textual representation, but - their perceived complexity and high entry level requires an extreme degree of - involvement for simple conversions, and excludes all but a few programmers. -

- The lexical_cast function template offers a convenient and - consistent form for supporting common conversions to and from arbitrary types - when they are represented as text. The simplification it offers is in - expression-level convenience for such conversions. For more involved - conversions, such as where precision or formatting need tighter control than is - offered by the default behavior of lexical_cast, the conventional - stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast - may offer more reasonable behavior than lexical_cast. -

- For a good discussion of the options and issues involved in string-based - formatting, including comparison of stringstream, lexical_cast, - and others, see Herb Sutter's article, - The String Formatters of Manor Farm. -

-


-

Examples

- The following example treats command line arguments as a sequence of numeric - data:
-
int main(int argc, char * argv[])
-{
-    using boost::lexical_cast;
-    using boost::bad_lexical_cast;
-
-    std::vector<short> args;
-
-    while(*++argv)
-    {
-        try
-        {
-            args.push_back(lexical_cast<short>(*argv));
-        }
-        catch(bad_lexical_cast &)
-        {
-            args.push_back(0);
-        }
-    }
-    ...
-}
-
-
The following example uses numeric data in a string expression:
-
void log_message(const std::string &);
-
-void log_errno(int yoko)
-{
-    log_message("Error " + boost::lexical_cast<std::string>(yoko) + ": " + strerror(yoko));
-}
-
-
-
-

Synopsis

- Library features defined in "boost/lexical_cast.hpp": -
-
namespace boost
-{
-    class bad_lexical_cast;
-    template<typename Target, typename Source>
-      Target lexical_cast(const Source& arg);
-}
-
-
Unit test defined in "lexical_cast_test.cpp". -

-


-

lexical_cast

-
-
template<typename Target, typename Source>
-  Target lexical_cast(const Source& arg);
-
-
Returns the result of streaming arg into a - standard library string-based stream and then out as a Target object. - Where Target is either std::string - or std::wstring, stream extraction takes the whole content - of the string, including spaces, rather than relying on the default - operator>> behavior. - If the conversion is unsuccessful, a - bad_lexical_cast exception is thrown. -

- The requirements on the argument and result types are: -

    -
  • - Source is OutputStreamable, meaning that an operator<< - is defined that takes a std::ostream or std::wostream object on the - left hand side and an instance of the argument type on the right. -
  • -
  • - Target is InputStreamable, meaning that an operator>> - is defined that takes a std::istream or std::wistream object on the left hand side - and an instance of the result type on the right. -
  • -
  • - Both Source and Target are CopyConstructible [20.1.3]. -
  • -
  • - Target is DefaultConstructible, meaning that it is possible - to default-initialize an object of that type [8.5, 20.1.4]. -
  • -
- The character type of the underlying stream is assumed to be char unless - either the Source or the Target requires wide-character - streaming, in which case the underlying stream uses wchar_t. - Source types that require wide-character streaming are wchar_t, - wchar_t *, and std::wstring. Target types that - require wide-character streaming are wchar_t and std::wstring. -

- Where a higher degree of control is required over conversions, std::stringstream - and std::wstringstream offer a more appropriate path. Where non-stream-based conversions are - required, lexical_cast - is the wrong tool for the job and is not special-cased for such scenarios. -

-


-

bad_lexical_cast

-
-
class bad_lexical_cast : public std::bad_cast
-{
-public:
-    ... // same member function interface as std::exception
-};
-
-
Exception used to indicate runtime lexical_cast - failure. -
- -

Changes

-

June 2005:

-
    -
  • Call-by-const reference for the parameters. This requires partial specialization - of class templates, so it doesn't work for MSVC 6, and it uses the original - pass by value there.
    -
  • -
  • The MSVC 6 support is deprecated, and will be removed in a future Boost - version.
  • -
-

Earlier:

- -
    -
  • The previous version of lexical_cast used the default stream - precision for reading and writing floating-point numbers. For numerics that - have a corresponding specialization of std::numeric_limits, the - current version now chooses a precision to match.
    -
  • The previous version of lexical_cast did not support conversion - to or from any wide-character-based types. For compilers with full language - and library support for wide characters, lexical_cast now supports - conversions from wchar_t, wchar_t *, and std::wstring - and to wchar_t and std::wstring.
    -
  • The previous version of lexical_cast assumed that the conventional - stream extractor operators were sufficient for reading values. However, string - I/O is asymmetric, with the result that spaces play the role of I/O separators - rather than string content. The current version fixes this error for std::string - and, where supported, std::wstring: lexical_cast<std::string>("Hello, - World") succeeds instead of failing with a bad_lexical_cast - exception.
    -
  • The previous version of lexical_cast allowed unsafe and meaningless - conversions to pointers. The current version now throws a bad_lexical_cast - for conversions to pointers: lexical_cast<char *>("Goodbye, World") - now throws an exception instead of causing undefined behavior. -
-

-


- -
© Copyright Kevlin Henney, 2000–2005
- - \ No newline at end of file diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp deleted file mode 100644 index 4182942..0000000 --- a/lexical_cast_test.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// Unit test for boost::lexical_cast. -// -// See http://www.boost.org for most recent version, including documentation. -// -// Copyright Terje Slettebø and Kevlin Henney, 2005. -// -// 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). -// -// Note: The unit test no longer compile on MSVC 6, but lexical_cast itself works for it. - -#include - -#if defined(__INTEL_COMPILER) -#pragma warning(disable: 193 383 488 981 1418 1419) -#elif defined(BOOST_MSVC) -#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) -#endif - -#include - -#include -#include - -#if defined(BOOST_NO_STRINGSTREAM) || \ - defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) -#define DISABLE_WIDE_CHAR_SUPPORT -#endif - -using namespace boost; - -void test_conversion_to_char(); -void test_conversion_to_int(); -void test_conversion_to_double(); -void test_conversion_to_bool(); -void test_conversion_to_string(); -void test_conversion_from_to_wchar_t_alias(); -void test_conversion_to_pointer(); -void test_conversion_from_wchar_t(); -void test_conversion_to_wchar_t(); -void test_conversion_from_wstring(); -void test_conversion_to_wstring(); -void test_bad_lexical_cast(); -void test_no_whitespace_stripping(); - -unit_test::test_suite *init_unit_test_suite(int, char *[]) -{ - unit_test_framework::test_suite *suite = - BOOST_TEST_SUITE("lexical_cast unit test"); - suite->add(BOOST_TEST_CASE(test_conversion_to_char)); - suite->add(BOOST_TEST_CASE(test_conversion_to_int)); - suite->add(BOOST_TEST_CASE(test_conversion_to_double)); - suite->add(BOOST_TEST_CASE(test_conversion_to_bool)); - suite->add(BOOST_TEST_CASE(test_conversion_from_to_wchar_t_alias)); - suite->add(BOOST_TEST_CASE(test_conversion_to_pointer)); - suite->add(BOOST_TEST_CASE(test_conversion_to_string)); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_from_wstring)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wstring)); - #endif - suite->add(BOOST_TEST_CASE(test_bad_lexical_cast)); - suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping)); - return suite; -} - -void test_conversion_to_char() -{ - BOOST_CHECK_EQUAL('A', lexical_cast('A')); - BOOST_CHECK_EQUAL(' ', lexical_cast(' ')); - BOOST_CHECK_EQUAL('1', lexical_cast(1)); - BOOST_CHECK_EQUAL('0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL('1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL('1', lexical_cast(true)); - BOOST_CHECK_EQUAL('0', lexical_cast(false)); - BOOST_CHECK_EQUAL('A', lexical_cast("A")); - BOOST_CHECK_EQUAL(' ', lexical_cast(" ")); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL('A', lexical_cast(std::string("A"))); - BOOST_CHECK_EQUAL(' ', lexical_cast(std::string(" "))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_int() -{ - BOOST_CHECK_EQUAL(1, lexical_cast('1')); - BOOST_CHECK_EQUAL(0, lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_EQUAL(1, lexical_cast(1)); - BOOST_CHECK_EQUAL( - (std::numeric_limits::max)(), - lexical_cast((std::numeric_limits::max)())); - BOOST_CHECK_EQUAL(1, lexical_cast(1.0)); - - BOOST_CHECK_THROW(lexical_cast(1.23), bad_lexical_cast); - - BOOST_CHECK_THROW(lexical_cast(1e20), bad_lexical_cast); - BOOST_CHECK_EQUAL(1, lexical_cast(true)); - BOOST_CHECK_EQUAL(0, lexical_cast(false)); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_THROW( - lexical_cast(" 123"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_EQUAL(123, lexical_cast(std::string("123"))); - BOOST_CHECK_THROW( - lexical_cast(std::string(" 123")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_double() -{ - BOOST_CHECK_CLOSE(1.0, lexical_cast('1'), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_CLOSE(1.0, lexical_cast(1), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.23, lexical_cast(1.23), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.234567890, 1.234567890, std::numeric_limits::epsilon()); - BOOST_CHECK_CLOSE(1.0, lexical_cast(true), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(0.0, lexical_cast(false), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.23, lexical_cast("1.23"), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_CLOSE(1.23, lexical_cast(std::string("1.23")), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_bool() -{ - BOOST_CHECK_EQUAL(true, lexical_cast('1')); - BOOST_CHECK_EQUAL(false, lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1)); - BOOST_CHECK_EQUAL(false, lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1.0)); - BOOST_CHECK_EQUAL(false, lexical_cast(0.0)); - BOOST_CHECK_EQUAL(true, lexical_cast(true)); - BOOST_CHECK_EQUAL(false, lexical_cast(false)); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_EQUAL(true, lexical_cast(std::string("1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::string("0"))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_string() -{ - BOOST_CHECK_EQUAL("A", lexical_cast('A')); - BOOST_CHECK_EQUAL(" ", lexical_cast(' ')); - BOOST_CHECK_EQUAL("123", lexical_cast(123)); - BOOST_CHECK_EQUAL("1.23", lexical_cast(1.23)); - BOOST_CHECK_EQUAL("1.111111111", lexical_cast(1.111111111)); - BOOST_CHECK_EQUAL("1", lexical_cast(true)); - BOOST_CHECK_EQUAL("0", lexical_cast(false)); - BOOST_CHECK_EQUAL("Test", lexical_cast("Test")); - BOOST_CHECK_EQUAL(" ", lexical_cast(" ")); - BOOST_CHECK_EQUAL("", lexical_cast("")); - BOOST_CHECK_EQUAL("Test", lexical_cast(std::string("Test"))); - BOOST_CHECK_EQUAL(" ", lexical_cast(std::string(" "))); - BOOST_CHECK_EQUAL("", lexical_cast(std::string(""))); -} - -void test_conversion_from_to_wchar_t_alias() -{ - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(std::string("123"), - lexical_cast(static_cast(123))); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123u)); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123ul)); -} - -void test_conversion_to_pointer() -{ - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #endif -} - -void test_conversion_from_wchar_t() -{ -#ifndef DISABLE_WIDE_CHAR_SUPPORT -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(1, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - - BOOST_CHECK_EQUAL(123, lexical_cast(L"123")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(1.0, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - - BOOST_CHECK_EQUAL(1.23, lexical_cast(L"1.23")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(true, lexical_cast(L'1')); - BOOST_CHECK_EQUAL(false, lexical_cast(L'0')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - BOOST_CHECK_EQUAL(true, lexical_cast(L"1")); - BOOST_CHECK_EQUAL(false, lexical_cast(L"0")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); -#endif -} - -void test_conversion_to_wchar_t() -{ -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(L'1', lexical_cast(1)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL(L'1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0.0)); - BOOST_CHECK_EQUAL(L'1', lexical_cast(true)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(false)); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L'A')); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L' ')); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L"A")); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L" ")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(L'A', lexical_cast(std::wstring(L"A"))); - BOOST_CHECK_EQUAL(L' ', lexical_cast(std::wstring(L" "))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - #endif -} - -void test_conversion_from_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_EQUAL(123, lexical_cast(std::wstring(L"123"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - - BOOST_CHECK_EQUAL(true, lexical_cast(std::wstring(L"1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::wstring(L"0"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - #endif -} - -void test_conversion_to_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK(L"123" == lexical_cast(123)); - BOOST_CHECK(L"1.23" == lexical_cast(1.23)); - BOOST_CHECK(L"1.111111111" == lexical_cast(1.111111111)); - BOOST_CHECK(L"1" == lexical_cast(true)); - BOOST_CHECK(L"0" == lexical_cast(false)); -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK(L"A" == lexical_cast(L'A')); - BOOST_CHECK(L" " == lexical_cast(L' ')); -#endif - BOOST_CHECK(L"Test" == lexical_cast(L"Test")); - BOOST_CHECK(L" " == lexical_cast(L" ")); - BOOST_CHECK(L"" == lexical_cast(L"")); - BOOST_CHECK(L"Test" == lexical_cast(std::wstring(L"Test"))); - BOOST_CHECK(L" " == lexical_cast(std::wstring(L" "))); - BOOST_CHECK(L"" == lexical_cast(std::wstring(L""))); - #endif -} - -void test_bad_lexical_cast() -{ - try - { - lexical_cast(std::string("Test")); - - BOOST_CHECK(false); // Exception expected - } - catch(const bad_lexical_cast &e) - { - BOOST_CHECK(e.source_type() == typeid(std::string)); - BOOST_CHECK(e.target_type() == typeid(int)); - } -} - -void test_no_whitespace_stripping() -{ - BOOST_CHECK_THROW(lexical_cast(" 123"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("123 "), bad_lexical_cast); -} diff --git a/numeric_cast_test.cpp b/numeric_cast_test.cpp deleted file mode 100644 index 0b5bcde..0000000 --- a/numeric_cast_test.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright Beman Dawes, Dave Abrahams 1999. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version including documentation. - -// Revision History -// 28 Set 04 factored out numeric_cast<> test (Fernando Cacciola) -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include // for DBL_MAX (Peter Schmid) -#include - -#include "boost/test/minimal.hpp" - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - - -int test_main( int argc, char * argv[] ) -{ - -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test implicit_cast and numeric_cast -------------------------------------// - - // tests which should succeed - long small_value = 1; - long small_negative_value = -1; - long large_value = LONG_MAX; - long large_negative_value = LONG_MIN; - signed char c = 0; - - c = large_value; // see if compiler generates warning - - c = numeric_cast( small_value ); - BOOST_CHECK( c == 1 ); - c = 0; - c = numeric_cast( small_value ); - BOOST_CHECK( c == 1 ); - c = 0; - c = numeric_cast( small_negative_value ); - BOOST_CHECK( c == -1 ); - - // These tests courtesy of Joe R NWP Swatosh - BOOST_CHECK( 0.0f == numeric_cast( 0.0 ) ); - BOOST_CHECK( 0.0 == numeric_cast( 0.0 ) ); - - // tests which should result in errors being detected - - bool caught_exception = false; - try { c = numeric_cast( large_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #1\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { c = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #2\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - unsigned long ul; - caught_exception = false; - try { ul = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #3\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { ul = numeric_cast( small_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #4\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { numeric_cast( DBL_MAX ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #5\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - return 0 ; -} diff --git a/test.hpp b/test.hpp deleted file mode 100644 index 4c7eecb..0000000 --- a/test.hpp +++ /dev/null @@ -1,308 +0,0 @@ -// what: simple unit test framework -// who: developed by Kevlin Henney -// when: November 2000 -// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.91 -// -// ChangeLog: -// 20 Jan 2001 - Fixed a warning for MSVC (Dave Abrahams) - -#ifndef TEST_INCLUDED -#define TEST_INCLUDED - -#include -#include -#include // for out-of-the-box g++ -#include - -namespace test // test tuple comprises name and nullary function (object) -{ - template - struct test - { - string_type name; - function_type action; - - static test make(string_type name, function_type action) - { - test result; // MSVC aggreggate initializer bugs - result.name = name; - result.action = action; - return result; - } - }; -} - -namespace test // failure exception used to indicate checked test failures -{ - class failure : public std::exception - { - public: // struction (default cases are OK) - - failure(const std::string & why) - : reason(why) - { - } - - // std::~string has no exception-specification (could throw anything), - // but we need to be compatible with std::~exception's empty one - // see std::15.4p13 and std::15.4p3 - ~failure() throw() - { - } - - public: // usage - - virtual const char * what() const throw() - { - return reason.c_str(); - } - - private: // representation - - std::string reason; - - }; -} - -namespace test // not_implemented exception used to mark unimplemented tests -{ - class not_implemented : public std::exception - { - public: // usage (default ctor and dtor are OK) - - virtual const char * what() const throw() - { - return "not implemented"; - } - - }; -} - -namespace test // test utilities -{ - inline void check(bool condition, const std::string & description) - { - if(!condition) - { - throw failure(description); - } - } - - inline void check_true(bool value, const std::string & description) - { - check(value, "expected true: " + description); - } - - inline void check_false(bool value, const std::string & description) - { - check(!value, "expected false: " + description); - } - - template - void check_equal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs == rhs, "expected equal values: " + description); - } - - template - void check_unequal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs != rhs, "expected unequal values: " + description); - } - - inline void check_null(const void* ptr, const std::string & description) - { - check(!ptr, "expected null pointer: " + description); - } - - inline void check_non_null(const void* ptr, const std::string & description) - { - check(ptr != 0, "expected non-null pointer: " + description); - } -} - -#define TEST_CHECK_THROW(expression, exception, description) \ - try \ - { \ - expression; \ - throw ::test::failure(description); \ - } \ - catch(exception &) \ - { \ - } - -namespace test // memory tracking (enabled if test new and delete linked in) -{ - class allocations - { - public: // singleton access - - static allocations & instance() - { - static allocations singleton; - return singleton; - } - - public: // logging - - void clear() - { - alloc_count = dealloc_count = 0; - } - - void allocation() - { - ++alloc_count; - } - - void deallocation() - { - ++dealloc_count; - } - - public: // reporting - - unsigned long allocated() const - { - return alloc_count; - } - - unsigned long deallocated() const - { - return dealloc_count; - } - - bool balanced() const - { - return alloc_count == dealloc_count; - } - - private: // structors (default dtor is fine) - - allocations() - : alloc_count(0), dealloc_count(0) - { - } - - private: // prevention - - allocations(const allocations &); - allocations & operator=(const allocations &); - - private: // state - - unsigned long alloc_count, dealloc_count; - - }; -} - -namespace test // tester is the driver class for a sequence of tests -{ - template - class tester - { - public: // structors (default destructor is OK) - - tester(test_iterator first_test, test_iterator after_last_test) - : begin(first_test), end(after_last_test) - { - } - - public: // usage - - bool operator()(); // returns true if all tests passed - - private: // representation - - test_iterator begin, end; - - private: // prevention - - tester(const tester &); - tester &operator=(const tester &); - - }; - - template - bool tester::operator()() - { - using namespace std; - - unsigned long passed = 0, failed = 0, unimplemented = 0; - - for(test_iterator current = begin; current != end; ++current) - { - cerr << "[" << current->name << "] " << flush; - string result = "passed"; // optimistic - - try - { - allocations::instance().clear(); - current->action(); - - if(!allocations::instance().balanced()) - { - unsigned long allocated = allocations::instance().allocated(); - unsigned long deallocated = allocations::instance().deallocated(); - ostrstream report; - report << "new/delete (" - << allocated << " allocated, " - << deallocated << " deallocated)" - << ends; - const char * text = report.str(); - report.freeze(false); - throw failure(text); - } - - ++passed; - } - catch(const failure & caught) - { - (result = "failed: ") += caught.what(); - ++failed; - } - catch(const not_implemented &) - { - result = "not implemented"; - ++unimplemented; - } - catch(const exception & caught) - { - (result = "exception: ") += caught.what(); - ++failed; - } - catch(...) - { - result = "failed with unknown exception"; - ++failed; - } - - cerr << result << endl; - } - - cerr << passed + failed << " tests: " - << passed << " passed, " - << failed << " failed"; - - if(unimplemented) - { - cerr << " (" << unimplemented << " not implemented)"; - } - - cerr << endl; - - return failed == 0; - } -} - -#endif - -// Copyright Kevlin Henney, 2000. All rights reserved. -// -// 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) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 deleted file mode 100644 index 56a03d8..0000000 --- a/test/Jamfile.v2 +++ /dev/null @@ -1,26 +0,0 @@ -# Signals library - -# Copyright (C) 2001-2003 Douglas Gregor - -# Permission to copy, use, sell and distribute this software is granted -# provided this copyright notice appears in all copies. Permission to modify -# the code and to distribute modified code is granted provided this copyright -# notice appears in all copies, and a notice that the code was modified is -# included with the copyright notice. This software is provided "as is" -# without express or implied warranty, and with no claim as to its suitability -# for any purpose. - -# For more information, see http://www.boost.org/ - -# bring in rules for testing -import testing ; - -test-suite conversion - : [ run implicit_cast.cpp ] - [ compile-fail implicit_cast_fail.cpp ] - [ run ../cast_test.cpp ] - [ run ../numeric_cast_test.cpp ] - [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/static ] - ; - - diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp deleted file mode 100644 index e18e17a..0000000 --- a/test/implicit_cast.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright David Abrahams 2003. -// 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) - -#include -#include -#include -using boost::implicit_cast; -using boost::type; - -template -type check_return(T) { return type(); } - -struct foo -{ - foo(char const*) {} - operator long() const { return 0; } -}; - -typedef type long_type; -typedef type foo_type; - -int main() -{ - type x = check_return(boost::implicit_cast(1)); - BOOST_TEST(boost::implicit_cast(1) == 1L); - - type f = check_return(boost::implicit_cast("hello")); - type z = check_return(boost::implicit_cast(foo("hello"))); - return boost::report_errors(); -} diff --git a/test/implicit_cast_fail.cpp b/test/implicit_cast_fail.cpp deleted file mode 100644 index 80143da..0000000 --- a/test/implicit_cast_fail.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright David Abrahams 2003. -// 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) - -#include -#include - -#define BOOST_INCLUDE_MAIN -#include - -using boost::implicit_cast; - -struct foo -{ - explicit foo(char const*) {} -}; - -int test_main(int, char*[]) -{ - foo x = implicit_cast("foobar"); -} From 2688da7c0d6e7da65fecd81b3eb9884cc03027c5 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 19 Jun 2007 01:09:15 +0000 Subject: [PATCH 033/138] This commit was manufactured by cvs2svn to create tag 'SPIRIT_1_8_5_MINIBOOST'. [SVN r38031] --- cast.htm | 140 ---------------- cast_test.cpp | 91 ---------- include/boost/cast.hpp | 107 ------------ index.html | 38 ----- lexical_cast.htm | 234 -------------------------- lexical_cast_test.cpp | 320 ------------------------------------ numeric_cast_test.cpp | 100 ----------- test.hpp | 308 ---------------------------------- test/Jamfile.v2 | 26 --- test/implicit_cast.cpp | 32 ---- test/implicit_cast_fail.cpp | 22 --- 11 files changed, 1418 deletions(-) delete mode 100644 cast.htm delete mode 100644 cast_test.cpp delete mode 100644 include/boost/cast.hpp delete mode 100644 index.html delete mode 100644 lexical_cast.htm delete mode 100644 lexical_cast_test.cpp delete mode 100644 numeric_cast_test.cpp delete mode 100644 test.hpp delete mode 100644 test/Jamfile.v2 delete mode 100644 test/implicit_cast.cpp delete mode 100644 test/implicit_cast_fail.cpp diff --git a/cast.htm b/cast.htm deleted file mode 100644 index 587d08a..0000000 --- a/cast.htm +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - Header boost/cast.hpp Documentation - - - -

boost.png (6897 bytes)Header boost/cast.hpp

- -

Cast Functions

- -

The header boost/cast.hpp provides - polymorphic_cast and polymorphic_downcast function templates designed to - complement the C++ built-in casts.

- -

The program cast_test.cpp can be used to - verify these function templates work as expected.

- -

Polymorphic casts

- -

Pointers to polymorphic objects (objects of classes which define at - least one virtual function) are sometimes downcast or crosscast. - Downcasting means casting from a base class to a derived class. - Crosscasting means casting across an inheritance hierarchy diagram, such - as from one base to the other in a Y diagram hierarchy.

- -

Such casts can be done with old-style casts, but this approach is - never to be recommended. Old-style casts are sorely lacking in type - safety, suffer poor readability, and are difficult to locate with search - tools.

- -

The C++ built-in static_cast can be used for efficiently - downcasting pointers to polymorphic objects, but provides no error - detection for the case where the pointer being cast actually points to - the wrong derived class. The polymorphic_downcast template retains - the efficiency of static_cast for non-debug compilations, but for - debug compilations adds safety via an assert() that a dynamic_cast - succeeds.

- -

The C++ built-in dynamic_cast can be used for downcasts and - crosscasts of pointers to polymorphic objects, but error notification in - the form of a returned value of 0 is inconvenient to test, or worse yet, - easy to forget to test. The throwing form of dynamic_cast, which - works on references, can be used on pointers through the ugly expression - &dynamic_cast<T&>(*p), which causes undefined - behavior if p is 0. The polymorphic_cast - template performs a dynamic_cast on a pointer, and throws an - exception if the dynamic_cast returns 0.

- -

A polymorphic_downcast should be used for - downcasts that you are certain should succeed. Error checking is - only performed in translation units where NDEBUG is - not defined, via -

  assert( dynamic_cast<Derived>(x) == x )
-
where x is the source pointer. This approach - ensures that not only is a non-zero pointer returned, but also - that it is correct in the presence of multiple inheritance. - Attempts to crosscast using polymorphic_downcast will - fail to compile. - Warning: Because polymorphic_downcast uses assert(), it - violates the One Definition Rule (ODR) if NDEBUG is inconsistently - defined across translation units. [See ISO Std 3.2] -

- For crosscasts, or when the success of a cast can only be known at - runtime, or when efficiency is not important, - polymorphic_cast is preferred.

- -

The C++ built-in dynamic_cast must be used to cast references - rather than pointers. It is also the only cast that can be used to check - whether a given interface is supported; in that case a return of 0 isn't - an error condition.

- -

polymorphic_cast and polymorphic_downcast synopsis

- -
-
namespace boost {
-
-template <class Derived, class Base>
-inline Derived polymorphic_cast(Base* x);
-// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )
-// Returns: dynamic_cast<Derived>(x)
-
-template <class Derived, class Base>
-inline Derived polymorphic_downcast(Base* x);
-// Effects: assert( dynamic_cast<Derived>(x) == x );
-// Returns: static_cast<Derived>(x)
-
-}
-
-
- -

polymorphic_downcast example

- -
-
#include <boost/cast.hpp>
-...
-class Fruit { public: virtual ~Fruit(){}; ... };
-class Banana : public Fruit { ... };
-...
-void f( Fruit * fruit ) {
-// ... logic which leads us to believe it is a Banana
-  Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
-  ...
-
-
- -

History

- -

polymorphic_cast was suggested by Bjarne Stroustrup in "The C++ - Programming Language".
- polymorphic_downcast was contributed by Dave Abrahams.
- An old - numeric_cast
that was contributed by Kevlin Henney is now superseeded by the Boost Numeric Conversion Library

-
- -

Revised - June 23, 2005

- -

© Copyright boost.org 1999. Permission to copy, use, modify, sell - and distribute this document is granted provided this copyright notice - appears in all copies. This document is provided "as is" without express - or implied warranty, and with no claim as to its suitability for any - purpose.

- - \ No newline at end of file diff --git a/cast_test.cpp b/cast_test.cpp deleted file mode 100644 index ad6b18f..0000000 --- a/cast_test.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright Beman Dawes, Dave Abrahams 1999. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version including documentation. - -// Revision History -// 28 Set 04 factored out numeric_cast<> test (Fernando Cacciola) -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include // for DBL_MAX (Peter Schmid) -#include - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - -namespace -{ - struct Base - { - virtual char kind() { return 'B'; } - }; - - struct Base2 - { - virtual char kind2() { return '2'; } - }; - - struct Derived : public Base, Base2 - { - virtual char kind() { return 'D'; } - }; -} - - -int main( int argc, char * argv[] ) -{ -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test polymorphic_cast ---------------------------------------------------// - - // tests which should succeed - Base * base = new Derived; - Base2 * base2 = 0; - Derived * derived = 0; - derived = polymorphic_downcast( base ); // downcast - assert( derived->kind() == 'D' ); - - derived = 0; - derived = polymorphic_cast( base ); // downcast, throw on error - assert( derived->kind() == 'D' ); - - base2 = polymorphic_cast( base ); // crosscast - assert( base2->kind2() == '2' ); - - // tests which should result in errors being detected - int err_count = 0; - base = new Base; - - if ( argc > 1 && *argv[1] == '1' ) - { derived = polymorphic_downcast( base ); } // #1 assert failure - - bool caught_exception = false; - try { derived = polymorphic_cast( base ); } - catch (std::bad_cast) - { cout<<"caught bad_cast\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - // the following is just so generated code can be inspected - if ( derived->kind() == 'B' ) ++err_count; - - cout << err_count << " errors detected\nTest " - << (err_count==0 ? "passed\n" : "failed\n"); - return err_count; -} // main diff --git a/include/boost/cast.hpp b/include/boost/cast.hpp deleted file mode 100644 index 2615d18..0000000 --- a/include/boost/cast.hpp +++ /dev/null @@ -1,107 +0,0 @@ -// boost cast.hpp header file ----------------------------------------------// - -// (C) Copyright Kevlin Henney and Dave Abrahams 1999. -// Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/conversion for Documentation. - -// Revision History -// 23 JUn 05 numeric_cast removed and redirected to the new verion (Fernando Cacciola) -// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included -// instead (the workaround did not -// actually compile when BOOST_NO_LIMITS was defined in -// any case, so we loose nothing). (John Maddock) -// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never -// worked with stock GCC; trying to get it to do that broke -// vc-stlport. -// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp. -// Removed unused BOOST_EXPLICIT_TARGET macro. Moved -// boost::detail::type to boost/type.hpp. Made it compile with -// stock gcc again (Dave Abrahams) -// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal -// Review (Beman Dawes) -// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams) -// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC -// (Dave Abrahams) -// 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams) -// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes) -// 27 Jun 00 More MSVC6 workarounds -// 15 Jun 00 Add workarounds for MSVC6 -// 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov) -// 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar) -// 29 Dec 99 Change using declarations so usages in other namespaces work -// correctly (Dave Abrahams) -// 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors -// as suggested Darin Adler and improved by Valentin Bonnard. -// 2 Sep 99 Remove controversial asserts, simplify, rename. -// 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast, -// place in nested namespace. -// 3 Aug 99 Initial version - -#ifndef BOOST_CAST_HPP -#define BOOST_CAST_HPP - -# include -# include -# include -# include -# include -# include - -// It has been demonstrated numerous times that MSVC 6.0 fails silently at link -// time if you use a template function which has template parameters that don't -// appear in the function's argument list. -// -// TODO: Add this to config.hpp? -# if defined(BOOST_MSVC) && BOOST_MSVC < 1300 -# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type* = 0 -# else -# define BOOST_EXPLICIT_DEFAULT_TARGET -# endif - -namespace boost -{ -// See the documentation for descriptions of how to choose between -// static_cast<>, dynamic_cast<>, polymorphic_cast<> and polymorphic_downcast<> - -// polymorphic_cast --------------------------------------------------------// - - // Runtime checked polymorphic downcasts and crosscasts. - // Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup, - // section 15.8 exercise 1, page 425. - - template - inline Target polymorphic_cast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) - { - Target tmp = dynamic_cast(x); - if ( tmp == 0 ) throw std::bad_cast(); - return tmp; - } - -// polymorphic_downcast ----------------------------------------------------// - - // BOOST_ASSERT() checked polymorphic downcast. Crosscasts prohibited. - - // WARNING: Because this cast uses BOOST_ASSERT(), it violates - // the One Definition Rule if used in multiple translation units - // where BOOST_DISABLE_ASSERTS, BOOST_ENABLE_ASSERT_HANDLER - // NDEBUG are defined inconsistently. - - // Contributed by Dave Abrahams - - template - inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) - { - BOOST_ASSERT( dynamic_cast(x) == x ); // detect logic error - return static_cast(x); - } - -# undef BOOST_EXPLICIT_DEFAULT_TARGET - -} // namespace boost - -# include - -#endif // BOOST_CAST_HPP diff --git a/index.html b/index.html deleted file mode 100644 index cf8527f..0000000 --- a/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - -Boost Conversion Library - - - - -

Boost -Conversion Library

- -

The Conversion Library improves program safety and clarity by performing -otherwise messy conversions.  It includes cast-style function templates designed to complement the C++ -Standard's built-in casts.

-

To reduce coupling, particularly to standard library IOStreams, the Boost -Conversion Library is -supplied by several headers:

-
    -
  • The boost/cast header provides polymorphic_cast<> - and polymorphic_downcast<> to perform safe casting between - polymorphic types.
    -
  • -
  • The boost/lexical_cast header provides lexical_cast<> - general literal text conversions, such as an int represented as - a string, or vice-versa.
  • -
-
-

Revised June 23, 2005 -

- - - - \ No newline at end of file diff --git a/lexical_cast.htm b/lexical_cast.htm deleted file mode 100644 index 949b70c..0000000 --- a/lexical_cast.htm +++ /dev/null @@ -1,234 +0,0 @@ - - - - - lexical_cast - - - - -

boost.png (6897 bytes)Header - boost/lexical_cast.hpp

- -
-

Motivation

- Sometimes a value must be converted to a literal text form, such as an int - represented as a string, or vice-versa, when a string - is interpreted as an int. Such examples are common when converting - between data types internal to a program and representation external to a - program, such as windows and configuration files. -

- The standard C and C++ libraries offer a number of facilities for performing - such conversions. However, they vary with their ease of use, extensibility, and - safety. -

- For instance, there are a number of limitations with the family of standard C - functions typified by atoi: -

    -
  • - Conversion is supported in one direction only: from text to internal data type. - Converting the other way using the C library requires either the inconvenience - and compromised safety of the sprintf function, or the loss of - portability associated with non-standard functions such as itoa. -
  • -
  • - The range of types supported is only a subset of the built-in numeric types, - namely int, long, and double. -
  • -
  • - The range of types cannot be extended in a uniform manner. For instance, - conversion from string representation to complex or rational. -
  • -
- The standard C functions typified by strtol have the same basic - limitations, but offer finer control over the conversion process. However, for - the common case such control is often either not required or not used. The scanf - family of functions offer even greater control, but also lack safety and ease - of use. -

- The standard C++ library offers stringstream for the kind of - in-core formatting being discussed. It offers a great deal of control over the - formatting and conversion of I/O to and from arbitrary types through text. - However, for simple conversions direct use of stringstream can be - either clumsy (with the introduction of extra local variables and the loss of - infix-expression convenience) or obscure (where stringstream - objects are created as temporary objects in an expression). Facets provide a - comprehensive concept and facility for controlling textual representation, but - their perceived complexity and high entry level requires an extreme degree of - involvement for simple conversions, and excludes all but a few programmers. -

- The lexical_cast function template offers a convenient and - consistent form for supporting common conversions to and from arbitrary types - when they are represented as text. The simplification it offers is in - expression-level convenience for such conversions. For more involved - conversions, such as where precision or formatting need tighter control than is - offered by the default behavior of lexical_cast, the conventional - stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast - may offer more reasonable behavior than lexical_cast. -

- For a good discussion of the options and issues involved in string-based - formatting, including comparison of stringstream, lexical_cast, - and others, see Herb Sutter's article, - The String Formatters of Manor Farm. -

-


-

Examples

- The following example treats command line arguments as a sequence of numeric - data:
-
int main(int argc, char * argv[])
-{
-    using boost::lexical_cast;
-    using boost::bad_lexical_cast;
-
-    std::vector<short> args;
-
-    while(*++argv)
-    {
-        try
-        {
-            args.push_back(lexical_cast<short>(*argv));
-        }
-        catch(bad_lexical_cast &)
-        {
-            args.push_back(0);
-        }
-    }
-    ...
-}
-
-
The following example uses numeric data in a string expression:
-
void log_message(const std::string &);
-
-void log_errno(int yoko)
-{
-    log_message("Error " + boost::lexical_cast<std::string>(yoko) + ": " + strerror(yoko));
-}
-
-
-
-

Synopsis

- Library features defined in "boost/lexical_cast.hpp": -
-
namespace boost
-{
-    class bad_lexical_cast;
-    template<typename Target, typename Source>
-      Target lexical_cast(const Source& arg);
-}
-
-
Unit test defined in "lexical_cast_test.cpp". -

-


-

lexical_cast

-
-
template<typename Target, typename Source>
-  Target lexical_cast(const Source& arg);
-
-
Returns the result of streaming arg into a - standard library string-based stream and then out as a Target object. - Where Target is either std::string - or std::wstring, stream extraction takes the whole content - of the string, including spaces, rather than relying on the default - operator>> behavior. - If the conversion is unsuccessful, a - bad_lexical_cast exception is thrown. -

- The requirements on the argument and result types are: -

    -
  • - Source is OutputStreamable, meaning that an operator<< - is defined that takes a std::ostream or std::wostream object on the - left hand side and an instance of the argument type on the right. -
  • -
  • - Target is InputStreamable, meaning that an operator>> - is defined that takes a std::istream or std::wistream object on the left hand side - and an instance of the result type on the right. -
  • -
  • - Both Source and Target are CopyConstructible [20.1.3]. -
  • -
  • - Target is DefaultConstructible, meaning that it is possible - to default-initialize an object of that type [8.5, 20.1.4]. -
  • -
- The character type of the underlying stream is assumed to be char unless - either the Source or the Target requires wide-character - streaming, in which case the underlying stream uses wchar_t. - Source types that require wide-character streaming are wchar_t, - wchar_t *, and std::wstring. Target types that - require wide-character streaming are wchar_t and std::wstring. -

- Where a higher degree of control is required over conversions, std::stringstream - and std::wstringstream offer a more appropriate path. Where non-stream-based conversions are - required, lexical_cast - is the wrong tool for the job and is not special-cased for such scenarios. -

-


-

bad_lexical_cast

-
-
class bad_lexical_cast : public std::bad_cast
-{
-public:
-    ... // same member function interface as std::exception
-};
-
-
Exception used to indicate runtime lexical_cast - failure. -
- -

Changes

-

June 2005:

-
    -
  • Call-by-const reference for the parameters. This requires partial specialization - of class templates, so it doesn't work for MSVC 6, and it uses the original - pass by value there.
    -
  • -
  • The MSVC 6 support is deprecated, and will be removed in a future Boost - version.
  • -
-

Earlier:

- -
    -
  • The previous version of lexical_cast used the default stream - precision for reading and writing floating-point numbers. For numerics that - have a corresponding specialization of std::numeric_limits, the - current version now chooses a precision to match.
    -
  • The previous version of lexical_cast did not support conversion - to or from any wide-character-based types. For compilers with full language - and library support for wide characters, lexical_cast now supports - conversions from wchar_t, wchar_t *, and std::wstring - and to wchar_t and std::wstring.
    -
  • The previous version of lexical_cast assumed that the conventional - stream extractor operators were sufficient for reading values. However, string - I/O is asymmetric, with the result that spaces play the role of I/O separators - rather than string content. The current version fixes this error for std::string - and, where supported, std::wstring: lexical_cast<std::string>("Hello, - World") succeeds instead of failing with a bad_lexical_cast - exception.
    -
  • The previous version of lexical_cast allowed unsafe and meaningless - conversions to pointers. The current version now throws a bad_lexical_cast - for conversions to pointers: lexical_cast<char *>("Goodbye, World") - now throws an exception instead of causing undefined behavior. -
-

-


- -
© Copyright Kevlin Henney, 2000–2005
- - \ No newline at end of file diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp deleted file mode 100644 index 4182942..0000000 --- a/lexical_cast_test.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// Unit test for boost::lexical_cast. -// -// See http://www.boost.org for most recent version, including documentation. -// -// Copyright Terje Slettebø and Kevlin Henney, 2005. -// -// 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). -// -// Note: The unit test no longer compile on MSVC 6, but lexical_cast itself works for it. - -#include - -#if defined(__INTEL_COMPILER) -#pragma warning(disable: 193 383 488 981 1418 1419) -#elif defined(BOOST_MSVC) -#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) -#endif - -#include - -#include -#include - -#if defined(BOOST_NO_STRINGSTREAM) || \ - defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) -#define DISABLE_WIDE_CHAR_SUPPORT -#endif - -using namespace boost; - -void test_conversion_to_char(); -void test_conversion_to_int(); -void test_conversion_to_double(); -void test_conversion_to_bool(); -void test_conversion_to_string(); -void test_conversion_from_to_wchar_t_alias(); -void test_conversion_to_pointer(); -void test_conversion_from_wchar_t(); -void test_conversion_to_wchar_t(); -void test_conversion_from_wstring(); -void test_conversion_to_wstring(); -void test_bad_lexical_cast(); -void test_no_whitespace_stripping(); - -unit_test::test_suite *init_unit_test_suite(int, char *[]) -{ - unit_test_framework::test_suite *suite = - BOOST_TEST_SUITE("lexical_cast unit test"); - suite->add(BOOST_TEST_CASE(test_conversion_to_char)); - suite->add(BOOST_TEST_CASE(test_conversion_to_int)); - suite->add(BOOST_TEST_CASE(test_conversion_to_double)); - suite->add(BOOST_TEST_CASE(test_conversion_to_bool)); - suite->add(BOOST_TEST_CASE(test_conversion_from_to_wchar_t_alias)); - suite->add(BOOST_TEST_CASE(test_conversion_to_pointer)); - suite->add(BOOST_TEST_CASE(test_conversion_to_string)); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_from_wstring)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wstring)); - #endif - suite->add(BOOST_TEST_CASE(test_bad_lexical_cast)); - suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping)); - return suite; -} - -void test_conversion_to_char() -{ - BOOST_CHECK_EQUAL('A', lexical_cast('A')); - BOOST_CHECK_EQUAL(' ', lexical_cast(' ')); - BOOST_CHECK_EQUAL('1', lexical_cast(1)); - BOOST_CHECK_EQUAL('0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL('1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL('1', lexical_cast(true)); - BOOST_CHECK_EQUAL('0', lexical_cast(false)); - BOOST_CHECK_EQUAL('A', lexical_cast("A")); - BOOST_CHECK_EQUAL(' ', lexical_cast(" ")); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL('A', lexical_cast(std::string("A"))); - BOOST_CHECK_EQUAL(' ', lexical_cast(std::string(" "))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_int() -{ - BOOST_CHECK_EQUAL(1, lexical_cast('1')); - BOOST_CHECK_EQUAL(0, lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_EQUAL(1, lexical_cast(1)); - BOOST_CHECK_EQUAL( - (std::numeric_limits::max)(), - lexical_cast((std::numeric_limits::max)())); - BOOST_CHECK_EQUAL(1, lexical_cast(1.0)); - - BOOST_CHECK_THROW(lexical_cast(1.23), bad_lexical_cast); - - BOOST_CHECK_THROW(lexical_cast(1e20), bad_lexical_cast); - BOOST_CHECK_EQUAL(1, lexical_cast(true)); - BOOST_CHECK_EQUAL(0, lexical_cast(false)); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_THROW( - lexical_cast(" 123"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_EQUAL(123, lexical_cast(std::string("123"))); - BOOST_CHECK_THROW( - lexical_cast(std::string(" 123")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_double() -{ - BOOST_CHECK_CLOSE(1.0, lexical_cast('1'), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_CLOSE(1.0, lexical_cast(1), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.23, lexical_cast(1.23), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.234567890, 1.234567890, std::numeric_limits::epsilon()); - BOOST_CHECK_CLOSE(1.0, lexical_cast(true), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(0.0, lexical_cast(false), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.23, lexical_cast("1.23"), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_CLOSE(1.23, lexical_cast(std::string("1.23")), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_bool() -{ - BOOST_CHECK_EQUAL(true, lexical_cast('1')); - BOOST_CHECK_EQUAL(false, lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1)); - BOOST_CHECK_EQUAL(false, lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1.0)); - BOOST_CHECK_EQUAL(false, lexical_cast(0.0)); - BOOST_CHECK_EQUAL(true, lexical_cast(true)); - BOOST_CHECK_EQUAL(false, lexical_cast(false)); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_EQUAL(true, lexical_cast(std::string("1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::string("0"))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_string() -{ - BOOST_CHECK_EQUAL("A", lexical_cast('A')); - BOOST_CHECK_EQUAL(" ", lexical_cast(' ')); - BOOST_CHECK_EQUAL("123", lexical_cast(123)); - BOOST_CHECK_EQUAL("1.23", lexical_cast(1.23)); - BOOST_CHECK_EQUAL("1.111111111", lexical_cast(1.111111111)); - BOOST_CHECK_EQUAL("1", lexical_cast(true)); - BOOST_CHECK_EQUAL("0", lexical_cast(false)); - BOOST_CHECK_EQUAL("Test", lexical_cast("Test")); - BOOST_CHECK_EQUAL(" ", lexical_cast(" ")); - BOOST_CHECK_EQUAL("", lexical_cast("")); - BOOST_CHECK_EQUAL("Test", lexical_cast(std::string("Test"))); - BOOST_CHECK_EQUAL(" ", lexical_cast(std::string(" "))); - BOOST_CHECK_EQUAL("", lexical_cast(std::string(""))); -} - -void test_conversion_from_to_wchar_t_alias() -{ - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(std::string("123"), - lexical_cast(static_cast(123))); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123u)); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123ul)); -} - -void test_conversion_to_pointer() -{ - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #endif -} - -void test_conversion_from_wchar_t() -{ -#ifndef DISABLE_WIDE_CHAR_SUPPORT -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(1, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - - BOOST_CHECK_EQUAL(123, lexical_cast(L"123")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(1.0, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - - BOOST_CHECK_EQUAL(1.23, lexical_cast(L"1.23")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(true, lexical_cast(L'1')); - BOOST_CHECK_EQUAL(false, lexical_cast(L'0')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - BOOST_CHECK_EQUAL(true, lexical_cast(L"1")); - BOOST_CHECK_EQUAL(false, lexical_cast(L"0")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); -#endif -} - -void test_conversion_to_wchar_t() -{ -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(L'1', lexical_cast(1)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL(L'1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0.0)); - BOOST_CHECK_EQUAL(L'1', lexical_cast(true)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(false)); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L'A')); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L' ')); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L"A")); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L" ")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(L'A', lexical_cast(std::wstring(L"A"))); - BOOST_CHECK_EQUAL(L' ', lexical_cast(std::wstring(L" "))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - #endif -} - -void test_conversion_from_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_EQUAL(123, lexical_cast(std::wstring(L"123"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - - BOOST_CHECK_EQUAL(true, lexical_cast(std::wstring(L"1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::wstring(L"0"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - #endif -} - -void test_conversion_to_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK(L"123" == lexical_cast(123)); - BOOST_CHECK(L"1.23" == lexical_cast(1.23)); - BOOST_CHECK(L"1.111111111" == lexical_cast(1.111111111)); - BOOST_CHECK(L"1" == lexical_cast(true)); - BOOST_CHECK(L"0" == lexical_cast(false)); -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK(L"A" == lexical_cast(L'A')); - BOOST_CHECK(L" " == lexical_cast(L' ')); -#endif - BOOST_CHECK(L"Test" == lexical_cast(L"Test")); - BOOST_CHECK(L" " == lexical_cast(L" ")); - BOOST_CHECK(L"" == lexical_cast(L"")); - BOOST_CHECK(L"Test" == lexical_cast(std::wstring(L"Test"))); - BOOST_CHECK(L" " == lexical_cast(std::wstring(L" "))); - BOOST_CHECK(L"" == lexical_cast(std::wstring(L""))); - #endif -} - -void test_bad_lexical_cast() -{ - try - { - lexical_cast(std::string("Test")); - - BOOST_CHECK(false); // Exception expected - } - catch(const bad_lexical_cast &e) - { - BOOST_CHECK(e.source_type() == typeid(std::string)); - BOOST_CHECK(e.target_type() == typeid(int)); - } -} - -void test_no_whitespace_stripping() -{ - BOOST_CHECK_THROW(lexical_cast(" 123"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("123 "), bad_lexical_cast); -} diff --git a/numeric_cast_test.cpp b/numeric_cast_test.cpp deleted file mode 100644 index 0b5bcde..0000000 --- a/numeric_cast_test.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright Beman Dawes, Dave Abrahams 1999. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version including documentation. - -// Revision History -// 28 Set 04 factored out numeric_cast<> test (Fernando Cacciola) -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include // for DBL_MAX (Peter Schmid) -#include - -#include "boost/test/minimal.hpp" - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - - -int test_main( int argc, char * argv[] ) -{ - -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test implicit_cast and numeric_cast -------------------------------------// - - // tests which should succeed - long small_value = 1; - long small_negative_value = -1; - long large_value = LONG_MAX; - long large_negative_value = LONG_MIN; - signed char c = 0; - - c = large_value; // see if compiler generates warning - - c = numeric_cast( small_value ); - BOOST_CHECK( c == 1 ); - c = 0; - c = numeric_cast( small_value ); - BOOST_CHECK( c == 1 ); - c = 0; - c = numeric_cast( small_negative_value ); - BOOST_CHECK( c == -1 ); - - // These tests courtesy of Joe R NWP Swatosh - BOOST_CHECK( 0.0f == numeric_cast( 0.0 ) ); - BOOST_CHECK( 0.0 == numeric_cast( 0.0 ) ); - - // tests which should result in errors being detected - - bool caught_exception = false; - try { c = numeric_cast( large_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #1\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { c = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #2\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - unsigned long ul; - caught_exception = false; - try { ul = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #3\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { ul = numeric_cast( small_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #4\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { numeric_cast( DBL_MAX ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #5\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - return 0 ; -} diff --git a/test.hpp b/test.hpp deleted file mode 100644 index 4c7eecb..0000000 --- a/test.hpp +++ /dev/null @@ -1,308 +0,0 @@ -// what: simple unit test framework -// who: developed by Kevlin Henney -// when: November 2000 -// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.91 -// -// ChangeLog: -// 20 Jan 2001 - Fixed a warning for MSVC (Dave Abrahams) - -#ifndef TEST_INCLUDED -#define TEST_INCLUDED - -#include -#include -#include // for out-of-the-box g++ -#include - -namespace test // test tuple comprises name and nullary function (object) -{ - template - struct test - { - string_type name; - function_type action; - - static test make(string_type name, function_type action) - { - test result; // MSVC aggreggate initializer bugs - result.name = name; - result.action = action; - return result; - } - }; -} - -namespace test // failure exception used to indicate checked test failures -{ - class failure : public std::exception - { - public: // struction (default cases are OK) - - failure(const std::string & why) - : reason(why) - { - } - - // std::~string has no exception-specification (could throw anything), - // but we need to be compatible with std::~exception's empty one - // see std::15.4p13 and std::15.4p3 - ~failure() throw() - { - } - - public: // usage - - virtual const char * what() const throw() - { - return reason.c_str(); - } - - private: // representation - - std::string reason; - - }; -} - -namespace test // not_implemented exception used to mark unimplemented tests -{ - class not_implemented : public std::exception - { - public: // usage (default ctor and dtor are OK) - - virtual const char * what() const throw() - { - return "not implemented"; - } - - }; -} - -namespace test // test utilities -{ - inline void check(bool condition, const std::string & description) - { - if(!condition) - { - throw failure(description); - } - } - - inline void check_true(bool value, const std::string & description) - { - check(value, "expected true: " + description); - } - - inline void check_false(bool value, const std::string & description) - { - check(!value, "expected false: " + description); - } - - template - void check_equal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs == rhs, "expected equal values: " + description); - } - - template - void check_unequal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs != rhs, "expected unequal values: " + description); - } - - inline void check_null(const void* ptr, const std::string & description) - { - check(!ptr, "expected null pointer: " + description); - } - - inline void check_non_null(const void* ptr, const std::string & description) - { - check(ptr != 0, "expected non-null pointer: " + description); - } -} - -#define TEST_CHECK_THROW(expression, exception, description) \ - try \ - { \ - expression; \ - throw ::test::failure(description); \ - } \ - catch(exception &) \ - { \ - } - -namespace test // memory tracking (enabled if test new and delete linked in) -{ - class allocations - { - public: // singleton access - - static allocations & instance() - { - static allocations singleton; - return singleton; - } - - public: // logging - - void clear() - { - alloc_count = dealloc_count = 0; - } - - void allocation() - { - ++alloc_count; - } - - void deallocation() - { - ++dealloc_count; - } - - public: // reporting - - unsigned long allocated() const - { - return alloc_count; - } - - unsigned long deallocated() const - { - return dealloc_count; - } - - bool balanced() const - { - return alloc_count == dealloc_count; - } - - private: // structors (default dtor is fine) - - allocations() - : alloc_count(0), dealloc_count(0) - { - } - - private: // prevention - - allocations(const allocations &); - allocations & operator=(const allocations &); - - private: // state - - unsigned long alloc_count, dealloc_count; - - }; -} - -namespace test // tester is the driver class for a sequence of tests -{ - template - class tester - { - public: // structors (default destructor is OK) - - tester(test_iterator first_test, test_iterator after_last_test) - : begin(first_test), end(after_last_test) - { - } - - public: // usage - - bool operator()(); // returns true if all tests passed - - private: // representation - - test_iterator begin, end; - - private: // prevention - - tester(const tester &); - tester &operator=(const tester &); - - }; - - template - bool tester::operator()() - { - using namespace std; - - unsigned long passed = 0, failed = 0, unimplemented = 0; - - for(test_iterator current = begin; current != end; ++current) - { - cerr << "[" << current->name << "] " << flush; - string result = "passed"; // optimistic - - try - { - allocations::instance().clear(); - current->action(); - - if(!allocations::instance().balanced()) - { - unsigned long allocated = allocations::instance().allocated(); - unsigned long deallocated = allocations::instance().deallocated(); - ostrstream report; - report << "new/delete (" - << allocated << " allocated, " - << deallocated << " deallocated)" - << ends; - const char * text = report.str(); - report.freeze(false); - throw failure(text); - } - - ++passed; - } - catch(const failure & caught) - { - (result = "failed: ") += caught.what(); - ++failed; - } - catch(const not_implemented &) - { - result = "not implemented"; - ++unimplemented; - } - catch(const exception & caught) - { - (result = "exception: ") += caught.what(); - ++failed; - } - catch(...) - { - result = "failed with unknown exception"; - ++failed; - } - - cerr << result << endl; - } - - cerr << passed + failed << " tests: " - << passed << " passed, " - << failed << " failed"; - - if(unimplemented) - { - cerr << " (" << unimplemented << " not implemented)"; - } - - cerr << endl; - - return failed == 0; - } -} - -#endif - -// Copyright Kevlin Henney, 2000. All rights reserved. -// -// 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) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 deleted file mode 100644 index 56a03d8..0000000 --- a/test/Jamfile.v2 +++ /dev/null @@ -1,26 +0,0 @@ -# Signals library - -# Copyright (C) 2001-2003 Douglas Gregor - -# Permission to copy, use, sell and distribute this software is granted -# provided this copyright notice appears in all copies. Permission to modify -# the code and to distribute modified code is granted provided this copyright -# notice appears in all copies, and a notice that the code was modified is -# included with the copyright notice. This software is provided "as is" -# without express or implied warranty, and with no claim as to its suitability -# for any purpose. - -# For more information, see http://www.boost.org/ - -# bring in rules for testing -import testing ; - -test-suite conversion - : [ run implicit_cast.cpp ] - [ compile-fail implicit_cast_fail.cpp ] - [ run ../cast_test.cpp ] - [ run ../numeric_cast_test.cpp ] - [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/static ] - ; - - diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp deleted file mode 100644 index e18e17a..0000000 --- a/test/implicit_cast.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright David Abrahams 2003. -// 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) - -#include -#include -#include -using boost::implicit_cast; -using boost::type; - -template -type check_return(T) { return type(); } - -struct foo -{ - foo(char const*) {} - operator long() const { return 0; } -}; - -typedef type long_type; -typedef type foo_type; - -int main() -{ - type x = check_return(boost::implicit_cast(1)); - BOOST_TEST(boost::implicit_cast(1) == 1L); - - type f = check_return(boost::implicit_cast("hello")); - type z = check_return(boost::implicit_cast(foo("hello"))); - return boost::report_errors(); -} diff --git a/test/implicit_cast_fail.cpp b/test/implicit_cast_fail.cpp deleted file mode 100644 index 80143da..0000000 --- a/test/implicit_cast_fail.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright David Abrahams 2003. -// 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) - -#include -#include - -#define BOOST_INCLUDE_MAIN -#include - -using boost::implicit_cast; - -struct foo -{ - explicit foo(char const*) {} -}; - -int test_main(int, char*[]) -{ - foo x = implicit_cast("foobar"); -} From 2273077563f6c25eae7701c8842360293592e48d Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 19 Jun 2007 01:09:16 +0000 Subject: [PATCH 034/138] This commit was manufactured by cvs2svn to create tag 'SPIRIT_MINIBOOST_1_34_0'. [SVN r38032] --- cast.htm | 140 ---------------- cast_test.cpp | 91 ---------- include/boost/cast.hpp | 107 ------------ index.html | 38 ----- lexical_cast.htm | 234 -------------------------- lexical_cast_test.cpp | 320 ------------------------------------ numeric_cast_test.cpp | 100 ----------- test.hpp | 308 ---------------------------------- test/Jamfile.v2 | 26 --- test/implicit_cast.cpp | 32 ---- test/implicit_cast_fail.cpp | 22 --- 11 files changed, 1418 deletions(-) delete mode 100644 cast.htm delete mode 100644 cast_test.cpp delete mode 100644 include/boost/cast.hpp delete mode 100644 index.html delete mode 100644 lexical_cast.htm delete mode 100644 lexical_cast_test.cpp delete mode 100644 numeric_cast_test.cpp delete mode 100644 test.hpp delete mode 100644 test/Jamfile.v2 delete mode 100644 test/implicit_cast.cpp delete mode 100644 test/implicit_cast_fail.cpp diff --git a/cast.htm b/cast.htm deleted file mode 100644 index 587d08a..0000000 --- a/cast.htm +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - - Header boost/cast.hpp Documentation - - - -

boost.png (6897 bytes)Header boost/cast.hpp

- -

Cast Functions

- -

The header boost/cast.hpp provides - polymorphic_cast and polymorphic_downcast function templates designed to - complement the C++ built-in casts.

- -

The program cast_test.cpp can be used to - verify these function templates work as expected.

- -

Polymorphic casts

- -

Pointers to polymorphic objects (objects of classes which define at - least one virtual function) are sometimes downcast or crosscast. - Downcasting means casting from a base class to a derived class. - Crosscasting means casting across an inheritance hierarchy diagram, such - as from one base to the other in a Y diagram hierarchy.

- -

Such casts can be done with old-style casts, but this approach is - never to be recommended. Old-style casts are sorely lacking in type - safety, suffer poor readability, and are difficult to locate with search - tools.

- -

The C++ built-in static_cast can be used for efficiently - downcasting pointers to polymorphic objects, but provides no error - detection for the case where the pointer being cast actually points to - the wrong derived class. The polymorphic_downcast template retains - the efficiency of static_cast for non-debug compilations, but for - debug compilations adds safety via an assert() that a dynamic_cast - succeeds.

- -

The C++ built-in dynamic_cast can be used for downcasts and - crosscasts of pointers to polymorphic objects, but error notification in - the form of a returned value of 0 is inconvenient to test, or worse yet, - easy to forget to test. The throwing form of dynamic_cast, which - works on references, can be used on pointers through the ugly expression - &dynamic_cast<T&>(*p), which causes undefined - behavior if p is 0. The polymorphic_cast - template performs a dynamic_cast on a pointer, and throws an - exception if the dynamic_cast returns 0.

- -

A polymorphic_downcast should be used for - downcasts that you are certain should succeed. Error checking is - only performed in translation units where NDEBUG is - not defined, via -

  assert( dynamic_cast<Derived>(x) == x )
-
where x is the source pointer. This approach - ensures that not only is a non-zero pointer returned, but also - that it is correct in the presence of multiple inheritance. - Attempts to crosscast using polymorphic_downcast will - fail to compile. - Warning: Because polymorphic_downcast uses assert(), it - violates the One Definition Rule (ODR) if NDEBUG is inconsistently - defined across translation units. [See ISO Std 3.2] -

- For crosscasts, or when the success of a cast can only be known at - runtime, or when efficiency is not important, - polymorphic_cast is preferred.

- -

The C++ built-in dynamic_cast must be used to cast references - rather than pointers. It is also the only cast that can be used to check - whether a given interface is supported; in that case a return of 0 isn't - an error condition.

- -

polymorphic_cast and polymorphic_downcast synopsis

- -
-
namespace boost {
-
-template <class Derived, class Base>
-inline Derived polymorphic_cast(Base* x);
-// Throws: std::bad_cast if ( dynamic_cast<Derived>(x) == 0 )
-// Returns: dynamic_cast<Derived>(x)
-
-template <class Derived, class Base>
-inline Derived polymorphic_downcast(Base* x);
-// Effects: assert( dynamic_cast<Derived>(x) == x );
-// Returns: static_cast<Derived>(x)
-
-}
-
-
- -

polymorphic_downcast example

- -
-
#include <boost/cast.hpp>
-...
-class Fruit { public: virtual ~Fruit(){}; ... };
-class Banana : public Fruit { ... };
-...
-void f( Fruit * fruit ) {
-// ... logic which leads us to believe it is a Banana
-  Banana * banana = boost::polymorphic_downcast<Banana*>(fruit);
-  ...
-
-
- -

History

- -

polymorphic_cast was suggested by Bjarne Stroustrup in "The C++ - Programming Language".
- polymorphic_downcast was contributed by Dave Abrahams.
- An old - numeric_cast
that was contributed by Kevlin Henney is now superseeded by the Boost Numeric Conversion Library

-
- -

Revised - June 23, 2005

- -

© Copyright boost.org 1999. Permission to copy, use, modify, sell - and distribute this document is granted provided this copyright notice - appears in all copies. This document is provided "as is" without express - or implied warranty, and with no claim as to its suitability for any - purpose.

- - \ No newline at end of file diff --git a/cast_test.cpp b/cast_test.cpp deleted file mode 100644 index ad6b18f..0000000 --- a/cast_test.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright Beman Dawes, Dave Abrahams 1999. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version including documentation. - -// Revision History -// 28 Set 04 factored out numeric_cast<> test (Fernando Cacciola) -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include // for DBL_MAX (Peter Schmid) -#include - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - -namespace -{ - struct Base - { - virtual char kind() { return 'B'; } - }; - - struct Base2 - { - virtual char kind2() { return '2'; } - }; - - struct Derived : public Base, Base2 - { - virtual char kind() { return 'D'; } - }; -} - - -int main( int argc, char * argv[] ) -{ -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test polymorphic_cast ---------------------------------------------------// - - // tests which should succeed - Base * base = new Derived; - Base2 * base2 = 0; - Derived * derived = 0; - derived = polymorphic_downcast( base ); // downcast - assert( derived->kind() == 'D' ); - - derived = 0; - derived = polymorphic_cast( base ); // downcast, throw on error - assert( derived->kind() == 'D' ); - - base2 = polymorphic_cast( base ); // crosscast - assert( base2->kind2() == '2' ); - - // tests which should result in errors being detected - int err_count = 0; - base = new Base; - - if ( argc > 1 && *argv[1] == '1' ) - { derived = polymorphic_downcast( base ); } // #1 assert failure - - bool caught_exception = false; - try { derived = polymorphic_cast( base ); } - catch (std::bad_cast) - { cout<<"caught bad_cast\n"; caught_exception = true; } - if ( !caught_exception ) ++err_count; - // the following is just so generated code can be inspected - if ( derived->kind() == 'B' ) ++err_count; - - cout << err_count << " errors detected\nTest " - << (err_count==0 ? "passed\n" : "failed\n"); - return err_count; -} // main diff --git a/include/boost/cast.hpp b/include/boost/cast.hpp deleted file mode 100644 index 2615d18..0000000 --- a/include/boost/cast.hpp +++ /dev/null @@ -1,107 +0,0 @@ -// boost cast.hpp header file ----------------------------------------------// - -// (C) Copyright Kevlin Henney and Dave Abrahams 1999. -// Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org/libs/conversion for Documentation. - -// Revision History -// 23 JUn 05 numeric_cast removed and redirected to the new verion (Fernando Cacciola) -// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included -// instead (the workaround did not -// actually compile when BOOST_NO_LIMITS was defined in -// any case, so we loose nothing). (John Maddock) -// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never -// worked with stock GCC; trying to get it to do that broke -// vc-stlport. -// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp. -// Removed unused BOOST_EXPLICIT_TARGET macro. Moved -// boost::detail::type to boost/type.hpp. Made it compile with -// stock gcc again (Dave Abrahams) -// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal -// Review (Beman Dawes) -// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams) -// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC -// (Dave Abrahams) -// 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams) -// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes) -// 27 Jun 00 More MSVC6 workarounds -// 15 Jun 00 Add workarounds for MSVC6 -// 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov) -// 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar) -// 29 Dec 99 Change using declarations so usages in other namespaces work -// correctly (Dave Abrahams) -// 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors -// as suggested Darin Adler and improved by Valentin Bonnard. -// 2 Sep 99 Remove controversial asserts, simplify, rename. -// 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast, -// place in nested namespace. -// 3 Aug 99 Initial version - -#ifndef BOOST_CAST_HPP -#define BOOST_CAST_HPP - -# include -# include -# include -# include -# include -# include - -// It has been demonstrated numerous times that MSVC 6.0 fails silently at link -// time if you use a template function which has template parameters that don't -// appear in the function's argument list. -// -// TODO: Add this to config.hpp? -# if defined(BOOST_MSVC) && BOOST_MSVC < 1300 -# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type* = 0 -# else -# define BOOST_EXPLICIT_DEFAULT_TARGET -# endif - -namespace boost -{ -// See the documentation for descriptions of how to choose between -// static_cast<>, dynamic_cast<>, polymorphic_cast<> and polymorphic_downcast<> - -// polymorphic_cast --------------------------------------------------------// - - // Runtime checked polymorphic downcasts and crosscasts. - // Suggested in The C++ Programming Language, 3rd Ed, Bjarne Stroustrup, - // section 15.8 exercise 1, page 425. - - template - inline Target polymorphic_cast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) - { - Target tmp = dynamic_cast(x); - if ( tmp == 0 ) throw std::bad_cast(); - return tmp; - } - -// polymorphic_downcast ----------------------------------------------------// - - // BOOST_ASSERT() checked polymorphic downcast. Crosscasts prohibited. - - // WARNING: Because this cast uses BOOST_ASSERT(), it violates - // the One Definition Rule if used in multiple translation units - // where BOOST_DISABLE_ASSERTS, BOOST_ENABLE_ASSERT_HANDLER - // NDEBUG are defined inconsistently. - - // Contributed by Dave Abrahams - - template - inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) - { - BOOST_ASSERT( dynamic_cast(x) == x ); // detect logic error - return static_cast(x); - } - -# undef BOOST_EXPLICIT_DEFAULT_TARGET - -} // namespace boost - -# include - -#endif // BOOST_CAST_HPP diff --git a/index.html b/index.html deleted file mode 100644 index cf8527f..0000000 --- a/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - -Boost Conversion Library - - - - -

Boost -Conversion Library

- -

The Conversion Library improves program safety and clarity by performing -otherwise messy conversions.  It includes cast-style function templates designed to complement the C++ -Standard's built-in casts.

-

To reduce coupling, particularly to standard library IOStreams, the Boost -Conversion Library is -supplied by several headers:

-
    -
  • The boost/cast header provides polymorphic_cast<> - and polymorphic_downcast<> to perform safe casting between - polymorphic types.
    -
  • -
  • The boost/lexical_cast header provides lexical_cast<> - general literal text conversions, such as an int represented as - a string, or vice-versa.
  • -
-
-

Revised June 23, 2005 -

- - - - \ No newline at end of file diff --git a/lexical_cast.htm b/lexical_cast.htm deleted file mode 100644 index 949b70c..0000000 --- a/lexical_cast.htm +++ /dev/null @@ -1,234 +0,0 @@ - - - - - lexical_cast - - - - -

boost.png (6897 bytes)Header - boost/lexical_cast.hpp

- -
-

Motivation

- Sometimes a value must be converted to a literal text form, such as an int - represented as a string, or vice-versa, when a string - is interpreted as an int. Such examples are common when converting - between data types internal to a program and representation external to a - program, such as windows and configuration files. -

- The standard C and C++ libraries offer a number of facilities for performing - such conversions. However, they vary with their ease of use, extensibility, and - safety. -

- For instance, there are a number of limitations with the family of standard C - functions typified by atoi: -

    -
  • - Conversion is supported in one direction only: from text to internal data type. - Converting the other way using the C library requires either the inconvenience - and compromised safety of the sprintf function, or the loss of - portability associated with non-standard functions such as itoa. -
  • -
  • - The range of types supported is only a subset of the built-in numeric types, - namely int, long, and double. -
  • -
  • - The range of types cannot be extended in a uniform manner. For instance, - conversion from string representation to complex or rational. -
  • -
- The standard C functions typified by strtol have the same basic - limitations, but offer finer control over the conversion process. However, for - the common case such control is often either not required or not used. The scanf - family of functions offer even greater control, but also lack safety and ease - of use. -

- The standard C++ library offers stringstream for the kind of - in-core formatting being discussed. It offers a great deal of control over the - formatting and conversion of I/O to and from arbitrary types through text. - However, for simple conversions direct use of stringstream can be - either clumsy (with the introduction of extra local variables and the loss of - infix-expression convenience) or obscure (where stringstream - objects are created as temporary objects in an expression). Facets provide a - comprehensive concept and facility for controlling textual representation, but - their perceived complexity and high entry level requires an extreme degree of - involvement for simple conversions, and excludes all but a few programmers. -

- The lexical_cast function template offers a convenient and - consistent form for supporting common conversions to and from arbitrary types - when they are represented as text. The simplification it offers is in - expression-level convenience for such conversions. For more involved - conversions, such as where precision or formatting need tighter control than is - offered by the default behavior of lexical_cast, the conventional - stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast - may offer more reasonable behavior than lexical_cast. -

- For a good discussion of the options and issues involved in string-based - formatting, including comparison of stringstream, lexical_cast, - and others, see Herb Sutter's article, - The String Formatters of Manor Farm. -

-


-

Examples

- The following example treats command line arguments as a sequence of numeric - data:
-
int main(int argc, char * argv[])
-{
-    using boost::lexical_cast;
-    using boost::bad_lexical_cast;
-
-    std::vector<short> args;
-
-    while(*++argv)
-    {
-        try
-        {
-            args.push_back(lexical_cast<short>(*argv));
-        }
-        catch(bad_lexical_cast &)
-        {
-            args.push_back(0);
-        }
-    }
-    ...
-}
-
-
The following example uses numeric data in a string expression:
-
void log_message(const std::string &);
-
-void log_errno(int yoko)
-{
-    log_message("Error " + boost::lexical_cast<std::string>(yoko) + ": " + strerror(yoko));
-}
-
-
-
-

Synopsis

- Library features defined in "boost/lexical_cast.hpp": -
-
namespace boost
-{
-    class bad_lexical_cast;
-    template<typename Target, typename Source>
-      Target lexical_cast(const Source& arg);
-}
-
-
Unit test defined in "lexical_cast_test.cpp". -

-


-

lexical_cast

-
-
template<typename Target, typename Source>
-  Target lexical_cast(const Source& arg);
-
-
Returns the result of streaming arg into a - standard library string-based stream and then out as a Target object. - Where Target is either std::string - or std::wstring, stream extraction takes the whole content - of the string, including spaces, rather than relying on the default - operator>> behavior. - If the conversion is unsuccessful, a - bad_lexical_cast exception is thrown. -

- The requirements on the argument and result types are: -

    -
  • - Source is OutputStreamable, meaning that an operator<< - is defined that takes a std::ostream or std::wostream object on the - left hand side and an instance of the argument type on the right. -
  • -
  • - Target is InputStreamable, meaning that an operator>> - is defined that takes a std::istream or std::wistream object on the left hand side - and an instance of the result type on the right. -
  • -
  • - Both Source and Target are CopyConstructible [20.1.3]. -
  • -
  • - Target is DefaultConstructible, meaning that it is possible - to default-initialize an object of that type [8.5, 20.1.4]. -
  • -
- The character type of the underlying stream is assumed to be char unless - either the Source or the Target requires wide-character - streaming, in which case the underlying stream uses wchar_t. - Source types that require wide-character streaming are wchar_t, - wchar_t *, and std::wstring. Target types that - require wide-character streaming are wchar_t and std::wstring. -

- Where a higher degree of control is required over conversions, std::stringstream - and std::wstringstream offer a more appropriate path. Where non-stream-based conversions are - required, lexical_cast - is the wrong tool for the job and is not special-cased for such scenarios. -

-


-

bad_lexical_cast

-
-
class bad_lexical_cast : public std::bad_cast
-{
-public:
-    ... // same member function interface as std::exception
-};
-
-
Exception used to indicate runtime lexical_cast - failure. -
- -

Changes

-

June 2005:

-
    -
  • Call-by-const reference for the parameters. This requires partial specialization - of class templates, so it doesn't work for MSVC 6, and it uses the original - pass by value there.
    -
  • -
  • The MSVC 6 support is deprecated, and will be removed in a future Boost - version.
  • -
-

Earlier:

- -
    -
  • The previous version of lexical_cast used the default stream - precision for reading and writing floating-point numbers. For numerics that - have a corresponding specialization of std::numeric_limits, the - current version now chooses a precision to match.
    -
  • The previous version of lexical_cast did not support conversion - to or from any wide-character-based types. For compilers with full language - and library support for wide characters, lexical_cast now supports - conversions from wchar_t, wchar_t *, and std::wstring - and to wchar_t and std::wstring.
    -
  • The previous version of lexical_cast assumed that the conventional - stream extractor operators were sufficient for reading values. However, string - I/O is asymmetric, with the result that spaces play the role of I/O separators - rather than string content. The current version fixes this error for std::string - and, where supported, std::wstring: lexical_cast<std::string>("Hello, - World") succeeds instead of failing with a bad_lexical_cast - exception.
    -
  • The previous version of lexical_cast allowed unsafe and meaningless - conversions to pointers. The current version now throws a bad_lexical_cast - for conversions to pointers: lexical_cast<char *>("Goodbye, World") - now throws an exception instead of causing undefined behavior. -
-

-


- -
© Copyright Kevlin Henney, 2000–2005
- - \ No newline at end of file diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp deleted file mode 100644 index 4182942..0000000 --- a/lexical_cast_test.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// Unit test for boost::lexical_cast. -// -// See http://www.boost.org for most recent version, including documentation. -// -// Copyright Terje Slettebø and Kevlin Henney, 2005. -// -// 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). -// -// Note: The unit test no longer compile on MSVC 6, but lexical_cast itself works for it. - -#include - -#if defined(__INTEL_COMPILER) -#pragma warning(disable: 193 383 488 981 1418 1419) -#elif defined(BOOST_MSVC) -#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) -#endif - -#include - -#include -#include - -#if defined(BOOST_NO_STRINGSTREAM) || \ - defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) -#define DISABLE_WIDE_CHAR_SUPPORT -#endif - -using namespace boost; - -void test_conversion_to_char(); -void test_conversion_to_int(); -void test_conversion_to_double(); -void test_conversion_to_bool(); -void test_conversion_to_string(); -void test_conversion_from_to_wchar_t_alias(); -void test_conversion_to_pointer(); -void test_conversion_from_wchar_t(); -void test_conversion_to_wchar_t(); -void test_conversion_from_wstring(); -void test_conversion_to_wstring(); -void test_bad_lexical_cast(); -void test_no_whitespace_stripping(); - -unit_test::test_suite *init_unit_test_suite(int, char *[]) -{ - unit_test_framework::test_suite *suite = - BOOST_TEST_SUITE("lexical_cast unit test"); - suite->add(BOOST_TEST_CASE(test_conversion_to_char)); - suite->add(BOOST_TEST_CASE(test_conversion_to_int)); - suite->add(BOOST_TEST_CASE(test_conversion_to_double)); - suite->add(BOOST_TEST_CASE(test_conversion_to_bool)); - suite->add(BOOST_TEST_CASE(test_conversion_from_to_wchar_t_alias)); - suite->add(BOOST_TEST_CASE(test_conversion_to_pointer)); - suite->add(BOOST_TEST_CASE(test_conversion_to_string)); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t)); - suite->add(BOOST_TEST_CASE(test_conversion_from_wstring)); - suite->add(BOOST_TEST_CASE(test_conversion_to_wstring)); - #endif - suite->add(BOOST_TEST_CASE(test_bad_lexical_cast)); - suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping)); - return suite; -} - -void test_conversion_to_char() -{ - BOOST_CHECK_EQUAL('A', lexical_cast('A')); - BOOST_CHECK_EQUAL(' ', lexical_cast(' ')); - BOOST_CHECK_EQUAL('1', lexical_cast(1)); - BOOST_CHECK_EQUAL('0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL('1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL('1', lexical_cast(true)); - BOOST_CHECK_EQUAL('0', lexical_cast(false)); - BOOST_CHECK_EQUAL('A', lexical_cast("A")); - BOOST_CHECK_EQUAL(' ', lexical_cast(" ")); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL('A', lexical_cast(std::string("A"))); - BOOST_CHECK_EQUAL(' ', lexical_cast(std::string(" "))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_int() -{ - BOOST_CHECK_EQUAL(1, lexical_cast('1')); - BOOST_CHECK_EQUAL(0, lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_EQUAL(1, lexical_cast(1)); - BOOST_CHECK_EQUAL( - (std::numeric_limits::max)(), - lexical_cast((std::numeric_limits::max)())); - BOOST_CHECK_EQUAL(1, lexical_cast(1.0)); - - BOOST_CHECK_THROW(lexical_cast(1.23), bad_lexical_cast); - - BOOST_CHECK_THROW(lexical_cast(1e20), bad_lexical_cast); - BOOST_CHECK_EQUAL(1, lexical_cast(true)); - BOOST_CHECK_EQUAL(0, lexical_cast(false)); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_THROW( - lexical_cast(" 123"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(123, lexical_cast("123")); - BOOST_CHECK_EQUAL(123, lexical_cast(std::string("123"))); - BOOST_CHECK_THROW( - lexical_cast(std::string(" 123")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_double() -{ - BOOST_CHECK_CLOSE(1.0, lexical_cast('1'), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_CLOSE(1.0, lexical_cast(1), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.23, lexical_cast(1.23), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.234567890, 1.234567890, std::numeric_limits::epsilon()); - BOOST_CHECK_CLOSE(1.0, lexical_cast(true), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(0.0, lexical_cast(false), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.23, lexical_cast("1.23"), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_CLOSE(1.23, lexical_cast(std::string("1.23")), (std::numeric_limits::epsilon())); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_bool() -{ - BOOST_CHECK_EQUAL(true, lexical_cast('1')); - BOOST_CHECK_EQUAL(false, lexical_cast('0')); - BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1)); - BOOST_CHECK_EQUAL(false, lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast(1.0)); - BOOST_CHECK_EQUAL(false, lexical_cast(0.0)); - BOOST_CHECK_EQUAL(true, lexical_cast(true)); - BOOST_CHECK_EQUAL(false, lexical_cast(false)); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(true, lexical_cast("1")); - BOOST_CHECK_EQUAL(false, lexical_cast("0")); - BOOST_CHECK_EQUAL(true, lexical_cast(std::string("1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::string("0"))); - BOOST_CHECK_THROW( - lexical_cast(std::string("")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::string("Test")), bad_lexical_cast); -} - -void test_conversion_to_string() -{ - BOOST_CHECK_EQUAL("A", lexical_cast('A')); - BOOST_CHECK_EQUAL(" ", lexical_cast(' ')); - BOOST_CHECK_EQUAL("123", lexical_cast(123)); - BOOST_CHECK_EQUAL("1.23", lexical_cast(1.23)); - BOOST_CHECK_EQUAL("1.111111111", lexical_cast(1.111111111)); - BOOST_CHECK_EQUAL("1", lexical_cast(true)); - BOOST_CHECK_EQUAL("0", lexical_cast(false)); - BOOST_CHECK_EQUAL("Test", lexical_cast("Test")); - BOOST_CHECK_EQUAL(" ", lexical_cast(" ")); - BOOST_CHECK_EQUAL("", lexical_cast("")); - BOOST_CHECK_EQUAL("Test", lexical_cast(std::string("Test"))); - BOOST_CHECK_EQUAL(" ", lexical_cast(std::string(" "))); - BOOST_CHECK_EQUAL("", lexical_cast(std::string(""))); -} - -void test_conversion_from_to_wchar_t_alias() -{ - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(123u, lexical_cast("123")); - BOOST_CHECK_EQUAL(std::string("123"), - lexical_cast(static_cast(123))); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123u)); - BOOST_CHECK_EQUAL(std::string("123"), lexical_cast(123ul)); -} - -void test_conversion_to_pointer() -{ - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #endif -} - -void test_conversion_from_wchar_t() -{ -#ifndef DISABLE_WIDE_CHAR_SUPPORT -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(1, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - - BOOST_CHECK_EQUAL(123, lexical_cast(L"123")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(1.0, lexical_cast(L'1')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - - BOOST_CHECK_EQUAL(1.23, lexical_cast(L"1.23")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(true, lexical_cast(L'1')); - BOOST_CHECK_EQUAL(false, lexical_cast(L'0')); - BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); -#endif - BOOST_CHECK_EQUAL(true, lexical_cast(L"1")); - BOOST_CHECK_EQUAL(false, lexical_cast(L"0")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); -#endif -} - -void test_conversion_to_wchar_t() -{ -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK_EQUAL(L'1', lexical_cast(1)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0)); - BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); - BOOST_CHECK_EQUAL(L'1', lexical_cast(1.0)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(0.0)); - BOOST_CHECK_EQUAL(L'1', lexical_cast(true)); - BOOST_CHECK_EQUAL(L'0', lexical_cast(false)); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L'A')); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L' ')); - BOOST_CHECK_EQUAL(L'A', lexical_cast(L"A")); - BOOST_CHECK_EQUAL(L' ', lexical_cast(L" ")); - BOOST_CHECK_THROW(lexical_cast(L""), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(L"Test"), bad_lexical_cast); - BOOST_CHECK_EQUAL(L'A', lexical_cast(std::wstring(L"A"))); - BOOST_CHECK_EQUAL(L' ', lexical_cast(std::wstring(L" "))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - #endif -} - -void test_conversion_from_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK_EQUAL(123, lexical_cast(std::wstring(L"123"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - - BOOST_CHECK_EQUAL(true, lexical_cast(std::wstring(L"1"))); - BOOST_CHECK_EQUAL(false, lexical_cast(std::wstring(L"0"))); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"")), bad_lexical_cast); - BOOST_CHECK_THROW( - lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - #endif -} - -void test_conversion_to_wstring() -{ - #ifndef DISABLE_WIDE_CHAR_SUPPORT - BOOST_CHECK(L"123" == lexical_cast(123)); - BOOST_CHECK(L"1.23" == lexical_cast(1.23)); - BOOST_CHECK(L"1.111111111" == lexical_cast(1.111111111)); - BOOST_CHECK(L"1" == lexical_cast(true)); - BOOST_CHECK(L"0" == lexical_cast(false)); -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) - BOOST_CHECK(L"A" == lexical_cast(L'A')); - BOOST_CHECK(L" " == lexical_cast(L' ')); -#endif - BOOST_CHECK(L"Test" == lexical_cast(L"Test")); - BOOST_CHECK(L" " == lexical_cast(L" ")); - BOOST_CHECK(L"" == lexical_cast(L"")); - BOOST_CHECK(L"Test" == lexical_cast(std::wstring(L"Test"))); - BOOST_CHECK(L" " == lexical_cast(std::wstring(L" "))); - BOOST_CHECK(L"" == lexical_cast(std::wstring(L""))); - #endif -} - -void test_bad_lexical_cast() -{ - try - { - lexical_cast(std::string("Test")); - - BOOST_CHECK(false); // Exception expected - } - catch(const bad_lexical_cast &e) - { - BOOST_CHECK(e.source_type() == typeid(std::string)); - BOOST_CHECK(e.target_type() == typeid(int)); - } -} - -void test_no_whitespace_stripping() -{ - BOOST_CHECK_THROW(lexical_cast(" 123"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("123 "), bad_lexical_cast); -} diff --git a/numeric_cast_test.cpp b/numeric_cast_test.cpp deleted file mode 100644 index 0b5bcde..0000000 --- a/numeric_cast_test.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// boost utility cast test program -----------------------------------------// - -// (C) Copyright Beman Dawes, Dave Abrahams 1999. Distributed under the Boost -// Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -// See http://www.boost.org for most recent version including documentation. - -// Revision History -// 28 Set 04 factored out numeric_cast<> test (Fernando Cacciola) -// 20 Jan 01 removed use of for portability to raw GCC (David Abrahams) -// 28 Jun 00 implicit_cast removed (Beman Dawes) -// 30 Aug 99 value_cast replaced by numeric_cast -// 3 Aug 99 Initial Version - -#include -#include -#include // for DBL_MAX (Peter Schmid) -#include - -#include "boost/test/minimal.hpp" - -# if SCHAR_MAX == LONG_MAX -# error "This test program doesn't work if SCHAR_MAX == LONG_MAX" -# endif - -using namespace boost; -using std::cout; - - -int test_main( int argc, char * argv[] ) -{ - -# ifdef NDEBUG - cout << "NDEBUG is defined\n"; -# else - cout << "NDEBUG is not defined\n"; -# endif - - cout << "\nBeginning tests...\n"; - -// test implicit_cast and numeric_cast -------------------------------------// - - // tests which should succeed - long small_value = 1; - long small_negative_value = -1; - long large_value = LONG_MAX; - long large_negative_value = LONG_MIN; - signed char c = 0; - - c = large_value; // see if compiler generates warning - - c = numeric_cast( small_value ); - BOOST_CHECK( c == 1 ); - c = 0; - c = numeric_cast( small_value ); - BOOST_CHECK( c == 1 ); - c = 0; - c = numeric_cast( small_negative_value ); - BOOST_CHECK( c == -1 ); - - // These tests courtesy of Joe R NWP Swatosh - BOOST_CHECK( 0.0f == numeric_cast( 0.0 ) ); - BOOST_CHECK( 0.0 == numeric_cast( 0.0 ) ); - - // tests which should result in errors being detected - - bool caught_exception = false; - try { c = numeric_cast( large_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #1\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { c = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #2\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - unsigned long ul; - caught_exception = false; - try { ul = numeric_cast( large_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #3\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { ul = numeric_cast( small_negative_value ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #4\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - caught_exception = false; - try { numeric_cast( DBL_MAX ); } - catch (bad_numeric_cast) - { cout<<"caught bad_numeric_cast #5\n"; caught_exception = true; } - BOOST_CHECK ( caught_exception ); - - return 0 ; -} diff --git a/test.hpp b/test.hpp deleted file mode 100644 index 4c7eecb..0000000 --- a/test.hpp +++ /dev/null @@ -1,308 +0,0 @@ -// what: simple unit test framework -// who: developed by Kevlin Henney -// when: November 2000 -// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.91 -// -// ChangeLog: -// 20 Jan 2001 - Fixed a warning for MSVC (Dave Abrahams) - -#ifndef TEST_INCLUDED -#define TEST_INCLUDED - -#include -#include -#include // for out-of-the-box g++ -#include - -namespace test // test tuple comprises name and nullary function (object) -{ - template - struct test - { - string_type name; - function_type action; - - static test make(string_type name, function_type action) - { - test result; // MSVC aggreggate initializer bugs - result.name = name; - result.action = action; - return result; - } - }; -} - -namespace test // failure exception used to indicate checked test failures -{ - class failure : public std::exception - { - public: // struction (default cases are OK) - - failure(const std::string & why) - : reason(why) - { - } - - // std::~string has no exception-specification (could throw anything), - // but we need to be compatible with std::~exception's empty one - // see std::15.4p13 and std::15.4p3 - ~failure() throw() - { - } - - public: // usage - - virtual const char * what() const throw() - { - return reason.c_str(); - } - - private: // representation - - std::string reason; - - }; -} - -namespace test // not_implemented exception used to mark unimplemented tests -{ - class not_implemented : public std::exception - { - public: // usage (default ctor and dtor are OK) - - virtual const char * what() const throw() - { - return "not implemented"; - } - - }; -} - -namespace test // test utilities -{ - inline void check(bool condition, const std::string & description) - { - if(!condition) - { - throw failure(description); - } - } - - inline void check_true(bool value, const std::string & description) - { - check(value, "expected true: " + description); - } - - inline void check_false(bool value, const std::string & description) - { - check(!value, "expected false: " + description); - } - - template - void check_equal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs == rhs, "expected equal values: " + description); - } - - template - void check_unequal( - const lhs_type & lhs, const rhs_type & rhs, - const std::string & description) - { - check(lhs != rhs, "expected unequal values: " + description); - } - - inline void check_null(const void* ptr, const std::string & description) - { - check(!ptr, "expected null pointer: " + description); - } - - inline void check_non_null(const void* ptr, const std::string & description) - { - check(ptr != 0, "expected non-null pointer: " + description); - } -} - -#define TEST_CHECK_THROW(expression, exception, description) \ - try \ - { \ - expression; \ - throw ::test::failure(description); \ - } \ - catch(exception &) \ - { \ - } - -namespace test // memory tracking (enabled if test new and delete linked in) -{ - class allocations - { - public: // singleton access - - static allocations & instance() - { - static allocations singleton; - return singleton; - } - - public: // logging - - void clear() - { - alloc_count = dealloc_count = 0; - } - - void allocation() - { - ++alloc_count; - } - - void deallocation() - { - ++dealloc_count; - } - - public: // reporting - - unsigned long allocated() const - { - return alloc_count; - } - - unsigned long deallocated() const - { - return dealloc_count; - } - - bool balanced() const - { - return alloc_count == dealloc_count; - } - - private: // structors (default dtor is fine) - - allocations() - : alloc_count(0), dealloc_count(0) - { - } - - private: // prevention - - allocations(const allocations &); - allocations & operator=(const allocations &); - - private: // state - - unsigned long alloc_count, dealloc_count; - - }; -} - -namespace test // tester is the driver class for a sequence of tests -{ - template - class tester - { - public: // structors (default destructor is OK) - - tester(test_iterator first_test, test_iterator after_last_test) - : begin(first_test), end(after_last_test) - { - } - - public: // usage - - bool operator()(); // returns true if all tests passed - - private: // representation - - test_iterator begin, end; - - private: // prevention - - tester(const tester &); - tester &operator=(const tester &); - - }; - - template - bool tester::operator()() - { - using namespace std; - - unsigned long passed = 0, failed = 0, unimplemented = 0; - - for(test_iterator current = begin; current != end; ++current) - { - cerr << "[" << current->name << "] " << flush; - string result = "passed"; // optimistic - - try - { - allocations::instance().clear(); - current->action(); - - if(!allocations::instance().balanced()) - { - unsigned long allocated = allocations::instance().allocated(); - unsigned long deallocated = allocations::instance().deallocated(); - ostrstream report; - report << "new/delete (" - << allocated << " allocated, " - << deallocated << " deallocated)" - << ends; - const char * text = report.str(); - report.freeze(false); - throw failure(text); - } - - ++passed; - } - catch(const failure & caught) - { - (result = "failed: ") += caught.what(); - ++failed; - } - catch(const not_implemented &) - { - result = "not implemented"; - ++unimplemented; - } - catch(const exception & caught) - { - (result = "exception: ") += caught.what(); - ++failed; - } - catch(...) - { - result = "failed with unknown exception"; - ++failed; - } - - cerr << result << endl; - } - - cerr << passed + failed << " tests: " - << passed << " passed, " - << failed << " failed"; - - if(unimplemented) - { - cerr << " (" << unimplemented << " not implemented)"; - } - - cerr << endl; - - return failed == 0; - } -} - -#endif - -// Copyright Kevlin Henney, 2000. All rights reserved. -// -// 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) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 deleted file mode 100644 index 56a03d8..0000000 --- a/test/Jamfile.v2 +++ /dev/null @@ -1,26 +0,0 @@ -# Signals library - -# Copyright (C) 2001-2003 Douglas Gregor - -# Permission to copy, use, sell and distribute this software is granted -# provided this copyright notice appears in all copies. Permission to modify -# the code and to distribute modified code is granted provided this copyright -# notice appears in all copies, and a notice that the code was modified is -# included with the copyright notice. This software is provided "as is" -# without express or implied warranty, and with no claim as to its suitability -# for any purpose. - -# For more information, see http://www.boost.org/ - -# bring in rules for testing -import testing ; - -test-suite conversion - : [ run implicit_cast.cpp ] - [ compile-fail implicit_cast_fail.cpp ] - [ run ../cast_test.cpp ] - [ run ../numeric_cast_test.cpp ] - [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/static ] - ; - - diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp deleted file mode 100644 index e18e17a..0000000 --- a/test/implicit_cast.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright David Abrahams 2003. -// 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) - -#include -#include -#include -using boost::implicit_cast; -using boost::type; - -template -type check_return(T) { return type(); } - -struct foo -{ - foo(char const*) {} - operator long() const { return 0; } -}; - -typedef type long_type; -typedef type foo_type; - -int main() -{ - type x = check_return(boost::implicit_cast(1)); - BOOST_TEST(boost::implicit_cast(1) == 1L); - - type f = check_return(boost::implicit_cast("hello")); - type z = check_return(boost::implicit_cast(foo("hello"))); - return boost::report_errors(); -} diff --git a/test/implicit_cast_fail.cpp b/test/implicit_cast_fail.cpp deleted file mode 100644 index 80143da..0000000 --- a/test/implicit_cast_fail.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright David Abrahams 2003. -// 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) - -#include -#include - -#define BOOST_INCLUDE_MAIN -#include - -using boost::implicit_cast; - -struct foo -{ - explicit foo(char const*) {} -}; - -int test_main(int, char*[]) -{ - foo x = implicit_cast("foobar"); -} From d6eea4ef813d7df541f522c00a90b3f2dbe94392 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 24 Jul 2007 19:28:14 +0000 Subject: [PATCH 035/138] This commit was manufactured by cvs2svn to create tag 'Version_1_34_1'. [SVN r38286] From ba7b26b0589f6b0d0bd6cf614db8b0bfe9f61682 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 8 Aug 2007 21:34:10 +0000 Subject: [PATCH 036/138] development version of proto for new-style transforms [SVN r38539] From 7b03e3127eb71748b4d552ba7597752d7072ac7a Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Mon, 13 Aug 2007 03:23:47 +0000 Subject: [PATCH 037/138] Create branch for next serialization release [SVN r38613] From 9477a087c632658d51f6d7fd5793144b2d8463c8 Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Sun, 26 Aug 2007 05:34:35 +0000 Subject: [PATCH 038/138] Created a branch from trunk [SVN r38959] From 42ac4cab8a7b272df35bc3725824fcbf384d6495 Mon Sep 17 00:00:00 2001 From: Nicola Musatti Date: Mon, 17 Sep 2007 20:28:43 +0000 Subject: [PATCH 039/138] Branch for CodeGear (Borland) specific fixes [SVN r39356] From 4224fa5deb2709fd14239fef634a75ba081b4cbc Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 5 Oct 2007 14:25:06 +0000 Subject: [PATCH 040/138] Starting point for releases [SVN r39706] From f7c2a160b029be602c5727c3fa3f97e77d64ead2 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Tue, 6 Nov 2007 19:12:30 +0000 Subject: [PATCH 041/138] Merged revisions 38539-40814 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r38547 | djowel | 2007-08-08 19:07:16 -0700 (Wed, 08 Aug 2007) | 1 line fix line endings ........ r38548 | djowel | 2007-08-08 19:10:29 -0700 (Wed, 08 Aug 2007) | 1 line fixed error (wrong include file assign_key.hh) ........ r38549 | djowel | 2007-08-09 00:23:00 -0700 (Thu, 09 Aug 2007) | 1 line added fusion to libraries list. ........ r38551 | johnmaddock | 2007-08-09 02:26:56 -0700 (Thu, 09 Aug 2007) | 1 line Updated. ........ r38553 | bemandawes | 2007-08-09 07:56:05 -0700 (Thu, 09 Aug 2007) | 1 line Get boost.png from web site ........ r38555 | johnmaddock | 2007-08-09 10:13:18 -0700 (Thu, 09 Aug 2007) | 1 line Added another entry ........ r38558 | speedsnail | 2007-08-09 18:22:59 -0700 (Thu, 09 Aug 2007) | 1 line made the feature "format" propagated ........ r38559 | djowel | 2007-08-09 18:45:05 -0700 (Thu, 09 Aug 2007) | 1 line push/pop pragma warning ........ r38560 | djowel | 2007-08-09 18:45:21 -0700 (Thu, 09 Aug 2007) | 1 line push/pop pragma warning ........ r38561 | johnmaddock | 2007-08-10 03:10:05 -0700 (Fri, 10 Aug 2007) | 1 line Added two more entries. ........ r38562 | johnmaddock | 2007-08-10 03:11:03 -0700 (Fri, 10 Aug 2007) | 1 line Tidied up msvc-warning suppression code. ........ r38563 | (no author) | 2007-08-10 03:32:21 -0700 (Fri, 10 Aug 2007) | 4 lines Add overloads of hash_value for more built in types. They're not strictly needed and aren't in the original specifiction but they avoid a warning. See ticket #1095 for details. ........ r38564 | (no author) | 2007-08-10 04:08:19 -0700 (Fri, 10 Aug 2007) | 1 line Add some missing 'inline's. ........ r38565 | (no author) | 2007-08-10 04:22:54 -0700 (Fri, 10 Aug 2007) | 1 line Add -Wsign-promo to the hash test compile flags since I'm now trying to avoid the warning. I still need to check that it won't break older versions of gcc. ........ r38567 | bemandawes | 2007-08-10 05:53:52 -0700 (Fri, 10 Aug 2007) | 1 line Fix #995 by adding inline ........ r38568 | hkaiser | 2007-08-10 08:03:46 -0700 (Fri, 10 Aug 2007) | 1 line Wave: Added missing file to real_positions example, fixed corresponding Jamfile. ........ r38576 | vladimir_prus | 2007-08-10 09:33:48 -0700 (Fri, 10 Aug 2007) | 1 line Fix typo. Closes #1150. ........ r38587 | grafik | 2007-08-10 17:32:25 -0700 (Fri, 10 Aug 2007) | 1 line Add test to check 'bjam -n'. ........ r38588 | grafik | 2007-08-10 17:42:32 -0700 (Fri, 10 Aug 2007) | 1 line Minor adjustment to -n test, and add corresponding -d2 test. ........ r38590 | grafik | 2007-08-10 19:39:13 -0700 (Fri, 10 Aug 2007) | 1 line Bring back midding output of -n option. The -o option continues to be broken as it has been for a long time now because of the @ file feature. (fixes #1155) ........ r38591 | grafik | 2007-08-10 19:46:49 -0700 (Fri, 10 Aug 2007) | 1 line Make shell script executable. ........ r38592 | grafik | 2007-08-10 19:58:04 -0700 (Fri, 10 Aug 2007) | 1 line Adjust test to reflect real results of empty strings instead of empty values. ........ r38593 | vladimir_prus | 2007-08-10 22:15:54 -0700 (Fri, 10 Aug 2007) | 1 line Stop BoostBuild.py from crashing on certain test failures. ........ r38594 | grafik | 2007-08-10 22:53:37 -0700 (Fri, 10 Aug 2007) | 1 line Update GC support to work with Boehm GC 7.0. ........ r38605 | djowel | 2007-08-11 18:24:22 -0700 (Sat, 11 Aug 2007) | 1 line pragma push/pop added ........ r38606 | agurtovoy | 2007-08-11 23:10:45 -0700 (Sat, 11 Aug 2007) | 1 line Move /libs/expected_results.xml to the /status/ directory ........ r38614 | agurtovoy | 2007-08-12 21:36:40 -0700 (Sun, 12 Aug 2007) | 1 line CVS -> SVN ........ r38615 | grafik | 2007-08-12 23:11:14 -0700 (Sun, 12 Aug 2007) | 1 line SVN update and bjam build commands working. ........ r38616 | agurtovoy | 2007-08-13 01:14:34 -0700 (Mon, 13 Aug 2007) | 1 line Update http://www.boost.org/regression/ redirects ........ r38618 | speedsnail | 2007-08-13 08:35:16 -0700 (Mon, 13 Aug 2007) | 2 lines Revert the last change, since the directory passed to boost-build should be first in searched paths, else project local build system will not be picked correctly. The order had been changed to allow searching of alternate user-config.jam files from boost build. This better should be done with --user-config= switch or similar. ........ r38619 | bemandawes | 2007-08-13 09:27:31 -0700 (Mon, 13 Aug 2007) | 1 line Final agreement. Effective date August 10, 2007. Signed by Beman G. Dawes on August 7, 2007, for Boost, and Bradley M. Kuhn on August 10, 2007, for the Software Freedom Conservancy. ........ r38620 | speedsnail | 2007-08-13 09:39:02 -0700 (Mon, 13 Aug 2007) | 1 line Added support for BOOST_USER_CONFIG environment variable. This variable is able to take the same rhs as --user-config= switch. The switch still overrides the variable when present. (This has been added to allow for the BOOST_BUILD_PATH to be restored to its original i.e. documented behaviour.) ........ r38626 | johnmaddock | 2007-08-13 10:54:01 -0700 (Mon, 13 Aug 2007) | 1 line Added some missing match_flag_type options. ........ r38638 | hkaiser | 2007-08-13 18:19:20 -0700 (Mon, 13 Aug 2007) | 1 line Wave: Fixed test Jamfile.v2 ........ r38647 | danieljames | 2007-08-14 02:53:55 -0700 (Tue, 14 Aug 2007) | 3 lines Test the hash library with warning level 4 on Visual C++ - although there's still one warning for hashing long doubles. ........ r38662 | garcia | 2007-08-14 12:30:31 -0700 (Tue, 14 Aug 2007) | 2 lines scope exit review begins. ........ r38669 | igaztanaga | 2007-08-14 17:18:10 -0700 (Tue, 14 Aug 2007) | 1 line Corrected incorrect iterator definition ........ r38679 | danieljames | 2007-08-15 07:35:39 -0700 (Wed, 15 Aug 2007) | 1 line Avoid a comparison with zero warning on gcc when compiling with -Wextra. ........ r38688 | grafik | 2007-08-15 10:25:46 -0700 (Wed, 15 Aug 2007) | 1 line Trow ValueError exception from remove functions to match the set.remove functionality. ........ r38694 | grafik | 2007-08-15 11:35:11 -0700 (Wed, 15 Aug 2007) | 1 line Change remove() to glob_remove() in expect_modification, even though this check is not used. ........ r38702 | grafik | 2007-08-15 13:15:36 -0700 (Wed, 15 Aug 2007) | 1 line Do some normalizing of paths to remove some of the variant feature subdirs that may be different based on platform and toolset. This fixes some tests that pass on GCC/Linux and not on MSVC/Windows. ........ r38704 | hljin | 2007-08-15 15:19:48 -0700 (Wed, 15 Aug 2007) | 1 line GIL: added runtime endian-ness detection routines: little_endian() and big_endian() ........ r38705 | hljin | 2007-08-15 15:21:06 -0700 (Wed, 15 Aug 2007) | 1 line GIL: fixed a endian-ness related bug in PNG IO routines ........ r38710 | grafik | 2007-08-15 21:56:08 -0700 (Wed, 15 Aug 2007) | 1 line More changes to account for differing variant subdirs between toolsets, and of toolset expansion. ........ r38711 | speedsnail | 2007-08-16 05:05:44 -0700 (Thu, 16 Aug 2007) | 1 line Changed BOOST_USER_CONFIG to BOOST_BUILD_USER_CONFIG as this is a more systematic name. ........ r38717 | samuel_krempp | 2007-08-16 06:56:57 -0700 (Thu, 16 Aug 2007) | 3 lines updated - can't be a student forever ! ........ r38724 | grafik | 2007-08-16 09:51:10 -0700 (Thu, 16 Aug 2007) | 1 line Fix changed remote shell command argument names. Disable the svn poller as it taxes the server too much. Bjam build, bjam run, and test tools build working now. ........ r38726 | samuel_krempp | 2007-08-16 10:00:13 -0700 (Thu, 16 Aug 2007) | 2 lines small fix (charset set to utf-8, + typo) ........ r38727 | samuel_krempp | 2007-08-16 10:04:05 -0700 (Thu, 16 Aug 2007) | 2 lines previous commit was messed-up ........ r38729 | samuel_krempp | 2007-08-16 10:33:47 -0700 (Thu, 16 Aug 2007) | 3 lines bug fixed : prefix_ was not reset by make_or_reuse (all other buffers were). Solves ticket #570 ........ r38730 | samuel_krempp | 2007-08-16 11:48:03 -0700 (Thu, 16 Aug 2007) | 3 lines handle invalid format string (ends with %) without asserting, closing ticket #493 ........ r38732 | grafik | 2007-08-16 14:30:21 -0700 (Thu, 16 Aug 2007) | 1 line Add testing step, which unfortunately doesn't work. ........ r38740 | grafik | 2007-08-17 07:51:49 -0700 (Fri, 17 Aug 2007) | 1 line Minor fix to get btest step working. ........ r38741 | dgregor | 2007-08-17 07:57:54 -0700 (Fri, 17 Aug 2007) | 1 line Revert inadvertent changes to csr_graph_test.cpp ........ r38755 | grafik | 2007-08-18 10:11:07 -0700 (Sat, 18 Aug 2007) | 1 line Guard against empty result files. ........ r38756 | grafik | 2007-08-18 23:05:26 -0700 (Sat, 18 Aug 2007) | 1 line Add support for posting to Dart server using the specified http proxy. ........ r38777 | burbelgruff | 2007-08-19 23:51:54 -0700 (Sun, 19 Aug 2007) | 1 line #1188 Removed extra (unnecessary) semicolons in BOOST_TYPEOF_NESTED_TYPEDEF. ........ r38781 | chris_kohlhoff | 2007-08-20 06:48:38 -0700 (Mon, 20 Aug 2007) | 1 line Fix inspect errors. ........ r38782 | chris_kohlhoff | 2007-08-20 06:50:30 -0700 (Mon, 20 Aug 2007) | 1 line Fix gcc warning about too few braces. ........ r38783 | chris_kohlhoff | 2007-08-20 06:53:27 -0700 (Mon, 20 Aug 2007) | 3 lines Add a note to basic_socket<>::close() indicating that shutdown() should be used for portable graceful closure. ........ r38784 | chris_kohlhoff | 2007-08-20 07:07:23 -0700 (Mon, 20 Aug 2007) | 4 lines Add a workaround for Windows Vista's handling of the boolean socket option tcp::no_delay, where ::getsockopt will return the size of the option as one byte, even though a four byte integer was passed in. ........ r38785 | chris_kohlhoff | 2007-08-20 07:08:16 -0700 (Mon, 20 Aug 2007) | 2 lines Add missing static keyword to the service_id_matches functions. ........ r38786 | chris_kohlhoff | 2007-08-20 07:11:46 -0700 (Mon, 20 Aug 2007) | 2 lines Fix order of initialisation problem with error categories. ........ r38787 | chris_kohlhoff | 2007-08-20 07:12:31 -0700 (Mon, 20 Aug 2007) | 2 lines Fix unused argument warning. ........ r38788 | chris_kohlhoff | 2007-08-20 07:17:15 -0700 (Mon, 20 Aug 2007) | 5 lines Increase number of buffers that may be sent or received in a single operation. Clean up win_iocp_socket_service's close-on-destruction handling to ensure non-blocking socket destructors. ........ r38789 | chris_kohlhoff | 2007-08-20 07:19:49 -0700 (Mon, 20 Aug 2007) | 2 lines Use shutdown() for portable graceful connection closure. ........ r38790 | chris_kohlhoff | 2007-08-20 07:21:47 -0700 (Mon, 20 Aug 2007) | 1 line Clean up gcc warnings. ........ r38791 | chris_kohlhoff | 2007-08-20 07:32:05 -0700 (Mon, 20 Aug 2007) | 2 lines Fix unused argument warnings. ........ r38792 | grafik | 2007-08-20 09:52:55 -0700 (Mon, 20 Aug 2007) | 1 line Merge changes from Version_1_34_1 back to trunk. ........ r38800 | ramey | 2007-08-20 11:06:17 -0700 (Mon, 20 Aug 2007) | 2 lines Merged in additions from serialization_next_release branch to support validation of one's current boost installation on a either a library by library or global basis ........ r38801 | burbelgruff | 2007-08-20 11:09:14 -0700 (Mon, 20 Aug 2007) | 1 line native typeof implementation for VC7.1 and VC8.0 now uses typeid() instead of sizeof() to map a type. This bypasses some bugs in Microsofts sizeof implementation, and removes a limitation on the number of typeof invocations that can be done in a single compilation unit ........ r38803 | speedsnail | 2007-08-20 12:14:14 -0700 (Mon, 20 Aug 2007) | 1 line Merge from RC_1_34_0 (CVS 1.12.2.53) to trunk. CVS RC_1_34_0 - 1.12.2.23 and CVS HEAD - 1.51 are the last versions that were equal. Between these and trunk was only a small diff for HPUX that removed pthread lib. This fix seems to be already present in the merged in version. ........ r38804 | garcia | 2007-08-20 12:16:39 -0700 (Mon, 20 Aug 2007) | 2 lines Added "dimensionality" compile-time constant to the MultiArray concept. ........ r38814 | johnmaddock | 2007-08-21 02:04:39 -0700 (Tue, 21 Aug 2007) | 1 line Added needed include: see http://article.gmane.org/gmane.comp.lib.boost.devel/163941. ........ r38815 | garcia | 2007-08-21 05:27:05 -0700 (Tue, 21 Aug 2007) | 2 lines Time Series accepted. ........ r38820 | garcia | 2007-08-21 06:54:25 -0700 (Tue, 21 Aug 2007) | 2 lines Added "dimensionality" compile-time constant to the MultiArray concept. ........ r38821 | garcia | 2007-08-21 06:54:58 -0700 (Tue, 21 Aug 2007) | 2 lines Changed all uses of assert to BOOST_ASSERT. ........ r38822 | vladimir_prus | 2007-08-21 06:55:41 -0700 (Tue, 21 Aug 2007) | 1 line Revive V1 Jamfiles at Christopher's request ........ r38827 | dgregor | 2007-08-21 08:35:19 -0700 (Tue, 21 Aug 2007) | 3 lines Committed patch to eliminate warnings with GCC's -Wundef. Fixes #1197 ........ r38834 | igaztanaga | 2007-08-21 12:18:32 -0700 (Tue, 21 Aug 2007) | 1 line Erased temporarily until problems on Mac Os PowerPC are solved ........ r38835 | vladimir_prus | 2007-08-22 05:14:05 -0700 (Wed, 22 Aug 2007) | 1 line Revive V1 Jamfile to please asio ........ r38837 | vladimir_prus | 2007-08-22 05:40:34 -0700 (Wed, 22 Aug 2007) | 1 line Revive V1 Jamfile to please asio ........ r38838 | johnmaddock | 2007-08-22 05:56:39 -0700 (Wed, 22 Aug 2007) | 1 line Fixed include guard. ........ r38847 | vladimir_prus | 2007-08-22 08:02:20 -0700 (Wed, 22 Aug 2007) | 1 line Make 'library_status' target explicit ........ r38853 | garcia | 2007-08-22 08:29:48 -0700 (Wed, 22 Aug 2007) | 2 lines Initial Revision. ........ r38854 | garcia | 2007-08-22 08:30:47 -0700 (Wed, 22 Aug 2007) | 2 lines Added a new test case for replacing asserts with exceptions. ........ r38856 | garcia | 2007-08-22 11:19:43 -0700 (Wed, 22 Aug 2007) | 2 lines Added mention of assert.cpp. ........ r38857 | garcia | 2007-08-22 11:31:43 -0700 (Wed, 22 Aug 2007) | 2 lines was missing storage_order_convert.cpp ........ r38864 | johnmaddock | 2007-08-23 02:06:24 -0700 (Thu, 23 Aug 2007) | 2 lines Fixes track issue #775, see http://svn.boost.org/trac/boost/ticket/775. All regex code should now compile warning free at level 4 with MSCV. ........ r38868 | hljin | 2007-08-23 12:26:55 -0700 (Thu, 23 Aug 2007) | 1 line GIL: a further fix on the PNG IO 16-bit bug ........ r38871 | vladimir_prus | 2007-08-23 12:51:47 -0700 (Thu, 23 Aug 2007) | 3 lines Apply patch to fix gcc warning. Fixes #1209. ........ r38872 | vladimir_prus | 2007-08-23 12:57:23 -0700 (Thu, 23 Aug 2007) | 3 lines Support the address-model feature for the sun toolset. Addresses #1186. ........ r38873 | danieljames | 2007-08-23 17:42:19 -0700 (Thu, 23 Aug 2007) | 6 lines Copy hash library from 1.34.1 over trunk. For the first merge with the release branch, I only want to include some of the changes I've been working on (fixes and some trivial changes), so I'm starting again from 1.34.1. ........ r38876 | danieljames | 2007-08-23 18:05:36 -0700 (Thu, 23 Aug 2007) | 1 line Update the copyright in the hash library. ........ r38877 | danieljames | 2007-08-23 18:11:33 -0700 (Thu, 23 Aug 2007) | 5 lines Remove the errno check when hashing floating point numbers. It's not really needed and was causing problems on the Microsoft Windows Smarthone Edition platform. Fixes #1064. ........ r38878 | danieljames | 2007-08-23 18:16:54 -0700 (Thu, 23 Aug 2007) | 2 lines Merge some documentation improvements from the development branch. ........ r38881 | danieljames | 2007-08-23 18:44:15 -0700 (Thu, 23 Aug 2007) | 1 line Add extra overloads for hash_value to cover all the specializations of boost::hash. Fixes 1095 ........ r38882 | danieljames | 2007-08-23 18:56:47 -0700 (Thu, 23 Aug 2007) | 1 line Add some missing hash_value documentation for the new overloads. ........ r38883 | danieljames | 2007-08-23 19:01:47 -0700 (Thu, 23 Aug 2007) | 6 lines Change a comparison in the float hashing code, which can cause a warning on gcc. Although the warning doesn't currently turn up in this branch, it could be caused quite easily. Originally reported in: http://lists.boost.org/Archives/boost/2007/08/126084.php ........ r38884 | danieljames | 2007-08-23 19:33:43 -0700 (Thu, 23 Aug 2007) | 2 lines Remove hash_complex_test - it should have been removed when I reverted to 1.34.1 ........ r38911 | igaztanaga | 2007-08-24 14:24:23 -0700 (Fri, 24 Aug 2007) | 1 line Erased old archives imported from CVS ........ r38913 | grafik | 2007-08-24 16:03:10 -0700 (Fri, 24 Aug 2007) | 1 line Disable interprocess tests until parallel execution problem is fixed. (see ticket #1211) ........ r38914 | grafik | 2007-08-24 16:27:14 -0700 (Fri, 24 Aug 2007) | 1 line Reverting changes from revision [http://svn.boost.org/trac/boost/changeset/38800 38800] as it break XSLT regression reports. ........ r38918 | grafik | 2007-08-24 21:08:28 -0700 (Fri, 24 Aug 2007) | 1 line On Windows static libs have the lib prefix, but DLLs don't. ........ r38919 | vladimir_prus | 2007-08-24 21:34:31 -0700 (Fri, 24 Aug 2007) | 1 line Use -KPIC for shared libs. Addresses #1186. ........ r38920 | vladimir_prus | 2007-08-24 21:36:02 -0700 (Fri, 24 Aug 2007) | 1 line Revert mistaken commit ........ r38923 | ramey | 2007-08-25 00:37:21 -0700 (Sat, 25 Aug 2007) | 1 line corrections for gcc compiler ........ r38924 | johnmaddock | 2007-08-25 01:53:29 -0700 (Sat, 25 Aug 2007) | 1 line Fix for http://svn.boost.org/trac/boost/ticket/1075. ........ r38934 | johnmaddock | 2007-08-25 05:26:25 -0700 (Sat, 25 Aug 2007) | 2 lines Fixes for http://svn.boost.org/trac/boost/ticket/1104, http://svn.boost.org/trac/boost/ticket/1102, http://svn.boost.org/trac/boost/ticket/1103 and http://svn.boost.org/trac/boost/ticket/1105. Also updated tests for some previous macro additions. ........ r38946 | igaztanaga | 2007-08-25 11:04:13 -0700 (Sat, 25 Aug 2007) | 2 lines #1211: Interprocess tests hang when run in parallel #1080 boost::interprocess win32 global file mapping issue ........ r38948 | igaztanaga | 2007-08-25 11:14:34 -0700 (Sat, 25 Aug 2007) | 2 lines #1211: Interprocess tests hang when run in parallel #1080 boost::interprocess win32 global file mapping issue ........ r38949 | igaztanaga | 2007-08-25 12:05:18 -0700 (Sat, 25 Aug 2007) | 2 lines #1211: Interprocess tests hang when run in parallel #1080 boost::interprocess win32 global file mapping issue ........ r38950 | igaztanaga | 2007-08-25 12:07:32 -0700 (Sat, 25 Aug 2007) | 2 lines #1211: Interprocess tests hang when run in parallel #1080 boost::interprocess win32 global file mapping issue ........ r38951 | igaztanaga | 2007-08-25 12:10:12 -0700 (Sat, 25 Aug 2007) | 2 lines #1211: Interprocess tests hang when run in parallel #1080 boost::interprocess win32 global file mapping issue ........ r38952 | igaztanaga | 2007-08-25 12:13:02 -0700 (Sat, 25 Aug 2007) | 2 lines #1211: Interprocess tests hang when run in parallel #1080 boost::interprocess win32 global file mapping issue ........ r38953 | igaztanaga | 2007-08-25 12:17:24 -0700 (Sat, 25 Aug 2007) | 2 lines #1211: Interprocess tests hang when run in parallel #1080 boost::interprocess win32 global file mapping issue ........ r38954 | igaztanaga | 2007-08-25 12:18:28 -0700 (Sat, 25 Aug 2007) | 2 lines #1211: Interprocess tests hang when run in parallel #1080 boost::interprocess win32 global file mapping issue ........ r38955 | igaztanaga | 2007-08-25 12:19:34 -0700 (Sat, 25 Aug 2007) | 2 lines #1211: Interprocess tests hang when run in parallel #1080 boost::interprocess win32 global file mapping issue ........ r38956 | aaron_windsor | 2007-08-25 14:11:06 -0700 (Sat, 25 Aug 2007) | 1 line merging planar graph algorithms into the BGL ........ r38960 | igaztanaga | 2007-08-26 02:59:28 -0700 (Sun, 26 Aug 2007) | 1 line This file is a badly imported CVS file ........ r38963 | vladimir_prus | 2007-08-26 08:53:45 -0700 (Sun, 26 Aug 2007) | 1 line Make executable ........ r38964 | grafik | 2007-08-26 09:14:44 -0700 (Sun, 26 Aug 2007) | 1 line Read expected files with universal EOL translation enabled to account for comparing with newline only Python strings. ........ r38965 | grafik | 2007-08-26 09:16:38 -0700 (Sun, 26 Aug 2007) | 1 line Use some wildcard matching on the expected output as 'echo' on Windows outputs extra space before EOLs, which Unix doesn't. ........ r38968 | vladimir_prus | 2007-08-26 10:15:51 -0700 (Sun, 26 Aug 2007) | 1 line Use SVN for nightly builds ........ r38969 | vladimir_prus | 2007-08-26 10:23:03 -0700 (Sun, 26 Aug 2007) | 1 line Include svn revision in nightly build ........ r38971 | vladimir_prus | 2007-08-26 11:32:21 -0700 (Sun, 26 Aug 2007) | 1 line Fix quoting. Remove .svn directories ........ r38973 | grafik | 2007-08-26 12:24:13 -0700 (Sun, 26 Aug 2007) | 1 line Make rm try the glob_file in addition to regular glob. Clears alternatives and project_glob failures on windows. ........ r38975 | pdimov | 2007-08-26 12:42:50 -0700 (Sun, 26 Aug 2007) | 1 line Updated the unspecified_bool_type to match shared_ptr. ........ r38976 | pdimov | 2007-08-26 13:34:40 -0700 (Sun, 26 Aug 2007) | 1 line BOOST_NO_TYPEID support (#1108). ........ r38977 | pdimov | 2007-08-26 13:35:52 -0700 (Sun, 26 Aug 2007) | 1 line BOOST_NO_TYPEID support (#1108). ........ r38981 | vladimir_prus | 2007-08-26 23:18:11 -0700 (Sun, 26 Aug 2007) | 1 line Run svnversion before removing .svn ........ r38984 | vladimir_prus | 2007-08-26 23:30:56 -0700 (Sun, 26 Aug 2007) | 1 line Run svnversion before modifying anything ........ r38985 | grafik | 2007-08-26 23:34:52 -0700 (Sun, 26 Aug 2007) | 1 line Repoint tarball source to direct tarball generator. ........ r38986 | vladimir_prus | 2007-08-26 23:41:18 -0700 (Sun, 26 Aug 2007) | 1 line Another svnversion fix ........ r38987 | vladimir_prus | 2007-08-27 00:00:18 -0700 (Mon, 27 Aug 2007) | 1 line Another fix ........ r38999 | garcia | 2007-08-27 04:51:04 -0700 (Mon, 27 Aug 2007) | 1 line *** empty log message *** ........ r39007 | grafik | 2007-08-27 09:02:50 -0700 (Mon, 27 Aug 2007) | 1 line Bring back the interprocess tests, as they seem fixed now for parallel execution. ........ r39009 | danieljames | 2007-08-27 10:59:54 -0700 (Mon, 27 Aug 2007) | 2 lines Comment out -Wextra because it doesn't work on older versions of gcc. ........ r39014 | danieljames | 2007-08-27 11:16:54 -0700 (Mon, 27 Aug 2007) | 1 line Add proper support for long longs and unsigned long longs. ........ r39020 | grafik | 2007-08-27 14:05:35 -0700 (Mon, 27 Aug 2007) | 1 line Tarball generation script. ........ r39022 | grafik | 2007-08-27 14:19:41 -0700 (Mon, 27 Aug 2007) | 1 line Add copyright+BSL. ........ r39052 | dgregor | 2007-08-29 09:00:53 -0700 (Wed, 29 Aug 2007) | 3 lines Constify status::count and status::cancelled. Fixes #1101 ........ r39060 | dgregor | 2007-08-29 11:59:16 -0700 (Wed, 29 Aug 2007) | 1 line Disable MSVC warning about native code generation. Fixes #1163 ........ r39061 | dgregor | 2007-08-29 12:06:11 -0700 (Wed, 29 Aug 2007) | 1 line Handle GCC's -fno-exceptions properly. Fixes #1198 ........ r39062 | dlwalker | 2007-08-29 12:54:14 -0700 (Wed, 29 Aug 2007) | 1 line Fixed comments listed in #766 that didn't match their described code ........ r39073 | eric_niebler | 2007-08-30 08:21:00 -0700 (Thu, 30 Aug 2007) | 1 line example/main.cpp compiles clean with gcc -Wall ........ r39075 | eric_niebler | 2007-08-30 08:40:34 -0700 (Thu, 30 Aug 2007) | 1 line dynamically optimizing TST, from Dave Jenkins ........ r39089 | dgregor | 2007-08-31 10:23:51 -0700 (Fri, 31 Aug 2007) | 1 line Add empty directory ........ r39090 | dgregor | 2007-08-31 10:24:36 -0700 (Fri, 31 Aug 2007) | 1 line Create an empty directory ........ r39091 | igaztanaga | 2007-08-31 15:57:11 -0700 (Fri, 31 Aug 2007) | 1 line Added missing comma ........ r39092 | chris_kohlhoff | 2007-08-31 23:08:45 -0700 (Fri, 31 Aug 2007) | 2 lines Need to try binding the acceptor to test whether IPv6 is supported. ........ r39093 | chris_kohlhoff | 2007-08-31 23:13:02 -0700 (Fri, 31 Aug 2007) | 2 lines Ignore errors from shutdown(). ........ r39094 | chris_kohlhoff | 2007-08-31 23:20:19 -0700 (Fri, 31 Aug 2007) | 2 lines Enable buffer() overload workaround for Sun C++. ........ r39095 | chris_kohlhoff | 2007-08-31 23:25:55 -0700 (Fri, 31 Aug 2007) | 3 lines Add AIX-specific compile time test for whether sockaddr_storage's family field is called ss_family or __ss_family. ........ r39096 | chris_kohlhoff | 2007-08-31 23:28:40 -0700 (Fri, 31 Aug 2007) | 3 lines Ensure that a strand is kept alive as long as there are wrapped handlers for it. ........ r39097 | chris_kohlhoff | 2007-08-31 23:33:44 -0700 (Fri, 31 Aug 2007) | 2 lines Add #include needed for IOV_MAX. ........ r39098 | chris_kohlhoff | 2007-08-31 23:41:15 -0700 (Fri, 31 Aug 2007) | 7 lines Fix problem where a thread can go idle even if there are handlers that are ready to be dispatched. Remove need to have a mutex per idle thread. Remove need to have a mutex per idle thread. ........ r39100 | chris_kohlhoff | 2007-09-01 00:32:28 -0700 (Sat, 01 Sep 2007) | 3 lines Define _WIN32_WINNT to suppress warnings. Add define necessary for building with cygwin. ........ r39102 | vladimir_prus | 2007-09-01 01:55:35 -0700 (Sat, 01 Sep 2007) | 1 line Initial support for defining action body from Python. ........ r39103 | vladimir_prus | 2007-09-01 13:28:42 -0700 (Sat, 01 Sep 2007) | 4 lines Fix glob excludes in subdirectories. Thanks to Norbert Unterberg for the bug report. ........ r39104 | vladimir_prus | 2007-09-01 14:46:09 -0700 (Sat, 01 Sep 2007) | 5 lines Make free features on the command line affect all targets, not just directly requested ones. Fixes #985. ........ r39105 | vladimir_prus | 2007-09-01 15:10:46 -0700 (Sat, 01 Sep 2007) | 4 lines Previously, I've accidentally committed a patch to make affect names of searched libraries. This commit greatly simplifies that. ........ r39106 | speedsnail | 2007-09-02 08:57:36 -0700 (Sun, 02 Sep 2007) | 2 lines Merged in volodyas patch from RC_1_34_0 http://lists.boost.org/boost-users/2007/05/27724.php ........ r39107 | speedsnail | 2007-09-02 11:37:14 -0700 (Sun, 02 Sep 2007) | 1 line Changed library naming convention for mingw and cygwin. For details see comment in file. Also should resolve Ticket #1058 . ........ r39112 | aaron_windsor | 2007-09-03 08:04:05 -0700 (Mon, 03 Sep 2007) | 1 line Modified odd_components_counter to fix signed/unsigned mismatch on Sandi pgi-6.1 tests. ........ r39113 | speedsnail | 2007-09-03 12:38:40 -0700 (Mon, 03 Sep 2007) | 1 line Make use of gnu ld's -Bstatic and -Bdynamic switches to choose order of libraries searched by -l switch. ........ r39120 | vladimir_prus | 2007-09-04 13:26:19 -0700 (Tue, 04 Sep 2007) | 2 lines Allow to print the tree delta to any file. ........ r39121 | vladimir_prus | 2007-09-04 13:29:56 -0700 (Tue, 04 Sep 2007) | 1 line Unbreak the gcc_runtime test ........ r39126 | eric_niebler | 2007-09-04 23:31:27 -0700 (Tue, 04 Sep 2007) | 1 line remove unused variables ........ r39128 | vladimir_prus | 2007-09-05 01:03:17 -0700 (Wed, 05 Sep 2007) | 1 line Remove unnecessary line ........ r39130 | bgubenko | 2007-09-05 10:14:29 -0700 (Wed, 05 Sep 2007) | 1 line missing conditionalization for g++ on HP-UX ........ r39131 | burbelgruff | 2007-09-05 12:52:18 -0700 (Wed, 05 Sep 2007) | 1 line boost.typeof now supports native typeof for VC8.0 ........ r39132 | bgubenko | 2007-09-05 16:43:40 -0700 (Wed, 05 Sep 2007) | 1 line Boost.Build V2 toolset for the HP aC++ compiler on PA-RISC ........ r39134 | burbelgruff | 2007-09-06 00:22:10 -0700 (Thu, 06 Sep 2007) | 1 line typeof: Implemented native typeof for DMC 8.50 based on the same bugfeature used to support VC6.5 and VC7.1 ........ r39150 | johnmaddock | 2007-09-06 10:10:05 -0700 (Thu, 06 Sep 2007) | 1 line Updated gcc config using STLport's settings so that TR1 functions correctly when Boost is installed in for example /usr/include/ ........ r39151 | bgubenko | 2007-09-06 12:01:07 -0700 (Thu, 06 Sep 2007) | 1 line marking up tests for acc_pa_risc toolset ........ r39156 | bgubenko | 2007-09-07 10:02:12 -0700 (Fri, 07 Sep 2007) | 1 line markup test is_lvalue_iterator for acc_pa_risc toolset ........ r39157 | nielsdekker | 2007-09-07 10:17:09 -0700 (Fri, 07 Sep 2007) | 1 line Added MSVC workaround to value_initialized, as described by ticket #1217, proposed at the Boost Developers mailing list, and discussed with Fernando Cacciola. ........ r39158 | bgubenko | 2007-09-07 11:40:47 -0700 (Fri, 07 Sep 2007) | 1 line conditionalization for PA-RISC ........ r39160 | vladimir_prus | 2007-09-07 14:34:27 -0700 (Fri, 07 Sep 2007) | 1 line Adjust faq entry about targets in site-config.jam ........ r39161 | vladimir_prus | 2007-09-07 16:18:20 -0700 (Fri, 07 Sep 2007) | 4 lines Make output from test run nicer, and more structured. In future, we might be able to generate XML, or any other voodoo we want. ........ r39162 | vladimir_prus | 2007-09-07 16:51:07 -0700 (Fri, 07 Sep 2007) | 1 line Undo #38702, which fixes alternative.py on linux. Real fix for win coming soon. ........ r39163 | vladimir_prus | 2007-09-07 16:59:10 -0700 (Fri, 07 Sep 2007) | 1 line Make it work ........ r39164 | vladimir_prus | 2007-09-07 16:59:54 -0700 (Fri, 07 Sep 2007) | 3 lines Implement --ignore-toolset-requirements and set in during testing. ........ r39165 | vladimir_prus | 2007-09-07 17:15:23 -0700 (Fri, 07 Sep 2007) | 3 lines Fix remove_requirements test. I have no idea how it could have passed as-is. ........ r39166 | vladimir_prus | 2007-09-07 17:26:18 -0700 (Fri, 07 Sep 2007) | 1 line Print test results summary at the end ........ r39168 | vladimir_prus | 2007-09-08 09:24:50 -0700 (Sat, 08 Sep 2007) | 4 lines Fix the rebuilds test on linux. * BoostBuild.py (wait_for_time_change): Use floor, to avoid waiting 0.5 seconds. * rebuilds.py: Wait for time change as necessary. ........ r39169 | vladimir_prus | 2007-09-08 10:10:26 -0700 (Sat, 08 Sep 2007) | 1 line Record failure reason when we fail to open a file. ........ r39173 | bemandawes | 2007-09-09 07:59:10 -0700 (Sun, 09 Sep 2007) | 1 line Merge system and filesystem branches, bringing them in sync with N2415. Several filesystem bugs fixed, and current_path setter added. ........ r39174 | bemandawes | 2007-09-09 10:48:17 -0700 (Sun, 09 Sep 2007) | 1 line Posix and Linux fixes ........ r39175 | johnmaddock | 2007-09-10 02:19:49 -0700 (Mon, 10 Sep 2007) | 8 lines Big type_traits update: Added make_signed, make_unsigned and is_complex. Added docs for some previously undocumented traits: is_signed, is_unsigned and decay.html Added synonyms for some traits that have changed name in the latest C++ std draft. Re-organised docs, moved docs out of the main doc build for now (it takes too long). This also fixes issues: http://svn.boost.org/trac/boost/ticket/492 and http://svn.boost.org/trac/boost/ticket/1008. ........ r39176 | johnmaddock | 2007-09-10 03:35:51 -0700 (Mon, 10 Sep 2007) | 1 line Applied fix for http://svn.boost.org/trac/boost/ticket/883. ........ r39177 | johnmaddock | 2007-09-10 03:37:19 -0700 (Mon, 10 Sep 2007) | 1 line Added optional code to test SGI rope with Regex. ........ r39178 | johnmaddock | 2007-09-10 04:24:53 -0700 (Mon, 10 Sep 2007) | 1 line Try and force a date update. ........ r39179 | johnmaddock | 2007-09-10 04:27:31 -0700 (Mon, 10 Sep 2007) | 1 line OK finally got date modified set right. ........ r39181 | johnmaddock | 2007-09-10 09:22:35 -0700 (Mon, 10 Sep 2007) | 1 line Oops, doc update broke the tests, fixed now. ........ r39183 | johnmaddock | 2007-09-10 10:18:16 -0700 (Mon, 10 Sep 2007) | 1 line Added new macros def's that are needed by the various additions that have been added to Boost.Config. ........ r39186 | bemandawes | 2007-09-10 18:11:03 -0700 (Mon, 10 Sep 2007) | 1 line Chris Kohlhoff says change needed for asio to link correctly ........ r39187 | bemandawes | 2007-09-10 19:05:58 -0700 (Mon, 10 Sep 2007) | 1 line Ha! Finally figured out how to shut off msvc exception switch warning. ........ r39188 | bemandawes | 2007-09-10 19:07:50 -0700 (Mon, 10 Sep 2007) | 1 line Ha! Finally figured out how to shut off msvc exception switch warning. Also fix define misspelling. ........ r39189 | chris_kohlhoff | 2007-09-11 04:17:56 -0700 (Tue, 11 Sep 2007) | 2 lines Use enum-based error code constants. ........ r39190 | bgubenko | 2007-09-11 09:24:28 -0700 (Tue, 11 Sep 2007) | 1 line add conditionalization for g++ on HP-UX ........ r39191 | rwgk | 2007-09-11 09:53:50 -0700 (Tue, 11 Sep 2007) | 1 line Patches by Nikolay Mladenov (nickm at sitius com): new pythonic signatures; docstring support for enums; fix unrelated Visual C++ 6 problem ........ r39193 | bgubenko | 2007-09-11 11:54:50 -0700 (Tue, 11 Sep 2007) | 1 line base detection of EDG-based compiler on __EDG__ macro ........ r39194 | vladimir_prus | 2007-09-11 12:16:06 -0700 (Tue, 11 Sep 2007) | 3 lines Don't try to apply --build-dir to standalone projects. Fixes build_dir test failure on linux. ........ r39195 | vladimir_prus | 2007-09-11 12:17:49 -0700 (Tue, 11 Sep 2007) | 4 lines * BoostBuild.py (wait_for_time_change): Wait for more serious time change, in order to fix sporadic dependency_test failures. ........ r39196 | bgubenko | 2007-09-11 12:31:55 -0700 (Tue, 11 Sep 2007) | 1 line define macros specific to RW V2.2 on HP-UX ........ r39197 | vladimir_prus | 2007-09-11 12:36:48 -0700 (Tue, 11 Sep 2007) | 1 line Don't run gcc_runtime test on msvc ........ r39198 | bgubenko | 2007-09-11 12:54:59 -0700 (Tue, 11 Sep 2007) | 1 line make sure HP-UX-specific macros are not redefined ........ r39199 | pdimov | 2007-09-11 13:58:19 -0700 (Tue, 11 Sep 2007) | 1 line Fixes #1243 ........ r39204 | grafik | 2007-09-11 21:21:57 -0700 (Tue, 11 Sep 2007) | 1 line Add regression result pages automation script. ........ r39211 | chris_kohlhoff | 2007-09-12 05:24:21 -0700 (Wed, 12 Sep 2007) | 2 lines AIX seems to have the socket address family as an unsigned char rather than unsigned short. ........ r39219 | johnmaddock | 2007-09-12 09:44:16 -0700 (Wed, 12 Sep 2007) | 1 line Fixed is_base_of/is_base_and_derived so that you get a compiler error if you try and use them with an incomplete class type. ........ r39220 | bemandawes | 2007-09-12 11:31:25 -0700 (Wed, 12 Sep 2007) | 1 line POSIX fix from Neal Becker ........ r39223 | nikiml | 2007-09-12 14:31:39 -0700 (Wed, 12 Sep 2007) | 1 line fixed problem reported by Neal Becker; added a test case ........ r39226 | bemandawes | 2007-09-12 14:43:20 -0700 (Wed, 12 Sep 2007) | 1 line Some compilers warn on trailing enum constant list commas, so remove these to quiet the warnings. ........ r39227 | guwi17 | 2007-09-12 14:44:37 -0700 (Wed, 12 Sep 2007) | 2 lines lu.hpp: introduced temporary to avoid strange compiler problem. ........ r39230 | bemandawes | 2007-09-12 20:17:17 -0700 (Wed, 12 Sep 2007) | 1 line Add Boost.System test suite ........ r39231 | johnmaddock | 2007-09-13 02:04:12 -0700 (Thu, 13 Sep 2007) | 1 line Fix for broken limits_test build. ........ r39233 | guwi17 | 2007-09-13 05:13:20 -0700 (Thu, 13 Sep 2007) | 3 lines overview.htm: fixed typo ........ r39237 | bgubenko | 2007-09-13 09:11:38 -0700 (Thu, 13 Sep 2007) | 1 line reapply fix for gcc on HP-UX in -r39130 ........ r39238 | garcia | 2007-09-13 09:17:05 -0700 (Thu, 13 Sep 2007) | 2 lines added fast-track reviews. ........ r39240 | dgregor | 2007-09-13 10:38:58 -0700 (Thu, 13 Sep 2007) | 7 lines function/function_base.hpp, function/function_template.hpp: - Switch from dynamic initialization of the vtable pointer to static initialization (Fixes #1260) - Handle member pointers properly, only using mem_fn within the invoker to deal with all of the messy bits of calling member pointers ........ r39242 | dgregor | 2007-09-13 11:43:00 -0700 (Thu, 13 Sep 2007) | 1 line Update the nag script to use Subversion ........ r39243 | dgregor | 2007-09-13 11:50:50 -0700 (Thu, 13 Sep 2007) | 1 line Work around bugs in Sun Studio 11 ........ r39244 | dgregor | 2007-09-13 12:06:53 -0700 (Thu, 13 Sep 2007) | 4 lines function_template.hpp: - Pass-by-reference internally, when we can. Fixes #1067 ........ r39245 | dgregor | 2007-09-13 12:31:03 -0700 (Thu, 13 Sep 2007) | 1 line Don't use BOOST_TEST_DONT_PRINT_LOG_VALUE if it isn't defined ........ r39246 | dgregor | 2007-09-13 12:41:27 -0700 (Thu, 13 Sep 2007) | 1 line Teach cycle_ratio_tests to find its input files during regression testing ........ r39247 | dgregor | 2007-09-13 12:58:30 -0700 (Thu, 13 Sep 2007) | 1 line We can no longer use is_base_and_derived with incomplete types, not that it worked well before ........ r39248 | bemandawes | 2007-09-13 14:47:25 -0700 (Thu, 13 Sep 2007) | 1 line Ensure error_category::operator< test works regardless of how compiler lays out memory. ........ r39249 | hkaiser | 2007-09-13 14:49:01 -0700 (Thu, 13 Sep 2007) | 1 line Wave: fixed test build/Jamfile.v2 to include threading library ........ r39251 | hkaiser | 2007-09-13 14:54:32 -0700 (Thu, 13 Sep 2007) | 1 line Wave: Fixed a bug in the Slex token class, which was the reason for some failing tests lately ........ r39254 | bemandawes | 2007-09-13 18:58:20 -0700 (Thu, 13 Sep 2007) | 1 line Add usage-requirements. See comment in file. ........ r39255 | bemandawes | 2007-09-13 19:00:25 -0700 (Thu, 13 Sep 2007) | 1 line Remove static to see if that is what is causing link problems on a few gcc platforms ........ r39256 | bgubenko | 2007-09-13 19:25:06 -0700 (Thu, 13 Sep 2007) | 1 line on HP-UX, macro BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS should be defined only if macro _REENTRANT is defined ........ r39258 | johnmaddock | 2007-09-14 01:54:31 -0700 (Fri, 14 Sep 2007) | 1 line Apply sunpro fix from 1.34.1 ........ r39259 | johnmaddock | 2007-09-14 02:20:37 -0700 (Fri, 14 Sep 2007) | 1 line Touched header to force rebuild of config tests. ........ r39260 | johnmaddock | 2007-09-14 02:25:29 -0700 (Fri, 14 Sep 2007) | 1 line Touched files to force tests to be re-run with new Jamfile. ........ r39261 | bemandawes | 2007-09-14 03:37:11 -0700 (Fri, 14 Sep 2007) | 1 line Supply errno values missing from Windows Mobile ........ r39266 | garcia | 2007-09-14 08:04:41 -0700 (Fri, 14 Sep 2007) | 2 lines Updated the comments on the libraries that were newly released in 1.34. ........ r39267 | vladimir_prus | 2007-09-14 08:28:13 -0700 (Fri, 14 Sep 2007) | 3 lines * gcc.jam (init-link-flags): Add missing 'unchecked'. This was breaking intel. ........ r39268 | vladimir_prus | 2007-09-14 08:30:42 -0700 (Fri, 14 Sep 2007) | 4 lines Remove acc_pa_risc.jam. Given that it's a copy of acc.jam with only toolset name changed, I see no point in having this file. ........ r39269 | bemandawes | 2007-09-14 08:43:22 -0700 (Fri, 14 Sep 2007) | 1 line Initial commit ........ r39270 | bemandawes | 2007-09-14 08:45:36 -0700 (Fri, 14 Sep 2007) | 1 line Replace docs with up-to-date contents, design ........ r39273 | grafik | 2007-09-14 09:29:37 -0700 (Fri, 14 Sep 2007) | 1 line Point dev reports to beta.boost.org site. ........ r39274 | cepstein | 2007-09-14 10:18:02 -0700 (Fri, 14 Sep 2007) | 2 lines Quiet unused argument warnings from gcc. ........ r39282 | pdimov | 2007-09-14 12:19:09 -0700 (Fri, 14 Sep 2007) | 1 line CINT support (Nils Krumnack) ........ r39283 | garcia | 2007-09-14 13:56:59 -0700 (Fri, 14 Sep 2007) | 2 lines Initial Revision. ........ r39284 | garcia | 2007-09-14 13:59:44 -0700 (Fri, 14 Sep 2007) | 2 lines Review Wizard Status Report for October 2007. ........ r39285 | dgregor | 2007-09-14 14:05:46 -0700 (Fri, 14 Sep 2007) | 5 lines Finalizes the fix to Bug #1260, making vtable_base an actual POD type (oops) and playing more nicely with reinterpret_cast (thanks to Brad King for the fixes). ........ r39286 | dgregor | 2007-09-14 14:17:06 -0700 (Fri, 14 Sep 2007) | 1 line Fix the cycle ratio tests for real ........ r39291 | djowel | 2007-09-14 17:19:44 -0700 (Fri, 14 Sep 2007) | 2 lines Fix Ticket Ticket #1235 (http://svn.boost.org/trac/boost/ticket/1235) ........ r39292 | bemandawes | 2007-09-14 18:36:14 -0700 (Fri, 14 Sep 2007) | 1 line Missing std added to ::remove to clear problem in Sun tests ........ r39295 | grafik | 2007-09-14 21:33:32 -0700 (Fri, 14 Sep 2007) | 1 line Call the correct subjam file. ........ r39302 | rwgk | 2007-09-15 16:11:50 -0700 (Sat, 15 Sep 2007) | 1 line work around Visual C++ 7.1 internal compiler error ........ r39307 | johnmaddock | 2007-09-16 01:50:09 -0700 (Sun, 16 Sep 2007) | 1 line Fix msvc warnings. ........ r39308 | niels_dekker | 2007-09-16 02:33:34 -0700 (Sun, 16 Sep 2007) | 1 line Visual C++ 7.1 ICE workaround by Ralf W. Grosse-Kunstleve added to ~const_T_base() as well. See also Boost Developers mailing list, subject "utility/value_init.hpp: VC 7.1 ICE & workaround" ........ r39309 | niels_dekker | 2007-09-16 02:48:28 -0700 (Sun, 16 Sep 2007) | 1 line Added unit test to make sure that Visual C++ 7.1 ICE reported by Ralf W. Grosse-Kunstleve (Boost Developers mailing list, subject "utility/value_init.hpp: VC 7.1 ICE & workaround") will not occur anymore. ........ r39315 | johnmaddock | 2007-09-16 04:20:25 -0700 (Sun, 16 Sep 2007) | 1 line Added needed include (for CHAR_BIT). ........ r39330 | grafik | 2007-09-16 14:35:19 -0700 (Sun, 16 Sep 2007) | 1 line Implement @() expansion during parse phase. (fixes #721) ........ r39331 | grafik | 2007-09-16 14:55:02 -0700 (Sun, 16 Sep 2007) | 1 line Define OSPLAT var unconditionally, and more generically, when possible. (fixes #798) ........ r39332 | grafik | 2007-09-16 15:13:02 -0700 (Sun, 16 Sep 2007) | 1 line Fix undeclared INT_MAX on some platforms, i.e. Linux. ........ r39334 | noel_belcourt | 2007-09-16 17:27:37 -0700 (Sun, 16 Sep 2007) | 14 lines Added missing #include and qualified make_pair with std:: to library_status.cpp. Added missing headers to make1.c and missing prototypes to builtin.h Modified execunix.c to add support for terminating processes that consume too much cpu or that hang and fail to consume cpu at all. This in support of the bjam -lx option. http://svn.boost.org/trac/boost/ticket/1266#comment:2 ........ r39335 | grafik | 2007-09-16 17:44:16 -0700 (Sun, 16 Sep 2007) | 1 line Add test for ticket #431. ........ r39336 | grafik | 2007-09-16 17:54:20 -0700 (Sun, 16 Sep 2007) | 1 line Really fix missing INT_MAX declaration. And fix pma.jam test on Unix. ........ r39337 | lbourdev | 2007-09-16 23:36:22 -0700 (Sun, 16 Sep 2007) | 3 lines GIL: Updating mandelbrot example with the new GIL. ........ r39338 | lbourdev | 2007-09-17 00:53:06 -0700 (Mon, 17 Sep 2007) | 1 line fixing affine ........ r39339 | lbourdev | 2007-09-17 01:12:19 -0700 (Mon, 17 Sep 2007) | 1 line GIL 2.0 to 2.1 (see http://opensource.adobe.com/gil/gil2.1_changes.pdf). GIL 2.1 to 2.1.1 (see http://sourceforge.net/forum/forum.php?thread_id=1824588&forum_id=648138) ........ r39341 | grafik | 2007-09-17 01:32:24 -0700 (Mon, 17 Sep 2007) | 1 line Add internal dependencies for multi-file generating actions to indicate that the targets all only appear when the first target appears. (fixes ticket #431) ........ r39342 | schoepflin | 2007-09-17 02:04:37 -0700 (Mon, 17 Sep 2007) | 1 line Corrections for Tru64/CXX. ........ r39350 | grafik | 2007-09-17 09:16:29 -0700 (Mon, 17 Sep 2007) | 1 line Add redirect for trunk so that we can point the issues email link to a stable location. ........ r39351 | grafik | 2007-09-17 09:17:52 -0700 (Mon, 17 Sep 2007) | 1 line Point issues link to stable location. ........ r39352 | grafik | 2007-09-17 09:58:10 -0700 (Mon, 17 Sep 2007) | 1 line Add test of -l limit option now that it's implemented on windows and unix. ........ r39353 | dgregor | 2007-09-17 11:33:20 -0700 (Mon, 17 Sep 2007) | 1 line Support Win64 ........ r39354 | vladimir_prus | 2007-09-17 12:29:06 -0700 (Mon, 17 Sep 2007) | 3 lines Allow to specify version, and explicitly specify the command, when initializing the acc toolset. ........ r39355 | grafik | 2007-09-17 13:00:18 -0700 (Mon, 17 Sep 2007) | 1 line Add test for no-op @() expansion. ........ r39357 | grafik | 2007-09-17 14:35:58 -0700 (Mon, 17 Sep 2007) | 1 line Handle invalid formats of @() as doing a straight substitution instead of erroring out. ........ r39358 | noel_belcourt | 2007-09-17 16:30:57 -0700 (Mon, 17 Sep 2007) | 7 lines Rene found a problem with the code I committed to terminate expired processes. This patch basically causes the select function to return after -l seconds. This gives me a shot at killing processes still running. ........ r39359 | djowel | 2007-09-17 17:18:56 -0700 (Mon, 17 Sep 2007) | 1 line bugfix tuples::null_type and tuples::tuple<> iterators not comparing ok. ........ r39360 | noel_belcourt | 2007-09-17 19:42:13 -0700 (Mon, 17 Sep 2007) | 7 lines Fix One more obscure way for the timeout to miss processes. If select times out (no processes terminated), then all running processes can be terminated. Cleaned up code when this condition applies. ........ r39361 | noel_belcourt | 2007-09-17 20:27:48 -0700 (Mon, 17 Sep 2007) | 7 lines A minor optimization to eliminate two OS calls (one to times, one to kill). Now all expired processes are killed in one place. If the select command times out, I set each processes start_time to zero to ensure it is picked up as an expired process. ........ r39362 | vladimir_prus | 2007-09-18 04:44:13 -0700 (Tue, 18 Sep 2007) | 1 line Expand aCC documentation ........ r39363 | dgregor | 2007-09-18 05:09:53 -0700 (Tue, 18 Sep 2007) | 1 line Second attempt at fixing usage of 64-bit integer type ........ r39364 | chris_kohlhoff | 2007-09-18 06:13:40 -0700 (Tue, 18 Sep 2007) | 2 lines Fix unused argument warning. ........ r39365 | bemandawes | 2007-09-18 08:37:36 -0700 (Tue, 18 Sep 2007) | 1 line Remove files after tests ........ r39366 | johnmaddock | 2007-09-18 09:32:29 -0700 (Tue, 18 Sep 2007) | 1 line Added Mathias Kock and Joerg Walter. ........ r39367 | grafik | 2007-09-18 10:02:04 -0700 (Tue, 18 Sep 2007) | 1 line Replace breaks, to remove warnings, with custom structural templates. ........ r39368 | nikiml | 2007-09-18 10:16:31 -0700 (Tue, 18 Sep 2007) | 1 line epydoc friendlier formatting ........ r39369 | johnmaddock | 2007-09-18 10:19:41 -0700 (Tue, 18 Sep 2007) | 1 line Updated licences using blanket_permission.txt. ........ r39370 | nikiml | 2007-09-18 10:28:23 -0700 (Tue, 18 Sep 2007) | 1 line tabs removes, code reformatting ........ r39371 | nikiml | 2007-09-18 10:32:06 -0700 (Tue, 18 Sep 2007) | 1 line epydoc friendlier formatting ........ r39372 | nikiml | 2007-09-18 10:51:47 -0700 (Tue, 18 Sep 2007) | 1 line fixed cpp signature related test failure ........ r39373 | garcia | 2007-09-18 12:03:47 -0700 (Tue, 18 Sep 2007) | 4 lines Added Tobias Schwinger as Review Manager for Exception. Added entry for X-files. Added download links for Property Maps and Graph. ........ r39374 | garcia | 2007-09-18 12:10:12 -0700 (Tue, 18 Sep 2007) | 2 lines Split X-Files review into three separate reviews. ........ r39375 | bemandawes | 2007-09-18 14:01:26 -0700 (Tue, 18 Sep 2007) | 1 line quiet compiler warning ........ r39376 | hljin | 2007-09-18 14:19:05 -0700 (Tue, 18 Sep 2007) | 4 lines GIL: 1. changed int to std::ptrdiff_t in utilities.hpp and iterator_from_2d.hpp for problems under 64-bit platforms 2. removed several extra semi-colons after GIL_CLASS_REQUIRE ........ r39377 | hljin | 2007-09-18 14:37:08 -0700 (Tue, 18 Sep 2007) | 1 line GIL: fixed incorrect header files for std::bad_cast ........ r39378 | noel_belcourt | 2007-09-18 15:46:26 -0700 (Tue, 18 Sep 2007) | 14 lines Remove unnecessary overhead in execunix.c related to the timeout implementation. Also removed unused variables as diagnosed by the Sgi (mipspro) compiler. Fixed const-correctness error in operations.hpp that Sgi complained about. There's no strerror_r function on Irix 6.5 so I replaced it with a strerror call. With these changes, I can now build process jam log and start running Sgi tests. ........ r39379 | noel_belcourt | 2007-09-18 18:46:11 -0700 (Tue, 18 Sep 2007) | 4 lines Undo patch of operations.hpp, Sgi wants this fix but it causes svn trunk to break. ........ r39381 | grafik | 2007-09-18 19:39:08 -0700 (Tue, 18 Sep 2007) | 1 line Fix extra, missed, para inside warning admonition. ........ r39382 | noel_belcourt | 2007-09-18 19:59:00 -0700 (Tue, 18 Sep 2007) | 8 lines Update the mipspro.jam file so have the compiler emit each referenced template in the object file where referenced and then rely on the linker to remove duplicates. Added some missing macros to sgi_mipspro.hpp. ........ r39383 | grafik | 2007-09-18 20:59:52 -0700 (Tue, 18 Sep 2007) | 1 line Style simplelist tables, to look like regular text lines. ........ r39384 | grafik | 2007-09-18 21:03:22 -0700 (Tue, 18 Sep 2007) | 1 line Don't make nav links white to prevent then from not showing up when the images are not present. ........ r39385 | grafik | 2007-09-18 21:54:30 -0700 (Tue, 18 Sep 2007) | 1 line Remove some outdated comments as some bugs are now fixed. Try to work around boostbook XSL. ........ r39392 | hljin | 2007-09-19 11:41:47 -0700 (Wed, 19 Sep 2007) | 1 line GIL: fixed the C4503 warnings under VC ........ r39393 | hljin | 2007-09-19 11:45:30 -0700 (Wed, 19 Sep 2007) | 1 line GIL: commented out unnecessary pragma warning directives ........ r39394 | bemandawes | 2007-09-19 12:28:56 -0700 (Wed, 19 Sep 2007) | 1 line Add get_posix_category, get_system_category, to solve order-of-initialization issues ........ r39395 | grafik | 2007-09-19 12:29:31 -0700 (Wed, 19 Sep 2007) | 1 line Make get-values preserve the values exactly, instead of treating them like paths and hence munging them. ........ r39396 | bemandawes | 2007-09-19 12:30:23 -0700 (Wed, 19 Sep 2007) | 1 line Add get_posix_category, get_system_category, to solve order-of-initialization issues ........ r39397 | grafik | 2007-09-19 12:47:25 -0700 (Wed, 19 Sep 2007) | 1 line Work around boostbook path issues. ........ r39398 | garcia | 2007-09-19 14:29:29 -0700 (Wed, 19 Sep 2007) | 2 lines made Tobias' reviews fast-track. ........ r39399 | noel_belcourt | 2007-09-19 21:11:11 -0700 (Wed, 19 Sep 2007) | 15 lines Fix a bug Chris Cambly reported with the timeout code on AIX. Apparently AIX doesn't permit a forked process to reference (set) memory in the parent's address space. No other system seems to object to this practice but it taught me a lesson! The fix was to move the call to get the child process start time directly before calling vfork. This isn't really fair to the forked process as we start counting time against the child process that we haven't even forked (we count the vfork/exec call overhead against the child process). Tested Rene's test.sh script on Sun, Linux, AIX, and Sgi. ........ r39400 | grafik | 2007-09-19 21:36:27 -0700 (Wed, 19 Sep 2007) | 1 line Now that the exec*.c files are really platform specific, adjust the build script to only build the needed ones for MinGW. ........ r39401 | schoepflin | 2007-09-20 00:35:43 -0700 (Thu, 20 Sep 2007) | 1 line Added missing include for assert. ........ r39404 | garcia | 2007-09-20 05:15:28 -0700 (Thu, 20 Sep 2007) | 2 lines Fixed dates and filename. ........ r39405 | johnmaddock | 2007-09-20 05:28:34 -0700 (Thu, 20 Sep 2007) | 1 line Updated ICU build options to fix build on Darwin and elsewhere. ........ r39408 | johnmaddock | 2007-09-20 05:38:53 -0700 (Thu, 20 Sep 2007) | 3 lines Update to TR1 to better support gcc. Refactored configuration settings so if the .hpp versions of the headers are included then there's no need to figure out the location of the actual std lib headers. Updated docs to match. ........ r39409 | bgubenko | 2007-09-20 05:42:27 -0700 (Thu, 20 Sep 2007) | 1 line add -AA to link actions, remove +DD64 ........ r39412 | garcia | 2007-09-20 08:34:17 -0700 (Thu, 20 Sep 2007) | 2 lines Fixed the date, updated the copy. ........ r39415 | garcia | 2007-09-20 08:59:57 -0700 (Thu, 20 Sep 2007) | 2 lines Added Lexer. ........ r39416 | grafik | 2007-09-20 09:31:44 -0700 (Thu, 20 Sep 2007) | 1 line Add partial code for indicating to the output function that a command finished because of a timeout. ........ r39417 | bgubenko | 2007-09-20 09:34:31 -0700 (Thu, 20 Sep 2007) | 1 line more conditionalization for PA-RISC ........ r39418 | bgubenko | 2007-09-20 09:59:45 -0700 (Thu, 20 Sep 2007) | 1 line check that on HP-UX, the Standard RW library is used ........ r39421 | johnmaddock | 2007-09-20 10:54:55 -0700 (Thu, 20 Sep 2007) | 1 line Oops, forgot to add new file!! ........ r39423 | noel_belcourt | 2007-09-20 12:06:54 -0700 (Thu, 20 Sep 2007) | 13 lines Added diagnostic message to output.c to inform users when a process has timed out and been killed. Because timed out processes now emit a diagnostic, I had to update option_l.jam so we wouldn't break test.sh when it runs. Minor cleanup to execunix.c to remove unneeded code and to set the process exit status as returned from waitpid. The exit status is used to identify timed out processes so we can emit a diagnostic to the user. ........ r39424 | garcia | 2007-09-20 12:39:53 -0700 (Thu, 20 Sep 2007) | 2 lines Updated. Added links for constrained value. ........ r39425 | bemandawes | 2007-09-20 12:55:32 -0700 (Thu, 20 Sep 2007) | 1 line Always update self. Updating based on file date was not reliable on all systems. ........ r39427 | pdimov | 2007-09-20 13:46:56 -0700 (Thu, 20 Sep 2007) | 1 line defined(__ppc) added (Daniel P Furlani) ........ r39428 | bemandawes | 2007-09-20 14:04:34 -0700 (Thu, 20 Sep 2007) | 1 line Strictly conforming compilers (EDG with --dep_name) require the make_* functions be defined before used. Report and fix from Markus Schopflin. EDG info from Boris Gubenko. ........ r39429 | chris_kohlhoff | 2007-09-20 15:20:57 -0700 (Thu, 20 Sep 2007) | 2 lines Larger storage size needed for Windows x64. ........ r39430 | chris_kohlhoff | 2007-09-20 15:26:55 -0700 (Thu, 20 Sep 2007) | 2 lines Move handler queue management to a separate class. ........ r39431 | chris_kohlhoff | 2007-09-20 15:30:54 -0700 (Thu, 20 Sep 2007) | 3 lines Some compilers require namespace-scope declarations of use_service, has_service and add_service. ........ r39432 | chris_kohlhoff | 2007-09-20 15:33:29 -0700 (Thu, 20 Sep 2007) | 3 lines Eliminate use of types and structure members that may not be present when build for non-XOPEN targets. ........ r39433 | chris_kohlhoff | 2007-09-20 15:44:33 -0700 (Thu, 20 Sep 2007) | 2 lines Regenerate documentation. ........ r39434 | rwgk | 2007-09-20 16:20:45 -0700 (Thu, 20 Sep 2007) | 1 line gcc 4.3.0 compatibility (resolves new "changes meaning" error) ........ r39435 | garcia | 2007-09-20 16:22:46 -0700 (Thu, 20 Sep 2007) | 2 lines A little note to minimize confusion (I know I was confused). ........ r39436 | chris_kohlhoff | 2007-09-20 22:42:55 -0700 (Thu, 20 Sep 2007) | 2 lines Fix documentation generation. ........ r39438 | bemandawes | 2007-09-21 04:45:23 -0700 (Fri, 21 Sep 2007) | 1 line Some compilers require all of the make_error_* functions be template specializations. See prior log message. ........ r39440 | bemandawes | 2007-09-21 04:58:05 -0700 (Fri, 21 Sep 2007) | 1 line Add revision to collected, uploaded, info ........ r39441 | bemandawes | 2007-09-21 04:59:54 -0700 (Fri, 21 Sep 2007) | 1 line Add revision to collected, uploaded, info. Add --have-source, --skip-tests options to ease regression.py testing. ........ r39442 | garcia | 2007-09-21 05:33:31 -0700 (Fri, 21 Sep 2007) | 2 lines small html and grammar fixes. ........ r39443 | chris_kohlhoff | 2007-09-21 05:34:19 -0700 (Fri, 21 Sep 2007) | 5 lines Strict compilers don't like it when you pass a function with C linkage as an argument when the parameter type has C++ linkage. Try using the type of the msghdr::msg_namelen field as an alternative way of deducing the socklen_t-equivalent type. ........ r39447 | bemandawes | 2007-09-21 07:46:04 -0700 (Fri, 21 Sep 2007) | 1 line revision default needs actual value ........ r39448 | danmarsden | 2007-09-21 08:44:57 -0700 (Fri, 21 Sep 2007) | 1 line fixing result of related fusion docs issues for fold, accumulate, and transform view/alg ........ r39449 | bemandawes | 2007-09-21 09:42:27 -0700 (Fri, 21 Sep 2007) | 1 line Fix order-of-initialization problem, add initialization_test.cpp to detect regression. ........ r39450 | grafik | 2007-09-21 10:14:13 -0700 (Fri, 21 Sep 2007) | 1 line Add svn_info.txt file to annotate the revision exported. ........ r39464 | igaztanaga | 2007-09-21 13:45:14 -0700 (Fri, 21 Sep 2007) | 2 lines Glenn Schrader patch: Segmentation fault with 1.34+ on Linux x86_64. Reason: The ~ only complemented the 32 bit unsigned value. When the value was expanded into a size_t the value isn't sign extended so the upper 32 bits wind up being zero. Since this is used as an address mask the upper half of the address is zeroed. ........ r39465 | bemandawes | 2007-09-21 13:57:44 -0700 (Fri, 21 Sep 2007) | 1 line Eliminate Concept library use to reduce dependencies ........ r39466 | grafik | 2007-09-21 14:01:45 -0700 (Fri, 21 Sep 2007) | 1 line Adjust timing to avoid spurious test failures on busy machines. ........ r39467 | noel_belcourt | 2007-09-21 15:38:17 -0700 (Fri, 21 Sep 2007) | 21 lines Another patch to fix the -lx timeout code. Some actions spawn sub-processes after bjam forks a new process (for example, after g++ is forked by bjam, g++ then forks sub-processes like cc1plus). The timeout code would kill the g++ process, but might not kill the subprocesses spawned by g++. I fixed this problem by making the bjam fork'ed process (g++) a session leader by calling setsid() before calling exec. The setsid call, in essence, gives all child processes a parent process id (ppid) of the g++ process id. This guarantees that killing g++ will kill all child processes spawned by g++ as well. One last comment on the maximum process time before a process is actually killed. The worst case process elapsed time is 2x seconds if -lx is given. The reason is that a process might be one second away from being killed and, if there's no other signal activity, the select function will wait x seconds before timing out and killing any active processes. So if you say -lx and monitor a build known to have lengthy processes, you may see a process with up to 2x seconds of time before it is killed. ........ r39468 | djowel | 2007-09-21 18:05:29 -0700 (Fri, 21 Sep 2007) | 1 line Doc updates ........ r39469 | djowel | 2007-09-21 18:08:51 -0700 (Fri, 21 Sep 2007) | 1 line bugfix tuples::null_type and tuples::tuple<> iterators not comparing ok. ........ r39470 | igaztanaga | 2007-09-21 23:15:21 -0700 (Fri, 21 Sep 2007) | 1 line Sign extension bug. Not should be applied after the constant has been expanded to size_t. Thanks to Glenn Schrader. ........ r39473 | johnmaddock | 2007-09-22 02:24:05 -0700 (Sat, 22 Sep 2007) | 1 line Fix for gcc -Wundef warnings. See http://svn.boost.org/trac/boost/ticket/1130. ........ r39474 | t_schwinger | 2007-09-22 04:09:35 -0700 (Sat, 22 Sep 2007) | 2 lines adds concept examples ........ r39475 | johnmaddock | 2007-09-22 04:27:25 -0700 (Sat, 22 Sep 2007) | 1 line Updated license declaration. ........ r39477 | bemandawes | 2007-09-22 07:39:50 -0700 (Sat, 22 Sep 2007) | 1 line Add revision to column heads. Patch courtesy of Sebastian Redl. ........ r39480 | aaron_windsor | 2007-09-22 10:41:18 -0700 (Sat, 22 Sep 2007) | 1 line Some fixes for errors and warnings on HP cxx. ........ r39481 | eric_niebler | 2007-09-22 12:30:25 -0700 (Sat, 22 Sep 2007) | 1 line attempt to fix hp tru64 ........ r39484 | ramey | 2007-09-22 14:24:41 -0700 (Sat, 22 Sep 2007) | 1 line merged in changes - tested with gcc and msvc ........ r39485 | nmusatti | 2007-09-23 05:47:52 -0700 (Sun, 23 Sep 2007) | 1 line Updated to support C++Builder 2007 Update 3 (bcc32 5.9.2) ........ r39490 | johnmaddock | 2007-09-23 10:49:44 -0700 (Sun, 23 Sep 2007) | 1 line Fix up file so it can be compiled in C mode. ........ r39492 | noel_belcourt | 2007-09-23 14:31:43 -0700 (Sun, 23 Sep 2007) | 5 lines Fix problems with Pathscale toolset (-G and -h options are unknown). Thanks John Maddock for pointing these out. ........ r39497 | djowel | 2007-09-23 23:03:12 -0700 (Sun, 23 Sep 2007) | 1 line added new import syntax for ignoring code. ........ r39498 | schoepflin | 2007-09-24 00:31:43 -0700 (Mon, 24 Sep 2007) | 1 line Removed unused variable. ........ r39499 | schoepflin | 2007-09-24 00:38:35 -0700 (Mon, 24 Sep 2007) | 1 line Add needed include (according to XOPEN) for definition of WIFEXITED and WEXITSTATUS. ........ r39502 | chris_kohlhoff | 2007-09-24 05:53:37 -0700 (Mon, 24 Sep 2007) | 2 lines Use a switch rather than an array to translate system_category error codes to their corresponding default error conditions. Add translations for the Winsock error codes. ........ r39503 | chris_kohlhoff | 2007-09-24 06:19:31 -0700 (Mon, 24 Sep 2007) | 2 lines Try making the ip::multicast::enable_loopback socket option an unsigned char on AIX. ........ r39504 | chris_kohlhoff | 2007-09-24 06:21:03 -0700 (Mon, 24 Sep 2007) | 3 lines Check whether exceptions are enabled on the output iostream and throw or not throw errors accordingly. ........ r39505 | chris_kohlhoff | 2007-09-24 06:21:49 -0700 (Mon, 24 Sep 2007) | 2 lines Output error codes and error messages when a test fails. ........ r39506 | grafik | 2007-09-24 06:24:23 -0700 (Mon, 24 Sep 2007) | 1 line Make per target manifest files and a single global catalog files, so that one can have multiple boostbook targets in one project. ........ r39507 | chris_kohlhoff | 2007-09-24 06:29:12 -0700 (Mon, 24 Sep 2007) | 2 lines Fix warning on AIX about omitted 'private' keyword when deriving from noncopyable. ........ r39508 | bemandawes | 2007-09-24 06:32:43 -0700 (Mon, 24 Sep 2007) | 1 line Replace use of re in detecting revision with string functions. Nicola Musatti reported problems with Italian version of XP. Although this change should fix the crash, it isn't the final solution. ........ r39509 | chris_kohlhoff | 2007-09-24 06:32:47 -0700 (Mon, 24 Sep 2007) | 2 lines Add extra library 'ipv6' needed on HP-UX. ........ r39510 | hljin | 2007-09-24 11:20:56 -0700 (Mon, 24 Sep 2007) | 1 line GIL: fixed the test files to the new bit_aligned_pixel_reference interface ........ r39511 | hljin | 2007-09-24 11:25:48 -0700 (Mon, 24 Sep 2007) | 1 line GIL: fixed endian-ness related bugs for bit_aligned_pixel_reference and pixel_aligned_pixel_iterator ........ r39512 | hljin | 2007-09-24 11:45:57 -0700 (Mon, 24 Sep 2007) | 1 line GIL: added a MSVC macro in the Jamfile to suppress warnings on unsafe STL calls ........ r39513 | guwi17 | 2007-09-24 14:01:11 -0700 (Mon, 24 Sep 2007) | 2 lines - Ticket #1234 : patch committed as suggested. ........ r39514 | noel_belcourt | 2007-09-24 14:01:45 -0700 (Mon, 24 Sep 2007) | 7 lines Fix a problem with the -lx timeout code on ppc darwin. The intel based darwin system was killing subprocesses okay but for some reason, ppc systems were not. This change fixes the timeout code so subprocesses are properly killed on ppc darwin systems. ........ r39516 | guwi17 | 2007-09-24 14:26:00 -0700 (Mon, 24 Sep 2007) | 2 lines - Ticket #688 : Outer iterators can now skip empty rows. Thus matrix_assign works now as expected. ........ r39517 | chris_kohlhoff | 2007-09-24 18:56:46 -0700 (Mon, 24 Sep 2007) | 2 lines Add missing "lib ipv6 ;" that's needed for HP-UX. ........ r39518 | noel_belcourt | 2007-09-24 20:39:06 -0700 (Mon, 24 Sep 2007) | 3 lines Get pic and threading working with pathscale. ........ r39519 | schoepflin | 2007-09-25 01:46:31 -0700 (Tue, 25 Sep 2007) | 1 line Added missing include. ........ r39520 | bemandawes | 2007-09-25 06:45:52 -0700 (Tue, 25 Sep 2007) | 1 line Clear compiler warnings ........ r39523 | garcia | 2007-09-25 08:32:23 -0700 (Tue, 25 Sep 2007) | 2 lines Initial Revision. Stolen from the write-graphviz.html docs. ........ r39524 | garcia | 2007-09-25 08:36:35 -0700 (Tue, 25 Sep 2007) | 2 lines Made the output of the example program more realistic. ........ r39525 | bemandawes | 2007-09-25 10:27:04 -0700 (Tue, 25 Sep 2007) | 1 line Supply std:: to fix Borland 5.9.2 errors ........ r39526 | bemandawes | 2007-09-25 10:55:58 -0700 (Tue, 25 Sep 2007) | 1 line Fix revision not propagating (Sebastian Redl) ........ r39531 | noel_belcourt | 2007-09-25 13:34:36 -0700 (Tue, 25 Sep 2007) | 9 lines Add pgi.hpp configuration file for the Portland Group. Fixed problems with threading, pic code, missing math library, etc. to get mipspro toolset working better. Updated pgi toolset to fix various problems with the link line. ........ r39532 | garcia | 2007-09-25 15:49:00 -0700 (Tue, 25 Sep 2007) | 2 lines set dates for reviews. ........ r39534 | noel_belcourt | 2007-09-25 16:11:12 -0700 (Tue, 25 Sep 2007) | 9 lines Add macros to gcc.hpp to support pathscale toolset. Added an optimization to the -lx unix timeout code. I compute the amount of time the select call should sleep until the "oldest" process times out. This ensures that all processes that timeout will be killed within one second of their expiration. ........ r39544 | garcia | 2007-09-26 08:07:19 -0700 (Wed, 26 Sep 2007) | 2 lines Thread-Safe Signals. ........ r39545 | igaztanaga | 2007-09-26 08:07:29 -0700 (Wed, 26 Sep 2007) | 1 line Changes introduced by the new intrusive version. ........ r39546 | igaztanaga | 2007-09-26 08:11:38 -0700 (Wed, 26 Sep 2007) | 1 line Changes introduced by the new intrusive version. ........ r39547 | igaztanaga | 2007-09-26 08:25:36 -0700 (Wed, 26 Sep 2007) | 1 line Changes introduced by the new intrusive version. ........ r39548 | igaztanaga | 2007-09-26 08:26:35 -0700 (Wed, 26 Sep 2007) | 1 line Changes introduced by the new intrusive version. ........ r39549 | igaztanaga | 2007-09-26 10:35:50 -0700 (Wed, 26 Sep 2007) | 1 line Changes introduced by the new intrusive version. ........ r39550 | igaztanaga | 2007-09-26 10:38:32 -0700 (Wed, 26 Sep 2007) | 1 line Changes introduced by the new intrusive version. ........ r39551 | igaztanaga | 2007-09-26 10:39:06 -0700 (Wed, 26 Sep 2007) | 1 line Changes introduced by the new intrusive version. ........ r39552 | igaztanaga | 2007-09-26 10:46:34 -0700 (Wed, 26 Sep 2007) | 1 line Changes introduced by the new intrusive version. ........ r39553 | bemandawes | 2007-09-26 10:48:27 -0700 (Wed, 26 Sep 2007) | 1 line Turns out the --dep_name errors were due to functions in the wrong namespace (Chris Kohlhoff) ........ r39554 | igaztanaga | 2007-09-26 10:51:58 -0700 (Wed, 26 Sep 2007) | 1 line Changes introduced by the new intrusive version. ........ r39555 | igaztanaga | 2007-09-26 10:53:01 -0700 (Wed, 26 Sep 2007) | 1 line Changes introduced by the new intrusive version. ........ r39556 | bemandawes | 2007-09-26 11:11:27 -0700 (Wed, 26 Sep 2007) | 1 line Win64 returns ERROR_BAD_PATHNAME for //nosuch, while Win32 returns ERROR_BAD_NETPATH ........ r39561 | bemandawes | 2007-09-26 17:22:16 -0700 (Wed, 26 Sep 2007) | 1 line Get rid of static. Appears to cause problems on Sun and perhaps other Unix boxes. ........ r39563 | noel_belcourt | 2007-09-26 20:41:11 -0700 (Wed, 26 Sep 2007) | 4 lines Fix pathscale.jam so -rpath is passed correctly to the linker. ........ r39574 | bemandawes | 2007-09-27 06:44:55 -0700 (Thu, 27 Sep 2007) | 1 line Change location of svn_info.txt to boost_root, as that's where it is in the tarball ........ r39575 | garcia | 2007-09-27 08:52:41 -0700 (Thu, 27 Sep 2007) | 2 lines exception review dates. ........ r39576 | igaztanaga | 2007-09-27 09:38:14 -0700 (Thu, 27 Sep 2007) | 1 line Updated unusable toolsets for Interprocess and Intrusive ........ r39577 | bemandawes | 2007-09-27 09:56:23 -0700 (Thu, 27 Sep 2007) | 1 line AIX treats ENOTEMPTY and EEXIST as the same value. Reported by Chris Cambly ........ r39583 | t_schwinger | 2007-09-27 14:25:18 -0700 (Thu, 27 Sep 2007) | 3 lines changes review dates for Boost.Exception as agreed on with Ron ........ r39584 | cepstein | 2007-09-27 18:30:27 -0700 (Thu, 27 Sep 2007) | 1 line Changed required toolset gcc-4.1.1_sunos_i86pc to gcc-4.1.2_sunos_i86pc ........ r39585 | bemandawes | 2007-09-27 19:03:29 -0700 (Thu, 27 Sep 2007) | 1 line Quiet compiler warnings ........ r39586 | schoepflin | 2007-09-28 00:19:29 -0700 (Fri, 28 Sep 2007) | 1 line Added missing include. ........ r39587 | schoepflin | 2007-09-28 03:28:26 -0700 (Fri, 28 Sep 2007) | 1 line Added two missing fwd declarations and a Tru64/CXX specific workaround. ........ r39588 | garcia | 2007-09-28 12:39:57 -0700 (Fri, 28 Sep 2007) | 2 lines Exception has begun. ........ r39589 | burbelgruff | 2007-09-28 13:09:01 -0700 (Fri, 28 Sep 2007) | 1 line Implement typeof emulation for the Borland compiler. Tested with Borland 5.8.2 ........ r39590 | burbelgruff | 2007-09-28 13:11:32 -0700 (Fri, 28 Sep 2007) | 1 line Modified tests to account for Borland compiler ........ r39591 | burbelgruff | 2007-09-28 13:16:39 -0700 (Fri, 28 Sep 2007) | 1 line Updated failures markup to account for typeof support for Borland ........ r39592 | grafik | 2007-09-28 18:50:16 -0700 (Fri, 28 Sep 2007) | 1 line Minor adjustment to save half of the upload bandwidth, at the cost of another layer of compression on both ends. ........ r39595 | eric_niebler | 2007-09-29 08:45:08 -0700 (Sat, 29 Sep 2007) | 1 line remove unnecessary semicolons ........ r39596 | eric_niebler | 2007-09-29 08:51:29 -0700 (Sat, 29 Sep 2007) | 1 line mark xpressive unusable with sun compiler ........ r39597 | vladimir_prus | 2007-09-29 10:12:49 -0700 (Sat, 29 Sep 2007) | 1 line Summarize changes ........ r39601 | vladimir_prus | 2007-09-29 10:28:10 -0700 (Sat, 29 Sep 2007) | 1 line Update version. ........ r39602 | vladimir_prus | 2007-09-29 10:29:49 -0700 (Sat, 29 Sep 2007) | 1 line Update download locations. ........ r39603 | vladimir_prus | 2007-09-29 10:31:44 -0700 (Sat, 29 Sep 2007) | 1 line Adjust date ........ r39605 | vladimir_prus | 2007-09-29 11:17:27 -0700 (Sat, 29 Sep 2007) | 7 lines Adjust boostbook test for boostbook changes. It seems that doxygen target now produces a target with different name, and it does not produce any target unless there's explicit dependency on it. I'm not sure I like the change, but anyway. ........ r39606 | vladimir_prus | 2007-09-29 11:21:49 -0700 (Sat, 29 Sep 2007) | 1 line Adjust Qt4 example test ........ r39607 | vladimir_prus | 2007-09-29 11:22:57 -0700 (Sat, 29 Sep 2007) | 1 line Set executable flag ........ r39608 | grafik | 2007-09-29 11:30:06 -0700 (Sat, 29 Sep 2007) | 1 line Fix action multi-generation for case when there are no targets for the action. ........ r39609 | bemandawes | 2007-09-29 12:40:23 -0700 (Sat, 29 Sep 2007) | 1 line Limit Windows expected message check to US English ........ r39610 | grafik | 2007-09-29 12:48:51 -0700 (Sat, 29 Sep 2007) | 1 line Update distribution and build scripts to account for inclusion of boehm_gc sources. Add history of changes to docs. ........ r39611 | grafik | 2007-09-29 12:58:28 -0700 (Sat, 29 Sep 2007) | 1 line Set executable flag. ........ r39612 | noel_belcourt | 2007-09-29 13:23:29 -0700 (Sat, 29 Sep 2007) | 6 lines When terminating unix processes I forgot to check for negative time differences. This patch only sets the select timeout if the difference between the requested and consumed time is positive. ........ r39613 | noel_belcourt | 2007-09-29 14:47:24 -0700 (Sat, 29 Sep 2007) | 15 lines Renamed variables used in timeout code so I don't make silly mistakes like using a negative time for the select timeout. Also added the setrlimit call back in since the named_condition_test occassionally consumes multiple cpus worth of time. That is, when I ran this test -j4, I found the named_condition test consuming 4 cpus worth of time so after 300 seconds of elapsed time when the test timed out, it had consumed almost 1200 seconds worth of cpu. While the test is killed after the elapsed time expired, setting a hard cpu limit ensures it's killed after consuming either -lx seconds worth of cpu or -lx seconds of elapsed time. ........ r39614 | eric_niebler | 2007-09-29 21:05:31 -0700 (Sat, 29 Sep 2007) | 1 line slightly more informative test errors ........ r39615 | garcia | 2007-09-30 07:58:38 -0700 (Sun, 30 Sep 2007) | 2 lines FSM dates. ........ r39616 | grafik | 2007-09-30 08:52:31 -0700 (Sun, 30 Sep 2007) | 1 line Fix missing files in tar generation, by using a tar format that doesn't have short limits on file name lengths. (and that is still readable by the Python tarfile module) ........ r39617 | grafik | 2007-09-30 09:33:36 -0700 (Sun, 30 Sep 2007) | 1 line Fix copying the wrong files for the archive, and prefer using POSIX/pax format. ........ r39619 | johnmaddock | 2007-09-30 10:29:54 -0700 (Sun, 30 Sep 2007) | 1 line Fix for failing Borland test results. ........ r39620 | grafik | 2007-09-30 10:33:21 -0700 (Sun, 30 Sep 2007) | 1 line Bump to bjam version 3.1.16 ........ r39621 | johnmaddock | 2007-09-30 10:35:14 -0700 (Sun, 30 Sep 2007) | 1 line Touched file to force regressions runners to rebuild the test. ........ r39623 | vladimir_prus | 2007-09-30 12:05:38 -0700 (Sun, 30 Sep 2007) | 1 line Update example test-config.jam ........ r39624 | vladimir_prus | 2007-09-30 12:06:19 -0700 (Sun, 30 Sep 2007) | 1 line Update roll.sh ........ r39630 | vladimir_prus | 2007-09-30 23:04:17 -0700 (Sun, 30 Sep 2007) | 1 line Correct example test-config.jam ........ r39631 | vladimir_prus | 2007-09-30 23:05:03 -0700 (Sun, 30 Sep 2007) | 1 line Update release procedure ........ r39632 | vladimir_prus | 2007-09-30 23:06:25 -0700 (Sun, 30 Sep 2007) | 1 line Set release date ........ r39633 | johnmaddock | 2007-10-01 01:29:15 -0700 (Mon, 01 Oct 2007) | 1 line Disable test for Intel-10. ........ r39634 | johnmaddock | 2007-10-01 02:38:05 -0700 (Mon, 01 Oct 2007) | 1 line Almost get things building with Borland. ........ r39635 | johnmaddock | 2007-10-01 02:39:07 -0700 (Mon, 01 Oct 2007) | 1 line Added workarounds for broken WCHAR_MAX. ........ r39638 | guwi17 | 2007-10-01 06:04:29 -0700 (Mon, 01 Oct 2007) | 2 lines - added redirect from index.html to real start page: index.htm ........ r39641 | vladimir_prus | 2007-10-01 10:29:11 -0700 (Mon, 01 Oct 2007) | 3 lines Allow to specify the list of bound targets and flags, when defining action from Python. ........ r39642 | vladimir_prus | 2007-10-01 10:34:43 -0700 (Mon, 01 Oct 2007) | 2 lines Fix gcc on HP-UX. Patch from Boris Gubenko. ........ r39643 | vladimir_prus | 2007-10-01 11:27:53 -0700 (Mon, 01 Oct 2007) | 3 lines Append .lib suffix to library names without :S= modifier. The latter will remove any existing suffix. ........ r39644 | vladimir_prus | 2007-10-01 11:40:44 -0700 (Mon, 01 Oct 2007) | 4 lines * builtin.jam (searched-lib-generator.run): When no feature present, use requested name. ........ r39645 | vladimir_prus | 2007-10-01 11:44:44 -0700 (Mon, 01 Oct 2007) | 8 lines STLPort improvements: - Add _static in library name as necessary - Define _STLP_USE_DYNAMIC_LIB depending on , not Patch from David Deakins. Addresses #1177. ........ r39646 | vladimir_prus | 2007-10-01 11:53:05 -0700 (Mon, 01 Oct 2007) | 5 lines Disallow using stlport by just adding /stlport//stlport to sources. This logic was trying to use non-free usage requirements that are not supported, and can potentially result in inconsistent builds. ........ r39647 | bemandawes | 2007-10-01 14:50:02 -0700 (Mon, 01 Oct 2007) | 1 line Detect and report missing boost-test lines in input log file ........ r39648 | bemandawes | 2007-10-01 18:33:00 -0700 (Mon, 01 Oct 2007) | 1 line Add --compile-time and --run-time options ........ r39649 | eric_niebler | 2007-10-01 23:47:58 -0700 (Mon, 01 Oct 2007) | 1 line attempt to fix xpressive formatting bug on tru64 ........ r39651 | hkaiser | 2007-10-02 08:10:05 -0700 (Tue, 02 Oct 2007) | 1 line [Wave] Unterminated C++/C comment diagnostics are now a warning and not an error anymore. ........ r39652 | bemandawes | 2007-10-02 09:30:04 -0700 (Tue, 02 Oct 2007) | 1 line Remove dependency on boost::bind so that tests will still work on broken compilers where bind fails. ........ r39654 | hkaiser | 2007-10-02 10:24:17 -0700 (Tue, 02 Oct 2007) | 1 line Wave: Fixed the waveidl example ........ r39655 | johnmaddock | 2007-10-02 10:28:01 -0700 (Tue, 02 Oct 2007) | 1 line Update for Borland compilers: new Borland versions, and new tests, but otherwise the same failures as before. ........ r39657 | johnmaddock | 2007-10-02 10:41:35 -0700 (Tue, 02 Oct 2007) | 1 line Fix for Borland compilers. ........ r39658 | eric_niebler | 2007-10-02 10:58:33 -0700 (Tue, 02 Oct 2007) | 1 line work around msvc-7.1 bugs ........ r39660 | bgubenko | 2007-10-02 12:07:37 -0700 (Tue, 02 Oct 2007) | 1 line mark lambda library test control_structures for gcc 4.2 series ........ r39663 | nmusatti | 2007-10-02 13:32:05 -0700 (Tue, 02 Oct 2007) | 1 line Updated to support C++Builder 2007 Update 3 (bcc32 5.9.2) ........ r39664 | chris_kohlhoff | 2007-10-02 18:40:55 -0700 (Tue, 02 Oct 2007) | 2 lines Add missing #include needed for MinGW. ........ r39665 | chris_kohlhoff | 2007-10-02 18:43:08 -0700 (Tue, 02 Oct 2007) | 3 lines Try using an unsigned char for the multicast::enable_loopback socket option when compiling for Tru64. ........ r39673 | hkaiser | 2007-10-03 06:18:23 -0700 (Wed, 03 Oct 2007) | 1 line Wave: Fixed a regex definition problem in the Slex lexer. ........ r39674 | hkaiser | 2007-10-03 06:44:42 -0700 (Wed, 03 Oct 2007) | 1 line Wave: Fixed a minor problem in the predefined macros code. ........ r39675 | hkaiser | 2007-10-03 06:51:32 -0700 (Wed, 03 Oct 2007) | 1 line Wave: Updated test to reflect recent error text changes. ........ r39676 | bemandawes | 2007-10-03 10:30:23 -0700 (Wed, 03 Oct 2007) | 1 line Add revision number to heading if boost-root is subversion working copy. Use BOOST_PLATFORM for platform description. Fix problem if test type was run_pyd. Make Boost build v2 the default. Link to www.boost.org for boost.png. ........ r39677 | burbelgruff | 2007-10-03 11:45:56 -0700 (Wed, 03 Oct 2007) | 1 line Mark borland 5.6.4 as unusable ........ r39678 | noel_belcourt | 2007-10-03 12:00:18 -0700 (Wed, 03 Oct 2007) | 3 lines Fix problem with -rpath for pathscale compiler. ........ r39680 | vladimir_prus | 2007-10-04 01:15:13 -0700 (Thu, 04 Oct 2007) | 1 line Redo homepage ........ r39681 | vladimir_prus | 2007-10-04 01:18:40 -0700 (Thu, 04 Oct 2007) | 3 lines When building docs, use the same Boost.Build that we're rolling. ........ r39682 | johnmaddock | 2007-10-04 02:18:16 -0700 (Thu, 04 Oct 2007) | 1 line Added tip to function_traits.qbk, rebuilt docs. ........ r39683 | schoepflin | 2007-10-04 04:51:51 -0700 (Thu, 04 Oct 2007) | 1 line Added missing boost namespace reference to as_literal. ........ r39684 | hkaiser | 2007-10-04 08:01:23 -0700 (Thu, 04 Oct 2007) | 1 line Wave: Changed an error text. ........ r39685 | igaztanaga | 2007-10-04 09:41:15 -0700 (Thu, 04 Oct 2007) | 1 line Marked acc as n/a for Interprocess. ........ r39686 | hkaiser | 2007-10-04 10:49:20 -0700 (Thu, 04 Oct 2007) | 1 line Trying to work around a SUN 5.8 compiler error. ........ r39687 | hkaiser | 2007-10-04 10:55:20 -0700 (Thu, 04 Oct 2007) | 1 line Wave: Silenced a SUN compiler warning. ........ r39688 | hkaiser | 2007-10-04 16:37:25 -0700 (Thu, 04 Oct 2007) | 1 line Wave: Trying to fix MSVC regressions. ........ r39689 | grafik | 2007-10-04 20:09:03 -0700 (Thu, 04 Oct 2007) | 1 line Fix mislabeled argument to collect_logs(). ........ r39690 | eric_niebler | 2007-10-04 23:50:00 -0700 (Thu, 04 Oct 2007) | 1 line one more try at getting tru64 tests to pass ........ r39691 | burbelgruff | 2007-10-05 00:06:13 -0700 (Fri, 05 Oct 2007) | 1 line Update typeof emulation to support Borland 5.9.2 ........ r39692 | danieljames | 2007-10-05 02:43:01 -0700 (Fri, 05 Oct 2007) | 2 lines Fix an if statement. ........ r39693 | anthonyw | 2007-10-05 02:46:00 -0700 (Fri, 05 Oct 2007) | 1 line Updated in line with RC 1.34 ........ r39694 | danieljames | 2007-10-05 02:46:22 -0700 (Fri, 05 Oct 2007) | 3 lines On Cygwin use a binary based hash function for floating point numbers, as Cygwin doesn't have decent floating point functions for long doubles. ........ r39701 | anthonyw | 2007-10-05 05:10:06 -0700 (Fri, 05 Oct 2007) | 1 line Changed call_once to header-only template that takes arbitrary function objects; this changes parameter order ........ r39702 | anthonyw | 2007-10-05 05:20:50 -0700 (Fri, 05 Oct 2007) | 1 line added platform-specific call_once implementations ........ r39703 | anthonyw | 2007-10-05 05:21:55 -0700 (Fri, 05 Oct 2007) | 1 line added platform dispatcher ........ r39704 | burbelgruff | 2007-10-05 05:39:15 -0700 (Fri, 05 Oct 2007) | 1 line typeof support for template template arguments for Borland 5.9.2 (also used for Borland 5.8.2) (reverted to old scheme for other compilers) ........ r39705 | anthonyw | 2007-10-05 05:50:29 -0700 (Fri, 05 Oct 2007) | 1 line include config header from right place for pthread/once.hpp ........ r39707 | burbelgruff | 2007-10-05 07:32:04 -0700 (Fri, 05 Oct 2007) | 1 line Better support for BOOST_TYPEOF_NESTED_TYPEDEF for Borland ........ r39708 | johnmaddock | 2007-10-05 08:00:40 -0700 (Fri, 05 Oct 2007) | 1 line Disable PP-logic for __DECCXX compiler: WCAHR_MAX is defined but doesn't work in PP-logic on that platform. ........ r39709 | johnmaddock | 2007-10-05 08:07:44 -0700 (Fri, 05 Oct 2007) | 1 line run_random was failing in the last release with Borland but wasn't marked up for some reason. ........ r39710 | johnmaddock | 2007-10-05 08:47:02 -0700 (Fri, 05 Oct 2007) | 1 line Markup for common_factor_test and Borland along with explanation of the issue (a code generation bug apparently). ........ r39711 | danieljames | 2007-10-05 09:57:38 -0700 (Fri, 05 Oct 2007) | 2 lines Generate documentation for typedef members of classes. Fixes #1218. ........ r39714 | johnmaddock | 2007-10-05 10:49:12 -0700 (Fri, 05 Oct 2007) | 1 line Update Jamfiles to make PDF generation easier. ........ r39715 | igaztanaga | 2007-10-05 10:54:39 -0700 (Fri, 05 Oct 2007) | 1 line Marked hpp_cxx* as broken for Interprocess/Intrusive, and acc for Interprocess. ........ r39716 | hkaiser | 2007-10-05 11:48:56 -0700 (Fri, 05 Oct 2007) | 1 line Pool: Added detection of availability of pthreads using the BOOST_HAS_PTHREADS constant. ........ r39717 | eric_niebler | 2007-10-05 12:00:43 -0700 (Fri, 05 Oct 2007) | 1 line put format string argument in non-deduced context ........ r39718 | hkaiser | 2007-10-05 15:04:04 -0700 (Fri, 05 Oct 2007) | 1 line Added a compiler workaround for IntelV9.1/linux. ........ r39719 | hkaiser | 2007-10-05 16:25:09 -0700 (Fri, 05 Oct 2007) | 1 line Wave: Fixed missing test case in regression status pages. ........ r39720 | hkaiser | 2007-10-05 16:27:43 -0700 (Fri, 05 Oct 2007) | 1 line ProgramOptions: Silenced VC++ warnings. ........ r39721 | hkaiser | 2007-10-05 17:26:30 -0700 (Fri, 05 Oct 2007) | 1 line Wave: Fixed typos in comments. ........ r39722 | pdimov | 2007-10-06 01:59:01 -0700 (Sat, 06 Oct 2007) | 1 line Marked up bind_placeholder_test ........ r39723 | johnmaddock | 2007-10-06 04:12:33 -0700 (Sat, 06 Oct 2007) | 1 line Fix Borland infinite looping issue. ........ r39724 | djowel | 2007-10-06 07:10:30 -0700 (Sat, 06 Oct 2007) | 1 line fix for incomplete type is not allowed when tuple is forward declared. fixed the other as_xxx files as well. ........ r39725 | johnmaddock | 2007-10-06 10:40:20 -0700 (Sat, 06 Oct 2007) | 1 line Fix typo. ........ r39726 | hkaiser | 2007-10-06 10:43:08 -0700 (Sat, 06 Oct 2007) | 1 line Wave: Fixed Jamfile for regression tests. ........ r39727 | johnmaddock | 2007-10-06 10:46:25 -0700 (Sat, 06 Oct 2007) | 1 line Update docs to match quickbook. ........ r39728 | hkaiser | 2007-10-06 10:54:28 -0700 (Sat, 06 Oct 2007) | 1 line Wave: added a missing header. ........ r39729 | vladimir_prus | 2007-10-06 11:24:04 -0700 (Sat, 06 Oct 2007) | 3 lines When we skip build of a target, say about that in --debug-building output. ........ r39731 | grafik | 2007-10-06 12:46:39 -0700 (Sat, 06 Oct 2007) | 1 line Remove BPL build conditional as it prevents normal build failures. ........ r39751 | nmusatti | 2007-10-06 14:32:05 -0700 (Sat, 06 Oct 2007) | 1 line Updated to support C++Builder 2007 Update 3 (bcc32 5.9.2) ........ r39752 | chris_kohlhoff | 2007-10-06 17:11:25 -0700 (Sat, 06 Oct 2007) | 5 lines The epoll_wait function can produce EPOLLHUP events for a descriptor even if not specifically requested, resulting in a tight loop of calls to epoll_wait. Delete a descriptor from epoll if an EPOLLHUP event is received and there are no registered operations for the descriptor. ........ r39753 | troyer | 2007-10-06 23:57:36 -0700 (Sat, 06 Oct 2007) | 1 line Fix for Borland ........ r39755 | johnmaddock | 2007-10-07 04:08:51 -0700 (Sun, 07 Oct 2007) | 1 line math_info doesn't link with Borland unless built against the static runtime. ........ r39756 | johnmaddock | 2007-10-07 04:09:45 -0700 (Sun, 07 Oct 2007) | 1 line math_info doesn't link with Borland unless built against the static runtime. ........ r39757 | johnmaddock | 2007-10-07 04:10:24 -0700 (Sun, 07 Oct 2007) | 1 line Added expm1 and lop1p support. ........ r39759 | hkaiser | 2007-10-07 07:46:52 -0700 (Sun, 07 Oct 2007) | 1 line Spirit: Fixed a couple of pedantic gcc warnings. ........ r39760 | hkaiser | 2007-10-07 07:51:46 -0700 (Sun, 07 Oct 2007) | 1 line Wave: Silenced a couple of pedantic gcc warnings. ........ r39761 | hkaiser | 2007-10-07 08:55:00 -0700 (Sun, 07 Oct 2007) | 1 line Spirit: Fixed a failing unit test. ........ r39762 | hkaiser | 2007-10-07 08:57:37 -0700 (Sun, 07 Oct 2007) | 1 line Spirit: Silenced some warnings. ........ r39763 | aaron_windsor | 2007-10-07 09:52:39 -0700 (Sun, 07 Oct 2007) | 1 line Fixing some errors and warnings on the planar graph tests coming from Sun compilers. ........ r39766 | danieljames | 2007-10-07 11:08:35 -0700 (Sun, 07 Oct 2007) | 1 line Include the size of function pointers, void* and std::size_t in the output of the function pointer hash test, to give me a clue why it's failling on a platform. ........ r39767 | aaron_windsor | 2007-10-07 11:43:16 -0700 (Sun, 07 Oct 2007) | 1 line Fix config issue for cycle ratio tests - the path to the input file used in the test should be relative to the graph test subdirectory. ........ r39772 | bemandawes | 2007-10-07 14:59:46 -0700 (Sun, 07 Oct 2007) | 1 line Appy Godegear patches from Nicola Musatti. Ticket #1304 ........ r39773 | aaron_windsor | 2007-10-07 16:49:07 -0700 (Sun, 07 Oct 2007) | 1 line Adding some missing typenames ........ r39774 | eric_niebler | 2007-10-07 17:44:52 -0700 (Sun, 07 Oct 2007) | 1 line add awesome number parser from Dave Jenkins ........ r39776 | eric_niebler | 2007-10-07 18:15:01 -0700 (Sun, 07 Oct 2007) | 1 line fix warnings under msvc ........ r39777 | anthonyw | 2007-10-08 00:18:27 -0700 (Mon, 08 Oct 2007) | 1 line Use InterlockedCompareExchange when _ReadWriteBarrier not available ........ r39778 | agurtovoy | 2007-10-08 01:06:15 -0700 (Mon, 08 Oct 2007) | 1 line MPL: more inclusive markup for the gcc 4.1 regression ........ r39780 | anthonyw | 2007-10-08 02:48:57 -0700 (Mon, 08 Oct 2007) | 1 line added extended test for new call_once ........ r39781 | anthonyw | 2007-10-08 02:55:56 -0700 (Mon, 08 Oct 2007) | 1 line call_once passes exceptions to caller and leaves flag unset ........ r39784 | anthonyw | 2007-10-08 08:41:05 -0700 (Mon, 08 Oct 2007) | 1 line New mutex implementations, more akin to C++0x ........ r39785 | anthonyw | 2007-10-08 08:44:13 -0700 (Mon, 08 Oct 2007) | 1 line added backwards-compatibility overload for call_once ........ r39786 | eric_niebler | 2007-10-08 08:49:09 -0700 (Mon, 08 Oct 2007) | 1 line fix postinc/assign problem with case_converting_iterator ........ r39787 | eric_niebler | 2007-10-08 08:57:04 -0700 (Mon, 08 Oct 2007) | 1 line doc tweaks ........ r39788 | burbelgruff | 2007-10-08 09:35:06 -0700 (Mon, 08 Oct 2007) | 1 line [typeof] Updated failures list to include failing borland tests and some failing native tests ........ r39789 | burbelgruff | 2007-10-08 09:37:01 -0700 (Mon, 08 Oct 2007) | 1 line [typeof] native typeof support added for the Digital Mars compiler (same as the typeof hack used for Visual C++) ........ r39790 | eric_niebler | 2007-10-08 09:49:00 -0700 (Mon, 08 Oct 2007) | 1 line work around msvc-7.1 bug ........ r39792 | johnmaddock | 2007-10-08 09:58:15 -0700 (Mon, 08 Oct 2007) | 2 lines Initial math-toolkit commit. Includes all code and tests, but no docs yet. ........ r39793 | eric_niebler | 2007-10-08 10:12:56 -0700 (Mon, 08 Oct 2007) | 1 line better fix for case_converting_iterator as suggested by Steven Watanabe ........ r39794 | eric_niebler | 2007-10-08 10:13:29 -0700 (Mon, 08 Oct 2007) | 1 line clean up gcc unused parameter warnings ........ r39796 | burbelgruff | 2007-10-08 10:46:23 -0700 (Mon, 08 Oct 2007) | 1 line [typeof] testing for typeof hacks on all compilers ........ r39805 | vladimir_prus | 2007-10-08 10:54:17 -0700 (Mon, 08 Oct 2007) | 1 line New changes ........ r39812 | johnmaddock | 2007-10-08 11:03:19 -0700 (Mon, 08 Oct 2007) | 1 line Initial commit of math-toolkit docs. ........ r39817 | vladimir_prus | 2007-10-08 14:10:41 -0700 (Mon, 08 Oct 2007) | 1 line Windows fix ........ r39818 | vladimir_prus | 2007-10-08 14:13:05 -0700 (Mon, 08 Oct 2007) | 1 line Windows fix ........ r39819 | eric_niebler | 2007-10-08 14:14:14 -0700 (Mon, 08 Oct 2007) | 1 line escape accented character ........ r39820 | vladimir_prus | 2007-10-08 14:28:09 -0700 (Mon, 08 Oct 2007) | 1 line Windows fix ........ r39821 | vladimir_prus | 2007-10-08 14:47:05 -0700 (Mon, 08 Oct 2007) | 1 line Windows fix ........ r39823 | eric_niebler | 2007-10-08 15:41:00 -0700 (Mon, 08 Oct 2007) | 1 line symbols docs, acknowledgement for dave j., doxygen tweaks ........ r39826 | eric_niebler | 2007-10-08 16:48:25 -0700 (Mon, 08 Oct 2007) | 1 line fix warning ........ r39828 | vladimir_prus | 2007-10-08 22:33:45 -0700 (Mon, 08 Oct 2007) | 2 lines Make NORMALIZE_PATH convert \ to /. ........ r39829 | vladimir_prus | 2007-10-08 22:35:48 -0700 (Mon, 08 Oct 2007) | 1 line Make it compile, even ........ r39830 | vladimir_prus | 2007-10-08 22:38:31 -0700 (Mon, 08 Oct 2007) | 1 line Make it work, for extra benefit ('=' vs '==' bug) ........ r39831 | vladimir_prus | 2007-10-08 23:37:00 -0700 (Mon, 08 Oct 2007) | 1 line Attemp to fix searched_lib on windows ........ r39832 | anthonyw | 2007-10-08 23:59:14 -0700 (Mon, 08 Oct 2007) | 1 line added missing move.hpp header ........ r39833 | danieljames | 2007-10-09 00:19:30 -0700 (Tue, 09 Oct 2007) | 1 line Output some info about a test failure when hashing function pointers. ........ r39834 | johnmaddock | 2007-10-09 04:15:11 -0700 (Tue, 09 Oct 2007) | 1 line Fix problem with GCC on Linux not finding std_real_concept overload for fmod. ........ r39835 | johnmaddock | 2007-10-09 04:30:19 -0700 (Tue, 09 Oct 2007) | 1 line Added HTML docs, changed some section names to shorten the file names produced. ........ r39836 | anthonyw | 2007-10-09 05:23:09 -0700 (Tue, 09 Oct 2007) | 1 line fixed direction of conditional ........ r39837 | johnmaddock | 2007-10-09 05:26:27 -0700 (Tue, 09 Oct 2007) | 1 line Disabled long double support on some platforms. ........ r39838 | anthonyw | 2007-10-09 05:45:46 -0700 (Tue, 09 Oct 2007) | 1 line fixed typo in pthread_cond_timedwait and ETIMEDOUT ........ r39839 | anthonyw | 2007-10-09 07:08:22 -0700 (Tue, 09 Oct 2007) | 1 line fixed typo in pthread_cond_timedwait and ETIMEDOUT ........ r39840 | garcia | 2007-10-09 07:28:42 -0700 (Tue, 09 Oct 2007) | 2 lines Exception review period has ended. ........ r39841 | anthonyw | 2007-10-09 07:44:37 -0700 (Tue, 09 Oct 2007) | 1 line fixed more has-timed-lock backwards conditions ........ r39842 | johnmaddock | 2007-10-09 07:49:04 -0700 (Tue, 09 Oct 2007) | 1 line Changed call signatures to keep Borland happy. ........ r39843 | johnmaddock | 2007-10-09 07:49:37 -0700 (Tue, 09 Oct 2007) | 1 line A few fixes to keep Borland happy. ........ r39848 | bemandawes | 2007-10-09 09:39:13 -0700 (Tue, 09 Oct 2007) | 1 line Apply dll fixes from David Deakins ........ r39849 | igaztanaga | 2007-10-09 09:49:47 -0700 (Tue, 09 Oct 2007) | 1 line Marked acc as n/a for Interprocess. ........ r39850 | johnmaddock | 2007-10-09 10:16:58 -0700 (Tue, 09 Oct 2007) | 1 line Added refactored docs for existing Boost.Math libraries. ........ r39851 | johnmaddock | 2007-10-09 10:17:50 -0700 (Tue, 09 Oct 2007) | 1 line Added refactored docs for existing Boost.Math libraries. ........ r39852 | johnmaddock | 2007-10-09 10:25:30 -0700 (Tue, 09 Oct 2007) | 1 line Added refactored docs for existing Boost.Math libraries. ........ r39853 | eric_niebler | 2007-10-09 10:56:18 -0700 (Tue, 09 Oct 2007) | 1 line fix broken link to OASIS DocBook DTD ........ r39854 | johnmaddock | 2007-10-09 11:11:17 -0700 (Tue, 09 Oct 2007) | 1 line More Borland workarounds. ........ r39855 | johnmaddock | 2007-10-09 11:12:06 -0700 (Tue, 09 Oct 2007) | 1 line More Borland workarounds. ........ r39863 | chris_kohlhoff | 2007-10-09 14:47:07 -0700 (Tue, 09 Oct 2007) | 2 lines Assume that HP-UX and AIX both need to have SIGPIPE blocked. ........ r39864 | chris_kohlhoff | 2007-10-09 14:47:40 -0700 (Tue, 09 Oct 2007) | 3 lines HP-UX with aCC uses a variant of select() that takes int* arguments rather than fd_set*. ........ r39865 | chris_kohlhoff | 2007-10-09 14:59:38 -0700 (Tue, 09 Oct 2007) | 3 lines Try changing the default target to Windows XP rather than Windows 2000 to see effect on borland-5.9.2. ........ r39867 | eric_niebler | 2007-10-09 15:25:18 -0700 (Tue, 09 Oct 2007) | 1 line more user docs for semantic actions ........ r39868 | eric_niebler | 2007-10-09 15:26:59 -0700 (Tue, 09 Oct 2007) | 1 line add xpressive::function<> for defining function objects for use in semantic actions ........ r39869 | djowel | 2007-10-09 16:15:12 -0700 (Tue, 09 Oct 2007) | 1 line adding fusion ........ r39870 | eric_niebler | 2007-10-09 18:46:53 -0700 (Tue, 09 Oct 2007) | 1 line fix buggy predicate_matcher and stomp more msvc warnings ........ r39871 | aaron_windsor | 2007-10-09 19:18:37 -0700 (Tue, 09 Oct 2007) | 1 line Trying to clear some errors from Sun CC. ........ r39872 | hkaiser | 2007-10-09 19:25:35 -0700 (Tue, 09 Oct 2007) | 1 line Boost.Thread now depends on Boost.DateTime. ........ r39873 | vladimir_prus | 2007-10-10 00:40:05 -0700 (Wed, 10 Oct 2007) | 4 lines Add values of variables specified with -s to .EVNRION module, so that we can override environment on command line. ........ r39874 | schoepflin | 2007-10-10 00:42:19 -0700 (Wed, 10 Oct 2007) | 1 line Disambiguate the identifier 'exception' and fix vector construction to make the test pass on Tru64/CXX. ........ r39875 | schoepflin | 2007-10-10 01:21:36 -0700 (Wed, 10 Oct 2007) | 1 line Blind shot trying to fix error blocking regression runs. ........ r39876 | vladimir_prus | 2007-10-10 01:25:27 -0700 (Wed, 10 Oct 2007) | 2 lines New bjam.variable function exposed to Python. ........ r39881 | johnmaddock | 2007-10-10 02:28:48 -0700 (Wed, 10 Oct 2007) | 1 line Adjusted limits for Win64 and Sun OS. ........ r39884 | johnmaddock | 2007-10-10 02:31:44 -0700 (Wed, 10 Oct 2007) | 1 line Tentative Sunpro workaround. ........ r39885 | joaquin | 2007-10-10 03:20:43 -0700 (Wed, 10 Oct 2007) | 1 line reverted 36306 for CW 8.3 ........ r39886 | vladimir_prus | 2007-10-10 03:23:20 -0700 (Wed, 10 Oct 2007) | 1 line Add link to PythonPort page ........ r39887 | vladimir_prus | 2007-10-10 03:35:07 -0700 (Wed, 10 Oct 2007) | 1 line Fix URL ........ r39890 | hkaiser | 2007-10-10 05:42:16 -0700 (Wed, 10 Oct 2007) | 1 line Wave: Updated Jamfiles to include Boost.DateTime. ........ r39891 | anthonyw | 2007-10-10 08:33:49 -0700 (Wed, 10 Oct 2007) | 1 line read_write_mutex makes a comeback --- as shared_mutex ........ r39892 | bemandawes | 2007-10-10 08:49:32 -0700 (Wed, 10 Oct 2007) | 1 line Fix date_time boo boo that was causing all regression tests to fail ........ r39893 | johnmaddock | 2007-10-10 09:05:26 -0700 (Wed, 10 Oct 2007) | 7 lines Added Compaq CXX long long workaround to real_concept.hpp. Added missing forward declaration to ellint_1.hpp. Adjusted native log1p support for aCC. Removed bad forward declaration of fpclassify: correct declaration appears later in the file. Adjusted compile_test/test_compile_result.hpp to not return a NULL reference. Adjusted permitted error-limits for new platforms. Split some of the tests into smaller units so we don't get compiler timeouts when building (hopefully!) ........ r39894 | hkaiser | 2007-10-10 09:44:29 -0700 (Wed, 10 Oct 2007) | 1 line Wave: Fixed Jamfiles. ........ r39897 | eric_niebler | 2007-10-10 11:13:18 -0700 (Wed, 10 Oct 2007) | 1 line work around gcc bug in proto, add test for custom assertions, fix more gcc warnings ........ r39898 | vladimir_prus | 2007-10-10 12:07:57 -0700 (Wed, 10 Oct 2007) | 1 line Add logo, tweak the page ........ r39899 | vladimir_prus | 2007-10-10 12:10:45 -0700 (Wed, 10 Oct 2007) | 1 line Revert mistaken commit ........ r39900 | johnmaddock | 2007-10-10 12:12:46 -0700 (Wed, 10 Oct 2007) | 1 line Workaround for msvc+stlport. ........ r39901 | vladimir_prus | 2007-10-10 12:18:25 -0700 (Wed, 10 Oct 2007) | 1 line Upload logo, too ........ r39902 | vladimir_prus | 2007-10-10 12:26:30 -0700 (Wed, 10 Oct 2007) | 1 line Keep the logo ........ r39903 | vladimir_prus | 2007-10-10 12:39:04 -0700 (Wed, 10 Oct 2007) | 1 line Doh. Fix link ........ r39909 | eric_niebler | 2007-10-10 14:20:49 -0700 (Wed, 10 Oct 2007) | 1 line extra test for custom assertions, fix nasty bug in custom assertion handling ........ r39913 | chris_kohlhoff | 2007-10-10 16:12:06 -0700 (Wed, 10 Oct 2007) | 2 lines Add a /dev/poll reactor implementation for Solaris. ........ r39914 | eric_niebler | 2007-10-10 17:44:57 -0700 (Wed, 10 Oct 2007) | 1 line document user-defined assertions ........ r39915 | eric_niebler | 2007-10-10 19:12:07 -0700 (Wed, 10 Oct 2007) | 1 line document placeholder<> and match_results<>::let() ........ r39918 | schoepflin | 2007-10-11 00:36:41 -0700 (Thu, 11 Oct 2007) | 1 line Fixed bug preventing compilation on Tru64/CXX. ........ r39921 | johnmaddock | 2007-10-11 03:51:10 -0700 (Thu, 11 Oct 2007) | 1 line Removed math docs from central build ........ r39922 | joaquin | 2007-10-11 03:57:30 -0700 (Thu, 11 Oct 2007) | 77 lines Boost 1.35 version of Boost.MultiIndex allocator_utilities.hpp: added partial_std_allocator_wrapper::value_type composite_key.hpp: used hash_fwd.hpp auto_space.hpp: added support for non-standard allocators bidir_node_iterator.hpp: moved friend-injected operators out of class copy_map.hpp: added support for non-standard allocators hash_index_args.hpp: removed deprecated use of hash_index_iterator.hpp: moved friend-injected operators our of class hash_index_node.hpp: added support for non-standard allocators header_holder.hpp:added support for non-standard allocators index_base.hpp: added support for non-standard allocators, added modify_rollback, added small improvement to modify index_loader.hpp: added support for non-standard allocators index_matcher.hpp: added support for non-standard allocators index_node_base.hpp: added support for non-standard allocators iter_adaptor.hpp: added some out-of-class operators to alleviate a MSVC++ 6.0 problem modify_key_adaptor.hpp: renamed some vars to accomudate broader usage scope node_type.hpp: added support for non-standard allocators ord_index_node.hpp: added support for non-standard allocators ord_index_ops.hpp: implemented a more efficient equal_range rnd_index_loader.hpp: added support for non-standard allocators rnd_index_node.hpp: added support for non-standard allocators rnd_index_ops.hpp: added support for non-standard allocators rnd_index_ptr_array.hpp: added support for non-standard allocators rnd_node_iterator.hpp: moved friend-injected operators out of class seq_index_node.hpp: added support for non-standard allocators seq_index_ops.hpp: added support for non-standard allocators uintptr_type.hpp: added support for __int64 unbounded.hpp: fixed ODR problem value_compare.hpp: fixed a small unefficiency global_fun: initial commit hashed_index.hpp: added support for non-standard allocators, added c[r]{begin|end}, [local_]iterator_to, rollback modify identity_fwd.hpp: fixed wrong include guard name key_extractors.hpp: added global_fun mem_fun.hpp: removed superfluous =0's ordered_index.hpp: added support for non-standard allocators, added c[r]{begin|end}, iterator_to, rollback modify, improved equal_range and range, added conformance to DR 233 random_access_index.hpp: added support for non-standard allocators, added c[r]{begin|end}, iterator_to, rollback modify, added conformance to 23.1.1/9 sequenced_index.hpp: added support for non-standard allocators, added c[r]{begin|end}, iterator_to, rollback modify, added conformance to 23.1.1/9, improved resize multi_index_container.hpp: added support for non-standard allocators, improved ctor_args_list, rollback modify acknowledgements.html: added entry for Boost 1.35 examples.html: renamed example 2, added B.IP example/composite_keys.cpp future_work.html: removed entry on bimap hash_indices.html: added c[r]{begin|end}, [local_]iterator_to, rollback modify reference/index.html: added global_fun reference/key_extraction.html: added global_fun, added technical correction multi_index_container.html: added support for non-standard allocators ord_indices.html: added c[r]{begin|end}, iterator_to, rollback modify rnd_indices.html: added c[r]{begin|end}, iterator_to, rollback modify seq_indices.html: added c[r]{begin|end}, iterator_to, rollback modify release_notes.html: added entry for Boost 1.35 tests.html: added new serialization test file basics.html: added rollback modify creation.html: added support for non-standard allocators tutorial/indices.html: added iterator_to tutorial/key_extraction.html: added global_fun composite_keys.cpp: fixed technicality fun_key.cpp: was memfun_key.cpp, added global_fun ip_allocator.cpp: initial commit example/Jamfile.v2: renamed memfun_key, added ip_allocator test_perf.cpp: fixed technicality employee.hpp: used a non-standard allocator test/Jamfile.v2: added new test file non_std_allocator.hpp: initial commit pair_of_ints.hpp: added decrement facilities test_capacity.cpp: added extra check on resize test_copy_assignment.cpp: added test for 23.1.1/9 test_iterators.cpp: added tests for c[r]{begin|end} and [local_]iterator_to, fixed technicality test_key_extractors.cpp: added tests for global_fun test_modifiers.cpp: added tests dor DR 233, fixed technicality test_range.cpp: added extra checks to secure range refactoring test_rearrange.cpp: fixed technicality test_serialization.cpp: added new test file test_serialization1.cpp: corrected include, used a non-standard allocator test_serialization2.cpp: corrected include, used a non-standard allocator, split some stuff ro test_serialization3.cpp test_serialization3.cpp: initial commit test_serialization3.hpp: initial commit test_serialization_template.hpp: removed some reliance on ADL test_update.cpp: addes tests for rollback modify, fixed technicality ........ r39923 | joaquin | 2007-10-11 04:23:47 -0700 (Thu, 11 Oct 2007) | 2 lines def_ctor_tuple_cons.hpp: no longer used memfun_key.cpp: is now fun_key.cpp ........ r39924 | johnmaddock | 2007-10-11 04:47:11 -0700 (Thu, 11 Oct 2007) | 1 line Added Boost.Math overview. ........ r39925 | johnmaddock | 2007-10-11 04:51:19 -0700 (Thu, 11 Oct 2007) | 1 line Redirect to new index. ........ r39926 | johnmaddock | 2007-10-11 05:05:29 -0700 (Thu, 11 Oct 2007) | 1 line Updated Math library entries. ........ r39927 | garcia | 2007-10-11 07:51:48 -0700 (Thu, 11 Oct 2007) | 2 lines math toolkit has been added to the trunk. ........ r39928 | johnmaddock | 2007-10-11 08:59:48 -0700 (Thu, 11 Oct 2007) | 1 line Fixed some typos, and rebuilt docs. ........ r39933 | eric_niebler | 2007-10-11 10:02:13 -0700 (Thu, 11 Oct 2007) | 1 line new number parser example from dave jenkins ........ r39934 | eric_niebler | 2007-10-11 10:05:35 -0700 (Thu, 11 Oct 2007) | 1 line remove self-adjusting TST optimization for thread-safety reasons ........ r39935 | danieljames | 2007-10-11 10:12:24 -0700 (Thu, 11 Oct 2007) | 3 lines Try to fix function pointer hashing for the sun compiler. A bit of a stab in the dark. ........ r39939 | danielw | 2007-10-11 13:37:37 -0700 (Thu, 11 Oct 2007) | 2 lines Added missing Py_INCREF(Py_None). ........ r39941 | eric_niebler | 2007-10-11 13:50:59 -0700 (Thu, 11 Oct 2007) | 1 line add let() so regexes with late-bound action args can be used with regex_(token_)iterator ........ r39944 | nmusatti | 2007-10-11 14:07:17 -0700 (Thu, 11 Oct 2007) | 1 line Updated to support C++Builder 2007 Update 3 (bcc32 5.9.2) ........ r39945 | nmusatti | 2007-10-11 14:09:07 -0700 (Thu, 11 Oct 2007) | 1 line Updated to support C++Builder 2007 Update 3 (bcc32 5.9.2) ........ r39946 | eric_niebler | 2007-10-11 14:12:22 -0700 (Thu, 11 Oct 2007) | 1 line add tests for late-bound action args with regex_(token_)iterator ........ r39947 | eric_niebler | 2007-10-11 14:29:57 -0700 (Thu, 11 Oct 2007) | 1 line document use of let() with regex_(token_)iterator ........ r39948 | eric_niebler | 2007-10-11 14:57:12 -0700 (Thu, 11 Oct 2007) | 1 line fix gcc warnings ........ r39955 | eric_niebler | 2007-10-11 21:31:10 -0700 (Thu, 11 Oct 2007) | 1 line reenable self-adjusting TST if BOOST_DISABLE_THREADS is defined ........ r39956 | eric_niebler | 2007-10-12 00:04:13 -0700 (Fri, 12 Oct 2007) | 1 line xpressive works with boost 1.34.1 ........ r39957 | igaztanaga | 2007-10-12 01:58:04 -0700 (Fri, 12 Oct 2007) | 1 line Corrected bug in atomic_dec32 for PPC ........ r39958 | johnmaddock | 2007-10-12 03:01:36 -0700 (Fri, 12 Oct 2007) | 1 line Lots of Borland specific patches: quite a few of the special-function tests do now do actually pass. ........ r39960 | danieljames | 2007-10-12 04:58:34 -0700 (Fri, 12 Oct 2007) | 5 lines Fix my botched attempt at supporting function pointers on Sun's compilers. Also, now only applies the workaround to function pointers, non-function pointers are treated as before. I might need to apply the special case to member function pointers as well. ........ r39962 | igaztanaga | 2007-10-12 08:41:44 -0700 (Fri, 12 Oct 2007) | 1 line Fixed dispose_and_assign bug in list ........ r39964 | eric_niebler | 2007-10-12 09:50:13 -0700 (Fri, 12 Oct 2007) | 1 line updated installation information ........ r39971 | johnmaddock | 2007-10-13 09:23:18 -0700 (Sat, 13 Oct 2007) | 2 lines Fixed most of the remaining Borland issues, and removed dependency to Boost.Lambda. Added tentative fix for the Sunpro compilers. ........ r39972 | danieljames | 2007-10-13 09:34:09 -0700 (Sat, 13 Oct 2007) | 11 lines New attempt at fixing the function pointer hash on the Sun compilers. I think I was barking up the wrong tree - it could be that when calling hash_value with a function pointer the compiler was choosing the hash_value(bool) overload over the hash_value(T*) overload, so instead I'm trying to call the correct one by giving it a template parameter. Another alternative would be to calculate the hash function inside boost::hash. Unfortunately, if I'm right, this means that other calls to hash_value will go wrong for function pointers. ........ r39973 | johnmaddock | 2007-10-13 09:40:36 -0700 (Sat, 13 Oct 2007) | 2 lines Fixed image path in complex number docs. Suppressed draft mode in PDF generation (stops the FO renderer from grabbing draft.png from sourceforge). ........ r39976 | grafik | 2007-10-13 10:25:41 -0700 (Sat, 13 Oct 2007) | 1 line Partial rework of regression scripts for branch independent testing. ........ r39977 | danieljames | 2007-10-13 10:35:48 -0700 (Sat, 13 Oct 2007) | 3 lines Remove the pointles separation of the float tests into three functions (probably a throwback to when I used Boost.Test) ........ r39978 | grafik | 2007-10-13 10:41:07 -0700 (Sat, 13 Oct 2007) | 1 line Partial rework of regression scripts for branch independent testing. ........ r39979 | danieljames | 2007-10-13 10:47:57 -0700 (Sat, 13 Oct 2007) | 5 lines Separate the long double hash tests from the test for other float types. On some platforms the standard library has poor support for long doubles causing long doubles to fail when the others pass. So this makes it clearer that the problem is only for long doubles. ........ r39982 | danieljames | 2007-10-13 10:57:23 -0700 (Sat, 13 Oct 2007) | 2 lines Oops, I messed the properties when adding files, this should hopefully fix them. ........ r39983 | danieljames | 2007-10-13 11:34:25 -0700 (Sat, 13 Oct 2007) | 2 lines Add support for complex numbers to Boost.Hash ........ r39984 | danieljames | 2007-10-13 11:47:10 -0700 (Sat, 13 Oct 2007) | 2 lines Fix the copyright line for the hash library. ........ r39985 | danieljames | 2007-10-13 11:47:41 -0700 (Sat, 13 Oct 2007) | 1 line Use quickbook v1.4 for the hash library. ........ r39986 | eric_niebler | 2007-10-13 14:16:23 -0700 (Sat, 13 Oct 2007) | 1 line update copyright year ........ r39988 | vladimir_prus | 2007-10-13 14:32:51 -0700 (Sat, 13 Oct 2007) | 1 line Fix module messup when calling into Python. ........ r39990 | eric_niebler | 2007-10-13 14:37:02 -0700 (Sat, 13 Oct 2007) | 1 line update copyright information ........ r39991 | danieljames | 2007-10-13 14:50:05 -0700 (Sat, 13 Oct 2007) | 1 line Use a pragma for warnings in Visual C++. ........ r39993 | danieljames | 2007-10-13 15:30:50 -0700 (Sat, 13 Oct 2007) | 1 line Clean up the hash tests a little. ........ r39994 | danieljames | 2007-10-13 15:43:13 -0700 (Sat, 13 Oct 2007) | 1 line Add a trivial test to see if the deprecated hash headers compile okay when included. ........ r40004 | danieljames | 2007-10-14 00:38:49 -0700 (Sun, 14 Oct 2007) | 2 lines Avoid some warnings when compiling the test with Visual C++. ........ r40005 | vladimir_prus | 2007-10-14 01:03:50 -0700 (Sun, 14 Oct 2007) | 1 line Remove tools/release/user-config.jam that keeps confusing everybody. ........ r40006 | vladimir_prus | 2007-10-14 02:09:41 -0700 (Sun, 14 Oct 2007) | 3 lines Better diagnostics when trying to import non-callable Python object to Jam. ........ r40008 | vladimir_prus | 2007-10-14 02:55:41 -0700 (Sun, 14 Oct 2007) | 7 lines * common.jam (get-invocation-command): When we cannot find a specified tool, return tool's name so that the command line looks sane, even if it does not work. (handle-options): Report which command will be used, in debug mode. ........ r40011 | bemandawes | 2007-10-14 05:40:10 -0700 (Sun, 14 Oct 2007) | 1 line Change svn info to svn info --xml to cope with non-English locales. Make scan for number insensitive to svn info --xml option. ........ r40012 | johnmaddock | 2007-10-14 05:54:49 -0700 (Sun, 14 Oct 2007) | 4 lines Renamed two over-long files simplified test_compile_result.hpp so hopefully Sunpro can cope with it. Modified Jamfile to static link to regex lib on Sun. Adjusted Solaris expected error levels. ........ r40014 | rogeeff | 2007-10-14 09:47:45 -0700 (Sun, 14 Oct 2007) | 1 line cleanup log ........ r40015 | rogeeff | 2007-10-14 09:49:00 -0700 (Sun, 14 Oct 2007) | 1 line cleanup Tag comment ........ r40018 | rogeeff | 2007-10-14 10:49:02 -0700 (Sun, 14 Oct 2007) | 1 line switch from non-portable warning to message ........ r40019 | nmusatti | 2007-10-14 10:51:32 -0700 (Sun, 14 Oct 2007) | 1 line Applied patch from Ticket #1319 ........ r40020 | nmusatti | 2007-10-14 10:53:15 -0700 (Sun, 14 Oct 2007) | 1 line Applied patch from Ticket #1320 ........ r40021 | grafik | 2007-10-14 10:54:28 -0700 (Sun, 14 Oct 2007) | 1 line Add usage dependency on system library. ........ r40023 | rogeeff | 2007-10-14 11:33:16 -0700 (Sun, 14 Oct 2007) | 1 line accessor to the reporter stream provided ........ r40024 | rogeeff | 2007-10-14 11:56:23 -0700 (Sun, 14 Oct 2007) | 1 line increase max number of elems in fixed map ........ r40025 | rogeeff | 2007-10-14 11:58:05 -0700 (Sun, 14 Oct 2007) | 3 lines 2 new command line arguments (yet unused): --auto_start_dbg --use_alt_stack ........ r40026 | rogeeff | 2007-10-14 12:23:14 -0700 (Sun, 14 Oct 2007) | 1 line typo in a comment ........ r40027 | rogeeff | 2007-10-14 12:24:19 -0700 (Sun, 14 Oct 2007) | 1 line set init value for result ........ r40028 | rogeeff | 2007-10-14 12:25:18 -0700 (Sun, 14 Oct 2007) | 1 line max macro guard ........ r40029 | rogeeff | 2007-10-14 12:26:23 -0700 (Sun, 14 Oct 2007) | 1 line bug in output_test_stream constructor error generation fixed ........ r40030 | rogeeff | 2007-10-14 12:27:32 -0700 (Sun, 14 Oct 2007) | 1 line avoid start/finish messages if log is disabled completely ........ r40031 | rogeeff | 2007-10-14 12:28:46 -0700 (Sun, 14 Oct 2007) | 1 line Test module initialization error message is redirected into result reporter stream ........ r40032 | rogeeff | 2007-10-14 12:29:59 -0700 (Sun, 14 Oct 2007) | 1 line typo in a comment ........ r40033 | rogeeff | 2007-10-14 12:39:33 -0700 (Sun, 14 Oct 2007) | 1 line Log level enum value renamed ........ r40035 | rogeeff | 2007-10-14 14:14:29 -0700 (Sun, 14 Oct 2007) | 6 lines Support for expected failures in test cases with automated registration reworked completely. It now allows to be used within auto-test-stuites. framework API changed to return non const references to the test units to allow post creation modifications unit_test_suite.hpp dependency on framework.hpp removed inlined version includes all necessary files now in test_tools.hpp BOOST_TEST_DECL is added/removed where necessary Test suite auto registration modified to allow c++ namespace like behavior ........ r40036 | danieljames | 2007-10-14 14:52:12 -0700 (Sun, 14 Oct 2007) | 1 line Sun C++ didn't like the function call, so just try inlining the implementation for now. ........ r40040 | joaquin | 2007-10-14 23:54:34 -0700 (Sun, 14 Oct 2007) | 1 line typo ........ r40041 | anthonyw | 2007-10-15 02:18:32 -0700 (Mon, 15 Oct 2007) | 1 line added missing include to basic_timed_mutex.hpp ........ r40046 | fmhess | 2007-10-15 06:06:26 -0700 (Mon, 15 Oct 2007) | 5 lines Fixed some invalid docbook ( is not allowed to be a child of ). This fixes one of the failures when building pdf docs with fop 0.94. ........ r40047 | fmhess | 2007-10-15 06:24:34 -0700 (Mon, 15 Oct 2007) | 4 lines Prevent the generation of empty elements, which is invalid docbook and causes apache fop 0.94 to choke and die. ........ r40048 | fmhess | 2007-10-15 06:27:50 -0700 (Mon, 15 Oct 2007) | 4 lines Fixed a problem with boostbook printing an extra colon in the class synopsis, when a class inherits from a single base class and it's too long to fit on one line. ........ r40049 | fmhess | 2007-10-15 06:43:00 -0700 (Mon, 15 Oct 2007) | 9 lines Updated setup_boostbook scripts to download newer versions of apache fop and docbook xsl, since the old versions are no longer posted for download. The newer version of apache fop is stricter about its input, and currently fails to validate its input when trying to build boost.pdf, due to various bits on invalid docbook. I have it working locally though, and will create tickets with patches in trac for the remaining issues in the library docs and tools. ........ r40050 | fmhess | 2007-10-15 06:46:23 -0700 (Mon, 15 Oct 2007) | 4 lines Stop quickbook from generating empty elements (which is invalid docbook and causes apache fop 0.94 to choke and die). ........ r40051 | bemandawes | 2007-10-15 07:50:59 -0700 (Mon, 15 Oct 2007) | 1 line Suppress message tests on Windows unless the language is US English ........ r40052 | grafik | 2007-10-15 07:53:28 -0700 (Mon, 15 Oct 2007) | 1 line Rework of regression scripts for branch independent testing -- complete. ........ r40053 | grafik | 2007-10-15 08:45:25 -0700 (Mon, 15 Oct 2007) | 1 line Bootstrap from trunk sources of regression scripts. ........ r40056 | joaquin | 2007-10-15 09:10:39 -0700 (Mon, 15 Oct 2007) | 1 line added missing #include ........ r40058 | igaztanaga | 2007-10-15 09:55:23 -0700 (Mon, 15 Oct 2007) | 1 line Fixed doxygen error in reference ........ r40059 | igaztanaga | 2007-10-15 09:56:27 -0700 (Mon, 15 Oct 2007) | 1 line Added missing include ........ r40060 | igaztanaga | 2007-10-15 09:57:15 -0700 (Mon, 15 Oct 2007) | 1 line Fixed assignment operator ........ r40061 | johnmaddock | 2007-10-15 09:57:57 -0700 (Mon, 15 Oct 2007) | 1 line Disregard ".svn" directories ........ r40062 | igaztanaga | 2007-10-15 09:58:15 -0700 (Mon, 15 Oct 2007) | 1 line Changed wrong insert_after_and_dispose() with insert_after ........ r40063 | danieljames | 2007-10-15 11:47:05 -0700 (Mon, 15 Oct 2007) | 1 line Mark up the expected hash error for the sun compilers. ........ r40064 | grafik | 2007-10-15 14:54:01 -0700 (Mon, 15 Oct 2007) | 1 line Add default to 'regression' when no commands are given. ........ r40065 | rogeeff | 2007-10-15 19:01:39 -0700 (Mon, 15 Oct 2007) | 1 line avoid warnings ........ r40066 | rogeeff | 2007-10-15 19:02:16 -0700 (Mon, 15 Oct 2007) | 1 line msvc 6.5 port ........ r40067 | rogeeff | 2007-10-15 19:03:16 -0700 (Mon, 15 Oct 2007) | 1 line proper report for the exceptions in inti_unit_test_suite function ........ r40068 | rogeeff | 2007-10-15 20:47:24 -0700 (Mon, 15 Oct 2007) | 1 line use io_saver directly ........ r40069 | rogeeff | 2007-10-15 20:51:54 -0700 (Mon, 15 Oct 2007) | 2 lines unified test runner interface for both original and alternative init API, the same time streamlining error handling for all the cases new property p_enabled is added to the test unit in preparation for the run by name ........ r40076 | rogeeff | 2007-10-16 00:06:10 -0700 (Tue, 16 Oct 2007) | 1 line fix A bug in auto TC exp failure support ........ r40077 | rogeeff | 2007-10-16 00:07:43 -0700 (Tue, 16 Oct 2007) | 1 line temporary disable debug related features - to be reverted soon ........ r40078 | rogeeff | 2007-10-16 00:18:10 -0700 (Tue, 16 Oct 2007) | 9 lines Major rework of execution monitor functionality: update to the error reporting on both NT and *nix support for signal handling on alternative stack execution monitor parameter made public properties structured exception handling moved to double __try approach with custom SE filter support for floating point errors enhanced on NT based compilers Notion of system_error is introduced (to be replaced potentially with boost::system later on) Invalid parameter error detected by MSVC runtime properly reported report_error implemented using vsnprintf allowing better output ........ r40079 | johnmaddock | 2007-10-16 02:32:28 -0700 (Tue, 16 Oct 2007) | 2 lines Fixed lots of "inspect" issues: bad hyperlinks, tabs in source and missing licenses. Tweaked some error levels again. ........ r40080 | anthonyw | 2007-10-16 04:08:17 -0700 (Tue, 16 Oct 2007) | 1 line removed lock_ops as no longer needed ........ r40082 | igaztanaga | 2007-10-16 08:25:13 -0700 (Tue, 16 Oct 2007) | 1 line Tru64 re-enabled for intrusive to try to solve remaining issues ........ r40083 | johnmaddock | 2007-10-16 08:41:57 -0700 (Tue, 16 Oct 2007) | 2 lines Fixes for the Sun-5.9 compiler: don't try and encode constants smaller than LDBL_MIN, the compiler chokes on it. Fixes for STLport: long double stream operators are broken (streaming in appears not to work at all, streaming out can segfault if the value is too small). ........ r40084 | grafik | 2007-10-16 08:52:38 -0700 (Tue, 16 Oct 2007) | 1 line Minor modification to pass in the branch type to generate results for, and to move the boost checkout to the root dir. ........ r40086 | johnmaddock | 2007-10-16 09:11:30 -0700 (Tue, 16 Oct 2007) | 1 line Fully qualified use of "extended" flag, to keep gcc on Solaris happy. ........ r40087 | johnmaddock | 2007-10-16 09:15:38 -0700 (Tue, 16 Oct 2007) | 1 line Update for Borland 5.8.2 and 5.9.2. ........ r40088 | niels_dekker | 2007-10-16 10:00:28 -0700 (Tue, 16 Oct 2007) | 1 line Disabled MSVC warning C4345, in response to Gennadiy Rozental, Boost Developer mailing list, "[utility] value_init warning", October 14, 2007. Push'n'pop reminder from Paul A Bristow taken into account. ........ r40089 | niels_dekker | 2007-10-16 10:06:39 -0700 (Tue, 16 Oct 2007) | 1 line Added value_initialized test, having T as aggregate POD struct. In the past, this would have triggered MSVC warning C4345; this warning is now disabled within value_init.hpp, changeset [40088] ........ r40090 | rogeeff | 2007-10-16 10:11:00 -0700 (Tue, 16 Oct 2007) | 1 line cygwin issue fix ........ r40091 | eric_niebler | 2007-10-16 10:15:44 -0700 (Tue, 16 Oct 2007) | 1 line cleanup ........ r40094 | eric_niebler | 2007-10-16 12:07:12 -0700 (Tue, 16 Oct 2007) | 1 line reverted to r40064 ........ r40095 | grafik | 2007-10-16 12:08:58 -0700 (Tue, 16 Oct 2007) | 1 line Allow specifying options with quotes, i.e. "--with-python=xyz", to work around the CMD shell using "=" as an argument separator. ........ r40096 | grafik | 2007-10-16 13:05:35 -0700 (Tue, 16 Oct 2007) | 1 line Specify user to post results to OSL server. ........ r40098 | guwi17 | 2007-10-16 14:48:01 -0700 (Tue, 16 Oct 2007) | 2 lines - added section "nested products" ........ r40099 | bemandawes | 2007-10-16 15:05:29 -0700 (Tue, 16 Oct 2007) | 1 line Add failure count for each compiler column. ........ r40100 | eric_niebler | 2007-10-16 15:13:11 -0700 (Tue, 16 Oct 2007) | 1 line revert more boost.test changes ........ r40101 | danieljames | 2007-10-16 16:25:37 -0700 (Tue, 16 Oct 2007) | 1 line Remove the free-function-groups from the hash reference documentation, they were causing the functions to be listed on the documentation for every specialization of boost::hash, and the functions to be described on the main synopsis page, instead of their own page. ........ r40103 | eric_niebler | 2007-10-16 21:26:36 -0700 (Tue, 16 Oct 2007) | 1 line misc cleann-up from Dave Jenkins ........ r40104 | chris_kohlhoff | 2007-10-16 21:44:38 -0700 (Tue, 16 Oct 2007) | 2 lines Revert HP-UX/aCC change to select() wrapper as it breaks more than it fixes. ........ r40106 | chris_kohlhoff | 2007-10-16 22:22:26 -0700 (Tue, 16 Oct 2007) | 2 lines Borland C++ wants friendship for the task_cleanup nested class. ........ r40107 | chris_kohlhoff | 2007-10-17 00:25:03 -0700 (Wed, 17 Oct 2007) | 2 lines Throw an exception if unable to create a pipe for the pipe_select_interrupter. ........ r40108 | chris_kohlhoff | 2007-10-17 00:58:38 -0700 (Wed, 17 Oct 2007) | 3 lines Make Windows XP the default target Windows version as the latest Windows SDK doesn't support IPv6 for Windows 2000 targets. ........ r40109 | chris_kohlhoff | 2007-10-17 01:20:30 -0700 (Wed, 17 Oct 2007) | 2 lines Add define to disable /dev/poll support. ........ r40110 | johnmaddock | 2007-10-17 02:19:35 -0700 (Wed, 17 Oct 2007) | 1 line Change #warning to #pragma message: #warning is a gcc-ism and the code in question is msvc-specific (Tested on all msvc variants, plus gcc-minw32). ........ r40117 | johnmaddock | 2007-10-17 05:58:55 -0700 (Wed, 17 Oct 2007) | 1 line Disable FOP1 extensions so we can build with xep extensions instead. ........ r40119 | chris_kohlhoff | 2007-10-17 07:04:42 -0700 (Wed, 17 Oct 2007) | 3 lines Add dummy enum for ssl errors. Change to static const references to error category objects to be consistent with boost.system. ........ r40124 | igaztanaga | 2007-10-17 08:40:41 -0700 (Wed, 17 Oct 2007) | 1 line Added include. Erased wrong "non" word in swap members' Throws clause. ........ r40128 | johnmaddock | 2007-10-17 10:15:53 -0700 (Wed, 17 Oct 2007) | 1 line Updates to build system: Sun and SGI compilers have a problem doing a shared link, and some platforms don't have an icudata library. ........ r40129 | eric_niebler | 2007-10-17 10:21:01 -0700 (Wed, 17 Oct 2007) | 1 line mark up expected xpressive failures on acc toolset ........ r40130 | danieljames | 2007-10-17 10:27:42 -0700 (Wed, 17 Oct 2007) | 1 line Include authors that are in authorgroups in the generated chapterinfo. ........ r40131 | danieljames | 2007-10-17 10:29:46 -0700 (Wed, 17 Oct 2007) | 1 line Merge some minor changes from the development branch to remove some unnecessary differences. ........ r40146 | joaquin | 2007-10-17 23:57:25 -0700 (Wed, 17 Oct 2007) | 1 line applied workaround for MSVC++ 6.5/7.0 problem with static constants inside templates, see http://lists.boost.org/Archives/boost/2007/10/128392.php ........ r40147 | rogeeff | 2007-10-18 00:13:43 -0700 (Thu, 18 Oct 2007) | 1 line try run ........ r40148 | rogeeff | 2007-10-18 00:14:56 -0700 (Thu, 18 Oct 2007) | 3 lines fixed issue with num of exp failure calculation mwerks port in execution_monitor.ipp bug in init function invocation fixed ........ r40149 | chris_kohlhoff | 2007-10-18 01:34:03 -0700 (Thu, 18 Oct 2007) | 2 lines Assume that Tru64 also needs SIGPIPE to be blocked. ........ r40155 | johnmaddock | 2007-10-18 08:37:01 -0700 (Thu, 18 Oct 2007) | 3 lines Workaround for real_concept when there are no long double math functions. Added HP-UX on PA RISC to list of platforms with no long double overloads. Added macro expansion suppression code to declarations of sign and to it's usages (an AIX fix). ........ r40156 | grafik | 2007-10-18 09:11:41 -0700 (Thu, 18 Oct 2007) | 1 line Fix build system error when Python is not configured, without preventing the BPL target from being declared. Instead the target is now unbuildable, and will be skipped when Python is not configured. ........ r40159 | igaztanaga | 2007-10-18 09:20:28 -0700 (Thu, 18 Oct 2007) | 1 line Added atomic operations for alpha processors ........ r40160 | vladimir_prus | 2007-10-18 09:53:01 -0700 (Thu, 18 Oct 2007) | 1 line Enable index for Boost.Build standalone docs. ........ r40162 | johnmaddock | 2007-10-18 11:17:15 -0700 (Thu, 18 Oct 2007) | 1 line Fixed some links and merged changes in the Sandbox to here. ........ r40165 | rogeeff | 2007-10-18 14:43:35 -0700 (Thu, 18 Oct 2007) | 2 lines FP exceptions made optional and disabled by default new CLA --detect_fp_exceptions=[yes|no] introduced ........ r40166 | rogeeff | 2007-10-18 14:53:14 -0700 (Thu, 18 Oct 2007) | 1 line included alias added ........ r40167 | aaron_windsor | 2007-10-18 17:16:36 -0700 (Thu, 18 Oct 2007) | 1 line Un-asserted two function calls - this was causing the function calls to turn into no-ops when the example was compiled with debugging off. ........ r40172 | rogeeff | 2007-10-18 19:17:52 -0700 (Thu, 18 Oct 2007) | 1 line msvc 6.5 port fix ........ r40173 | eric_niebler | 2007-10-18 20:16:51 -0700 (Thu, 18 Oct 2007) | 1 line don't copy singular iterator in sub_match, misc clean-up ........ r40174 | vladimir_prus | 2007-10-19 00:00:03 -0700 (Fri, 19 Oct 2007) | 1 line Add indexterms for glob-tree and install-source-root. ........ r40176 | chris_kohlhoff | 2007-10-19 01:09:55 -0700 (Fri, 19 Oct 2007) | 2 lines Add get_io_service() synonym for io_service() to match TR2 proposal. ........ r40178 | schoepflin | 2007-10-19 02:06:04 -0700 (Fri, 19 Oct 2007) | 1 line Detailed OSF detection macro to include the compiler used. ........ r40179 | schoepflin | 2007-10-19 02:52:23 -0700 (Fri, 19 Oct 2007) | 1 line Added missing include file. ........ r40180 | danieljames | 2007-10-19 02:55:10 -0700 (Fri, 19 Oct 2007) | 1 line Fix the deprecated warnings on Borland, should also check before using #warning. ........ r40181 | johnmaddock | 2007-10-19 05:03:54 -0700 (Fri, 19 Oct 2007) | 1 line Add needed config options. ........ r40183 | johnmaddock | 2007-10-19 05:30:46 -0700 (Fri, 19 Oct 2007) | 1 line Added revision ID. ........ r40184 | johnmaddock | 2007-10-19 05:46:54 -0700 (Fri, 19 Oct 2007) | 1 line Update configure files with revision Id and some compiler specific fixes. ........ r40186 | schoepflin | 2007-10-19 07:45:06 -0700 (Fri, 19 Oct 2007) | 1 line Added support for Tru64/CXX. ........ r40187 | anthonyw | 2007-10-19 07:52:52 -0700 (Fri, 19 Oct 2007) | 1 line small changes to reduce warnings; extracted pthread_mutex_scoped_lock to its own file ........ r40188 | igaztanaga | 2007-10-19 07:54:18 -0700 (Fri, 19 Oct 2007) | 1 line Fixed newline issue between two [endsect]. ........ r40189 | anthonyw | 2007-10-19 08:31:35 -0700 (Fri, 19 Oct 2007) | 1 line more tweaks to remove warnings ........ r40191 | anthonyw | 2007-10-19 10:40:04 -0700 (Fri, 19 Oct 2007) | 1 line New condition_variable and condition_variable_any as per proposed C++0x interface ........ r40192 | bemandawes | 2007-10-19 10:43:44 -0700 (Fri, 19 Oct 2007) | 1 line Initial commit ........ r40193 | johnmaddock | 2007-10-19 10:55:44 -0700 (Fri, 19 Oct 2007) | 1 line Adjust ICU build support: almost works now :-) ........ r40194 | turkanis | 2007-10-19 11:09:54 -0700 (Fri, 19 Oct 2007) | 1 line updated turkanis email address (iostreams + rational) ........ r40196 | vladimir_prus | 2007-10-19 12:16:10 -0700 (Fri, 19 Oct 2007) | 1 line Remove unused code ........ r40197 | vladimir_prus | 2007-10-19 12:18:32 -0700 (Fri, 19 Oct 2007) | 2 lines Remove project-target.intern-constants as unused. ........ r40203 | rogeeff | 2007-10-19 22:38:57 -0700 (Fri, 19 Oct 2007) | 1 line borland port ........ r40204 | rogeeff | 2007-10-19 23:59:27 -0700 (Fri, 19 Oct 2007) | 1 line intel port ........ r40205 | johnmaddock | 2007-10-20 02:20:30 -0700 (Sat, 20 Oct 2007) | 1 line Removed ICU options from main requirements: BBv2 barfs at it. ........ r40206 | danieljames | 2007-10-20 03:31:58 -0700 (Sat, 20 Oct 2007) | 2 lines Try to only issue deprecation warnings on compilers that support them. ........ r40208 | djowel | 2007-10-20 04:01:50 -0700 (Sat, 20 Oct 2007) | 1 line refactoring for v2.1 ........ r40209 | djowel | 2007-10-20 04:31:03 -0700 (Sat, 20 Oct 2007) | 1 line phase2: refactoring for v2.1 ........ r40210 | djowel | 2007-10-20 04:49:17 -0700 (Sat, 20 Oct 2007) | 1 line phase3: refactoring for v2.1 ........ r40211 | djowel | 2007-10-20 04:50:27 -0700 (Sat, 20 Oct 2007) | 1 line phase3: refactoring for v2.1 ........ r40212 | djowel | 2007-10-20 06:13:46 -0700 (Sat, 20 Oct 2007) | 1 line phase4: refactoring for v2.1 ........ r40213 | djowel | 2007-10-20 06:13:58 -0700 (Sat, 20 Oct 2007) | 1 line phase4: refactoring for v2.1 ........ r40214 | johnmaddock | 2007-10-20 09:30:01 -0700 (Sat, 20 Oct 2007) | 1 line ICU libraries are only available as shared libraries. ........ r40215 | grafik | 2007-10-20 09:35:58 -0700 (Sat, 20 Oct 2007) | 1 line Do not refer to nonexistent target when python is not configured. ........ r40216 | grafik | 2007-10-20 09:36:18 -0700 (Sat, 20 Oct 2007) | 1 line Do not refer to nonexistent target when python is not configured. ........ r40219 | djowel | 2007-10-20 15:21:43 -0700 (Sat, 20 Oct 2007) | 1 line reverting to 2.0 ........ r40220 | djowel | 2007-10-20 15:33:52 -0700 (Sat, 20 Oct 2007) | 1 line reverting to 2.0 ........ r40233 | danieljames | 2007-10-20 17:41:01 -0700 (Sat, 20 Oct 2007) | 2 lines Don't test long double in hash_number_test. This is a bit of a cop out, but it's silly to fail this test just because a platform has poor support for long double - hash_long_double_test is thorough enough. ........ r40236 | danieljames | 2007-10-20 17:51:43 -0700 (Sat, 20 Oct 2007) | 6 lines Markup test that fail because of poor long double support. gcc-3.4.3_sunos doesn't seem to be tested any more, but I'll leave it in. PA Risc has a software long double which doesn't seem to be very well supported by the standard library functions. ........ r40241 | chris_kohlhoff | 2007-10-20 18:48:03 -0700 (Sat, 20 Oct 2007) | 3 lines Ensure the buffers and completion condition objects are destroyed before the completion handler is invoked. ........ r40255 | chris_kohlhoff | 2007-10-20 22:46:15 -0700 (Sat, 20 Oct 2007) | 3 lines HP-UX fails to declare if_nametoindex and if_indextoname as extern "C". Added declarations for them with correct linkage to avoid linker errors. ........ r40256 | chris_kohlhoff | 2007-10-20 22:46:47 -0700 (Sat, 20 Oct 2007) | 2 lines Documentation fixes. ........ r40259 | chris_kohlhoff | 2007-10-21 00:09:19 -0700 (Sun, 21 Oct 2007) | 4 lines On HP-UX use pselect() rather than select() to avoid weirdness where different select() prototypes are declared depending on the order the system headers are included. ........ r40261 | chris_kohlhoff | 2007-10-21 00:30:04 -0700 (Sun, 21 Oct 2007) | 2 lines Use an unsigned char for the enable_loopback socket option on HP-UX. ........ r40262 | chris_kohlhoff | 2007-10-21 00:59:53 -0700 (Sun, 21 Oct 2007) | 2 lines Seems that the watermark socket options are supported on HP-UX 11i v3. ........ r40263 | chris_kohlhoff | 2007-10-21 01:13:21 -0700 (Sun, 21 Oct 2007) | 2 lines Fix address_v6::operator<. ........ r40264 | danieljames | 2007-10-21 01:36:47 -0700 (Sun, 21 Oct 2007) | 2 lines New algorithm for hash floating point numbers. ........ r40265 | igaztanaga | 2007-10-21 01:49:42 -0700 (Sun, 21 Oct 2007) | 1 line Solved Doxygen bug ........ r40267 | igaztanaga | 2007-10-21 02:01:16 -0700 (Sun, 21 Oct 2007) | 1 line Doxygen bug workaround. Corrected Solaris errors. Experimental grow/shrink_to_fit for managed_shared_memory and managed_mapped_file. ........ r40268 | igaztanaga | 2007-10-21 02:02:23 -0700 (Sun, 21 Oct 2007) | 1 line Doxygen bug workaround. Corrected Solaris errors. Experimental grow/shrink_to_fit for managed_shared_memory and managed_mapped_file. ........ r40269 | johnmaddock | 2007-10-21 09:02:34 -0700 (Sun, 21 Oct 2007) | 1 line Use __hppa to detect HP-UX on PA-RISC. ........ r40270 | rogeeff | 2007-10-21 13:53:56 -0700 (Sun, 21 Oct 2007) | 3 lines Missing header in exception_safety.hpp Run by name support new tools BOOST_CHECK_NE, BOOST_CHECK_LE, BOOST_CHECK_LT, BOOST_CHECK_GE, BOOST_CHECK_GT implemented ........ r40271 | rogeeff | 2007-10-21 13:59:15 -0700 (Sun, 21 Oct 2007) | 6 lines correct run rules in examples make example 2 more pronounced removed unnecessary ; in example 4 and 5 new alias test in test directory msvc 6.5 should use static lib test case for new tools added ........ r40272 | rogeeff | 2007-10-21 17:36:26 -0700 (Sun, 21 Oct 2007) | 1 line clean up ........ r40273 | rogeeff | 2007-10-21 21:02:53 -0700 (Sun, 21 Oct 2007) | 3 lines added missing export for framework::get added line number to the name of the TU registrar, allowing to restart test suites within same module test_suite::size() implemented to provide an access to the suite size ........ r40274 | rogeeff | 2007-10-21 21:09:01 -0700 (Sun, 21 Oct 2007) | 1 line new unit test: test_tree_management_test.cpp ........ r40276 | rogeeff | 2007-10-21 23:36:50 -0700 (Sun, 21 Oct 2007) | 4 lines framework::is_initialized introduced to catch framework misuse errors Message report too few failed assertions updated New message added to report no assertion occurred in a test case test_suite::remove interface is added to allow remove test units from the test suite if necessary ........ r40277 | schoepflin | 2007-10-22 00:54:08 -0700 (Mon, 22 Oct 2007) | 1 line Fix compilation. ........ r40278 | johnmaddock | 2007-10-22 01:43:52 -0700 (Mon, 22 Oct 2007) | 1 line Skip some "impossible" vc8 targets. ........ r40280 | rogeeff | 2007-10-22 04:11:51 -0700 (Mon, 22 Oct 2007) | 1 line correct patterns ........ r40281 | johnmaddock | 2007-10-22 04:16:15 -0700 (Mon, 22 Oct 2007) | 2 lines Added Bjorn Roald's patches to enable scans of svn. Updated docs accordingly. ........ r40282 | fmhess | 2007-10-22 06:17:19 -0700 (Mon, 22 Oct 2007) | 4 lines Eliminated the possibility of empty elements in enum references (invalid docbook, apache fop doesn't like it). ........ r40284 | joaquin | 2007-10-22 07:50:08 -0700 (Mon, 22 Oct 2007) | 2 lines extended MSVC 6.5 fix to Intel ........ r40285 | igaztanaga | 2007-10-22 08:20:21 -0700 (Mon, 22 Oct 2007) | 1 line Marked (temporarily) win64 toolsets unusable for Interprocess ........ r40288 | johnmaddock | 2007-10-22 09:14:02 -0700 (Mon, 22 Oct 2007) | 1 line Simplified regex usage. ........ r40289 | vladimir_prus | 2007-10-22 09:45:49 -0700 (Mon, 22 Oct 2007) | 2 lines Add missing Py_INCREF on Py_None objects. ........ r40292 | joaquin | 2007-10-22 10:22:46 -0700 (Mon, 22 Oct 2007) | 1 line guarded some static asserts in project() funs from Sun C++ 5.7 ........ r40293 | johnmaddock | 2007-10-22 10:46:40 -0700 (Mon, 22 Oct 2007) | 1 line Added support for _WIN32_WCE. ........ r40294 | johnmaddock | 2007-10-22 10:48:51 -0700 (Mon, 22 Oct 2007) | 3 lines Disabled intrinsic type traits testing for SGI compiler. Disabled one is_convertible test for aCC on PA RISC. Disabled some tests in promote_basic_test.cpp for more platforms that have broken WCHAR_MAX macros. ........ r40295 | johnmaddock | 2007-10-22 10:53:05 -0700 (Mon, 22 Oct 2007) | 1 line IBM xlc++ has support for TR1 when __IBMCPP_TR1__ is defined. ........ r40299 | dgregor | 2007-10-22 12:37:05 -0700 (Mon, 22 Oct 2007) | 3 lines Fix warnings from GCC 4.3. Fixes #1337 ........ r40300 | dgregor | 2007-10-22 12:54:54 -0700 (Mon, 22 Oct 2007) | 4 lines Suppress a GCC 4.3 warning and fix a couple header-inclusion issues. Fixes #1338 ........ r40301 | eric_niebler | 2007-10-22 13:14:11 -0700 (Mon, 22 Oct 2007) | 1 line needed typeof registrations, from David Jenkins ........ r40302 | nesotto | 2007-10-22 13:26:51 -0700 (Mon, 22 Oct 2007) | 1 line added copyability to all containers ........ r40306 | nesotto | 2007-10-22 15:50:52 -0700 (Mon, 22 Oct 2007) | 4 lines minor refactorings to support copyability etc ........ r40307 | nesotto | 2007-10-22 15:51:42 -0700 (Mon, 22 Oct 2007) | 1 line update of test to try copyability ........ r40310 | eric_niebler | 2007-10-22 17:40:16 -0700 (Mon, 22 Oct 2007) | 1 line fix problem with ->* rewrite in actions, add x->*y as alias for y(x) ........ r40322 | rogeeff | 2007-10-22 20:44:01 -0700 (Mon, 22 Oct 2007) | 1 line streamlined handling of SIGPOLL ........ r40323 | bgubenko | 2007-10-22 20:44:33 -0700 (Mon, 22 Oct 2007) | 1 line fix typo in rev. 40321 ........ r40338 | rogeeff | 2007-10-22 22:25:42 -0700 (Mon, 22 Oct 2007) | 1 line update to tests and example ........ r40342 | eric_niebler | 2007-10-23 00:01:53 -0700 (Tue, 23 Oct 2007) | 1 line clean-up, actionable need not be a template ........ r40344 | chris_kohlhoff | 2007-10-23 01:09:21 -0700 (Tue, 23 Oct 2007) | 2 lines Only use pselect() when compiling with aCC. ........ r40345 | chris_kohlhoff | 2007-10-23 01:09:46 -0700 (Tue, 23 Oct 2007) | 2 lines Documentation fixes. ........ r40346 | schoepflin | 2007-10-23 01:20:26 -0700 (Tue, 23 Oct 2007) | 2 lines Now that intrusive is working, enable the interprocess library for Tru64/CXX. ........ r40347 | schoepflin | 2007-10-23 01:26:51 -0700 (Tue, 23 Oct 2007) | 3 lines Toolsets tru64cxx* have long been renamed to hp_cxx-*_tru64; removed markup obsoleted by the rename. ........ r40348 | anthonyw | 2007-10-23 01:57:17 -0700 (Tue, 23 Oct 2007) | 1 line platform split for pthread and win32 builds so can use pthread-win32 library on Windows with pthread feature; new C++0x-alike thread class interface on win32. ........ r40349 | johnmaddock | 2007-10-23 02:34:40 -0700 (Tue, 23 Oct 2007) | 1 line Ooops, put preprocessor logic in the right place! ........ r40352 | bemandawes | 2007-10-23 06:00:18 -0700 (Tue, 23 Oct 2007) | 1 line Rename posix, windows, Linux, and cygwin namespaces to conform with C++ std. ........ r40353 | johnmaddock | 2007-10-23 06:10:32 -0700 (Tue, 23 Oct 2007) | 1 line Removed redundant #define. ........ r40354 | t_schwinger | 2007-10-23 06:25:57 -0700 (Tue, 23 Oct 2007) | 3 lines removes dependencies to MPL intrinsics (removes top-level cv-qualifiers from element types, now) ........ r40355 | t_schwinger | 2007-10-23 06:26:56 -0700 (Tue, 23 Oct 2007) | 3 lines adjusts test: deduce_sequence removes top-level cv-qualifiers from element types, now ........ r40356 | chris_kohlhoff | 2007-10-23 06:31:12 -0700 (Tue, 23 Oct 2007) | 2 lines Clean up documentation. ........ r40359 | djowel | 2007-10-23 06:39:15 -0700 (Tue, 23 Oct 2007) | 1 line remove superfluous include ........ r40360 | bemandawes | 2007-10-23 08:04:43 -0700 (Tue, 23 Oct 2007) | 1 line Fix linux_errno misspelling ........ r40361 | igaztanaga | 2007-10-23 08:48:08 -0700 (Tue, 23 Oct 2007) | 1 line Marked win64 toolsets again for testing in Interprocess ........ r40363 | igaztanaga | 2007-10-23 10:46:36 -0700 (Tue, 23 Oct 2007) | 1 line Temporary hack to avoid compilation errors in operator->() ........ r40364 | igaztanaga | 2007-10-23 10:47:49 -0700 (Tue, 23 Oct 2007) | 1 line Corrected error in create_from_istream ........ r40365 | dgregor | 2007-10-23 11:16:57 -0700 (Tue, 23 Oct 2007) | 1 line Fix SIGPOLL and sigemptyset handling on Darwin ........ r40367 | nesotto | 2007-10-23 11:36:03 -0700 (Tue, 23 Oct 2007) | 1 line added test for char array with nested null in response to Ticket #471 ........ r40370 | nesotto | 2007-10-23 11:59:11 -0700 (Tue, 23 Oct 2007) | 2 lines applied patch from Ticket #1302 (new Patches) to handle char arrays correctly ........ r40371 | nesotto | 2007-10-23 12:06:39 -0700 (Tue, 23 Oct 2007) | 1 line change names of ADL functions back to 1.34 names ... the old names have been in use for too long so let's not break code that depends on them ........ r40372 | nesotto | 2007-10-23 12:07:38 -0700 (Tue, 23 Oct 2007) | 1 line changed ADL functions back the names of 1.34 ... these names have been in use for too long ... let's not break code that depends on them ........ r40373 | nesotto | 2007-10-23 12:12:19 -0700 (Tue, 23 Oct 2007) | 1 line new fancy quickbook documentaion ........ r40374 | nesotto | 2007-10-23 12:34:06 -0700 (Tue, 23 Oct 2007) | 1 line added test for operator() ........ r40375 | nesotto | 2007-10-23 12:34:38 -0700 (Tue, 23 Oct 2007) | 1 line added operator() to allow random access index with transform iterators ........ r40376 | nesotto | 2007-10-23 12:50:59 -0700 (Tue, 23 Oct 2007) | 1 line displabed some warnings and applied Ticket #1284: sub_range_copy.patch ........ r40377 | nesotto | 2007-10-23 12:56:39 -0700 (Tue, 23 Oct 2007) | 1 line applied Ticket #1309 (new Patches) ........ r40378 | nesotto | 2007-10-23 13:08:35 -0700 (Tue, 23 Oct 2007) | 1 line cleanup ........ r40379 | nesotto | 2007-10-23 13:23:05 -0700 (Tue, 23 Oct 2007) | 1 line Adding Shunsuke Sogame fantastic MFC/ATL mappings ........ r40381 | nesotto | 2007-10-23 13:28:52 -0700 (Tue, 23 Oct 2007) | 1 line Shunsuke Sogame's MFC/ATL docs and tests ........ r40382 | chris_kohlhoff | 2007-10-23 15:32:11 -0700 (Tue, 23 Oct 2007) | 2 lines Mark borland 5.6.* and 5.8.* as unusable for asio. ........ r40389 | djowel | 2007-10-23 19:30:52 -0700 (Tue, 23 Oct 2007) | 1 line Fusion 2.1 one more time with care ........ r40390 | djowel | 2007-10-23 19:32:28 -0700 (Tue, 23 Oct 2007) | 1 line Fusion 2.1 one more time with care ........ r40391 | djowel | 2007-10-23 19:33:38 -0700 (Tue, 23 Oct 2007) | 1 line Fusion 2.1 one more time with care ........ r40392 | djowel | 2007-10-23 19:36:29 -0700 (Tue, 23 Oct 2007) | 1 line Fusion 2.1 one more time with care ........ r40393 | djowel | 2007-10-23 19:37:23 -0700 (Tue, 23 Oct 2007) | 1 line Fusion 2.1 one more time with care ........ r40394 | djowel | 2007-10-23 19:38:02 -0700 (Tue, 23 Oct 2007) | 1 line Fusion 2.1 one more time with care ........ r40396 | rogeeff | 2007-10-23 21:48:16 -0700 (Tue, 23 Oct 2007) | 1 line win CE and solaris workarounds ........ r40397 | djowel | 2007-10-23 21:58:50 -0700 (Tue, 23 Oct 2007) | 1 line merging tobias changes ........ r40399 | schoepflin | 2007-10-24 01:21:15 -0700 (Wed, 24 Oct 2007) | 2 lines Added missing include file. ........ r40401 | johnmaddock | 2007-10-24 01:49:06 -0700 (Wed, 24 Oct 2007) | 1 line Fix HPUX error levels: reordered expected failure rates so that they still work when largest_real == double. ........ r40403 | schoepflin | 2007-10-24 02:02:32 -0700 (Wed, 24 Oct 2007) | 3 lines Fixed code which incorrectly assumed that an iterator returned by begin() is always a modifiable lvalue. ........ r40404 | schoepflin | 2007-10-24 02:04:47 -0700 (Wed, 24 Oct 2007) | 1 line Clarify lookup for destroy_n(). ........ r40405 | johnmaddock | 2007-10-24 02:15:20 -0700 (Wed, 24 Oct 2007) | 1 line Update makefiles and the script that creates them: was generating dependencies that weren't required. ........ r40406 | anthonyw | 2007-10-24 02:32:29 -0700 (Wed, 24 Oct 2007) | 1 line added real default constructor to condition::list_entry ........ r40407 | anthonyw | 2007-10-24 02:36:51 -0700 (Wed, 24 Oct 2007) | 1 line thrd-api is no longer a symmetric feature ........ r40408 | schoepflin | 2007-10-24 04:17:05 -0700 (Wed, 24 Oct 2007) | 2 lines Added missing include file. ........ r40409 | vladimir_prus | 2007-10-24 04:34:53 -0700 (Wed, 24 Oct 2007) | 1 line Improve comments ........ r40410 | vladimir_prus | 2007-10-24 04:38:49 -0700 (Wed, 24 Oct 2007) | 1 line Fix typo ........ r40411 | schoepflin | 2007-10-24 04:41:21 -0700 (Wed, 24 Oct 2007) | 3 lines Use external linkage for function templates, otherwise they are not considered as candidate functions during name loopkup. ........ r40412 | anthonyw | 2007-10-24 05:00:14 -0700 (Wed, 24 Oct 2007) | 1 line updated thread move semantics to work with Borland ........ r40413 | chris_kohlhoff | 2007-10-24 06:23:59 -0700 (Wed, 24 Oct 2007) | 2 lines Fixes for HP-UX test failures. ........ r40414 | nesotto | 2007-10-24 06:35:04 -0700 (Wed, 24 Oct 2007) | 1 line changed example with prime numbers according to Ticket #807 (new Bugs: None) ........ r40415 | nesotto | 2007-10-24 06:54:11 -0700 (Wed, 24 Oct 2007) | 1 line conversion operator was not in 1.34, so removed here also ........ r40416 | nesotto | 2007-10-24 06:54:52 -0700 (Wed, 24 Oct 2007) | 1 line cleanup ........ r40417 | nesotto | 2007-10-24 07:46:42 -0700 (Wed, 24 Oct 2007) | 1 line some updates from 1,34 branch ........ r40418 | eric_niebler | 2007-10-24 08:00:20 -0700 (Wed, 24 Oct 2007) | 1 line s/boost_range_begin/range_begin/ ........ r40419 | nesotto | 2007-10-24 08:02:01 -0700 (Wed, 24 Oct 2007) | 1 line newer docs from 1.34 ........ r40420 | eric_niebler | 2007-10-24 08:04:41 -0700 (Wed, 24 Oct 2007) | 1 line more typeof registrations from Dave Jankins ........ r40422 | nesotto | 2007-10-24 08:18:22 -0700 (Wed, 24 Oct 2007) | 1 line roll back of ADL names ........ r40423 | nesotto | 2007-10-24 08:19:16 -0700 (Wed, 24 Oct 2007) | 1 line roll-back of ADL names ........ r40424 | anthonyw | 2007-10-24 08:39:14 -0700 (Wed, 24 Oct 2007) | 1 line updated pthreads code to support move and multiple joins ........ r40425 | nesotto | 2007-10-24 08:53:54 -0700 (Wed, 24 Oct 2007) | 1 line removed deprecated mfc stuff ........ r40426 | nesotto | 2007-10-24 09:26:54 -0700 (Wed, 24 Oct 2007) | 1 line minor updates from 1.34 ........ r40427 | johnmaddock | 2007-10-24 10:57:45 -0700 (Wed, 24 Oct 2007) | 2 lines Removed files that are no longer used and regenerated the Makefiles so they are no longer dependent on the removed files. Hidden some seldom-used dependencies in static_mutex.hpp to reduce library footprint when extracted with bcp. ........ r40428 | igaztanaga | 2007-10-24 11:59:26 -0700 (Wed, 24 Oct 2007) | 1 line Fixed Solaris-gcc errors and added splay trees ........ r40429 | igaztanaga | 2007-10-24 12:00:30 -0700 (Wed, 24 Oct 2007) | 1 line Fixed Solaris-gcc errors and added splay trees ........ r40430 | igaztanaga | 2007-10-24 12:25:40 -0700 (Wed, 24 Oct 2007) | 1 line Corrected operator >> bug ........ r40433 | grafik | 2007-10-24 12:56:54 -0700 (Wed, 24 Oct 2007) | 1 line Obsolete in new web site. (fixes #1373) ........ r40435 | burbelgruff | 2007-10-24 13:30:31 -0700 (Wed, 24 Oct 2007) | 1 line Deleted regression tests. ........ r40437 | grafik | 2007-10-24 14:01:44 -0700 (Wed, 24 Oct 2007) | 1 line Obsolete files, as they are now moved to the new web site structure. (fixes #1248) ........ r40438 | eric_niebler | 2007-10-24 14:37:09 -0700 (Wed, 24 Oct 2007) | 1 line remove unneeded msvc-7.1 work-around ........ r40440 | danieljames | 2007-10-24 15:56:42 -0700 (Wed, 24 Oct 2007) | 2 lines Delete background.html as it's now in the new web site. ........ r40442 | djowel | 2007-10-24 16:29:54 -0700 (Wed, 24 Oct 2007) | 1 line fix remaining includes ........ r40444 | danieljames | 2007-10-24 16:36:57 -0700 (Wed, 24 Oct 2007) | 2 lines Delete bibliography, now that it's updated in the site. Fixes #1254. ........ r40445 | eric_niebler | 2007-10-24 16:37:40 -0700 (Wed, 24 Oct 2007) | 1 line replace all throw statements with boost::throw_exception ........ r40447 | rogeeff | 2007-10-24 17:01:38 -0700 (Wed, 24 Oct 2007) | 2 lines avoid msvc 8.0 warning more win CE workaround ........ r40448 | rogeeff | 2007-10-24 17:02:14 -0700 (Wed, 24 Oct 2007) | 1 line avoid some msvc warning ........ r40449 | rogeeff | 2007-10-24 17:17:25 -0700 (Wed, 24 Oct 2007) | 1 line missed sunpro workaround ........ r40451 | rogeeff | 2007-10-24 22:38:19 -0700 (Wed, 24 Oct 2007) | 2 lines minor cleanup final major piece of this update: debug services (almost complete: without stack dump) ........ r40453 | igaztanaga | 2007-10-24 23:33:50 -0700 (Wed, 24 Oct 2007) | 1 line Fixed Solaris and Linux bugs ........ r40454 | igaztanaga | 2007-10-24 23:34:41 -0700 (Wed, 24 Oct 2007) | 1 line Fixed intrusive_ptr and named condition test and added documentation. ........ r40455 | rogeeff | 2007-10-24 23:35:14 -0700 (Wed, 24 Oct 2007) | 1 line missing file included ........ r40456 | anthonyw | 2007-10-25 00:17:20 -0700 (Thu, 25 Oct 2007) | 1 line thread move constructor is not explicit, so self() compiles for MSVC8 and Intel; thread_exit_callback_node constructor added to remove warnings on MSVC8; thread destructor no longer calls cancel ........ r40457 | rogeeff | 2007-10-25 00:29:07 -0700 (Thu, 25 Oct 2007) | 1 line missed debug in another included component ........ r40458 | speedsnail | 2007-10-25 00:52:25 -0700 (Thu, 25 Oct 2007) | 1 line More verbose "Skipping" message, telling what it is beeing skipped. ........ r40459 | speedsnail | 2007-10-25 00:57:12 -0700 (Thu, 25 Oct 2007) | 1 line Corrected typo ........ r40460 | schoepflin | 2007-10-25 03:21:10 -0700 (Thu, 25 Oct 2007) | 1 line Removed extra semicolons to silence warnings. ........ r40461 | igaztanaga | 2007-10-25 08:53:19 -0700 (Thu, 25 Oct 2007) | 1 line Corrected error when checking file size against maximum address range for 64 bit platforms ........ r40462 | vladimir_prus | 2007-10-25 09:48:24 -0700 (Thu, 25 Oct 2007) | 3 lines Report underfined paths before trying to replace spaces in them (and crash on emptry paths). ........ r40463 | vladimir_prus | 2007-10-25 10:08:27 -0700 (Thu, 25 Oct 2007) | 1 line Don't use boost.test for testing. ........ r40464 | nesotto | 2007-10-25 13:47:59 -0700 (Thu, 25 Oct 2007) | 1 line major update of copy-operations and various pending fixes ........ r40465 | nesotto | 2007-10-25 13:49:02 -0700 (Thu, 25 Oct 2007) | 1 line major update of test to handle new functionality and better test of old functionality ........ r40466 | nesotto | 2007-10-25 13:50:51 -0700 (Thu, 25 Oct 2007) | 1 line update of test for ptr_list_of which can now actually works because of copyability of the ptr_contaners ........ r40467 | nesotto | 2007-10-25 13:51:16 -0700 (Thu, 25 Oct 2007) | 1 line proper definition of the conversion operator ........ r40468 | dave | 2007-10-25 16:19:48 -0700 (Thu, 25 Oct 2007) | 3 lines Closes #1379. It would be good to have a much more principled approach; see comments in the diffs for details. ........ r40469 | grafik | 2007-10-25 18:02:48 -0700 (Thu, 25 Oct 2007) | 1 line Merge search path for include & import from backend branch. And add corresponding support for to BBv2 quickbook tool. Remove obsolete quickbook.xml file. (fixes #1263) ........ r40471 | rogeeff | 2007-10-25 23:47:29 -0700 (Thu, 25 Oct 2007) | 2 lines made it to compile if unicode is defined avoid assertion for negative chars ........ r40472 | anthonyw | 2007-10-26 00:33:22 -0700 (Fri, 26 Oct 2007) | 1 line added tests for cancellation ........ r40473 | vladimir_prus | 2007-10-26 01:41:34 -0700 (Fri, 26 Oct 2007) | 1 line Fix typo ........ r40474 | vladimir_prus | 2007-10-26 01:45:26 -0700 (Fri, 26 Oct 2007) | 2 lines Make 'install' for individual lib explicit. ........ r40475 | vladimir_prus | 2007-10-26 02:04:25 -0700 (Fri, 26 Oct 2007) | 6 lines Make sure every library can be installed by using bjam stage|install in libs//build. ........ r40476 | anthonyw | 2007-10-26 02:45:46 -0700 (Fri, 26 Oct 2007) | 1 line disable_cancellation and restore_cancellation need to be declared BOOST_THREAD_DECL to work with DLLs ........ r40477 | anthonyw | 2007-10-26 02:53:10 -0700 (Fri, 26 Oct 2007) | 1 line disable_cancellation and restore_cancellation need to be declared BOOST_THREAD_DECL to work with DLLs with pthread-win32 ........ r40478 | anthonyw | 2007-10-26 03:46:01 -0700 (Fri, 26 Oct 2007) | 1 line improved lifetime management of thread data ........ r40479 | t_schwinger | 2007-10-26 05:16:37 -0700 (Fri, 26 Oct 2007) | 3 lines reverts clobbered changes before merge ........ r40480 | igaztanaga | 2007-10-26 07:24:58 -0700 (Fri, 26 Oct 2007) | 1 line Added missing include ........ r40483 | schoepflin | 2007-10-26 08:36:56 -0700 (Fri, 26 Oct 2007) | 3 lines Use external linkage for function templates, otherwise they are not considered as candidate functions during name loopkup. ........ r40484 | johnmaddock | 2007-10-26 11:12:28 -0700 (Fri, 26 Oct 2007) | 1 line Try and work around a Tru64 overload resolution bug. ........ r40485 | rogeeff | 2007-10-26 11:31:55 -0700 (Fri, 26 Oct 2007) | 1 line removed install target for now ........ r40487 | vladimir_prus | 2007-10-26 12:37:56 -0700 (Fri, 26 Oct 2007) | 1 line Fix winmain test ........ r40488 | nesotto | 2007-10-26 16:03:11 -0700 (Fri, 26 Oct 2007) | 1 line Added test of xml-archives. ........ r40489 | nesotto | 2007-10-26 16:16:15 -0700 (Fri, 26 Oct 2007) | 1 line Ticket #1027 (new Patches) ........ r40494 | igaztanaga | 2007-10-27 02:17:14 -0700 (Sat, 27 Oct 2007) | 1 line updated new acc toolsets as unusable for Interprocess ........ r40497 | vladimir_prus | 2007-10-27 02:55:58 -0700 (Sat, 27 Oct 2007) | 2 lines New Python rule -- 'backtrace'. ........ r40498 | johnmaddock | 2007-10-27 04:25:05 -0700 (Sat, 27 Oct 2007) | 1 line Added first lot of markup for the new Boost.Math additions. ........ r40499 | johnmaddock | 2007-10-27 04:27:19 -0700 (Sat, 27 Oct 2007) | 1 line Changed concept code so there are no null-references any more (the code breaks on EDG based compilers otherwise). ........ r40500 | johnmaddock | 2007-10-27 04:32:30 -0700 (Sat, 27 Oct 2007) | 2 lines Set expected error limits for HP Tru64. Prevent very extreme-value round-trip tests from being run. ........ r40506 | nesotto | 2007-10-27 08:57:20 -0700 (Sat, 27 Oct 2007) | 1 line cleaned up deprecated headers ........ r40507 | nesotto | 2007-10-27 08:57:56 -0700 (Sat, 27 Oct 2007) | 1 line updated example to new syntax ........ r40508 | nesotto | 2007-10-27 08:58:22 -0700 (Sat, 27 Oct 2007) | 1 line first update ... more to come ........ r40509 | nesotto | 2007-10-27 11:20:45 -0700 (Sat, 27 Oct 2007) | 1 line small renaming ........ r40510 | nesotto | 2007-10-27 11:21:17 -0700 (Sat, 27 Oct 2007) | 1 line better test of bilk headers ........ r40511 | nesotto | 2007-10-27 14:50:14 -0700 (Sat, 27 Oct 2007) | 1 line update of all new functionality ........ r40512 | nesotto | 2007-10-27 14:52:13 -0700 (Sat, 27 Oct 2007) | 1 line minor change to scoped_deleter, some cleanup of explicit, and fixed a bug in assignment of ptr_maps ........ r40513 | nesotto | 2007-10-27 14:52:51 -0700 (Sat, 27 Oct 2007) | 1 line minor update of copying of maps ........ r40514 | nesotto | 2007-10-27 15:00:47 -0700 (Sat, 27 Oct 2007) | 1 line added mfc/atl link ........ r40515 | danmarsden | 2007-10-27 15:16:35 -0700 (Sat, 27 Oct 2007) | 1 line fixing performance tests, mainly result of issues, and arity issues with unfused typed ........ r40516 | danmarsden | 2007-10-27 15:18:13 -0700 (Sat, 27 Oct 2007) | 1 line fixing missing traversal category on binary transform view, by reusing zip_view algorithm ........ r40517 | nesotto | 2007-10-27 15:35:20 -0700 (Sat, 27 Oct 2007) | 1 line update that hopefully will help eg the sun compiler ........ r40518 | nesotto | 2007-10-27 15:52:29 -0700 (Sat, 27 Oct 2007) | 1 line changed range_result_iterator to range_iterator ........ r40520 | nesotto | 2007-10-28 03:11:10 -0700 (Sun, 28 Oct 2007) | 1 line fixes broken one from trunk ... still not finished ........ r40521 | nesotto | 2007-10-28 03:11:54 -0700 (Sun, 28 Oct 2007) | 1 line adds test for inclusion of concept header ........ r40522 | johnmaddock | 2007-10-28 04:07:14 -0700 (Sun, 28 Oct 2007) | 2 lines split test_policy into 2 to reduce compile times. Added expected error rates for Mac OS X on Intel. ........ r40524 | andreas_huber69 | 2007-10-28 06:26:00 -0700 (Sun, 28 Oct 2007) | 2 lines - Added to-do - Update for 1.35 ........ r40527 | hkaiser | 2007-10-28 07:29:40 -0700 (Sun, 28 Oct 2007) | 1 line Changed the code to allow ADL to find the correct pow() function, not relying on an existing overload in the std namespace anymore. ........ r40530 | martin_wille | 2007-10-28 09:02:15 -0700 (Sun, 28 Oct 2007) | 5 lines -- compensated for changes to Boost.Thread: o Boost.Thread no longer accepts boost::reference_wrapper instances as callable arguments o created a new callable_reference_wrapper type that gets used instead of the no longer accepted type. ........ r40531 | hkaiser | 2007-10-28 09:16:52 -0700 (Sun, 28 Oct 2007) | 1 line Added test of real_parser specialized for a custom data type. ........ r40534 | danmarsden | 2007-10-28 10:40:45 -0700 (Sun, 28 Oct 2007) | 1 line Documentation for the struct extension macros ........ r40535 | dave | 2007-10-28 12:22:21 -0700 (Sun, 28 Oct 2007) | 2 lines Closes #1379, really this time. The old code would sandwich argv[1] between quotes and interpret it as a string, so backslashes in windows paths were interpreted as escape sequences. ........ r40536 | dave | 2007-10-28 12:24:02 -0700 (Sun, 28 Oct 2007) | 2 lines Take out print statement I added for debugging purposes. ........ r40537 | grafik | 2007-10-28 12:53:09 -0700 (Sun, 28 Oct 2007) | 1 line Fix misspelled test file name. ........ r40539 | djowel | 2007-10-28 18:19:31 -0700 (Sun, 28 Oct 2007) | 1 line added Tobias to fusion authors list ........ r40540 | burbelgruff | 2007-10-29 01:05:17 -0700 (Mon, 29 Oct 2007) | 1 line Fixed duplicate definition of boost::type_of::push_back when BOOST_TYPEOF_LIMIT_SIZE>50 and not a multiple of 50. (From Dave Jenkins) ........ r40541 | joaquin | 2007-10-29 01:12:58 -0700 (Mon, 29 Oct 2007) | 1 line updated according to latest regression tests results ........ r40542 | joaquin | 2007-10-29 01:16:56 -0700 (Mon, 29 Oct 2007) | 1 line fixed some struct/class discordances between decls and defs ........ r40543 | nesotto | 2007-10-29 05:29:57 -0700 (Mon, 29 Oct 2007) | 1 line change use of range_result_iterator to range_iterator ........ r40546 | chris_kohlhoff | 2007-10-29 06:06:12 -0700 (Mon, 29 Oct 2007) | 3 lines Mac OS X 10.5 (Leopard) gives a compile error if you try to perform an operation on a const fd_set pointer. ........ r40547 | chris_kohlhoff | 2007-10-29 06:06:39 -0700 (Mon, 29 Oct 2007) | 2 lines Ensure the task handler is put back on the queue after polling. ........ r40548 | chris_kohlhoff | 2007-10-29 06:07:08 -0700 (Mon, 29 Oct 2007) | 3 lines Use GetModuleHandleA rather than GetModuleHandle to avoid being broken by UNICODE #defines. ........ r40549 | chris_kohlhoff | 2007-10-29 06:08:32 -0700 (Mon, 29 Oct 2007) | 3 lines HP-UX fails to declare if_nametoindex as extern "C". Added a declaration for it with correct linkage to avoid a linker error. ........ r40551 | dgregor | 2007-10-29 07:43:19 -0700 (Mon, 29 Oct 2007) | 1 line sigemptyset is a macro on Darwin, so don't precede it by :: ........ r40553 | eric_niebler | 2007-10-29 08:04:11 -0700 (Mon, 29 Oct 2007) | 1 line better solution for deprecated range_result_iterator ........ r40554 | fmhess | 2007-10-29 08:08:46 -0700 (Mon, 29 Oct 2007) | 3 lines Extended the hack in docbook.xsl for dealing with nested elements. It now handles the case of children of . ........ r40555 | fmhess | 2007-10-29 08:18:49 -0700 (Mon, 29 Oct 2007) | 16 lines Added support for new boostbook element for documenting non-public class members. function.xsl, type.xsl, utility.xsl: Added support for elements to allow nonpublic access specifiers for class member documentation. boostbook.dtd: Updated to reflect new element. Updated Peter Simons email address. Added mention of boost license. reference.dtdxml: Added reference documentation for new element. Removed some obsolete remarks from the description of inherit element. reference.xml: The changes to this file were generated by applying dtd2boostbook.xsl to the updated reference.dtdxml file. ........ r40556 | grafik | 2007-10-29 09:12:14 -0700 (Mon, 29 Oct 2007) | 1 line Fix force-update and have-source options to be correct boolean options. And bring back the rmtree code to work around Python rmtree deficiencies. ........ r40557 | grafik | 2007-10-29 12:12:07 -0700 (Mon, 29 Oct 2007) | 1 line Now that tarballs are working again... Implement getting the tools source from tarballs, and fix getting boost sources from tarball. ........ r40558 | rwgk | 2007-10-29 12:12:56 -0700 (Mon, 29 Oct 2007) | 1 line gcc 4.3.0 compatibility (resolves new "changes meaning" error) ........ r40595 | grafik | 2007-10-29 18:50:42 -0700 (Mon, 29 Oct 2007) | 1 line Add support for using a proxy as some firewalls are restrictive even to HTTP/GET access. ........ r40597 | igaztanaga | 2007-10-30 00:00:51 -0700 (Tue, 30 Oct 2007) | 1 line Added avl trees ........ r40598 | igaztanaga | 2007-10-30 00:02:10 -0700 (Tue, 30 Oct 2007) | 1 line Added avl trees ........ r40599 | agurtovoy | 2007-10-30 00:25:27 -0700 (Tue, 30 Oct 2007) | 1 line xsl_reports: display the corresponding run's revision/timestamp on the test output page ........ r40603 | bgubenko | 2007-10-30 05:43:47 -0700 (Tue, 30 Oct 2007) | 1 line add support for aC++ on HP-UX ia64 ........ r40604 | bgubenko | 2007-10-30 05:48:44 -0700 (Tue, 30 Oct 2007) | 1 line add support for aC++ on HP-UX ia64 ........ r40605 | bgubenko | 2007-10-30 05:58:36 -0700 (Tue, 30 Oct 2007) | 1 line fix typo in comment ........ r40609 | anthonyw | 2007-10-30 10:16:24 -0700 (Tue, 30 Oct 2007) | 1 line Added specialization for reference_wrapper to allow use of boost::ref with boost::thread (again) ........ r40611 | hkaiser | 2007-10-30 11:17:59 -0700 (Tue, 30 Oct 2007) | 1 line Merged a change from 1.34.1. ........ r40612 | nesotto | 2007-10-30 12:47:40 -0700 (Tue, 30 Oct 2007) | 1 line current version gave problem in regression ... to be updated later ........ r40614 | andreas_huber69 | 2007-10-30 14:27:34 -0700 (Tue, 30 Oct 2007) | 1 line Marked up new failures for 1.35 ........ r40615 | andreas_huber69 | 2007-10-30 15:01:41 -0700 (Tue, 30 Oct 2007) | 1 line Updated link to test results. ........ r40617 | danieljames | 2007-10-30 15:33:35 -0700 (Tue, 30 Oct 2007) | 3 lines Remove regression/.htaccess as it has been merged with the beta website's .htaccess. Fixes #1249. ........ r40623 | johnmaddock | 2007-10-31 05:43:10 -0700 (Wed, 31 Oct 2007) | 1 line Try and get better error messages to debug Tru64 failures. ........ r40625 | bemandawes | 2007-10-31 08:09:35 -0700 (Wed, 31 Oct 2007) | 1 line Remove some older compilers from required list ........ r40627 | bemandawes | 2007-10-31 11:28:39 -0700 (Wed, 31 Oct 2007) | 1 line Add missing BOOST_SYSTEM_NO_DEPRECATED #ifndef ........ r40628 | grafik | 2007-10-31 13:20:07 -0700 (Wed, 31 Oct 2007) | 1 line Remove dependence on boost.test for PJL. It causes too many dependence problems on the testing platforms. ........ r40629 | nesotto | 2007-10-31 14:48:11 -0700 (Wed, 31 Oct 2007) | 1 line added deprecated headers again for backward compatibility sake ........ r40630 | bemandawes | 2007-10-31 15:01:58 -0700 (Wed, 31 Oct 2007) | 1 line Treat Windows ERROR_SHARING_VIOLATION as an existing file of unknown type. Fixes ticket #897 ........ r40631 | agurtovoy | 2007-10-31 15:25:46 -0700 (Wed, 31 Oct 2007) | 1 line xsl_report: fix timestamp/revision age highlighting ........ r40632 | hkaiser | 2007-10-31 16:13:34 -0700 (Wed, 31 Oct 2007) | 1 line Applied patch from #1208. ........ r40633 | bgubenko | 2007-10-31 18:05:07 -0700 (Wed, 31 Oct 2007) | 1 line mark parameter library tests affected by GCC Bugzilla Bug 33580 ........ r40634 | rogeeff | 2007-10-31 19:46:57 -0700 (Wed, 31 Oct 2007) | 1 line disable on CE ........ r40635 | rogeeff | 2007-10-31 19:54:15 -0700 (Wed, 31 Oct 2007) | 1 line debug was missing in PEM ........ r40636 | johnmaddock | 2007-11-01 03:17:49 -0700 (Thu, 01 Nov 2007) | 1 line Still more tweaks to try and figure out why this fails on Tru64. ........ r40637 | igaztanaga | 2007-11-01 04:47:00 -0700 (Thu, 01 Nov 2007) | 1 line Uncommented pointer conversion utilities ........ r40638 | bgubenko | 2007-11-01 04:47:20 -0700 (Thu, 01 Nov 2007) | 1 line fix typo ........ r40639 | johnmaddock | 2007-11-01 07:01:44 -0700 (Thu, 01 Nov 2007) | 1 line Added and to the list of Unix-specific includes: these are needed by Sun's compiler, and for that matter, by Boost.Test to be std conforming. ........ r40640 | bemandawes | 2007-11-01 08:23:06 -0700 (Thu, 01 Nov 2007) | 2 lines Enable the XPG-compliant version of readdir_r() on AIX. Merged from 1.34.1. ........ r40642 | gmelquio | 2007-11-01 09:01:30 -0700 (Thu, 01 Nov 2007) | 1 line Ported patch from 1.34.1 about conflicting math.h functions on PPC. Commented use of old control function for MSVC. ........ r40645 | dgregor | 2007-11-01 09:16:30 -0700 (Thu, 01 Nov 2007) | 1 line Use unsigned long long for the path count to avoid overflows. Fixes #1398 ........ r40646 | bemandawes | 2007-11-01 09:35:45 -0700 (Thu, 01 Nov 2007) | 1 line Mingw doesn't support GetUserDefaultUILanguage so set it to US English. ........ r40647 | anthonyw | 2007-11-01 10:07:47 -0700 (Thu, 01 Nov 2007) | 1 line condition wait and sleep are now cancellation points ........ r40649 | johnmaddock | 2007-11-01 10:16:41 -0700 (Thu, 01 Nov 2007) | 1 line Fix for http://svn.boost.org/trac/boost/ticket/1381. ........ r40650 | anthonyw | 2007-11-01 10:18:54 -0700 (Thu, 01 Nov 2007) | 1 line shared_mutex lock functions are not cancellation points ........ r40651 | danieljames | 2007-11-01 10:58:13 -0700 (Thu, 01 Nov 2007) | 2 lines Merge version history from 1.34.1. ........ r40652 | johnmaddock | 2007-11-01 11:02:37 -0700 (Thu, 01 Nov 2007) | 1 line Ticket #583. ........ r40653 | anthonyw | 2007-11-01 11:04:55 -0700 (Thu, 01 Nov 2007) | 1 line added timed_join to thread ........ r40654 | johnmaddock | 2007-11-01 11:05:33 -0700 (Thu, 01 Nov 2007) | 1 line Patches from Trac #583. ........ r40655 | danieljames | 2007-11-01 11:22:33 -0700 (Thu, 01 Nov 2007) | 1 line Fix the previous merge commit, it didn't include all the changes. ........ r40656 | johnmaddock | 2007-11-01 11:26:07 -0700 (Thu, 01 Nov 2007) | 1 line Strengthened admonishment and rebuilt docs. ........ r40657 | bemandawes | 2007-11-01 11:39:32 -0700 (Thu, 01 Nov 2007) | 1 line Add Boost.System ........ r40669 | danieljames | 2007-11-01 14:57:03 -0700 (Thu, 01 Nov 2007) | 2 lines Delete people from main repository, now that the beta website has been updated. ........ r40670 | chris_kohlhoff | 2007-11-01 15:42:26 -0700 (Thu, 01 Nov 2007) | 3 lines Fix memory leak when an io_service is allowed to destruct with unfinished async_wait operations. ........ r40671 | dave | 2007-11-01 16:39:02 -0700 (Thu, 01 Nov 2007) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-40670" from https://svn.boost.org/svn/boost/branches/RC_1_34_0/boost ........ r40672 | dave | 2007-11-01 16:44:39 -0700 (Thu, 01 Nov 2007) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-33417" from https://svn.boost.org/svn/boost/branches/RC_1_34_0/boost ........ r40673 | dgregor | 2007-11-01 20:07:24 -0700 (Thu, 01 Nov 2007) | 1 line Fix for Borland/CodeGear, from JongSoo Park ........ r40674 | matias | 2007-11-01 20:51:40 -0700 (Thu, 01 Nov 2007) | 1 line Add not supported compilers for Bimap ........ r40675 | eric_niebler | 2007-11-01 21:35:01 -0700 (Thu, 01 Nov 2007) | 1 line merge Changeset 37947 ........ r40676 | speedsnail | 2007-11-02 00:42:49 -0700 (Fri, 02 Nov 2007) | 1 line changed translate-indirect to skip rules, that are already in indirect format. This allows e.g. to make use of the - to remove already set tag feature. ........ r40677 | speedsnail | 2007-11-02 01:40:11 -0700 (Fri, 02 Nov 2007) | 2 lines New thread Jamfile. Requirement multi now correctly handled, even when requested with single. New project specific feature with values win32 and pthread available. ........ r40678 | johnmaddock | 2007-11-02 01:59:24 -0700 (Fri, 02 Nov 2007) | 1 line Some minor tweaks to support Sun's compiler on Linux. ........ r40679 | anthonyw | 2007-11-02 02:17:02 -0700 (Fri, 02 Nov 2007) | 1 line Added changes from David Deakins to enable compilation on Windows CE ........ r40680 | anthonyw | 2007-11-02 04:47:56 -0700 (Fri, 02 Nov 2007) | 1 line rewrite xtime_get in terms of get_system_time to ensure clock consistency, and fix Borland test failures ........ r40682 | bemandawes | 2007-11-02 05:43:47 -0700 (Fri, 02 Nov 2007) | 1 line WinCE workaround for lack of FormatMessageA ........ r40683 | johnmaddock | 2007-11-02 06:01:39 -0700 (Fri, 02 Nov 2007) | 1 line Added a couple of boost:: qualifiers that were present in 1.34.1 but got lost from the Trunk. ........ r40684 | johnmaddock | 2007-11-02 06:02:41 -0700 (Fri, 02 Nov 2007) | 1 line Fixes for Mac OS X on PowerPC Darwin. ........ r40685 | anthonyw | 2007-11-02 07:58:48 -0700 (Fri, 02 Nov 2007) | 1 line renamed cancellation to interruption ........ r40687 | rogeeff | 2007-11-02 09:08:47 -0700 (Fri, 02 Nov 2007) | 1 line allow tests to be run by regression testing facilities ........ r40688 | johnmaddock | 2007-11-02 10:40:10 -0700 (Fri, 02 Nov 2007) | 1 line Added one more needed #include (stdlib.h for mkstemp). ........ r40692 | anthonyw | 2007-11-02 11:19:49 -0700 (Fri, 02 Nov 2007) | 1 line Fixed typo with interruption change ........ r40693 | johnmaddock | 2007-11-02 11:26:47 -0700 (Fri, 02 Nov 2007) | 1 line Added needed #include and using declaration. ........ r40697 | pavol_droba | 2007-11-02 13:55:26 -0700 (Fri, 02 Nov 2007) | 2 lines merging changes from 1.34 ........ r40698 | pavol_droba | 2007-11-02 14:00:08 -0700 (Fri, 02 Nov 2007) | 3 lines merging changes from 1.34 ........ r40702 | fmhess | 2007-11-02 15:37:52 -0700 (Fri, 02 Nov 2007) | 4 lines Fixed spurious paragraph in html output for overloaded methods. ........ r40703 | fmhess | 2007-11-02 15:40:25 -0700 (Fri, 02 Nov 2007) | 4 lines Added descriptions of class member typedefs to class documentation. This replaces Daniel James' previous one-line patch from changeset 39711. ........ r40704 | fcacciola | 2007-11-02 15:55:49 -0700 (Fri, 02 Nov 2007) | 1 line Merged changests from RC_1_34_0 - base rev 33417 ........ r40705 | fcacciola | 2007-11-02 15:56:23 -0700 (Fri, 02 Nov 2007) | 1 line Merged changests from RC_1_34_0 - base rev 33417 ........ r40706 | fcacciola | 2007-11-02 16:06:42 -0700 (Fri, 02 Nov 2007) | 1 line Fixed error reported by Edward Diener ........ r40707 | fcacciola | 2007-11-02 16:41:37 -0700 (Fri, 02 Nov 2007) | 1 line Added test to ensure proper binding of optional references (in reference to Ticket 1301) ........ r40708 | pdimov | 2007-11-02 16:46:04 -0700 (Fri, 02 Nov 2007) | 1 line Port unspecified_bool fix for Sun 5.8 from RC_1_34 ........ r40709 | hkaiser | 2007-11-02 17:30:33 -0700 (Fri, 02 Nov 2007) | 1 line Bumped Spirit version to 1.8.6. ........ r40710 | bemandawes | 2007-11-02 17:49:07 -0700 (Fri, 02 Nov 2007) | 1 line Detect Windows FormatMessage errors, standardize message() return on message-not-found errors ........ r40712 | djowel | 2007-11-02 20:05:26 -0700 (Fri, 02 Nov 2007) | 1 line replacing reinterpret_cast with static_cast(static_cast(i)) ........ r40714 | dave | 2007-11-02 20:25:13 -0700 (Fri, 02 Nov 2007) | 3 lines Merging some of the more obvious changes from RC_1_34_0 ........ r40715 | noel_belcourt | 2007-11-02 21:08:23 -0700 (Fri, 02 Nov 2007) | 3 lines Have intel on darwin use intel-linux.jam toolset. ........ r40716 | danieljames | 2007-11-03 03:10:11 -0700 (Sat, 03 Nov 2007) | 2 lines Merge in changes to forwarding html files in doc/html. ........ r40717 | danieljames | 2007-11-03 03:18:52 -0700 (Sat, 03 Nov 2007) | 2 lines Add titles to redirect pages so that they will validate. ........ r40718 | danieljames | 2007-11-03 03:32:35 -0700 (Sat, 03 Nov 2007) | 9 lines Attribute copyright to Douglas Gregor. The copyright in these files was attributed to William Kempf, but the revision history shows that he has never touched them and the original file that they were based on (threads.html) was created by Douglas Gregor. The copyright was actually added by Hartmut Kaiser, who was adding the copyright to all the Boost.Thread files and included this one. ........ r40719 | johnmaddock | 2007-11-03 05:36:55 -0700 (Sat, 03 Nov 2007) | 1 line Hopefully, take care of the remaining Tru64 failures: adjust >= test to > in some of the tests, and fix one expected error level for the incomplete beta function. ........ r40720 | johnmaddock | 2007-11-03 05:43:41 -0700 (Sat, 03 Nov 2007) | 1 line Try again to fix Darwin failure: the wrong error limit is currently being found. ........ r40725 | johnmaddock | 2007-11-03 10:05:11 -0700 (Sat, 03 Nov 2007) | 1 line Need stdarg.h to use vsnprintf as well as stdio.h ........ r40726 | johnmaddock | 2007-11-03 11:30:07 -0700 (Sat, 03 Nov 2007) | 1 line Beginning to add Math Library markup. ........ r40727 | johnmaddock | 2007-11-03 11:32:54 -0700 (Sat, 03 Nov 2007) | 3 lines Added workaround for Sunpro not compiling the traits classes. Added workaround for platforms where numeric_limits<>::denorm_min() does not return a denorm! Updated Solaris error rates. ........ r40728 | pdimov | 2007-11-03 13:55:22 -0700 (Sat, 03 Nov 2007) | 1 line BOOST_VERIFY added. ........ r40730 | anthonyw | 2007-11-03 15:00:12 -0700 (Sat, 03 Nov 2007) | 1 line added missing include ........ r40731 | pdimov | 2007-11-03 15:47:17 -0700 (Sat, 03 Nov 2007) | 1 line Added a sentence with a brief explanation of the intended uses of BOOST_VERIFY. ........ r40733 | djowel | 2007-11-03 16:42:06 -0700 (Sat, 03 Nov 2007) | 1 line fixed [cpp] to [c++] ........ r40734 | djowel | 2007-11-03 17:12:29 -0700 (Sat, 03 Nov 2007) | 1 line tutorial update ........ r40735 | agurtovoy | 2007-11-03 18:34:39 -0700 (Sat, 03 Nov 2007) | 1 line explicit-failures-markup.xml: partially reverting change #39788 (see http://article.gmane.org/gmane.comp.lib.boost.testing/5254) ........ r40736 | johnmaddock | 2007-11-04 04:01:16 -0800 (Sun, 04 Nov 2007) | 1 line Fix path to test case. ........ r40737 | danmarsden | 2007-11-04 07:26:51 -0800 (Sun, 04 Nov 2007) | 1 line Basic sequence and iterator fascade docs ........ r40738 | bemandawes | 2007-11-04 07:32:03 -0800 (Sun, 04 Nov 2007) | 1 line glibc++ may append unknown error value, so only test first part of string ........ r40739 | bemandawes | 2007-11-04 07:48:31 -0800 (Sun, 04 Nov 2007) | 1 line Try to bring the required toolsets more in sync with what testers are actually running. Sort required toolsets. ........ r40742 | speedsnail | 2007-11-04 09:17:01 -0800 (Sun, 04 Nov 2007) | 3 lines Get rid of "unsused variable" warnings by making use of BOOST_VERIFY. This changeset is for pthread only. ........ r40744 | bemandawes | 2007-11-04 09:18:53 -0800 (Sun, 04 Nov 2007) | 1 line Workaround MingW doesn't supply GetUserDefaultUILanguage ........ r40749 | rwgk | 2007-11-04 10:08:28 -0800 (Sun, 04 Nov 2007) | 1 line reinterpret_cast -> const_cast; commented out dead code removed ........ r40751 | danieljames | 2007-11-04 11:09:56 -0800 (Sun, 04 Nov 2007) | 2 lines Remove borland_cpp.html as it has been added to the new site. ........ r40753 | danieljames | 2007-11-04 11:29:41 -0800 (Sun, 04 Nov 2007) | 2 lines Remove the submission process documentation as it's up to date in the new site. ........ r40758 | danieljames | 2007-11-04 13:07:02 -0800 (Sun, 04 Nov 2007) | 3 lines Delete int_const_guidlines from trunk, as it's been added to the beta site. Fixes: #1356. ........ r40759 | chris_kohlhoff | 2007-11-04 13:25:49 -0800 (Sun, 04 Nov 2007) | 2 lines Some changes to enable support for WinCE. ........ r40762 | eric_niebler | 2007-11-04 14:53:27 -0800 (Sun, 04 Nov 2007) | 1 line remove dead proto v1 code ........ r40763 | eric_niebler | 2007-11-04 15:53:13 -0800 (Sun, 04 Nov 2007) | 1 line various fixes and missing includes, from Jens Seidel ........ r40764 | eric_niebler | 2007-11-04 15:58:44 -0800 (Sun, 04 Nov 2007) | 1 line change header include order ........ r40765 | djowel | 2007-11-04 17:13:11 -0800 (Sun, 04 Nov 2007) | 1 line Fixed Ticket #1328 (http://svn.boost.org/trac/boost/ticket/1328) ........ r40766 | djowel | 2007-11-04 18:10:42 -0800 (Sun, 04 Nov 2007) | 1 line Workarounds for Fusion on IBM xlc ........ r40767 | bemandawes | 2007-11-04 18:34:04 -0800 (Sun, 04 Nov 2007) | 1 line Add copyright and license ........ r40768 | garcia | 2007-11-04 19:13:15 -0800 (Sun, 04 Nov 2007) | 2 lines multi_array doesn't work under Borland 5.9. ........ r40769 | dave | 2007-11-04 19:54:19 -0800 (Sun, 04 Nov 2007) | 9 lines Updated Concept Check library documentation. Changed BOOST_CONCEPT_WHERE to BOOST_CONCEPT_REQUIRES to be more consistent with the current C++0x proposal, which now uses a "requires" keyword in lieu of "where." Factored GCC workarounds into the BOOST_CONCEPT_USAGE macro. ........ r40770 | dave | 2007-11-04 20:43:31 -0800 (Sun, 04 Nov 2007) | 7 lines Moved boost/concept/where.hpp to boost/concept/requires.hpp Updated reference.htm to include BOOST_CONCEPT_REQUIRES Fixed a copyright notice. ........ r40771 | johnmaddock | 2007-11-05 01:33:31 -0800 (Mon, 05 Nov 2007) | 1 line Still trying to get Mac OS error rates correct... ........ r40774 | anthonyw | 2007-11-05 02:15:24 -0800 (Mon, 05 Nov 2007) | 1 line threadapi is a composite feature again ........ r40779 | chris_kohlhoff | 2007-11-05 03:52:52 -0800 (Mon, 05 Nov 2007) | 2 lines Don't set errno when building for Windows targets. Should fix WinCE build. ........ r40780 | johnmaddock | 2007-11-05 04:07:47 -0800 (Mon, 05 Nov 2007) | 1 line Disabled long double support for Intel on Linux prior to version 10. ........ r40781 | johnmaddock | 2007-11-05 04:08:39 -0800 (Mon, 05 Nov 2007) | 1 line Changed test so that input values are exact binary values to fix failure at float precision. ........ r40782 | bemandawes | 2007-11-05 04:36:41 -0800 (Mon, 05 Nov 2007) | 1 line Add message display to illuminate why aCC fails Unknown error test ........ r40783 | chris_kohlhoff | 2007-11-05 04:38:39 -0800 (Mon, 05 Nov 2007) | 2 lines Add checks for expected failures on Windows CE. ........ r40785 | nesotto | 2007-11-05 05:54:23 -0800 (Mon, 05 Nov 2007) | 1 line added lost changes from 1.34 branch ........ r40787 | anthonyw | 2007-11-05 06:16:21 -0800 (Mon, 05 Nov 2007) | 1 line Use pthread_equal for comparing pthread_t IDs; use BOOST_VERIFY instead of BOOST_ASSERT in many places in order to avoid unused variable warnings ........ r40789 | djowel | 2007-11-05 07:13:58 -0800 (Mon, 05 Nov 2007) | 1 line fusion markups ........ r40790 | speedsnail | 2007-11-05 08:12:49 -0800 (Mon, 05 Nov 2007) | 2 lines Usage requirements added. ........ r40791 | speedsnail | 2007-11-05 08:22:17 -0800 (Mon, 05 Nov 2007) | 2 lines Cosmetic change to please gcc. ........ r40792 | anthonyw | 2007-11-05 08:47:25 -0800 (Mon, 05 Nov 2007) | 1 line Use BOOST_VERIFY instead of BOOST_ASSERT in many places in order to avoid unused variable warnings ........ r40793 | eric_niebler | 2007-11-05 09:12:50 -0800 (Mon, 05 Nov 2007) | 1 line markup foreach failures on sun-5.9 ........ r40794 | t_schwinger | 2007-11-05 09:15:04 -0800 (Mon, 05 Nov 2007) | 4 lines - nonstandard calling conventions disabled by default - automatic fallback configuration ........ r40795 | t_schwinger | 2007-11-05 09:16:30 -0800 (Mon, 05 Nov 2007) | 2 lines removes unportable 'chdir' ........ r40796 | t_schwinger | 2007-11-05 09:17:57 -0800 (Mon, 05 Nov 2007) | 3 lines just a touch ........ r40797 | t_schwinger | 2007-11-05 09:19:23 -0800 (Mon, 05 Nov 2007) | 3 lines adds test case for pointer to data member type ........ r40798 | t_schwinger | 2007-11-05 09:20:44 -0800 (Mon, 05 Nov 2007) | 4 lines - nonstandard calling conventions need to be enabled now - using #ifdef ... #error to detect whether test makes sense for a particular compiler ........ r40799 | t_schwinger | 2007-11-05 09:23:57 -0800 (Mon, 05 Nov 2007) | 3 lines adds navigation icons ........ r40800 | t_schwinger | 2007-11-05 09:24:58 -0800 (Mon, 05 Nov 2007) | 3 lines integrates forgotten changes ........ r40801 | t_schwinger | 2007-11-05 09:25:26 -0800 (Mon, 05 Nov 2007) | 3 lines updates html ........ r40802 | hljin | 2007-11-05 10:33:19 -0800 (Mon, 05 Nov 2007) | 1 line GIL: added documentation links and maintainer info into libs/libraries.htm and libs/maintainers.txt ........ r40803 | igaztanaga | 2007-11-05 10:46:38 -0800 (Mon, 05 Nov 2007) | 1 line Marked sun5.9 and Borland 5.9 for Interprocess and Intrusive as unusable ........ r40804 | hljin | 2007-11-05 11:04:08 -0800 (Mon, 05 Nov 2007) | 1 line GIL: minor cumulative fixes ........ r40805 | t_schwinger | 2007-11-05 12:00:43 -0800 (Mon, 05 Nov 2007) | 3 lines adds redirect to documentation ........ r40806 | t_schwinger | 2007-11-05 12:01:33 -0800 (Mon, 05 Nov 2007) | 4 lines - adds FunctionTypes - adds myself to all occurences of the Fusion authors ........ r40807 | eric_niebler | 2007-11-05 12:28:51 -0800 (Mon, 05 Nov 2007) | 1 line doc tweaks ........ r40808 | dgregor | 2007-11-05 13:16:26 -0800 (Mon, 05 Nov 2007) | 1 line Add MPI library ........ r40809 | dgregor | 2007-11-05 13:20:23 -0800 (Mon, 05 Nov 2007) | 1 line Add copyright, 1.34.1 history ........ r40810 | nasonov | 2007-11-05 13:20:35 -0800 (Mon, 05 Nov 2007) | 1 line lexical_cast_loopback_test ........ r40811 | dgregor | 2007-11-05 13:22:29 -0800 (Mon, 05 Nov 2007) | 1 line Merge lots of copyrights ........ r40812 | dgregor | 2007-11-05 13:25:10 -0800 (Mon, 05 Nov 2007) | 1 line Removed ancient BGL-Python code ........ r40813 | dgregor | 2007-11-05 13:43:24 -0800 (Mon, 05 Nov 2007) | 1 line Merge in Boost.Graph changes from RC_1_34_0 branch ........ [SVN r40849] --- include/boost/detail/lcast_precision.hpp | 12 +++++++++--- include/boost/lexical_cast.hpp | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/boost/detail/lcast_precision.hpp b/include/boost/detail/lcast_precision.hpp index 5bd96fd..ef23c8a 100644 --- a/include/boost/detail/lcast_precision.hpp +++ b/include/boost/detail/lcast_precision.hpp @@ -21,7 +21,13 @@ #include #endif -#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +#if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || \ + (defined(BOOST_MSVC) && (BOOST_MSVC<1310)) + +#define BOOST_LCAST_NO_COMPILE_TIME_PRECISION +#endif + +#ifdef BOOST_LCAST_NO_COMPILE_TIME_PRECISION #include #else #include @@ -31,7 +37,7 @@ namespace boost { namespace detail { class lcast_abstract_stub {}; -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION // Calculate an argument to pass to std::ios_base::precision from // lexical_cast. See alternative implementation for broken standard // libraries in lcast_get_precision below. Keep them in sync, please. @@ -92,7 +98,7 @@ struct lcast_precision template inline std::streamsize lcast_get_precision(T* = 0) { -#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) +#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION return lcast_precision::value; #else // Follow lcast_precision algorithm at run-time: diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 1cd23f7..8f40d47 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -307,7 +307,7 @@ namespace boost #undef BOOST_AUX_LEXICAL_CAST_DEF #undef BOOST_AUX_LEXICAL_CAST_DEF1 -#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION // This #if is in sync with lcast_precision // Helper for floating point types. @@ -376,7 +376,7 @@ namespace boost }; #endif // #ifndef DISABLE_WIDE_CHAR_SUPPORT -#endif // #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS +#endif // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION } namespace detail // '0' and '-' constants From 49c4f0e0602cd975a7f3f464248f340a94cb1240 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Tue, 6 Nov 2007 20:13:21 +0000 Subject: [PATCH 042/138] Merged revisions 40815-40850 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r40816 | nasonov | 2007-11-05 14:22:48 -0800 (Mon, 05 Nov 2007) | 1 line #839 fixed: local variable shadow patch ........ r40817 | danmarsden | 2007-11-05 14:24:53 -0800 (Mon, 05 Nov 2007) | 1 line fixed spelling mistake in documentation ........ r40818 | noel_belcourt | 2007-11-05 14:39:49 -0800 (Mon, 05 Nov 2007) | 3 lines Commit patch submitted by John Maddock. ........ r40819 | grafik | 2007-11-05 14:48:41 -0800 (Mon, 05 Nov 2007) | 1 line Add missing action for --skip-tests option since it's a boolean flag. ........ r40820 | grafik | 2007-11-05 14:49:09 -0800 (Mon, 05 Nov 2007) | 1 line Oops, forgot a comma. ........ r40822 | djowel | 2007-11-05 17:44:49 -0800 (Mon, 05 Nov 2007) | 1 line fix for real number parsers with custom types that do not have a std::numeric_limits specialization. ........ r40824 | bemandawes | 2007-11-05 18:29:50 -0800 (Mon, 05 Nov 2007) | 1 line Make message test conditional for Windows, Linux, HP-UX, OSF, and VMS (Boris Gubenko) ........ r40825 | bemandawes | 2007-11-05 18:54:29 -0800 (Mon, 05 Nov 2007) | 1 line Remove prematurely committed portion of prior change ........ r40827 | djowel | 2007-11-06 02:09:38 -0800 (Tue, 06 Nov 2007) | 1 line doc updates to reflect structure changes ........ r40828 | djowel | 2007-11-06 03:40:27 -0800 (Tue, 06 Nov 2007) | 1 line Regenerating/reorganizing docs ........ r40829 | schoepflin | 2007-11-06 03:52:01 -0800 (Tue, 06 Nov 2007) | 2 lines Again removed markup which has been wrongly reintroduced by @40735. ........ r40830 | djowel | 2007-11-06 03:58:37 -0800 (Tue, 06 Nov 2007) | 1 line doc updates + some more header tweaks ........ r40831 | djowel | 2007-11-06 04:05:12 -0800 (Tue, 06 Nov 2007) | 1 line doc updates + some more header tweaks ........ r40832 | djowel | 2007-11-06 04:13:52 -0800 (Tue, 06 Nov 2007) | 1 line Regenerating/reorganizing docs ........ r40833 | djowel | 2007-11-06 04:17:26 -0800 (Tue, 06 Nov 2007) | 1 line todo update ........ r40834 | bemandawes | 2007-11-06 05:24:38 -0800 (Tue, 06 Nov 2007) | 1 line Add missing Boost.System entry ........ r40835 | bemandawes | 2007-11-06 05:41:19 -0800 (Tue, 06 Nov 2007) | 1 line Add missing copyright and license ........ r40836 | aaron_windsor | 2007-11-06 05:55:05 -0800 (Tue, 06 Nov 2007) | 1 line Renaming planar graph test files to under 32 characters each. ........ r40837 | bemandawes | 2007-11-06 06:22:00 -0800 (Tue, 06 Nov 2007) | 1 line Add license ........ r40838 | joaquin | 2007-11-06 06:33:59 -0800 (Tue, 06 Nov 2007) | 1 line updated according to latest regression tests results ........ r40840 | bemandawes | 2007-11-06 08:10:11 -0800 (Tue, 06 Nov 2007) | 1 line Add repository URL and revision number, plus other minor tweaks and fixes. ........ r40841 | igaztanaga | 2007-11-06 08:56:28 -0800 (Tue, 06 Nov 2007) | 1 line Corrected _CRT_SECURE_NO_DEPRECATE detection ........ r40842 | igaztanaga | 2007-11-06 08:56:48 -0800 (Tue, 06 Nov 2007) | 1 line Initialized native handle to avoid warnings in Visual2005 ........ r40843 | johnmaddock | 2007-11-06 08:58:46 -0800 (Tue, 06 Nov 2007) | 1 line Disabled static assertions for compilers that don't support them. ........ r40844 | johnmaddock | 2007-11-06 09:02:26 -0800 (Tue, 06 Nov 2007) | 1 line Still trying to get the Solaris error rates correct. ........ r40845 | johnmaddock | 2007-11-06 09:09:33 -0800 (Tue, 06 Nov 2007) | 1 line Still trying to get those Solaris error rates correct. ........ r40846 | anthonyw | 2007-11-06 09:15:50 -0800 (Tue, 06 Nov 2007) | 1 line use condition so we know when threads have unblocked, to avoid hard-coding a delay ........ r40847 | johnmaddock | 2007-11-06 09:21:28 -0800 (Tue, 06 Nov 2007) | 1 line Fix for Mac OS error rates. ........ r40848 | johnmaddock | 2007-11-06 10:32:57 -0800 (Tue, 06 Nov 2007) | 1 line Updates for new toolset Sun-5.9. ........ r40850 | hljin | 2007-11-06 11:15:03 -0800 (Tue, 06 Nov 2007) | 1 line GIL: removed an extra semi-colon and made some cosmetic changes ........ [SVN r40851] --- include/boost/lexical_cast.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 8f40d47..5a29e85 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -52,9 +52,9 @@ namespace boost { } bad_lexical_cast( - const std::type_info &source_type, - const std::type_info &target_type) : - source(&source_type), target(&target_type) + const std::type_info &source_type_arg, + const std::type_info &target_type_arg) : + source(&source_type_arg), target(&target_type_arg) { } const std::type_info &source_type() const From 7bcb4d9091b9ebc9e33005e4fb7b34feb1b42997 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Thu, 8 Nov 2007 14:20:16 +0000 Subject: [PATCH 043/138] Branch for development of boost.system related changes [SVN r40931] From e79c00d659de8466495feda46757a6d8281e319b Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 10 Nov 2007 22:53:12 +0000 Subject: [PATCH 044/138] Branch for developing Bitten client/server testing [SVN r41004] From ef06decf65cfedcd537e78240b2dc28b5d9738ac Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Tue, 20 Nov 2007 07:41:38 +0000 Subject: [PATCH 045/138] Merged revisions 41161-41246 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r41161 | bemandawes | 2007-11-16 15:21:47 -0800 (Fri, 16 Nov 2007) | 1 line Fix markup error ........ r41163 | bgubenko | 2007-11-16 17:28:10 -0800 (Fri, 16 Nov 2007) | 1 line mark some fusion library tests for acc toolset ........ r41164 | djowel | 2007-11-16 17:51:04 -0800 (Fri, 16 Nov 2007) | 1 line fix for trac ticket #1450 ........ r41165 | lbourdev | 2007-11-16 19:38:25 -0800 (Fri, 16 Nov 2007) | 10 lines Updated to version 2.1.2 Added support for more compilers. Added new flag GIL_NONWORD_POINTER_ALIGNMENT_SUPPORTED to indicate whether dereferencing on non-word boundary is supported. Enabling this flag improves performance. Fixed two bugs related to non-byte-aligned images. The image alignment parameter is now specified in bytes, and has a default of 0, which means "packed" alignment. In particular, for non-byte-aligned images alignment of 0 means there are no padding bits at the ends of rows. Added the allocator as an optional parameter to image constructors and image recreate methods. ........ r41167 | grafik | 2007-11-16 20:11:49 -0800 (Fri, 16 Nov 2007) | 1 line Add "--out-xml=xyz.xml" option that dumps the output of all actions, and the test.jam information, to the given file. Changes are mostly from Dave. ........ r41169 | johnmaddock | 2007-11-17 02:00:43 -0800 (Sat, 17 Nov 2007) | 1 line Ooops, check on wrong index, now fixed. ........ r41170 | johnmaddock | 2007-11-17 04:17:05 -0800 (Sat, 17 Nov 2007) | 1 line Fix WinCE issues. ........ r41172 | johnmaddock | 2007-11-17 10:41:29 -0800 (Sat, 17 Nov 2007) | 1 line Changed test to catch throw exceptions from thread creation. ........ r41173 | bemandawes | 2007-11-17 12:13:16 -0800 (Sat, 17 Nov 2007) | 1 line // Add or correct comment identifying Boost library this header is associated with. ........ r41174 | grafik | 2007-11-17 12:14:24 -0800 (Sat, 17 Nov 2007) | 1 line Add in Dave's comments, and expand information in XML output to include action names, sources, properties, bjam info, and platform info. This required one minor change to actions to keep track of the action object generating the targets. ........ r41175 | nesotto | 2007-11-17 12:22:05 -0800 (Sat, 17 Nov 2007) | 1 line minor update of comments ........ r41176 | nesotto | 2007-11-17 12:22:20 -0800 (Sat, 17 Nov 2007) | 1 line last updates ........ r41177 | nesotto | 2007-11-17 12:44:29 -0800 (Sat, 17 Nov 2007) | 1 line works after local test with vc8 ........ r41178 | nesotto | 2007-11-17 13:02:22 -0800 (Sat, 17 Nov 2007) | 1 line added missing header ........ r41180 | nesotto | 2007-11-17 13:19:13 -0800 (Sat, 17 Nov 2007) | 1 line iostream macro patch ........ r41181 | nesotto | 2007-11-17 13:21:53 -0800 (Sat, 17 Nov 2007) | 1 line removed some warnings ........ r41182 | grafik | 2007-11-17 13:22:40 -0800 (Sat, 17 Nov 2007) | 1 line Add working dir to build description, move jam version to an attribute. ........ r41183 | nesotto | 2007-11-17 13:24:16 -0800 (Sat, 17 Nov 2007) | 1 line macro patch ........ r41185 | nesotto | 2007-11-17 13:43:32 -0800 (Sat, 17 Nov 2007) | 1 line minor change to define the value type of the iterators better ........ r41186 | grafik | 2007-11-17 14:09:26 -0800 (Sat, 17 Nov 2007) | 1 line Change "actual" to the more natural "target", and change "target" to "path". Add bjam command and bb version to XML. ........ r41187 | bemandawes | 2007-11-17 14:48:06 -0800 (Sat, 17 Nov 2007) | 1 line Add or correct comment identifying Boost library this header is associated with. ........ r41188 | andreas_huber69 | 2007-11-17 16:08:46 -0800 (Sat, 17 Nov 2007) | 1 line Added markup for statechart failures on msvc-8.0~wm5~stlport5.1 ........ r41192 | grafik | 2007-11-17 22:42:14 -0800 (Sat, 17 Nov 2007) | 1 line Add to XML output the known targets and dependencies to allow creation of the full build dependency graph. Merge from Dave's Bitten branch. ........ r41193 | johnmaddock | 2007-11-18 02:07:14 -0800 (Sun, 18 Nov 2007) | 1 line Ooops: previous commit broke platforms/compilers with no long double support, added workaround as fix. ........ r41194 | igaztanaga | 2007-11-18 02:41:57 -0800 (Sun, 18 Nov 2007) | 1 line Interprocess changes to support systems with filesystem-based shared memory ........ r41195 | igaztanaga | 2007-11-18 02:43:35 -0800 (Sun, 18 Nov 2007) | 1 line Added scapegoat trees and an option to store the hash value in the hook for unordered containers ........ r41196 | igaztanaga | 2007-11-18 02:44:56 -0800 (Sun, 18 Nov 2007) | 1 line Added scapegoat trees and an option to store the hash value in the hook for unordered containers ........ r41197 | igaztanaga | 2007-11-18 02:51:19 -0800 (Sun, 18 Nov 2007) | 1 line Interprocess changes to support systems with filesystem-based shared memory ........ r41198 | igaztanaga | 2007-11-18 02:54:48 -0800 (Sun, 18 Nov 2007) | 1 line Interprocess changes to support systems with filesystem-based shared memory ........ r41199 | johnmaddock | 2007-11-18 04:23:37 -0800 (Sun, 18 Nov 2007) | 1 line Added missing template argument to specialisations. ........ r41200 | johnmaddock | 2007-11-18 04:24:42 -0800 (Sun, 18 Nov 2007) | 1 line Fix IMB xlc error limits, added workarounds where these were missed by the last commit. ........ r41201 | t_schwinger | 2007-11-18 06:06:47 -0800 (Sun, 18 Nov 2007) | 3 lines adds comment to fusion aCC failure markup ........ r41202 | danieljames | 2007-11-18 08:10:12 -0800 (Sun, 18 Nov 2007) | 2 lines Move the instructions for running regression tests to the new site. Fixes #1265. ........ r41210 | danieljames | 2007-11-18 12:18:04 -0800 (Sun, 18 Nov 2007) | 2 lines Move the 'implementation variations' page to the new site. Fixes #1355. ........ r41211 | eric_niebler | 2007-11-18 12:19:55 -0800 (Sun, 18 Nov 2007) | 1 line vc6 doesn't like BOOST_MPL_ASSERT_MSG ........ r41212 | grafik | 2007-11-18 12:24:25 -0800 (Sun, 18 Nov 2007) | 1 line Inspection report fixes. ........ r41213 | grafik | 2007-11-18 12:53:28 -0800 (Sun, 18 Nov 2007) | 1 line Cleanup tools/regression to remove obsolete runner scripts, move existing docs to doc subdir, and clean html docs into valid xhtml. ........ r41214 | grafik | 2007-11-18 13:02:51 -0800 (Sun, 18 Nov 2007) | 1 line Add missing include, for std::strchr function. ........ r41215 | grafik | 2007-11-18 13:07:26 -0800 (Sun, 18 Nov 2007) | 1 line Add keyword tags. ........ r41216 | niels_dekker | 2007-11-18 14:11:57 -0800 (Sun, 18 Nov 2007) | 1 line Code refactoring: removed private base classes of value_initialized, as suggested by Fernando Cacciola. ........ r41217 | djowel | 2007-11-18 16:05:43 -0800 (Sun, 18 Nov 2007) | 1 line added link to docs ........ r41218 | johnmaddock | 2007-11-19 02:02:16 -0800 (Mon, 19 Nov 2007) | 1 line Oops: added missing template specialisation argument. ........ r41219 | johnmaddock | 2007-11-19 02:20:36 -0800 (Mon, 19 Nov 2007) | 1 line No user32.lib on WinCE ........ r41220 | joaquin | 2007-11-19 03:08:11 -0800 (Mon, 19 Nov 2007) | 1 line moved some ADL stuff out of a potentially name-hiding scope ........ r41221 | troyer | 2007-11-19 04:15:58 -0800 (Mon, 19 Nov 2007) | 1 line made complex seriaqlization more portable ........ r41222 | anthonyw | 2007-11-19 04:17:31 -0800 (Mon, 19 Nov 2007) | 1 line fixed TSS cleanup on 64-bit Windows ........ r41223 | anthonyw | 2007-11-19 04:29:14 -0800 (Mon, 19 Nov 2007) | 1 line fixed problems with TSS cleanup when using LoadLibrary and when threads finish after thread_specific_ptr instance has been destroyed ........ r41224 | garcia | 2007-11-19 05:28:00 -0800 (Mon, 19 Nov 2007) | 2 lines A bunch of review volunteers. ........ r41225 | garcia | 2007-11-19 06:01:34 -0800 (Mon, 19 Nov 2007) | 2 lines Added boost.range update ........ r41226 | anthonyw | 2007-11-19 06:29:22 -0800 (Mon, 19 Nov 2007) | 1 line added copyright ........ r41227 | aaron_windsor | 2007-11-19 07:28:26 -0800 (Mon, 19 Nov 2007) | 1 line Cleaning up #includes to avoid errors on gcc 4.1 and above. ........ r41234 | igaztanaga | 2007-11-19 08:55:23 -0800 (Mon, 19 Nov 2007) | 1 line Fixed errors detected by gcc-4.3 ........ r41235 | hljin | 2007-11-19 09:26:12 -0800 (Mon, 19 Nov 2007) | 1 line GIL: updated the design guide based on the new changes ........ r41236 | grafik | 2007-11-19 09:44:31 -0800 (Mon, 19 Nov 2007) | 1 line Make quietly actions really quiet by not printing the command output. The output for the quietly actions is still available through "__ACTION_RULE__". ........ r41237 | grafik | 2007-11-19 10:02:43 -0800 (Mon, 19 Nov 2007) | 1 line Add architecture and instruction-set values for HP/PA-RISC. ........ r41238 | igaztanaga | 2007-11-19 10:09:13 -0800 (Mon, 19 Nov 2007) | 1 line Corrected ifdef ........ r41240 | igaztanaga | 2007-11-19 10:32:12 -0800 (Mon, 19 Nov 2007) | 1 line Fixed 64 bit std::size_t specialization error ........ r41241 | hljin | 2007-11-19 10:34:59 -0800 (Mon, 19 Nov 2007) | 1 line GIL: broke the main test into small tests ........ r41242 | bgubenko | 2007-11-19 11:25:21 -0800 (Mon, 19 Nov 2007) | 1 line add OSPLAT=PARISC for HP-UX PA-RISC ........ [SVN r41247] --- include/boost/lexical_cast.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 5a29e85..4428275 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -3,7 +3,7 @@ // Boost lexical_cast.hpp header -------------------------------------------// // -// See http://www.boost.org/ for most recent version including documentation. +// See http://www.boost.org/libs/converston for documentation. // See end of this header for rights and permissions. // // what: lexical_cast custom keyword cast From 7bc8f85c41a9a35b62ae263381b3f6556fdde8a1 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Tue, 20 Nov 2007 21:11:19 +0000 Subject: [PATCH 046/138] Merged revisions 41247-41267 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r41249 | schoepflin | 2007-11-20 01:07:05 -0800 (Tue, 20 Nov 2007) | 2 lines Fixed SNAFU caused by last checkin. ........ r41251 | johnmaddock | 2007-11-20 03:12:36 -0800 (Tue, 20 Nov 2007) | 1 line aCC on PA-RISC emits hard errors if a numeric constant underflows: enable existing workaround for that compiler. ........ r41252 | johnmaddock | 2007-11-20 03:18:48 -0800 (Tue, 20 Nov 2007) | 1 line Changed order of #includes to keep Borland C++ 5.5.1 happy. ........ r41253 | hkaiser | 2007-11-20 03:20:47 -0800 (Tue, 20 Nov 2007) | 1 line Wave: Suppressed MS warning for tests. ........ r41254 | johnmaddock | 2007-11-20 03:40:28 -0800 (Tue, 20 Nov 2007) | 4 lines Added missing #include. Fix warnings on MSVC: the code should now be clean with -W4. Fix warnings on gcc: the code should now be clean with -Wall -Wshadow. This fixes Track issues #585, #980, #1196, #1278 and #1340. ........ r41256 | garcia | 2007-11-20 07:56:29 -0800 (Tue, 20 Nov 2007) | 3 lines Added a simple test that changes index bases while resizing (thanks to wasti.redl@gmx.net for this code, which caught a bug). ........ r41257 | garcia | 2007-11-20 07:56:51 -0800 (Tue, 20 Nov 2007) | 2 lines Fixes #1461 ........ r41258 | eric_niebler | 2007-11-20 08:52:43 -0800 (Tue, 20 Nov 2007) | 1 line fix warning in gcc-4.3 ........ r41259 | johnmaddock | 2007-11-20 08:57:32 -0800 (Tue, 20 Nov 2007) | 1 line Added warning suppression for VC-9. ........ r41260 | grafik | 2007-11-20 09:51:21 -0800 (Tue, 20 Nov 2007) | 1 line Allow indication of the Boost.Build location with an argument. This allows to override the built-in BB when testing. ........ r41262 | bgubenko | 2007-11-20 10:51:04 -0800 (Tue, 20 Nov 2007) | 1 line fixed markup validation error: consolidated two consequtive notes ........ r41263 | bgubenko | 2007-11-20 11:09:33 -0800 (Tue, 20 Nov 2007) | 1 line mark some function_types and serialization library tests for acc toolset ........ [SVN r41268] --- include/boost/detail/lcast_precision.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/detail/lcast_precision.hpp b/include/boost/detail/lcast_precision.hpp index ef23c8a..d40ca21 100644 --- a/include/boost/detail/lcast_precision.hpp +++ b/include/boost/detail/lcast_precision.hpp @@ -83,9 +83,9 @@ struct lcast_precision ); BOOST_STATIC_ASSERT(!is_specialized_bin || - limits::digits + 0UL < ULONG_MAX / 30103UL && + (limits::digits + 0UL < ULONG_MAX / 30103UL && precision_bin > limits::digits10 + 0UL && - precision_bin <= streamsize_max + 0UL + precision_bin <= streamsize_max + 0UL) ); BOOST_STATIC_CONSTANT(std::streamsize, value = From ac6e41d676328940dbe656cc47f8b6affd8b95f4 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 23 Nov 2007 17:03:14 +0000 Subject: [PATCH 047/138] config, detail, filesystem, system, tools, at 41278. [SVN r41316] --- include/boost/detail/lcast_precision.hpp | 184 +++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 include/boost/detail/lcast_precision.hpp diff --git a/include/boost/detail/lcast_precision.hpp b/include/boost/detail/lcast_precision.hpp new file mode 100644 index 0000000..d40ca21 --- /dev/null +++ b/include/boost/detail/lcast_precision.hpp @@ -0,0 +1,184 @@ +// Copyright Alexander Nasonov & Paul A. Bristow 2006. + +// Use, modification and distribution are subject to 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_DETAIL_LCAST_PRECISION_HPP_INCLUDED +#define BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED + +#include +#include +#include + +#include +#include + +#ifndef BOOST_NO_IS_ABSTRACT +// Fix for SF:1358600 - lexical_cast & pure virtual functions & VC 8 STL +#include +#include +#endif + +#if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || \ + (defined(BOOST_MSVC) && (BOOST_MSVC<1310)) + +#define BOOST_LCAST_NO_COMPILE_TIME_PRECISION +#endif + +#ifdef BOOST_LCAST_NO_COMPILE_TIME_PRECISION +#include +#else +#include +#endif + +namespace boost { namespace detail { + +class lcast_abstract_stub {}; + +#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION +// Calculate an argument to pass to std::ios_base::precision from +// lexical_cast. See alternative implementation for broken standard +// libraries in lcast_get_precision below. Keep them in sync, please. +template +struct lcast_precision +{ +#ifdef BOOST_NO_IS_ABSTRACT + typedef std::numeric_limits limits; // No fix for SF:1358600. +#else + typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_< + boost::is_abstract + , std::numeric_limits + , std::numeric_limits + >::type limits; +#endif + + BOOST_STATIC_CONSTANT(bool, use_default_precision = + !limits::is_specialized || limits::is_exact + ); + + BOOST_STATIC_CONSTANT(bool, is_specialized_bin = + !use_default_precision && + limits::radix == 2 && limits::digits > 0 + ); + + BOOST_STATIC_CONSTANT(bool, is_specialized_dec = + !use_default_precision && + limits::radix == 10 && limits::digits10 > 0 + ); + + BOOST_STATIC_CONSTANT(std::streamsize, streamsize_max = + boost::integer_traits::const_max + ); + + BOOST_STATIC_CONSTANT(unsigned int, precision_dec = limits::digits10 + 1U); + + BOOST_STATIC_ASSERT(!is_specialized_dec || + precision_dec <= streamsize_max + 0UL + ); + + BOOST_STATIC_CONSTANT(unsigned long, precision_bin = + 2UL + limits::digits * 30103UL / 100000UL + ); + + BOOST_STATIC_ASSERT(!is_specialized_bin || + (limits::digits + 0UL < ULONG_MAX / 30103UL && + precision_bin > limits::digits10 + 0UL && + precision_bin <= streamsize_max + 0UL) + ); + + BOOST_STATIC_CONSTANT(std::streamsize, value = + is_specialized_bin ? precision_bin + : is_specialized_dec ? precision_dec : 6 + ); +}; +#endif + +template +inline std::streamsize lcast_get_precision(T* = 0) +{ +#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION + return lcast_precision::value; +#else // Follow lcast_precision algorithm at run-time: + +#ifdef BOOST_NO_IS_ABSTRACT + typedef std::numeric_limits limits; // No fix for SF:1358600. +#else + typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_< + boost::is_abstract + , std::numeric_limits + , std::numeric_limits + >::type limits; +#endif + + bool const use_default_precision = + !limits::is_specialized || limits::is_exact; + + if(!use_default_precision) + { // Includes all built-in floating-point types, float, double ... + // and UDT types for which digits (significand bits) is defined (not zero) + + bool const is_specialized_bin = + limits::radix == 2 && limits::digits > 0; + bool const is_specialized_dec = + limits::radix == 10 && limits::digits10 > 0; + std::streamsize const streamsize_max = + (boost::integer_traits::max)(); + + if(is_specialized_bin) + { // Floating-point types with + // limits::digits defined by the specialization. + + unsigned long const digits = limits::digits; + unsigned long const precision = 2UL + digits * 30103UL / 100000UL; + // unsigned long is selected because it is at least 32-bits + // and thus ULONG_MAX / 30103UL is big enough for all types. + BOOST_ASSERT( + digits < ULONG_MAX / 30103UL && + precision > limits::digits10 + 0UL && + precision <= streamsize_max + 0UL + ); + return precision; + } + else if(is_specialized_dec) + { // Decimal Floating-point type, most likely a User Defined Type + // rather than a real floating-point hardware type. + unsigned int const precision = limits::digits10 + 1U; + BOOST_ASSERT(precision <= streamsize_max + 0UL); + return precision; + } + } + + // Integral type (for which precision has no effect) + // or type T for which limits is NOT specialized, + // so assume stream precision remains the default 6 decimal digits. + // Warning: if your User-defined Floating-point type T is NOT specialized, + // then you may lose accuracy by only using 6 decimal digits. + // To avoid this, you need to specialize T with either + // radix == 2 and digits == the number of significand bits, + // OR + // radix = 10 and digits10 == the number of decimal digits. + + return 6; +#endif +} + +template +inline void lcast_set_precision(std::ios_base& stream, T*) +{ + stream.precision(lcast_get_precision()); +} + +template +inline void lcast_set_precision(std::ios_base& stream, Source*, Target*) +{ + std::streamsize const s = lcast_get_precision((Source*)0); + std::streamsize const t = lcast_get_precision((Target*)0); + stream.precision(s > t ? s : t); +} + +}} + +#endif // BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED + From d44a6fcf8bace4216b57ddf61951952a44268c3f Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 25 Nov 2007 18:07:19 +0000 Subject: [PATCH 048/138] Full merge from trunk at revision 41356 of entire boost-root tree. [SVN r41369] --- include/boost/implicit_cast.hpp | 2 +- include/boost/lexical_cast.hpp | 902 +++++++++++++++++++++++++++++++- 2 files changed, 876 insertions(+), 28 deletions(-) diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp index 7043085..5b1cd92 100755 --- a/include/boost/implicit_cast.hpp +++ b/include/boost/implicit_cast.hpp @@ -23,7 +23,7 @@ inline T implicit_cast (typename mpl::identity::type x) { //template //void implicit_cast (...); - } // namespace boost + #endif // IMPLICIT_CAST_DWA200356_HPP diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 926b95e..754aecf 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -3,24 +3,31 @@ // Boost lexical_cast.hpp header -------------------------------------------// // -// See http://www.boost.org for most recent version including documentation. +// See http://www.boost.org/libs/converston for documentation. // See end of this header for rights and permissions. // // what: lexical_cast custom keyword cast // who: contributed by Kevlin Henney, -// enhanced with contributions from Terje Slettebø, +// enhanced with contributions from Terje Slettebo, // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, -// and other Boosters -// when: November 2000, March 2003, June 2005 +// Alexander Nasonov and other Boosters +// when: November 2000, March 2003, June 2005, June 2006 +#include #include +#include +#include #include #include #include #include +#include #include #include +#include +#include +#include #ifdef BOOST_NO_STRINGSTREAM #include @@ -45,9 +52,9 @@ namespace boost { } bad_lexical_cast( - const std::type_info &source_type, - const std::type_info &target_type) : - source(&source_type), target(&target_type) + const std::type_info &source_type_arg, + const std::type_info &target_type_arg) : + source(&source_type_arg), target(&target_type_arg) { } const std::type_info &source_type() const @@ -79,8 +86,8 @@ namespace boost typedef char type; }; - #ifndef DISABLE_WIDE_CHAR_SUPPORT -#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_NO_INTRINSIC_WCHAR_T template<> struct stream_char { @@ -105,7 +112,7 @@ namespace boost { typedef wchar_t type; }; - #endif +#endif template struct widest_char @@ -119,7 +126,393 @@ namespace boost typedef wchar_t type; }; } - + + namespace detail // lcast_src_length + { + // Return max. length of string representation of Source; + // 0 if unlimited (with exceptions for some types, see below). + // Values with limited string representation are placed to + // the buffer locally defined in lexical_cast function. + // 1 is returned for few types such as CharT const* or + // std::basic_string that already have an internal + // buffer ready to be reused by lexical_stream_limited_src. + // Each specialization should have a correspondent operator<< + // defined in lexical_stream_limited_src. + template< class CharT // A result of widest_char transformation. + , class Source // Source type of lexical_cast. + > + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 0); + // To check coverage, build the test with + // bjam --v2 profile optimization=off + static void check_coverage() {} + }; + + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + + // No specializations for: + // lcast_src_length + // lcast_src_length + // lcast_src_length + // lcast_src_length + // lcast_src_length + // lcast_src_length + +#ifndef DISABLE_WIDE_CHAR_SUPPORT + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + +#ifndef BOOST_NO_INTRINSIC_WCHAR_T + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; +#endif +#endif + + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + +#ifndef DISABLE_WIDE_CHAR_SUPPORT + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; +#endif + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + struct lcast_src_length< CharT, std::basic_string > + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; +#else + template<> + struct lcast_src_length< char, std::basic_string > + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + +#ifndef DISABLE_WIDE_CHAR_SUPPORT + template<> + struct lcast_src_length< wchar_t, std::basic_string > + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; +#endif +#endif + + // Helper for integral types. + // Notes on length calculation: + // Max length for 32bit int with grouping "\1" and thousands_sep ',': + // "-2,1,4,7,4,8,3,6,4,7" + // ^ - is_signed + // ^ - 1 digit not counted by digits10 + // ^^^^^^^^^^^^^^^^^^ - digits10 * 2 + // + // Constant is_specialized is used instead of constant 1 + // to prevent buffer overflow in a rare case when + // doesn't add missing specialization for + // numeric_limits for some integral type T. + // When is_specialized is false, the whole expression is 0. + template + struct lcast_src_length_integral + { +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_CONSTANT(std::size_t, value = + std::numeric_limits::is_signed + + std::numeric_limits::is_specialized + // == 1 + std::numeric_limits::digits10 * 2 + ); +#else + BOOST_STATIC_CONSTANT(std::size_t, value = 156); + BOOST_STATIC_ASSERT(sizeof(Source) * CHAR_BIT <= 256); +#endif + }; + +#define BOOST_AUX_LEXICAL_CAST_DEF1(CharT, T) template<> \ + struct lcast_src_length : lcast_src_length_integral \ + { static void check_coverage() {} }; + +#ifdef DISABLE_WIDE_CHAR_SUPPORT +#define BOOST_AUX_LEXICAL_CAST_DEF(T) BOOST_AUX_LEXICAL_CAST_DEF1(char, T) +#else +#define BOOST_AUX_LEXICAL_CAST_DEF(T) \ + BOOST_AUX_LEXICAL_CAST_DEF1(char, T) \ + BOOST_AUX_LEXICAL_CAST_DEF1(wchar_t, T) +#endif + + BOOST_AUX_LEXICAL_CAST_DEF(short) + BOOST_AUX_LEXICAL_CAST_DEF(unsigned short) + BOOST_AUX_LEXICAL_CAST_DEF(int) + BOOST_AUX_LEXICAL_CAST_DEF(unsigned int) + BOOST_AUX_LEXICAL_CAST_DEF(long) + BOOST_AUX_LEXICAL_CAST_DEF(unsigned long) +#if defined(BOOST_HAS_LONG_LONG) + BOOST_AUX_LEXICAL_CAST_DEF(boost::ulong_long_type) + BOOST_AUX_LEXICAL_CAST_DEF(boost::long_long_type ) +#elif defined(BOOST_HAS_MS_INT64) + BOOST_AUX_LEXICAL_CAST_DEF(unsigned __int64) + BOOST_AUX_LEXICAL_CAST_DEF( __int64) +#endif + +#undef BOOST_AUX_LEXICAL_CAST_DEF +#undef BOOST_AUX_LEXICAL_CAST_DEF1 + +#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION +// This #if is in sync with lcast_precision + + // Helper for floating point types. + // -1.23456789e-123456 + // ^ sign + // ^ leading digit + // ^ decimal point + // ^^^^^^^^ lcast_precision::value + // ^ "e" + // ^ exponent sign + // ^^^^^^ exponent (assumed 6 or less digits) + // sign + leading digit + decimal point + "e" + exponent sign == 5 + template + struct lcast_src_length_floating + { + BOOST_STATIC_ASSERT( + std::numeric_limits::max_exponent10 <= 999999L && + std::numeric_limits::min_exponent10 >= -999999L + ); + BOOST_STATIC_CONSTANT(std::size_t, value = + 5 + lcast_precision::value + 6 + ); + }; + + template<> + struct lcast_src_length + : lcast_src_length_floating + { + static void check_coverage() {} + }; + + template<> + struct lcast_src_length + : lcast_src_length_floating + { + static void check_coverage() {} + }; + + template<> + struct lcast_src_length + : lcast_src_length_floating + { + static void check_coverage() {} + }; + +#ifndef DISABLE_WIDE_CHAR_SUPPORT + template<> + struct lcast_src_length + : lcast_src_length_floating + { + static void check_coverage() {} + }; + + template<> + struct lcast_src_length + : lcast_src_length_floating + { + static void check_coverage() {} + }; + + template<> + struct lcast_src_length + : lcast_src_length_floating + { + static void check_coverage() {} + }; + +#endif // #ifndef DISABLE_WIDE_CHAR_SUPPORT +#endif // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION + } + + namespace detail // '0' and '-' constants + { + template struct lcast_char_constants; + + template<> + struct lcast_char_constants + { + BOOST_STATIC_CONSTANT(char, zero = '0'); + BOOST_STATIC_CONSTANT(char, minus = '-'); + }; + +#ifndef DISABLE_WIDE_CHAR_SUPPORT + template<> + struct lcast_char_constants + { + BOOST_STATIC_CONSTANT(wchar_t, zero = L'0'); + BOOST_STATIC_CONSTANT(wchar_t, minus = L'-'); + }; +#endif + } + + namespace detail // lexical_streambuf_fake + { + struct lexical_streambuf_fake + { + }; + } + + namespace detail // lcast_to_unsigned + { +#if (defined _MSC_VER) +# pragma warning( push ) +// C4146: unary minus operator applied to unsigned type, result still unsigned +# pragma warning( disable : 4146 ) +#endif + + inline unsigned int lcast_to_unsigned(int value) + { + unsigned int uval = value; + return value < 0 ? -uval : uval; + } + + inline unsigned long lcast_to_unsigned(long value) + { + unsigned long uval = value; + return value < 0 ? -uval : uval; + } + +#if defined(BOOST_HAS_LONG_LONG) + inline boost::ulong_long_type lcast_to_unsigned(boost::long_long_type v) + { + boost::ulong_long_type uval = v; + return v < 0 ? -uval : uval; + } +#elif defined(BOOST_HAS_MS_INT64) + inline unsigned __int64 lcast_to_unsigned(__int64 value) + { + unsigned __int64 uval = value; + return value < 0 ? -uval : uval; + } +#endif + +#if (defined _MSC_VER) +# pragma warning( pop ) // C4146: unary minus operator applied to unsigned type, + // result still unsigned +#endif + } + + namespace detail // lcast_put_unsigned + { + // I'd personally put lcast_put_unsigned in .cpp file if not + // boost practice for header-only libraries (Alexander Nasonov). + template + CharT* lcast_put_unsigned(T n, CharT* finish) + { +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); +#endif + CharT thousands_sep = 0; + +#ifdef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE + char const* grouping = ""; + std::size_t const grouping_size = 0; +#else + std::locale loc; + typedef std::numpunct numpunct; + numpunct const& np = BOOST_USE_FACET(numpunct, loc); + std::string const& grouping = np.grouping(); + std::string::size_type const grouping_size = grouping.size(); + + if(grouping_size) + thousands_sep = np.thousands_sep(); +#endif + + std::string::size_type group = 0; // current group number + char last_grp_size = grouping[0] <= 0 ? CHAR_MAX : grouping[0]; + // a) Since grouping is const, grouping[grouping.size()] returns 0. + // b) It's safe to assume here and below that CHAR_MAX + // is equivalent to unlimited grouping: +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_ASSERT(std::numeric_limits::digits10 < CHAR_MAX); +#endif + + char left = last_grp_size; + + do + { + if(left == 0) + { + ++group; + if(group < grouping_size) + { + char const grp_size = grouping[group]; + last_grp_size = grp_size <= 0 ? CHAR_MAX : grp_size; + } + + left = last_grp_size; + --finish; + *finish = thousands_sep; + } + + --left; + --finish; + int const digit = static_cast(n % 10); + int const cdigit = digit + lcast_char_constants::zero; + *finish = static_cast(cdigit); + n /= 10; + } while(n); + + return finish; + } + } + namespace detail // stream wrapper for handling lexical conversions { template @@ -131,14 +524,10 @@ namespace boost typename stream_char::type>::type char_type; public: - lexical_stream() + lexical_stream(char_type* = 0, char_type* = 0) { stream.unsetf(std::ios::skipws); - - if(std::numeric_limits::is_specialized) - stream.precision(std::numeric_limits::digits10 + 1); - else if(std::numeric_limits::is_specialized) - stream.precision(std::numeric_limits::digits10 + 1); + lcast_set_precision(stream, (Source*)0, (Target*)0); } ~lexical_stream() { @@ -171,13 +560,13 @@ namespace boost #if defined(BOOST_NO_STRINGSTREAM) stream << '\0'; #endif - output = stream.str(); + stream.str().swap(output); return true; } #ifndef DISABLE_WIDE_CHAR_SUPPORT bool operator>>(std::wstring &output) { - output = stream.str(); + stream.str().swap(output); return true; } #endif @@ -192,6 +581,419 @@ namespace boost }; } + namespace detail // optimized stream wrapper + { + // String representation of Source has an upper limit. + template< class CharT // a result of widest_char transformation + , class Base // lexical_streambuf_fake or basic_streambuf + > + class lexical_stream_limited_src : public Base + { + // A string representation of Source is written to [start, finish). + // Currently, it is assumed that [start, finish) is big enough + // to hold a string representation of any Source value. + CharT* start; + CharT* finish; + + private: + + static void widen_and_assign(char*p, char ch) + { + *p = ch; + } + +#ifndef DISABLE_WIDE_CHAR_SUPPORT + static void widen_and_assign(wchar_t* p, char ch) + { + std::locale loc; + *p = BOOST_USE_FACET(std::ctype, loc).widen(ch); + } + + static void widen_and_assign(wchar_t* p, wchar_t ch) + { + *p = ch; + } + + static void widen_and_assign(char*, wchar_t ch); // undefined +#endif + + template + bool lcast_put(const OutputStreamable& input) + { + this->setp(start, finish); + std::basic_ostream stream(static_cast(this)); + lcast_set_precision(stream, (OutputStreamable*)0); + bool const result = !(stream << input).fail(); + finish = this->pptr(); + return result; + } + + // Undefined: + lexical_stream_limited_src(lexical_stream_limited_src const&); + void operator=(lexical_stream_limited_src const&); + + public: + + lexical_stream_limited_src(CharT* start, CharT* finish) + : start(start) + , finish(finish) + {} + + public: // output + + template + bool operator<<(std::basic_string const& str) + { + start = const_cast(str.data()); + finish = start + str.length(); + return true; + } + + bool operator<<(bool); + bool operator<<(char); +#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + bool operator<<(wchar_t); +#endif + bool operator<<(CharT const*); + bool operator<<(short); + bool operator<<(int); + bool operator<<(long); + bool operator<<(unsigned short); + bool operator<<(unsigned int); + bool operator<<(unsigned long); +#if defined(BOOST_HAS_LONG_LONG) + bool operator<<(boost::ulong_long_type); + bool operator<<(boost::long_long_type ); +#elif defined(BOOST_HAS_MS_INT64) + bool operator<<(unsigned __int64); + bool operator<<( __int64); +#endif + // These three operators use ostream and streambuf. + // lcast_streambuf_for_source::value is true. + bool operator<<(float); + bool operator<<(double); + bool operator<<(long double); + + public: // input + + // Generic istream-based algorithm. + // lcast_streambuf_for_target::value is true. + template + bool operator>>(InputStreamable& output) + { +#if (defined _MSC_VER) +# pragma warning( push ) + // conditional expression is constant +# pragma warning( disable : 4127 ) +#endif + if(is_pointer::value) + return false; + + this->setg(start, start, finish); + std::basic_istream stream(static_cast(this)); + stream.unsetf(std::ios::skipws); + lcast_set_precision(stream, (InputStreamable*)0); +#if (defined _MSC_VER) +# pragma warning( pop ) +#endif + return stream >> output && + stream.get() == +#if defined(__GNUC__) && (__GNUC__<3) && defined(BOOST_NO_STD_WSTRING) + // GCC 2.9x lacks std::char_traits<>::eof(). + // We use BOOST_NO_STD_WSTRING to filter out STLport and libstdc++-v3 + // configurations, which do provide std::char_traits<>::eof(). + + EOF; +#else + std::char_traits::eof(); +#endif + } + + bool operator>>(CharT&); + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +// This #if is in sync with lcast_streambuf_for_target + + bool operator>>(std::string&); + +#ifndef DISABLE_WIDE_CHAR_SUPPORT + bool operator>>(std::wstring&); +#endif + +#else + template + bool operator>>(std::basic_string& str) + { + str.assign(start, finish); + return true; + } +#endif + }; + + template + inline bool lexical_stream_limited_src::operator<<( + bool value) + { + *start = value + lcast_char_constants::zero; + finish = start + 1; + return true; + } + + template + inline bool lexical_stream_limited_src::operator<<(char ch) + { + widen_and_assign(start, ch); + finish = start + 1; + return true; + } + +#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + template + inline bool lexical_stream_limited_src::operator<<( + wchar_t ch) + { + widen_and_assign(start, ch); + finish = start + 1; + return true; + } +#endif + + template + inline bool lexical_stream_limited_src::operator<<(short n) + { + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + if(n < 0) + *--start = lcast_char_constants::minus; + return true; + } + + template + inline bool lexical_stream_limited_src::operator<<(int n) + { + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + if(n < 0) + *--start = lcast_char_constants::minus; + return true; + } + + template + inline bool lexical_stream_limited_src::operator<<(long n) + { + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + if(n < 0) + *--start = lcast_char_constants::minus; + return true; + } + +#if defined(BOOST_HAS_LONG_LONG) + template + inline bool lexical_stream_limited_src::operator<<( + boost::long_long_type n) + { + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + if(n < 0) + *--start = lcast_char_constants::minus; + return true; + } +#elif defined(BOOST_HAS_MS_INT64) + template + inline bool lexical_stream_limited_src::operator<<( + __int64 n) + { + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + if(n < 0) + *--start = lcast_char_constants::minus; + return true; + } +#endif + + template + inline bool lexical_stream_limited_src::operator<<( + unsigned short n) + { + start = lcast_put_unsigned(+n, finish); + return true; + } + + template + inline bool lexical_stream_limited_src::operator<<( + unsigned int n) + { + start = lcast_put_unsigned(n, finish); + return true; + } + + template + inline bool lexical_stream_limited_src::operator<<( + unsigned long n) + { + start = lcast_put_unsigned(n, finish); + return true; + } + +#if defined(BOOST_HAS_LONG_LONG) + template + inline bool lexical_stream_limited_src::operator<<( + boost::ulong_long_type n) + { + start = lcast_put_unsigned(n, finish); + return true; + } +#elif defined(BOOST_HAS_MS_INT64) + template + inline bool lexical_stream_limited_src::operator<<( + unsigned __int64 n) + { + start = lcast_put_unsigned(n, finish); + return true; + } +#endif + + template + inline bool lexical_stream_limited_src::operator<<( + float val) + { + return this->lcast_put(val); + } + + template + inline bool lexical_stream_limited_src::operator<<( + double val) + { + return this->lcast_put(val); + } + + template + inline bool lexical_stream_limited_src::operator<<( + long double val) + { + return this->lcast_put(val); + } + + template + inline bool lexical_stream_limited_src::operator<<( + CharT const* str) + { + start = const_cast(str); + finish = start + std::char_traits::length(str); + return true; + } + + template + inline bool lexical_stream_limited_src::operator>>( + CharT& output) + { + bool const ok = (finish - start == 1); + if(ok) + output = *start; + return ok; + } + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + inline bool lexical_stream_limited_src::operator>>( + std::string& str) + { + str.assign(start, finish); + return true; + } + +#ifndef DISABLE_WIDE_CHAR_SUPPORT + template + inline bool lexical_stream_limited_src::operator>>( + std::wstring& str) + { + str.assign(start, finish); + return true; + } +#endif +#endif + } + + namespace detail // lcast_streambuf_for_source + { + // Returns true if optimized stream wrapper needs ostream for writing. + template + struct lcast_streambuf_for_source + { + BOOST_STATIC_CONSTANT(bool, value = false); + }; + + template<> + struct lcast_streambuf_for_source + { + BOOST_STATIC_CONSTANT(bool, value = true); + }; + + template<> + struct lcast_streambuf_for_source + { + BOOST_STATIC_CONSTANT(bool, value = true); + }; + + template<> + struct lcast_streambuf_for_source + { + BOOST_STATIC_CONSTANT(bool, value = true); + }; + } + + namespace detail // lcast_streambuf_for_target + { + // Returns true if optimized stream wrapper needs istream for reading. + template + struct lcast_streambuf_for_target + { + BOOST_STATIC_CONSTANT(bool, value = true); + }; + + template<> + struct lcast_streambuf_for_target + { + BOOST_STATIC_CONSTANT(bool, value = false); + }; + +#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + template<> + struct lcast_streambuf_for_target + { + BOOST_STATIC_CONSTANT(bool, value = false); + }; +#endif + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + struct lcast_streambuf_for_target< + std::basic_string > + { + BOOST_STATIC_CONSTANT(bool, value = false); + }; + +#ifndef DISABLE_WIDE_CHAR_SUPPORT + template + struct lcast_streambuf_for_target< + std::basic_string > + { + BOOST_STATIC_CONSTANT(bool, value = false); + }; +#endif +#else + template<> + struct lcast_streambuf_for_target + { + BOOST_STATIC_CONSTANT(bool, value = false); + }; + +#ifndef DISABLE_WIDE_CHAR_SUPPORT + template<> + struct lcast_streambuf_for_target + { + BOOST_STATIC_CONSTANT(bool, value = false); + }; +#endif +#endif + } + #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION // call-by-const reference version @@ -209,19 +1011,64 @@ namespace boost { typedef const T * type; }; + + template< typename Target + , typename Source + , bool Unlimited // string representation of Source is unlimited + , typename CharT + > + Target lexical_cast( + BOOST_DEDUCED_TYPENAME boost::call_traits::param_type arg, + CharT* buf, std::size_t src_len) + { + typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c< + lcast_streambuf_for_target::value || + lcast_streambuf_for_source::value + , std::basic_streambuf + , lexical_streambuf_fake + >::type base; + + BOOST_DEDUCED_TYPENAME boost::mpl::if_c< + Unlimited + , detail::lexical_stream + , detail::lexical_stream_limited_src + >::type interpreter(buf, buf + src_len); + + // The original form, reproduced below, is more elegant + // but yields a spurious C4701 warning ("possible use of + // "result" before initialization") with VC7.1 (/W4). +// +// Target result; +// +// if(!(interpreter << arg && interpreter >> result)) +// throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); +// return result; + + if(interpreter << arg) { + Target result; + if (interpreter >> result) + return result; + } + throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); + return Target(); // normally never reached (throw_exception) + } } template - Target lexical_cast(const Source &arg) + inline Target lexical_cast(const Source &arg) { - typedef typename detail::array_to_pointer_decay::type NewSource; + typedef typename detail::array_to_pointer_decay::type src; - detail::lexical_stream interpreter; - Target result; + typedef typename detail::widest_char< + typename detail::stream_char::type + , typename detail::stream_char::type + >::type char_type; - if(!(interpreter << arg && interpreter >> result)) - throw_exception(bad_lexical_cast(typeid(NewSource), typeid(Target))); - return result; + typedef detail::lcast_src_length lcast_src_length; + std::size_t const src_len = lcast_src_length::value; + char_type buf[src_len + 1]; + lcast_src_length::check_coverage(); + return detail::lexical_cast(arg, buf, src_len); } #else @@ -242,7 +1089,8 @@ namespace boost #endif } -// Copyright Kevlin Henney, 2000-2005. All rights reserved. +// Copyright Kevlin Henney, 2000-2005. +// Copyright Alexander Nasonov, 2006-2007. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at From ee3f643c5e9ed40a4bd0d1e24a2dd99204b91e92 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 25 Nov 2007 18:38:02 +0000 Subject: [PATCH 049/138] Full merge from trunk at revision 41356 of entire boost-root tree. [SVN r41370] --- lexical_cast.htm | 40 +++- lexical_cast_test.cpp | 288 +++++++++++++++++++++++++ test/Jamfile.v2 | 3 + test/lexical_cast_abstract_test.cpp | 61 ++++++ test/lexical_cast_loopback_test.cpp | 98 +++++++++ test/lexical_cast_noncopyable_test.cpp | 54 +++++ 6 files changed, 542 insertions(+), 2 deletions(-) create mode 100644 test/lexical_cast_abstract_test.cpp create mode 100644 test/lexical_cast_loopback_test.cpp create mode 100644 test/lexical_cast_noncopyable_test.cpp diff --git a/lexical_cast.htm b/lexical_cast.htm index 949b70c..2a08541 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -20,6 +20,10 @@ lexical_cast
  • bad_lexical_cast
  • +
  • + Frequently Asked Questions
  • +
  • + References
  • Changes
  • @@ -160,7 +164,7 @@ void log_errno(int yoko) and an instance of the result type on the right.
  • - Both Source and Target are CopyConstructible [20.1.3]. + Target is CopyConstructible [20.1.3].
  • Target is DefaultConstructible, meaning that it is possible @@ -192,7 +196,39 @@ public: failure.
    +

    Frequently Asked Questions

    +

    Q: Why does lexical_cast<int8_t>("127") throw bad_lexical_cast? +
    A: The type int8_t is a typedef to char or signed char. + Lexical conversion to these types is simply reading a byte from source but since the source has + more than one byte, the exception is thrown. +

    Please use other integer types such as int or short int. If bounds checking + is important, you can also call numeric_cast: + +

    numeric_cast<int8_t>(lexical_cast<int>("127"));
    + +

    Q: What does lexical_cast<std::string> of an int8_t or uint8_t not do what I expect? +
    A: As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid this, cast to an integer type first: + +

    lexical_cast<std::string>(static_cast<int>(n));
    + +

    Q: The implementation always resets the ios_base::skipws flag of an underlying stream object. It breaks my operator>> that works only in presence of this flag. Can you remove code that resets the flag? +
    A: May be in a future version. There is no requirement in [N1973] to reset the flag but remember that [N1973] is not yet accepted by the committee. By the way, it's a great opportunity to make your operator>> conform to the standard. Read a good C++ book, study std::sentry and ios_state_saver. + +

    References

    +
      +
    • [N1973] Kevlin Henney, Beman Dawes, Lexical Conversion Library Proposal for TR2, + N1973. +
    • [Tuning] Alexander Nasonov, Fine Tuning for lexical_cast, + Overload #74, + August 2006.
    • +

    Changes

    +

    August, October 2006:

    +
      +
    • Better performance for many combinations of Source and Target + types. Refer to [Tuning] for more details. +
    • +

    June 2005:

    • Call-by-const reference for the parameters. This requires partial specialization @@ -231,4 +267,4 @@ public:
      © Copyright Kevlin Henney, 2000–2005
      - \ No newline at end of file + diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 4182942..6ba26a3 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -3,6 +3,7 @@ // See http://www.boost.org for most recent version, including documentation. // // Copyright Terje Slettebø and Kevlin Henney, 2005. +// Copyright Alexander Nasonov, 2006. // // Distributed under the Boost // Software License, Version 1.0. (See accompanying file @@ -29,6 +30,18 @@ #define DISABLE_WIDE_CHAR_SUPPORT #endif +#if (defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)) \ + && !(defined(BOOST_MSVC) && BOOST_MSVC < 1300) +#define LCAST_TEST_LONGLONG +#endif + +// Test all 65536 values if true: +bool const lcast_test_small_integral_types_completely = false; + +// lcast_integral_test_counter: use when testing all values of an integral +// types is not possible. Max. portable value is 32767. +int const lcast_integral_test_counter=1000; + using namespace boost; void test_conversion_to_char(); @@ -44,6 +57,16 @@ void test_conversion_from_wstring(); void test_conversion_to_wstring(); void test_bad_lexical_cast(); void test_no_whitespace_stripping(); +void test_conversion_from_short(); +void test_conversion_from_ushort(); +void test_conversion_from_int(); +void test_conversion_from_uint(); +void test_conversion_from_long(); +void test_conversion_from_ulong(); +#ifdef LCAST_TEST_LONGLONG +void test_conversion_from_longlong(); +void test_conversion_from_ulonglong(); +#endif unit_test::test_suite *init_unit_test_suite(int, char *[]) { @@ -64,6 +87,17 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) #endif suite->add(BOOST_TEST_CASE(test_bad_lexical_cast)); suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_short)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_ushort)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_int)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_uint)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_ulong)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_long)); + #ifdef LCAST_TEST_LONGLONG + suite->add(BOOST_TEST_CASE(&test_conversion_from_longlong)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_ulonglong)); + #endif + return suite; } @@ -167,6 +201,9 @@ void test_conversion_to_bool() void test_conversion_to_string() { + char buf[] = "hello"; + char* str = buf; + BOOST_CHECK_EQUAL(str, lexical_cast(str)); BOOST_CHECK_EQUAL("A", lexical_cast('A')); BOOST_CHECK_EQUAL(" ", lexical_cast(' ')); BOOST_CHECK_EQUAL("123", lexical_cast(123)); @@ -239,6 +276,8 @@ void test_conversion_to_wchar_t() #if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) BOOST_CHECK_EQUAL(L'1', lexical_cast(1)); BOOST_CHECK_EQUAL(L'0', lexical_cast(0)); + BOOST_CHECK_EQUAL(L'1', lexical_cast('1')); + BOOST_CHECK_EQUAL(L'0', lexical_cast('0')); BOOST_CHECK_THROW(lexical_cast(123), bad_lexical_cast); BOOST_CHECK_EQUAL(L'1', lexical_cast(1.0)); BOOST_CHECK_EQUAL(L'0', lexical_cast(0.0)); @@ -280,6 +319,9 @@ void test_conversion_from_wstring() void test_conversion_to_wstring() { #ifndef DISABLE_WIDE_CHAR_SUPPORT + wchar_t buf[] = L"hello"; + wchar_t* str = buf; + BOOST_CHECK(str == lexical_cast(str)); BOOST_CHECK(L"123" == lexical_cast(123)); BOOST_CHECK(L"1.23" == lexical_cast(1.23)); BOOST_CHECK(L"1.111111111" == lexical_cast(1.111111111)); @@ -288,6 +330,7 @@ void test_conversion_to_wstring() #if !defined(BOOST_NO_INTRINSIC_WCHAR_T) BOOST_CHECK(L"A" == lexical_cast(L'A')); BOOST_CHECK(L" " == lexical_cast(L' ')); + BOOST_CHECK(L"A" == lexical_cast('A')); #endif BOOST_CHECK(L"Test" == lexical_cast(L"Test")); BOOST_CHECK(L" " == lexical_cast(L" ")); @@ -318,3 +361,248 @@ void test_no_whitespace_stripping() BOOST_CHECK_THROW(lexical_cast(" 123"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("123 "), bad_lexical_cast); } + +// Replace "-,999" with "-999". +template +std::basic_string to_str_gcc_workaround(std::basic_string str) +{ + std::locale loc; + std::numpunct const& np = BOOST_USE_FACET(std::numpunct, loc); + std::ctype const& ct = BOOST_USE_FACET(std::ctype, loc); + + if(np.grouping().empty()) + return str; + + CharT prefix[3] = { ct.widen('-'), np.thousands_sep(), CharT() }; + + if(str.find(prefix) != 0) + return str; + + prefix[1] = CharT(); + str.replace(0, 2, prefix); + return str; +} + +template +std::basic_string to_str(T t) +{ + std::basic_ostringstream o; + o << t; + return to_str_gcc_workaround(o.str()); +} + +template +void test_conversion_from_integral_to_char(CharT zero) +{ + BOOST_CHECK(lexical_cast(static_cast(0)) == zero + 0); + BOOST_CHECK(lexical_cast(static_cast(1)) == zero + 1); + BOOST_CHECK(lexical_cast(static_cast(2)) == zero + 2); + BOOST_CHECK(lexical_cast(static_cast(3)) == zero + 3); + BOOST_CHECK(lexical_cast(static_cast(4)) == zero + 4); + BOOST_CHECK(lexical_cast(static_cast(5)) == zero + 5); + BOOST_CHECK(lexical_cast(static_cast(6)) == zero + 6); + BOOST_CHECK(lexical_cast(static_cast(7)) == zero + 7); + BOOST_CHECK(lexical_cast(static_cast(8)) == zero + 8); + BOOST_CHECK(lexical_cast(static_cast(9)) == zero + 9); + + BOOST_CHECK_THROW(lexical_cast(static_cast(10)), bad_lexical_cast); + + T t = std::numeric_limits::max(); + BOOST_CHECK_THROW(lexical_cast(t), bad_lexical_cast); +} + +template +void test_conversion_from_integral_to_integral() +{ + T t = 0; + BOOST_CHECK(lexical_cast(t) == t); + + // Next two variables are used to supress warnings. + int st = 32767; unsigned int ut = st; + t = st; + BOOST_CHECK(lexical_cast(t) == st); + BOOST_CHECK(lexical_cast(t) == ut); + BOOST_CHECK(lexical_cast(t) == st); + BOOST_CHECK(lexical_cast(t) == ut); + BOOST_CHECK(lexical_cast(t) == st); + BOOST_CHECK(lexical_cast(t) == ut); + + t = std::numeric_limits::max(); + BOOST_CHECK(lexical_cast(t) == t); + + t = std::numeric_limits::min(); + BOOST_CHECK(lexical_cast(t) == t); +} + +template +void test_conversion_from_integral_to_string(CharT) +{ + typedef std::numeric_limits limits; + typedef std::basic_string string_type; + + T t; + + t = limits::min(); + BOOST_CHECK(lexical_cast(t) == to_str(t)); + + t = limits::max(); + BOOST_CHECK(lexical_cast(t) == to_str(t)); + + if(limits::digits <= 16 && lcast_test_small_integral_types_completely) + for(t = 1 + limits::min(); t != limits::max(); ++t) + BOOST_CHECK(lexical_cast(t) == to_str(t)); + else + { + T const min_val = limits::min(); + T const max_val = limits::max(); + T const half_max_val = max_val / 2; + T const cnt = lcast_integral_test_counter; // to supress warnings + unsigned int const counter = cnt < half_max_val ? cnt : half_max_val; + + unsigned int i; + + // Test values around min: + t = min_val; + for(i = 0; i < counter; ++i, ++t) + BOOST_CHECK(lexical_cast(t) == to_str(t)); + + // Test values around max: + t = max_val; + for(i = 0; i < counter; ++i, --t) + BOOST_CHECK(lexical_cast(t) == to_str(t)); + + // Test values around zero: + if(limits::is_signed) + for(t = -counter; t < static_cast(counter); ++t) + BOOST_CHECK(lexical_cast(t) == to_str(t)); + + // Test values around 100, 1000, 10000, ... + T ten_power = 100; + for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10) + { + // I believe that (ten_power + 100) never overflows + for(t = ten_power - 100; t != ten_power + 100; ++t) + BOOST_CHECK(lexical_cast(t) == to_str(t)); + } + } +} + +template +void test_conversion_from_integral_for_locale() +{ + test_conversion_from_integral_to_integral(); + test_conversion_from_integral_to_string('0'); +#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + test_conversion_from_integral_to_string(L'0'); +#endif +} + +struct restore_oldloc +{ + std::locale oldloc; + ~restore_oldloc() { std::locale::global(oldloc); } +}; + +template +void test_conversion_from_integral() +{ + char const zero = '0'; + signed char const szero = '0'; + unsigned char const uzero = '0'; + test_conversion_from_integral_to_char(zero); + test_conversion_from_integral_to_char(szero); + test_conversion_from_integral_to_char(uzero); +#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + wchar_t const wzero = L'0'; + test_conversion_from_integral_to_char(wzero); +#endif + + // test_conversion_from_integral_for_locale + + typedef std::numpunct numpunct; + + restore_oldloc guard; + std::locale const& oldloc = guard.oldloc; + + std::string grouping1 = BOOST_USE_FACET(numpunct, oldloc).grouping(); + std::string grouping2(grouping1); + + test_conversion_from_integral_for_locale(); + + try + { + std::locale newloc(""); + std::locale::global(newloc); + + grouping2 = BOOST_USE_FACET(numpunct, newloc).grouping(); + } + catch(std::exception const& ex) + { + std::string msg("Failed to set system locale: "); + msg += ex.what(); + BOOST_TEST_MESSAGE(msg); + } + + if(grouping1 != grouping2) + test_conversion_from_integral_for_locale(); + + if(grouping1.empty() && grouping2.empty()) + BOOST_TEST_MESSAGE("Formatting with thousands_sep has not been tested"); +} + +void test_conversion_from_short() +{ + test_conversion_from_integral(); +} + +void test_conversion_from_ushort() +{ + test_conversion_from_integral(); +} + +void test_conversion_from_int() +{ + test_conversion_from_integral(); +} + +void test_conversion_from_uint() +{ + test_conversion_from_integral(); +} + +void test_conversion_from_ulong() +{ + test_conversion_from_integral(); +} + +void test_conversion_from_long() +{ + test_conversion_from_integral(); +} + +#if defined(BOOST_HAS_LONG_LONG) + +void test_conversion_from_longlong() +{ + test_conversion_from_integral(); +} + +void test_conversion_from_ulonglong() +{ + test_conversion_from_integral(); +} + +#elif defined(LCAST_TEST_LONGLONG) + +void test_conversion_from_longlong() +{ + test_conversion_from_integral<__int64>(); +} + +void test_conversion_from_ulonglong() +{ + test_conversion_from_integral(); +} + +#endif + diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 56a03d8..af68510 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -21,6 +21,9 @@ test-suite conversion [ run ../cast_test.cpp ] [ run ../numeric_cast_test.cpp ] [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_loopback_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_abstract_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_noncopyable_test.cpp ../../test/build//boost_unit_test_framework/static ] ; diff --git a/test/lexical_cast_abstract_test.cpp b/test/lexical_cast_abstract_test.cpp new file mode 100644 index 0000000..207d3a5 --- /dev/null +++ b/test/lexical_cast_abstract_test.cpp @@ -0,0 +1,61 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Sergey Shandar 2005, Alexander Nasonov, 2007. +// +// 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). +// +// Test abstract class. Bug 1358600: +// http://sf.net/tracker/?func=detail&aid=1358600&group_id=7586&atid=107586 + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include + +using namespace boost; + +void test_abstract(); + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test_framework::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast unit test"); + suite->add(BOOST_TEST_CASE(&test_abstract)); + + return suite; +} + +class A +{ +public: + virtual void out(std::ostream &) const = 0; +}; + +class B: public A +{ +public: + virtual void out(std::ostream &O) const { O << "B"; } +}; + +std::ostream &operator<<(std::ostream &O, const A &a) +{ + a.out(O); + return O; +}; + +void test_abstract() +{ + const A &a = B(); + BOOST_CHECK(boost::lexical_cast(a) == "B"); +} + diff --git a/test/lexical_cast_loopback_test.cpp b/test/lexical_cast_loopback_test.cpp new file mode 100644 index 0000000..cd058fe --- /dev/null +++ b/test/lexical_cast_loopback_test.cpp @@ -0,0 +1,98 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Alexander Nasonov, 2006. +// +// Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). +// +// Test round-tripping conversion FPT -> string -> FPT, +// where FPT is Floating Point Type. + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include + +using namespace boost; + +void test_round_conversion_float(); +void test_round_conversion_double(); +void test_round_conversion_long_double(); + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test_framework::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast unit test"); + suite->add(BOOST_TEST_CASE(&test_round_conversion_float)); + suite->add(BOOST_TEST_CASE(&test_round_conversion_double)); + suite->add(BOOST_TEST_CASE(&test_round_conversion_long_double)); + + return suite; +} + +template +void test_round_conversion() +{ + T epsilon = std::numeric_limits::epsilon(); + std::string const epsilon_s = boost::lexical_cast(epsilon); + BOOST_CHECK(epsilon == lexical_cast(epsilon_s)); + + T max_ = (std::numeric_limits::max)(); + std::string const max_s = boost::lexical_cast(max_); + BOOST_CHECK(max_ == lexical_cast(max_s)); + + T min_ = (std::numeric_limits::min)(); + std::string const min_s = boost::lexical_cast(min_); + BOOST_CHECK(min_ == lexical_cast(min_s)); + + T max_div137 = max_ / 137; + std::string max_div137_s = boost::lexical_cast(max_div137); + BOOST_CHECK(max_div137 == lexical_cast(max_div137_s)); + + T epsilon_mult137 = epsilon * 137; + std::string epsilon_mult137_s(lexical_cast(epsilon_mult137)); + BOOST_CHECK(epsilon_mult137 == lexical_cast(epsilon_mult137_s)); + +} + +#if defined(BOOST_MSVC) +// See bug http://tinyurl.com/vhpvo +template +void test_msvc_magic_values() +{ + T magic_msvc = 0.00010000433948393407; + std::string magic_msvc_s = boost::lexical_cast(magic_msvc); + BOOST_CHECK(magic_msvc == lexical_cast(magic_msvc_s)); +} +#endif + +void test_round_conversion_float() +{ + test_round_conversion(); +} + +void test_round_conversion_double() +{ + test_round_conversion(); +#if defined(BOOST_MSVC) + test_msvc_magic_values(); +#endif +} + +void test_round_conversion_long_double() +{ + test_round_conversion(); +#if defined(BOOST_MSVC) + test_msvc_magic_values(); +#endif +} + diff --git a/test/lexical_cast_noncopyable_test.cpp b/test/lexical_cast_noncopyable_test.cpp new file mode 100644 index 0000000..6284b14 --- /dev/null +++ b/test/lexical_cast_noncopyable_test.cpp @@ -0,0 +1,54 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Alexander Nasonov, 2007. +// +// 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). +// +// Test that Source can be non-copyable. + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include +#include + +using namespace boost; + +void test_noncopyable(); + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test_framework::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast unit test"); + suite->add(BOOST_TEST_CASE(&test_noncopyable)); + + return suite; +} + +class Noncopyable : private boost::noncopyable +{ +public: + Noncopyable() {} +}; + +inline std::ostream &operator<<(std::ostream &out, const Noncopyable&) +{ + return out << "Noncopyable"; +} + +void test_noncopyable() +{ + Noncopyable x; + BOOST_CHECK(boost::lexical_cast(x) == "Noncopyable"); +} + From eec77cd0406c89a8c48bd3cf4ab61506e78f9972 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Mon, 26 Nov 2007 16:25:40 +0000 Subject: [PATCH 050/138] Merged revisions 41268-41398 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r41270 | dgregor | 2007-11-20 21:50:21 -0800 (Tue, 20 Nov 2007) | 1 line Fixes #1456 ........ r41271 | johnmaddock | 2007-11-21 01:39:00 -0800 (Wed, 21 Nov 2007) | 1 line Added super/subscript styling as per boost-docs mailing list discussion. ........ r41272 | johnmaddock | 2007-11-21 01:46:36 -0800 (Wed, 21 Nov 2007) | 1 line Fix << iostream operator for the NTL bindings. ........ r41273 | anthonyw | 2007-11-21 02:44:22 -0800 (Wed, 21 Nov 2007) | 1 line changed platform split to allow bjam to track includes and check dependencies ........ r41274 | schoepflin | 2007-11-21 03:00:18 -0800 (Wed, 21 Nov 2007) | 2 lines Added myself to the platform maintainers file. ........ r41276 | bgubenko | 2007-11-21 03:43:00 -0800 (Wed, 21 Nov 2007) | 1 line fix typo in the marking of function_types library tests ........ r41277 | johnmaddock | 2007-11-21 04:09:28 -0800 (Wed, 21 Nov 2007) | 1 line Change warning suppression, to suppress warnings for VC8 as well. ........ r41278 | johnmaddock | 2007-11-21 06:03:16 -0800 (Wed, 21 Nov 2007) | 1 line Apply warning fix for VC8 and later only: earlier versions warn about the warning suppression :-( ........ r41279 | schoepflin | 2007-11-21 07:21:53 -0800 (Wed, 21 Nov 2007) | 2 lines Marked function_types failures depending on stdcall as expected on Tru64/CXX. ........ r41280 | igaztanaga | 2007-11-21 08:18:29 -0800 (Wed, 21 Nov 2007) | 1 line Added offset_ptr test ........ r41281 | igaztanaga | 2007-11-21 08:19:19 -0800 (Wed, 21 Nov 2007) | 1 line Fixed offset_ptr issues with volatile values. ........ r41282 | igaztanaga | 2007-11-21 08:39:48 -0800 (Wed, 21 Nov 2007) | 1 line Changed precalculated sqrt(2) values selection to use enable_if. ........ r41284 | igaztanaga | 2007-11-21 09:32:20 -0800 (Wed, 21 Nov 2007) | 1 line Added performance Jamfile to the project ........ r41285 | hkaiser | 2007-11-21 09:53:37 -0800 (Wed, 21 Nov 2007) | 1 line Wave: Fixed #line statements in generated files not to contain Windows paths anymore. ........ r41286 | marshall | 2007-11-21 11:20:15 -0800 (Wed, 21 Nov 2007) | 1 line Bug fixes #284, #836, #991 ........ r41287 | grafik | 2007-11-21 11:29:55 -0800 (Wed, 21 Nov 2007) | 1 line Fix search for Boost.Build so that it only finds the approved version. ........ r41288 | djowel | 2007-11-21 14:24:37 -0800 (Wed, 21 Nov 2007) | 1 line updated the master css ........ r41289 | matias | 2007-11-21 20:55:54 -0800 (Wed, 21 Nov 2007) | 1 line Explicit failure markup for Bimap ........ r41290 | matias | 2007-11-21 21:18:38 -0800 (Wed, 21 Nov 2007) | 1 line remove wrong placed typename ........ r41297 | joaquin | 2007-11-21 23:59:28 -0800 (Wed, 21 Nov 2007) | 1 line included an exe filename modifying rule to avoid interference problems with Vista UAC (fixes #1429) ........ r41299 | djowel | 2007-11-22 00:39:46 -0800 (Thu, 22 Nov 2007) | 1 line bug fix ........ r41300 | schoepflin | 2007-11-22 01:32:15 -0800 (Thu, 22 Nov 2007) | 3 lines Marked failures for kolmogorov_max_flow_test and max_flow_test in the graph library as expected for cxx and acc. ........ r41301 | johnmaddock | 2007-11-22 01:59:38 -0800 (Thu, 22 Nov 2007) | 1 line Added try...catch around TSS initialisation. ........ r41302 | johnmaddock | 2007-11-22 02:38:48 -0800 (Thu, 22 Nov 2007) | 1 line Fixes #501 #1334. ........ r41303 | bgubenko | 2007-11-22 03:33:09 -0800 (Thu, 22 Nov 2007) | 1 line fix typo in r41302 causing validation error ........ r41304 | rogeeff | 2007-11-22 11:44:12 -0800 (Thu, 22 Nov 2007) | 1 line Try to make it work in release build ........ r41305 | rogeeff | 2007-11-22 11:56:58 -0800 (Thu, 22 Nov 2007) | 1 line new file ........ r41308 | rogeeff | 2007-11-22 12:56:07 -0800 (Thu, 22 Nov 2007) | 2 lines negative chars test added some statements added to the online_test ........ r41310 | rogeeff | 2007-11-22 13:57:16 -0800 (Thu, 22 Nov 2007) | 1 line issue with class base test cases addressed ........ r41311 | anthonyw | 2007-11-22 14:01:30 -0800 (Thu, 22 Nov 2007) | 1 line Removed thread::self in favour of allowing interruption through a thread::id; no longer requires DuplicateHandle ........ r41312 | rogeeff | 2007-11-22 14:06:59 -0800 (Thu, 22 Nov 2007) | 1 line comments cleanup ........ r41313 | grafik | 2007-11-22 18:57:42 -0800 (Thu, 22 Nov 2007) | 1 line Produce less regression reports to reduce the cycle time for test reporting. ........ r41314 | grafik | 2007-11-22 18:58:14 -0800 (Thu, 22 Nov 2007) | 1 line Produce less regression reports to reduce the cycle time for test reporting. ........ r41315 | joaquin | 2007-11-22 23:57:15 -0800 (Thu, 22 Nov 2007) | 1 line added .exe suffix missing at rev 41297 ........ r41317 | johnmaddock | 2007-11-23 09:05:25 -0800 (Fri, 23 Nov 2007) | 1 line Remove the log files, we don't need these in SVN Trunk. ........ r41318 | grafik | 2007-11-23 12:43:38 -0800 (Fri, 23 Nov 2007) | 1 line Add --skip-script-download option to run.py to avoid repeated regression script downloads. Thanks to _m_ for the changes. ........ r41319 | bemandawes | 2007-11-23 14:55:48 -0800 (Fri, 23 Nov 2007) | 1 line Add the instructions formerly in the (now deleted) runner sub-directory ........ r41320 | anthonyw | 2007-11-23 15:09:36 -0800 (Fri, 23 Nov 2007) | 1 line Integrate TSS with thread data; test to ensure cleanup done for native threads as well as boost::thread-launched threads now runs for pthread API as well as win32 API ........ r41324 | grafik | 2007-11-23 18:16:50 -0800 (Fri, 23 Nov 2007) | 1 line Allow use of "conditional" to multiply a condition that already has the full condition in it. ........ r41325 | igaztanaga | 2007-11-24 01:44:30 -0800 (Sat, 24 Nov 2007) | 1 line Marked msvc-8.0-wm5 as unusable ........ r41326 | niels_dekker | 2007-11-24 03:51:03 -0800 (Sat, 24 Nov 2007) | 1 line Checked the result of value_init test function, hoping to pinpoint exactly for what particular type T value_initialized might fail, on some platforms ........ r41327 | johnmaddock | 2007-11-24 04:25:25 -0800 (Sat, 24 Nov 2007) | 1 line Apply patches for building regex on WinCE see: http://lists.boost.org/Archives/boost/2007/11/130839.php ........ r41328 | bemandawes | 2007-11-24 05:15:03 -0800 (Sat, 24 Nov 2007) | 1 line Bring required compilers list closer into sync with actual testers and list discussion ........ r41330 | bemandawes | 2007-11-24 06:59:08 -0800 (Sat, 24 Nov 2007) | 1 line Remove mingw plus some compilers no longer being tested from required list ........ r41331 | nasonov | 2007-11-24 07:22:52 -0800 (Sat, 24 Nov 2007) | 1 line minor changes ........ r41333 | bemandawes | 2007-11-24 08:39:30 -0800 (Sat, 24 Nov 2007) | 1 line Change long name inspection to follow ISO 9660:1997, thus replacing all length requirements with a single 207 maximum path length requirement. ........ r41338 | garcia | 2007-11-24 10:19:22 -0800 (Sat, 24 Nov 2007) | 2 lines A bunch of review dates have been added. ........ r41339 | johnmaddock | 2007-11-24 10:34:17 -0800 (Sat, 24 Nov 2007) | 1 line Changed meaning of "at_end" needs copy-constructor fix. ........ r41341 | noel_belcourt | 2007-11-24 11:09:56 -0800 (Sat, 24 Nov 2007) | 6 lines Replace mpi wrappers with native pathscale compilers. Fixed how we invoke f77 (pathf90 -f77). Thanks to Alain Miniussi for reporting this. ........ r41342 | igaztanaga | 2007-11-24 11:47:58 -0800 (Sat, 24 Nov 2007) | 1 line Added workaround for systems without SEM_FAILED and semaphores based on filesystem ........ r41343 | rogeeff | 2007-11-24 11:49:24 -0800 (Sat, 24 Nov 2007) | 5 lines switch to nasic_cstring.hpp instead of fwd header added failed expression to the system error system_error is caught and reported in cpp_main.ipp 64 bit compatibility issue in debug.ipp fixed missing headers in algorithm.hpp added ........ r41344 | davedeakins | 2007-11-24 12:30:50 -0800 (Sat, 24 Nov 2007) | 1 line Define the BOOST_NO_SWPRINTF macro for WinCE. WinCE's CRT does not have a conforming swprintf signature. ........ r41348 | igaztanaga | 2007-11-24 16:55:14 -0800 (Sat, 24 Nov 2007) | 1 line Marked pathscale and vacpp as unusable for Interprocess/Intrusive ........ r41350 | davedeakins | 2007-11-24 20:30:02 -0800 (Sat, 24 Nov 2007) | 1 line A few corrections to the WinCE patches ........ r41352 | dave | 2007-11-25 01:02:01 -0800 (Sun, 25 Nov 2007) | 2 lines Attempt SunPro workaround ........ r41353 | guwi17 | 2007-11-25 05:34:20 -0800 (Sun, 25 Nov 2007) | 6 lines - fix and close #1237 - symmetric resize used wrong internal resize method -- Dese und die folgenden Zeilen werden ignoriert -- M symmetric.hpp ........ r41355 | bemandawes | 2007-11-25 05:56:09 -0800 (Sun, 25 Nov 2007) | 1 line Remove extra ) from prior commit ........ r41356 | danieljames | 2007-11-25 06:10:05 -0800 (Sun, 25 Nov 2007) | 2 lines Deleting the BoostCon* files. Fixes #1256 ........ r41357 | bemandawes | 2007-11-25 07:08:28 -0800 (Sun, 25 Nov 2007) | 1 line clear # 1230, mbstate uninitialized ........ r41358 | igaztanaga | 2007-11-25 07:18:04 -0800 (Sun, 25 Nov 2007) | 1 line Marked intel-linux-8.* as unusable for Interprocess and Intrusive ........ r41359 | johnmaddock | 2007-11-25 07:47:58 -0800 (Sun, 25 Nov 2007) | 1 line Oops, previous commit messed up POSIX timing code, now fixed. ........ r41361 | johnmaddock | 2007-11-25 08:26:36 -0800 (Sun, 25 Nov 2007) | 1 line Redirection file. ........ r41362 | grafik | 2007-11-25 09:06:17 -0800 (Sun, 25 Nov 2007) | 1 line Move buildbot support to sandbox until we decide what to do with it. ........ r41363 | grafik | 2007-11-25 09:12:42 -0800 (Sun, 25 Nov 2007) | 1 line Some cleanup of tools documentation. Add boostbook redir file. Delete duplicate time_string.hpp. Repoint regression instructions to web site. ........ r41364 | johnmaddock | 2007-11-25 09:23:25 -0800 (Sun, 25 Nov 2007) | 1 line Fix date. ........ r41378 | bemandawes | 2007-11-25 11:56:10 -0800 (Sun, 25 Nov 2007) | 1 line remove hp_cxx-71_006_tru64 as required. ........ r41380 | grafik | 2007-11-25 12:10:10 -0800 (Sun, 25 Nov 2007) | 1 line Add --build-type option to root build. Two choices possible at the moment "minimal" and "complete". With minimal as the default we only build the common release variant. The old behavior of building many variants is available with "complete". ........ r41381 | fcacciola | 2007-11-25 12:26:14 -0800 (Sun, 25 Nov 2007) | 1 line Cast to base added to avoid a call to the convertir constructor/assignment (see Tickes 1419 and 1420) ........ r41383 | burbelgruff | 2007-11-25 13:16:46 -0800 (Sun, 25 Nov 2007) | 1 line Revert to old sizeof based solution for retrieving the type from a typeof hack. This is in order to overcome problems with the code analysis module introduced in Visual Studio 2005. ........ r41384 | davedeakins | 2007-11-25 13:53:26 -0800 (Sun, 25 Nov 2007) | 1 line Added a primitive tmpnam function for WinCE (which does not supply any kind of tmpnam in its CRT) ........ r41385 | nasonov | 2007-11-25 14:28:16 -0800 (Sun, 25 Nov 2007) | 3 lines Pass unsigned type to lcast_put_unsigned. ........ r41387 | nasonov | 2007-11-25 15:08:50 -0800 (Sun, 25 Nov 2007) | 2 lines Support for string with non-default char_traits and allocator. ........ r41391 | davedeakins | 2007-11-25 22:36:55 -0800 (Sun, 25 Nov 2007) | 1 line Nearly all test for the intrusive library pass on the MSVC8/WM5 platform. ........ r41394 | joaquin | 2007-11-26 03:52:03 -0800 (Mon, 26 Nov 2007) | 1 line added missing traits template arg to a lexical_stream instantiation ........ r41395 | anthonyw | 2007-11-26 04:17:45 -0800 (Mon, 26 Nov 2007) | 1 line workaround for Borland compiler ........ r41396 | anthonyw | 2007-11-26 05:29:15 -0800 (Mon, 26 Nov 2007) | 1 line Don't compare native_handle_t against 0 --- do appropriate checks in create_native_thread for platforms where pthread_t is not comparable ........ r41397 | joaquin | 2007-11-26 05:48:36 -0800 (Mon, 26 Nov 2007) | 1 line ADL-based swap call moved to an utility function (after mistaken attempt at rev 41220 to solve name-hiding issues) ........ r41398 | anthonyw | 2007-11-26 07:44:07 -0800 (Mon, 26 Nov 2007) | 1 line fixed import/export declarations so new once code works with pthread-win32 ........ [SVN r41399] --- include/boost/lexical_cast.hpp | 299 ++++++++++++++++++++++----------- lexical_cast_test.cpp | 245 +++++++++++++++++++++------ 2 files changed, 397 insertions(+), 147 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 4428275..cb2fa50 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -86,6 +86,14 @@ namespace boost typedef char type; }; +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + struct stream_char< std::basic_string > + { + typedef CharT type; + }; +#endif + #ifndef DISABLE_WIDE_CHAR_SUPPORT #ifndef BOOST_NO_INTRINSIC_WCHAR_T template<> @@ -107,11 +115,13 @@ namespace boost typedef wchar_t type; }; +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template<> struct stream_char { typedef wchar_t type; }; +#endif #endif template @@ -127,6 +137,44 @@ namespace boost }; } + namespace detail // deduce_char_traits template + { +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + struct deduce_char_traits + { + typedef std::char_traits type; + }; + + template + struct deduce_char_traits< CharT + , std::basic_string + , Source + > + { + typedef Traits type; + }; + + template + struct deduce_char_traits< CharT + , Target + , std::basic_string + > + { + typedef Traits type; + }; + + template + struct deduce_char_traits< CharT + , std::basic_string + , std::basic_string + > + { + typedef Traits type; + }; +#endif + } + namespace detail // lcast_src_length { // Return max. length of string representation of Source; @@ -267,14 +315,15 @@ namespace boost template struct lcast_src_length_integral { -#if !defined(__BORLANDC__) || __BORLANDC__ >= 0x581 +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_CONSTANT(std::size_t, value = std::numeric_limits::is_signed + std::numeric_limits::is_specialized + // == 1 std::numeric_limits::digits10 * 2 ); #else - BOOST_STATIC_CONSTANT(std::size_t, value = 156); // 256bit integers + BOOST_STATIC_CONSTANT(std::size_t, value = 156); + BOOST_STATIC_ASSERT(sizeof(Source) * CHAR_BIT <= 256); #endif }; @@ -308,8 +357,6 @@ namespace boost #undef BOOST_AUX_LEXICAL_CAST_DEF1 #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION -// This #if is in sync with lcast_precision - // Helper for floating point types. // -1.23456789e-123456 // ^ sign @@ -400,14 +447,8 @@ namespace boost #endif } - namespace detail // lexical_streambuf and lexical_streambuf_fake + namespace detail // lexical_streambuf_fake { - template - class lexical_streambuf : public std::basic_streambuf - { - }; - - template struct lexical_streambuf_fake { }; @@ -448,17 +489,19 @@ namespace boost #endif #if (defined _MSC_VER) -# pragma warning( pop ) // C4146: unary minus operator applied to unsigned type, result still unsigned +# pragma warning( pop ) // C4146: unary minus operator applied to unsigned type, + // result still unsigned #endif } namespace detail // lcast_put_unsigned { - // I'd personally put lcast_put_unsigned in .cpp file if not - // boost practice for header-only libraries (Alexander Nasonov). - template + template CharT* lcast_put_unsigned(T n, CharT* finish) { +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); +#endif CharT thousands_sep = 0; #ifdef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE @@ -483,6 +526,9 @@ namespace boost #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT(std::numeric_limits::digits10 < CHAR_MAX); #endif + typedef typename Traits::int_type int_type; + CharT const czero = lcast_char_constants::zero; + int_type const zero = Traits::to_int_type(czero); char left = last_grp_size; @@ -499,14 +545,13 @@ namespace boost left = last_grp_size; --finish; - *finish = thousands_sep; + Traits::assign(*finish, thousands_sep); } --left; --finish; - int const digit = static_cast(n % 10); - int const cdigit = digit + lcast_char_constants::zero; - *finish = static_cast(cdigit); + int_type const digit = static_cast(n % 10U); + Traits::assign(*finish, Traits::to_char_type(zero + digit)); n /= 10; } while(n); @@ -516,7 +561,7 @@ namespace boost namespace detail // stream wrapper for handling lexical conversions { - template + template class lexical_stream { private: @@ -524,6 +569,8 @@ namespace boost typename stream_char::type, typename stream_char::type>::type char_type; + typedef Traits traits_type; + public: lexical_stream(char_type* = 0, char_type* = 0) { @@ -553,9 +600,12 @@ namespace boost EOF; #else - std::char_traits::eof(); + traits_type::eof(); #endif } + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + bool operator>>(std::string &output) { #if defined(BOOST_NO_STRINGSTREAM) @@ -571,13 +621,29 @@ namespace boost return true; } #endif + +#else + bool operator>>(std::basic_string& output) + { + stream.str().swap(output); + return true; + } + + template + bool operator>>(std::basic_string& out) + { + std::basic_string str(stream.str()); + out.assign(str.begin(), str.end()); + return true; + } +#endif private: #if defined(BOOST_NO_STRINGSTREAM) std::strstream stream; #elif defined(BOOST_NO_STD_LOCALE) std::stringstream stream; #else - std::basic_stringstream stream; + std::basic_stringstream stream; #endif }; } @@ -586,7 +652,8 @@ namespace boost { // String representation of Source has an upper limit. template< class CharT // a result of widest_char transformation - , class Base // lexical_streambuf or lexical_streambuf_fake + , class Base // lexical_streambuf_fake or basic_streambuf + , class Traits // usually char_traits > class lexical_stream_limited_src : public Base { @@ -600,19 +667,20 @@ namespace boost static void widen_and_assign(char*p, char ch) { - *p = ch; + Traits::assign(*p, ch); } #ifndef DISABLE_WIDE_CHAR_SUPPORT static void widen_and_assign(wchar_t* p, char ch) { std::locale loc; - *p = BOOST_USE_FACET(std::ctype, loc).widen(ch); + wchar_t w = BOOST_USE_FACET(std::ctype, loc).widen(ch); + Traits::assign(*p, w); } static void widen_and_assign(wchar_t* p, wchar_t ch) { - *p = ch; + Traits::assign(*p, ch); } static void widen_and_assign(char*, wchar_t ch); // undefined @@ -642,8 +710,8 @@ namespace boost public: // output - template - bool operator<<(std::basic_string const& str) + template + bool operator<<(std::basic_string const& str) { start = const_cast(str.data()); finish = start + str.length(); @@ -706,7 +774,7 @@ namespace boost EOF; #else - std::char_traits::eof(); + Traits::eof(); #endif } @@ -722,7 +790,7 @@ namespace boost #endif #else - template + template bool operator>>(std::basic_string& str) { str.assign(start, finish); @@ -731,17 +799,21 @@ namespace boost #endif }; - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( bool value) { - *start = value + lcast_char_constants::zero; + typedef typename Traits::int_type int_type; + CharT const czero = lcast_char_constants::zero; + int_type const zero = Traits::to_int_type(czero); + Traits::assign(*start, Traits::to_char_type(zero + value)); finish = start + 1; return true; } - template - inline bool lexical_stream_limited_src::operator<<(char ch) + template + inline bool lexical_stream_limited_src::operator<<( + char ch) { widen_and_assign(start, ch); finish = start + 1; @@ -749,8 +821,8 @@ namespace boost } #if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( wchar_t ch) { widen_and_assign(start, ch); @@ -759,140 +831,163 @@ namespace boost } #endif - template - inline bool lexical_stream_limited_src::operator<<(short n) + template + inline bool lexical_stream_limited_src::operator<<( + short n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); if(n < 0) - *--start = lcast_char_constants::minus; + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } return true; } - template - inline bool lexical_stream_limited_src::operator<<(int n) + template + inline bool lexical_stream_limited_src::operator<<( + int n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); if(n < 0) - *--start = lcast_char_constants::minus; + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } return true; } - template - inline bool lexical_stream_limited_src::operator<<(long n) + template + inline bool lexical_stream_limited_src::operator<<( + long n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); if(n < 0) - *--start = lcast_char_constants::minus; + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } return true; } #if defined(BOOST_HAS_LONG_LONG) - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( boost::long_long_type n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); if(n < 0) - *--start = lcast_char_constants::minus; + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } return true; } #elif defined(BOOST_HAS_MS_INT64) - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( __int64 n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); if(n < 0) - *--start = lcast_char_constants::minus; + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } return true; } #endif - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( unsigned short n) { - start = lcast_put_unsigned(+n, finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); return true; } - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( unsigned int n) { - start = lcast_put_unsigned(n, finish); + start = lcast_put_unsigned(n, finish); return true; } - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( unsigned long n) { - start = lcast_put_unsigned(n, finish); + start = lcast_put_unsigned(n, finish); return true; } #if defined(BOOST_HAS_LONG_LONG) - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( boost::ulong_long_type n) { - start = lcast_put_unsigned(n, finish); + start = lcast_put_unsigned(n, finish); return true; } #elif defined(BOOST_HAS_MS_INT64) - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( unsigned __int64 n) { - start = lcast_put_unsigned(n, finish); + start = lcast_put_unsigned(n, finish); return true; } #endif - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( float val) { return this->lcast_put(val); } - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( double val) { return this->lcast_put(val); } - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( long double val) { return this->lcast_put(val); } - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( CharT const* str) { start = const_cast(str); - finish = start + std::char_traits::length(str); + finish = start + Traits::length(str); return true; } - template - inline bool lexical_stream_limited_src::operator>>( + template + inline bool lexical_stream_limited_src::operator>>( CharT& output) { bool const ok = (finish - start == 1); if(ok) - output = *start; + Traits::assign(output, *start); return ok; } #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template - inline bool lexical_stream_limited_src::operator>>( + template + inline bool lexical_stream_limited_src::operator>>( std::string& str) { str.assign(start, finish); @@ -900,8 +995,8 @@ namespace boost } #ifndef DISABLE_WIDE_CHAR_SUPPORT - template - inline bool lexical_stream_limited_src::operator>>( + template + inline bool lexical_stream_limited_src::operator>>( std::wstring& str) { str.assign(start, finish); @@ -913,7 +1008,7 @@ namespace boost namespace detail // lcast_streambuf_for_source { - // Returns true if optimized stream wrapper uses ostream for formatting. + // Returns true if optimized stream wrapper needs ostream for writing. template struct lcast_streambuf_for_source { @@ -941,7 +1036,7 @@ namespace boost namespace detail // lcast_streambuf_for_target { - // Returns true if optimized stream wrapper use istream for reading. + // Returns true if optimized stream wrapper needs istream for reading. template struct lcast_streambuf_for_target { @@ -1022,17 +1117,23 @@ namespace boost BOOST_DEDUCED_TYPENAME boost::call_traits::param_type arg, CharT* buf, std::size_t src_len) { +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + typedef BOOST_DEDUCED_TYPENAME + deduce_char_traits::type traits; +#else + typedef std::char_traits traits; +#endif typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c< lcast_streambuf_for_target::value || lcast_streambuf_for_source::value - , lexical_streambuf - , lexical_streambuf_fake + , std::basic_streambuf + , lexical_streambuf_fake >::type base; BOOST_DEDUCED_TYPENAME boost::mpl::if_c< Unlimited - , detail::lexical_stream - , detail::lexical_stream_limited_src + , detail::lexical_stream + , detail::lexical_stream_limited_src >::type interpreter(buf, buf + src_len); // The original form, reproduced below, is more elegant @@ -1079,7 +1180,13 @@ namespace boost template Target lexical_cast(Source arg) { - detail::lexical_stream interpreter; + typedef typename detail::widest_char< + BOOST_DEDUCED_TYPENAME detail::stream_char::type + , BOOST_DEDUCED_TYPENAME detail::stream_char::type + >::type char_type; + + typedef std::char_traits traits; + detail::lexical_stream interpreter; Target result; if(!(interpreter << arg && interpreter >> result)) @@ -1091,7 +1198,7 @@ namespace boost } // Copyright Kevlin Henney, 2000-2005. -// Copyright Alexander Nasonov, 2006. +// Copyright Alexander Nasonov, 2006-2007. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 6ba26a3..04478e0 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -24,6 +24,9 @@ #include #include +#include +#include + #if defined(BOOST_NO_STRINGSTREAM) || \ defined(BOOST_NO_STD_WSTRING) || \ defined(BOOST_NO_STD_LOCALE) @@ -35,6 +38,16 @@ #define LCAST_TEST_LONGLONG #endif +template +struct my_traits : std::char_traits +{ +}; + +template +struct my_allocator : std::allocator +{ +}; + // Test all 65536 values if true: bool const lcast_test_small_integral_types_completely = false; @@ -57,15 +70,21 @@ void test_conversion_from_wstring(); void test_conversion_to_wstring(); void test_bad_lexical_cast(); void test_no_whitespace_stripping(); -void test_conversion_from_short(); -void test_conversion_from_ushort(); -void test_conversion_from_int(); -void test_conversion_from_uint(); -void test_conversion_from_long(); -void test_conversion_from_ulong(); +void test_conversion_from_to_short(); +void test_conversion_from_to_ushort(); +void test_conversion_from_to_int(); +void test_conversion_from_to_uint(); +void test_conversion_from_to_long(); +void test_conversion_from_to_ulong(); #ifdef LCAST_TEST_LONGLONG -void test_conversion_from_longlong(); -void test_conversion_from_ulonglong(); +void test_conversion_from_to_longlong(); +void test_conversion_from_to_ulonglong(); +#endif +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +void test_traits(); +void test_wtraits(); +void test_allocator(); +void test_wallocator(); #endif unit_test::test_suite *init_unit_test_suite(int, char *[]) @@ -87,15 +106,21 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) #endif suite->add(BOOST_TEST_CASE(test_bad_lexical_cast)); suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_short)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_ushort)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_int)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_uint)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_ulong)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_long)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_short)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ushort)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_int)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uint)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulong)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_long)); #ifdef LCAST_TEST_LONGLONG - suite->add(BOOST_TEST_CASE(&test_conversion_from_longlong)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_ulonglong)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong)); + #endif + #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + suite->add(BOOST_TEST_CASE(&test_traits)); + suite->add(BOOST_TEST_CASE(&test_wtraits)); + suite->add(BOOST_TEST_CASE(&test_allocator)); + suite->add(BOOST_TEST_CASE(&test_wallocator)); #endif return suite; @@ -129,10 +154,15 @@ void test_conversion_to_int() BOOST_CHECK_EQUAL(0, lexical_cast('0')); BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); BOOST_CHECK_EQUAL(1, lexical_cast(1)); + BOOST_CHECK_EQUAL(1, lexical_cast(1.0)); + BOOST_CHECK_EQUAL( (std::numeric_limits::max)(), lexical_cast((std::numeric_limits::max)())); - BOOST_CHECK_EQUAL(1, lexical_cast(1.0)); + + BOOST_CHECK_EQUAL( + (std::numeric_limits::min)(), + lexical_cast((std::numeric_limits::min)())); BOOST_CHECK_THROW(lexical_cast(1.23), bad_lexical_cast); @@ -407,7 +437,7 @@ void test_conversion_from_integral_to_char(CharT zero) BOOST_CHECK_THROW(lexical_cast(static_cast(10)), bad_lexical_cast); - T t = std::numeric_limits::max(); + T t = (std::numeric_limits::max)(); BOOST_CHECK_THROW(lexical_cast(t), bad_lexical_cast); } @@ -427,10 +457,10 @@ void test_conversion_from_integral_to_integral() BOOST_CHECK(lexical_cast(t) == st); BOOST_CHECK(lexical_cast(t) == ut); - t = std::numeric_limits::max(); + t = (std::numeric_limits::max)(); BOOST_CHECK(lexical_cast(t) == t); - t = std::numeric_limits::min(); + t = (std::numeric_limits::min)(); BOOST_CHECK(lexical_cast(t) == t); } @@ -442,19 +472,20 @@ void test_conversion_from_integral_to_string(CharT) T t; - t = limits::min(); + t = (limits::min)(); BOOST_CHECK(lexical_cast(t) == to_str(t)); - t = limits::max(); + t = (limits::max)(); BOOST_CHECK(lexical_cast(t) == to_str(t)); if(limits::digits <= 16 && lcast_test_small_integral_types_completely) - for(t = 1 + limits::min(); t != limits::max(); ++t) + // min and max have already been tested. + for(t = 1 + (limits::min)(); t != (limits::max)(); ++t) BOOST_CHECK(lexical_cast(t) == to_str(t)); else { - T const min_val = limits::min(); - T const max_val = limits::max(); + T const min_val = (limits::min)(); + T const max_val = (limits::max)(); T const half_max_val = max_val / 2; T const cnt = lcast_integral_test_counter; // to supress warnings unsigned int const counter = cnt < half_max_val ? cnt : half_max_val; @@ -480,20 +511,75 @@ void test_conversion_from_integral_to_string(CharT) T ten_power = 100; for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10) { - // I believe that (ten_power + 100) never overflows + // ten_power + 100 probably never overflows for(t = ten_power - 100; t != ten_power + 100; ++t) BOOST_CHECK(lexical_cast(t) == to_str(t)); } } } +template +void test_conversion_from_string_to_integral(CharT) +{ + typedef std::numeric_limits limits; + + T t; + + t = (limits::min)(); + BOOST_CHECK(lexical_cast(to_str(t)) == t); + + t = (limits::max)(); + BOOST_CHECK(lexical_cast(to_str(t)) == t); + + if(limits::digits <= 16 && lcast_test_small_integral_types_completely) + // min and max have already been tested. + for(t = 1 + (limits::min)(); t != (limits::max)(); ++t) + BOOST_CHECK(lexical_cast(to_str(t)) == t); + else + { + T const min_val = (limits::min)(); + T const max_val = (limits::max)(); + T const half_max_val = max_val / 2; + T const cnt = lcast_integral_test_counter; // to supress warnings + unsigned int const counter = cnt < half_max_val ? cnt : half_max_val; + + unsigned int i; + + // Test values around min: + t = min_val; + for(i = 0; i < counter; ++i, ++t) + BOOST_CHECK(lexical_cast(to_str(t)) == t); + + // Test values around max: + t = max_val; + for(i = 0; i < counter; ++i, --t) + BOOST_CHECK(lexical_cast(to_str(t)) == t); + + // Test values around zero: + if(limits::is_signed) + for(t = -counter; t < static_cast(counter); ++t) + BOOST_CHECK(lexical_cast(to_str(t)) == t); + + // Test values around 100, 1000, 10000, ... + T ten_power = 100; + for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10) + { + // ten_power + 100 probably never overflows + for(t = ten_power - 100; t != ten_power + 100; ++t) + BOOST_CHECK(lexical_cast(to_str(t)) == t); + } + } +} + template -void test_conversion_from_integral_for_locale() +void test_conversion_from_to_integral_for_locale() { test_conversion_from_integral_to_integral(); test_conversion_from_integral_to_string('0'); + test_conversion_from_string_to_integral('0'); #if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) test_conversion_from_integral_to_string(L'0'); + test_conversion_from_string_to_integral(L'0'); #endif } @@ -504,7 +590,7 @@ struct restore_oldloc }; template -void test_conversion_from_integral() +void test_conversion_from_to_integral() { char const zero = '0'; signed char const szero = '0'; @@ -517,7 +603,7 @@ void test_conversion_from_integral() test_conversion_from_integral_to_char(wzero); #endif - // test_conversion_from_integral_for_locale + // test_conversion_from_to_integral_for_locale typedef std::numpunct numpunct; @@ -527,7 +613,7 @@ void test_conversion_from_integral() std::string grouping1 = BOOST_USE_FACET(numpunct, oldloc).grouping(); std::string grouping2(grouping1); - test_conversion_from_integral_for_locale(); + test_conversion_from_to_integral_for_locale(); try { @@ -544,64 +630,121 @@ void test_conversion_from_integral() } if(grouping1 != grouping2) - test_conversion_from_integral_for_locale(); + test_conversion_from_to_integral_for_locale(); if(grouping1.empty() && grouping2.empty()) BOOST_TEST_MESSAGE("Formatting with thousands_sep has not been tested"); } -void test_conversion_from_short() +void test_conversion_from_to_short() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_ushort() +void test_conversion_from_to_ushort() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_int() +void test_conversion_from_to_int() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_uint() +void test_conversion_from_to_uint() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_ulong() +void test_conversion_from_to_ulong() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_long() +void test_conversion_from_to_long() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } #if defined(BOOST_HAS_LONG_LONG) -void test_conversion_from_longlong() +void test_conversion_from_to_longlong() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_ulonglong() +void test_conversion_from_to_ulonglong() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } #elif defined(LCAST_TEST_LONGLONG) -void test_conversion_from_longlong() +void test_conversion_from_to_longlong() { - test_conversion_from_integral<__int64>(); + test_conversion_from_to_integral<__int64>(); } -void test_conversion_from_ulonglong() +void test_conversion_from_to_ulonglong() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); +} + +#endif + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +void test_traits() +{ + typedef std::basic_string > my_string; + + my_string const s("s"); + BOOST_CHECK(boost::lexical_cast(s) == s[0]); + BOOST_CHECK(boost::lexical_cast(s) == s); + BOOST_CHECK(boost::lexical_cast(-1) == "-1"); +} + +void test_wtraits() +{ + typedef std::basic_string > my_string; + + my_string const s(L"s"); + BOOST_CHECK(boost::lexical_cast(s) == s[0]); + BOOST_CHECK(boost::lexical_cast(s) == s); + //BOOST_CHECK(boost::lexical_cast(-1) == L"-1"); + // Commented out because gcc 3.3 doesn't support this: + // basic_ostream > o; o << -1; +} + +void test_allocator() +{ + typedef std::basic_string< char + , std::char_traits + , my_allocator + > my_string; + + my_string s("s"); + BOOST_CHECK(boost::lexical_cast(s) == s[0]); + BOOST_CHECK(boost::lexical_cast(s) == "s"); + BOOST_CHECK(boost::lexical_cast(s) == s); + BOOST_CHECK(boost::lexical_cast(1) == "1"); + BOOST_CHECK(boost::lexical_cast("s") == s); + BOOST_CHECK(boost::lexical_cast(std::string("s")) == s); +} + +void test_wallocator() +{ + typedef std::basic_string< wchar_t + , std::char_traits + , my_allocator + > my_string; + + my_string s(L"s"); + BOOST_CHECK(boost::lexical_cast(s) == s[0]); + BOOST_CHECK(boost::lexical_cast(s) == L"s"); + BOOST_CHECK(boost::lexical_cast(s) == s); + BOOST_CHECK(boost::lexical_cast(1) == L"1"); + BOOST_CHECK(boost::lexical_cast(L"s") == s); + BOOST_CHECK(boost::lexical_cast(std::wstring(L"s")) == s); } #endif From 42f6163f1859f4d0e09fae7b3b67be868cf32ff4 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 28 Nov 2007 22:03:59 +0000 Subject: [PATCH 051/138] Merged revisions 41399-41442 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r41400 | igaztanaga | 2007-11-26 08:34:13 -0800 (Mon, 26 Nov 2007) | 1 line Added missing #include ........ r41401 | anthonyw | 2007-11-26 09:01:08 -0800 (Mon, 26 Nov 2007) | 1 line once_flag uses zero-initialization on POSIX as well as windows ........ r41402 | niels_dekker | 2007-11-26 09:36:52 -0800 (Mon, 26 Nov 2007) | 1 line Marked value_init_test failures on Borland C++ as "expected failures", as discussed with Fernando Cacciola. ........ r41404 | rwgk | 2007-11-26 12:46:28 -0800 (Mon, 26 Nov 2007) | 1 line g++ 4.3.0 compatibility (4.3.0 20071125 (experimental)) ........ r41405 | anthonyw | 2007-11-26 13:15:04 -0800 (Mon, 26 Nov 2007) | 1 line reverted accidental checkin of new timed_wait functions on condition_variable ........ r41406 | nasonov | 2007-11-26 13:29:04 -0800 (Mon, 26 Nov 2007) | 3 lines Remove redundant BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION. ........ r41407 | chris_kohlhoff | 2007-11-26 13:29:38 -0800 (Mon, 26 Nov 2007) | 3 lines WinCE doesn't work with all multicast addresses, and even though it doesn't support the multicast::enable_loopback option you can still get the value. ........ r41408 | dave | 2007-11-26 14:01:50 -0800 (Mon, 26 Nov 2007) | 2 lines Try to extend the workaround to SunPro 5.9, since we're marked as not working on 5.8 ........ r41409 | dave | 2007-11-26 17:40:01 -0800 (Mon, 26 Nov 2007) | 3 lines Allow Sun-5.7 and Sun-5.8 to fail loudly for Boost.Python so I can see what's really wrong. ........ r41413 | anthonyw | 2007-11-27 06:24:29 -0800 (Tue, 27 Nov 2007) | 1 line add support for relative timeouts to condition timed_wait ........ r41414 | grafik | 2007-11-27 09:53:56 -0800 (Tue, 27 Nov 2007) | 1 line Remove non-existent option info. ........ r41415 | grafik | 2007-11-27 09:55:13 -0800 (Tue, 27 Nov 2007) | 1 line Add some utility output formatting functions. ........ r41416 | grafik | 2007-11-27 09:57:15 -0800 (Tue, 27 Nov 2007) | 1 line Check empty string invariants, instead of assuming all strings are allocated. And reset strings when they are freed. ........ r41417 | grafik | 2007-11-27 09:58:50 -0800 (Tue, 27 Nov 2007) | 1 line Fix buffer overrun bug in expanding @() subexpressions. ........ r41418 | hkaiser | 2007-11-27 10:18:10 -0800 (Tue, 27 Nov 2007) | 1 line Wave: Fixed gcc warning, bumped version number. ........ r41419 | djenkins | 2007-11-27 10:57:48 -0800 (Tue, 27 Nov 2007) | 1 line Changes for msvc-9.0 /clr flag ........ r41420 | djenkins | 2007-11-27 10:59:06 -0800 (Tue, 27 Nov 2007) | 1 line Changes for msvc-9.0 /clr flag ........ r41423 | niels_dekker | 2007-11-27 13:34:08 -0800 (Tue, 27 Nov 2007) | 1 line Added value_init test for struct as used in MSVC bug report regarding value-initialization. ........ r41429 | noel_belcourt | 2007-11-27 18:27:13 -0800 (Tue, 27 Nov 2007) | 3 lines Fix pathscale rpath issue per Alain Minussi's suggestion. ........ r41430 | grafik | 2007-11-27 23:08:13 -0800 (Tue, 27 Nov 2007) | 1 line Add test for result status values of simple actions, i.e. empty actions. ........ r41431 | grafik | 2007-11-27 23:21:49 -0800 (Tue, 27 Nov 2007) | 19 lines build-system.jam * Reflect added start/end timestamps for actions in xml output. And update action rules for new args. execcmd.h * Add start/end timestamps to action timing info. execnt.c * Fix filetime_seconds calculation when time is larger than low 32 bit value. * Add calc of C time_t from Windows FILETIME. * Add start/end timestamps recording to action timing info. execunix.c * Add start/end timestamps recording to action timing info. jam.c * Change JAMDATE to use common ISO date format. make1.c * Redo __TIMING_RULE__ and __ACTION__RULE__ invocations to new argument ordering and added end/result timestamp values. ........ r41432 | chris_kohlhoff | 2007-11-28 05:26:33 -0800 (Wed, 28 Nov 2007) | 3 lines Make async operations fail with an error if the socket descriptor doesn't fit into the select call's fd_set. ........ r41433 | bgubenko | 2007-11-28 07:33:16 -0800 (Wed, 28 Nov 2007) | 1 line add "gcc*hpux*" toolset for serialization library bug on big endian platforms ........ r41436 | niels_dekker | 2007-11-28 09:19:37 -0800 (Wed, 28 Nov 2007) | 1 line Added tests for two more struct types to value_init_test -- discussed with Fernando Cacciola ........ r41439 | bgubenko | 2007-11-28 11:04:53 -0800 (Wed, 28 Nov 2007) | 1 line add "-lrt" for acc* toolsets ........ r41440 | grafik | 2007-11-28 12:24:17 -0800 (Wed, 28 Nov 2007) | 1 line Fix for latest Doxygen namespace file names. And support for method groups. From Samuel Debionne. ........ [SVN r41444] --- include/boost/lexical_cast.hpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index cb2fa50..2794c86 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1117,12 +1117,9 @@ namespace boost BOOST_DEDUCED_TYPENAME boost::call_traits::param_type arg, CharT* buf, std::size_t src_len) { -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION typedef BOOST_DEDUCED_TYPENAME deduce_char_traits::type traits; -#else - typedef std::char_traits traits; -#endif + typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c< lcast_streambuf_for_target::value || lcast_streambuf_for_source::value From 706704b72cd324153d07c7545bd79c6a7542790b Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 6 Dec 2007 07:20:07 +0000 Subject: [PATCH 052/138] Merged revisions 41678-41775 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r41679 | anthonyw | 2007-12-03 23:57:23 -0800 (Mon, 03 Dec 2007) | 1 line fixed typo in condition_variable_any::timed_wait ........ r41681 | anthonyw | 2007-12-04 01:15:37 -0800 (Tue, 04 Dec 2007) | 1 line changed boost::move to boost::detail::thread_move to fix issue #1492 ........ r41682 | anthonyw | 2007-12-04 02:04:30 -0800 (Tue, 04 Dec 2007) | 1 line split shared mutex tests in two to take less time ........ r41683 | anthonyw | 2007-12-04 03:44:25 -0800 (Tue, 04 Dec 2007) | 1 line don't dllexport/dllimport inline functions ........ r41684 | anthonyw | 2007-12-04 04:08:38 -0800 (Tue, 04 Dec 2007) | 1 line add explicit casts to remove warnings ........ r41686 | anthonyw | 2007-12-04 05:02:58 -0800 (Tue, 04 Dec 2007) | 1 line Added test for thread move constructor; implemented move on pthreads ........ r41687 | anthonyw | 2007-12-04 06:07:01 -0800 (Tue, 04 Dec 2007) | 1 line changed order of declaration to eliminate warnings ........ r41688 | nesotto | 2007-12-04 06:41:44 -0800 (Tue, 04 Dec 2007) | 1 line ticket 1488 ........ r41696 | fmhess | 2007-12-04 11:42:08 -0800 (Tue, 04 Dec 2007) | 2 lines Make sure output filenames don't include any illegal characters. ........ r41697 | fmhess | 2007-12-04 11:45:10 -0800 (Tue, 04 Dec 2007) | 4 lines Fixed printing of object name for nested classes (merge of revision 41421 from sandbox/boost_docs). ........ r41698 | fmhess | 2007-12-04 11:55:50 -0800 (Tue, 04 Dec 2007) | 17 lines Made generated ids for functions and overloaded functions human-readable which also results in (mostly) human-readable names for their .html output files. Made generate.id template properly use its node parameter (merge of parts of revision 41461 from sandbox/boost_docs). Made class name in synopsis a link to class reference page, which is useful for nested classes (merge of revision 41435 from sandbox/boost_docs). Removed spurious new line in synopisis between a nested class and the comment describing its purpose (merge of revision 41434 from sandbox/boost_docs). Added a warning if an "inherit" element has no "type" child element (partial merge of revision 41463 from sandbox/boost_docs). ........ r41701 | chris_kohlhoff | 2007-12-04 13:28:42 -0800 (Tue, 04 Dec 2007) | 2 lines Prevent deprecated function warnings for MSVC >= 8. ........ r41703 | nasonov | 2007-12-04 13:49:51 -0800 (Tue, 04 Dec 2007) | 1 line Link to html version of [Tuning] and BOOST_LEXICAL_CAST_ASSUME_C_LOCALE synopsis ........ r41704 | igaztanaga | 2007-12-04 14:05:28 -0800 (Tue, 04 Dec 2007) | 1 line Added Leopard workaround. _POSIX_THREAD_PROCESS_SHARED is defined but does not seem to work. For the moment, Mac OS will use emulation code ........ r41705 | djenkins | 2007-12-04 14:19:58 -0800 (Tue, 04 Dec 2007) | 1 line Fix msvc-9.0 code analysis problem ........ r41707 | noel_belcourt | 2007-12-04 15:18:38 -0800 (Tue, 04 Dec 2007) | 6 lines Fixes to get pgi shared libraries working, executables that don't core, and limiting the number of error messages emitted by the compiler so as to reduce the size of the log file. ........ r41727 | grafik | 2007-12-04 16:32:04 -0800 (Tue, 04 Dec 2007) | 1 line Switch FTP site for results. ........ r41734 | noel_belcourt | 2007-12-04 19:11:25 -0800 (Tue, 04 Dec 2007) | 5 lines Pgi compilers can't accept shared library with Boost version suffix appended to it. Add logic to tag rule in Jamroot to suppress appending version suffix for pgi toolset. ........ r41735 | noel_belcourt | 2007-12-04 19:20:30 -0800 (Tue, 04 Dec 2007) | 3 lines Patch pgi shared library use. ........ r41736 | grafik | 2007-12-04 20:33:36 -0800 (Tue, 04 Dec 2007) | 1 line Fix parsing of macosx version numbers from detected SDKs. ........ r41738 | anthonyw | 2007-12-05 00:27:44 -0800 (Wed, 05 Dec 2007) | 1 line added missing include of detail/config.hpp ........ r41739 | t_schwinger | 2007-12-05 02:24:21 -0800 (Wed, 05 Dec 2007) | 3 lines clarifies #error message ........ r41740 | t_schwinger | 2007-12-05 02:26:16 -0800 (Wed, 05 Dec 2007) | 2 lines updates function_types failures ........ r41741 | anthonyw | 2007-12-05 02:58:45 -0800 (Wed, 05 Dec 2007) | 1 line improved timeout checks ........ r41742 | t_schwinger | 2007-12-05 05:20:13 -0800 (Wed, 05 Dec 2007) | 3 lines attempts to fix strange problems with Pathscale compilers ........ r41762 | chris_kohlhoff | 2007-12-05 13:46:19 -0800 (Wed, 05 Dec 2007) | 2 lines Don't use deprecated function workaround when compiling for Windows CE. ........ r41770 | ramey | 2007-12-05 18:33:59 -0800 (Wed, 05 Dec 2007) | 2 lines change to fix failures with gcc 4.1+ modification to string input primitives ........ r41775 | djenkins | 2007-12-05 22:23:55 -0800 (Wed, 05 Dec 2007) | 1 line Avoid bug in Microsoft Code Analysis ........ [SVN r41776] --- lexical_cast.htm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lexical_cast.htm b/lexical_cast.htm index 2a08541..6e38014 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -194,7 +194,18 @@ public:
  • Exception used to indicate runtime lexical_cast failure. -
    + +
    +

    BOOST_LEXICAL_CAST_ASSUME_C_LOCALE

    +
    #define BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
    +
    +or,
    +
    +g++ -DBOOST_LEXICAL_CAST_ASSUME_C_LOCALE ...  (gcc on Linux/Unix)
    +cl.exe /DBOOST_LEXICAL_CAST_ASSUME_C_LOCALE ... (Visual C++ on Windows)
    +
    +Eliminate an overhead of std::locale if your program runs in the "C" locale. If the option is set but a program runs in other locale, lexical_cast result is unspecified. +

    Frequently Asked Questions

    Q: Why does lexical_cast<int8_t>("127") throw bad_lexical_cast? @@ -219,7 +230,7 @@ public:

  • [N1973] Kevlin Henney, Beman Dawes, Lexical Conversion Library Proposal for TR2, N1973.
  • [Tuning] Alexander Nasonov, Fine Tuning for lexical_cast, - Overload #74, + Overload #74 (PDF), August 2006.
  • Changes

    From e9a5ac6d7a95b34fc2113b9dfa6338333dd7f44b Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sat, 15 Dec 2007 14:39:18 +0000 Subject: [PATCH 053/138] Merge conversion library at rev 41517 [SVN r42070] --- include/boost/lexical_cast.hpp | 267 +++++++++++++++++++++++---------- lexical_cast_test.cpp | 245 +++++++++++++++++++++++------- 2 files changed, 380 insertions(+), 132 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 754aecf..44c7a66 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -3,7 +3,7 @@ // Boost lexical_cast.hpp header -------------------------------------------// // -// See http://www.boost.org/libs/converston for documentation. +// See http://www.boost.org/libs/conversion for documentation. // See end of this header for rights and permissions. // // what: lexical_cast custom keyword cast @@ -86,6 +86,14 @@ namespace boost typedef char type; }; +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + struct stream_char< std::basic_string > + { + typedef CharT type; + }; +#endif + #ifndef DISABLE_WIDE_CHAR_SUPPORT #ifndef BOOST_NO_INTRINSIC_WCHAR_T template<> @@ -107,11 +115,13 @@ namespace boost typedef wchar_t type; }; +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template<> struct stream_char { typedef wchar_t type; }; +#endif #endif template @@ -127,6 +137,44 @@ namespace boost }; } + namespace detail // deduce_char_traits template + { +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + struct deduce_char_traits + { + typedef std::char_traits type; + }; + + template + struct deduce_char_traits< CharT + , std::basic_string + , Source + > + { + typedef Traits type; + }; + + template + struct deduce_char_traits< CharT + , Target + , std::basic_string + > + { + typedef Traits type; + }; + + template + struct deduce_char_traits< CharT + , std::basic_string + , std::basic_string + > + { + typedef Traits type; + }; +#endif + } + namespace detail // lcast_src_length { // Return max. length of string representation of Source; @@ -309,8 +357,6 @@ namespace boost #undef BOOST_AUX_LEXICAL_CAST_DEF1 #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION -// This #if is in sync with lcast_precision - // Helper for floating point types. // -1.23456789e-123456 // ^ sign @@ -450,9 +496,7 @@ namespace boost namespace detail // lcast_put_unsigned { - // I'd personally put lcast_put_unsigned in .cpp file if not - // boost practice for header-only libraries (Alexander Nasonov). - template + template CharT* lcast_put_unsigned(T n, CharT* finish) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS @@ -482,6 +526,9 @@ namespace boost #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT(std::numeric_limits::digits10 < CHAR_MAX); #endif + typedef typename Traits::int_type int_type; + CharT const czero = lcast_char_constants::zero; + int_type const zero = Traits::to_int_type(czero); char left = last_grp_size; @@ -498,14 +545,13 @@ namespace boost left = last_grp_size; --finish; - *finish = thousands_sep; + Traits::assign(*finish, thousands_sep); } --left; --finish; - int const digit = static_cast(n % 10); - int const cdigit = digit + lcast_char_constants::zero; - *finish = static_cast(cdigit); + int_type const digit = static_cast(n % 10U); + Traits::assign(*finish, Traits::to_char_type(zero + digit)); n /= 10; } while(n); @@ -515,7 +561,7 @@ namespace boost namespace detail // stream wrapper for handling lexical conversions { - template + template class lexical_stream { private: @@ -523,6 +569,8 @@ namespace boost typename stream_char::type, typename stream_char::type>::type char_type; + typedef Traits traits_type; + public: lexical_stream(char_type* = 0, char_type* = 0) { @@ -552,9 +600,12 @@ namespace boost EOF; #else - std::char_traits::eof(); + traits_type::eof(); #endif } + +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + bool operator>>(std::string &output) { #if defined(BOOST_NO_STRINGSTREAM) @@ -570,13 +621,29 @@ namespace boost return true; } #endif + +#else + bool operator>>(std::basic_string& output) + { + stream.str().swap(output); + return true; + } + + template + bool operator>>(std::basic_string& out) + { + std::basic_string str(stream.str()); + out.assign(str.begin(), str.end()); + return true; + } +#endif private: #if defined(BOOST_NO_STRINGSTREAM) std::strstream stream; #elif defined(BOOST_NO_STD_LOCALE) std::stringstream stream; #else - std::basic_stringstream stream; + std::basic_stringstream stream; #endif }; } @@ -586,6 +653,7 @@ namespace boost // String representation of Source has an upper limit. template< class CharT // a result of widest_char transformation , class Base // lexical_streambuf_fake or basic_streambuf + , class Traits // usually char_traits > class lexical_stream_limited_src : public Base { @@ -599,19 +667,20 @@ namespace boost static void widen_and_assign(char*p, char ch) { - *p = ch; + Traits::assign(*p, ch); } #ifndef DISABLE_WIDE_CHAR_SUPPORT static void widen_and_assign(wchar_t* p, char ch) { std::locale loc; - *p = BOOST_USE_FACET(std::ctype, loc).widen(ch); + wchar_t w = BOOST_USE_FACET(std::ctype, loc).widen(ch); + Traits::assign(*p, w); } static void widen_and_assign(wchar_t* p, wchar_t ch) { - *p = ch; + Traits::assign(*p, ch); } static void widen_and_assign(char*, wchar_t ch); // undefined @@ -641,8 +710,8 @@ namespace boost public: // output - template - bool operator<<(std::basic_string const& str) + template + bool operator<<(std::basic_string const& str) { start = const_cast(str.data()); finish = start + str.length(); @@ -705,7 +774,7 @@ namespace boost EOF; #else - std::char_traits::eof(); + Traits::eof(); #endif } @@ -721,7 +790,7 @@ namespace boost #endif #else - template + template bool operator>>(std::basic_string& str) { str.assign(start, finish); @@ -730,17 +799,21 @@ namespace boost #endif }; - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( bool value) { - *start = value + lcast_char_constants::zero; + typedef typename Traits::int_type int_type; + CharT const czero = lcast_char_constants::zero; + int_type const zero = Traits::to_int_type(czero); + Traits::assign(*start, Traits::to_char_type(zero + value)); finish = start + 1; return true; } - template - inline bool lexical_stream_limited_src::operator<<(char ch) + template + inline bool lexical_stream_limited_src::operator<<( + char ch) { widen_and_assign(start, ch); finish = start + 1; @@ -748,8 +821,8 @@ namespace boost } #if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( wchar_t ch) { widen_and_assign(start, ch); @@ -758,140 +831,163 @@ namespace boost } #endif - template - inline bool lexical_stream_limited_src::operator<<(short n) + template + inline bool lexical_stream_limited_src::operator<<( + short n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); if(n < 0) - *--start = lcast_char_constants::minus; + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } return true; } - template - inline bool lexical_stream_limited_src::operator<<(int n) + template + inline bool lexical_stream_limited_src::operator<<( + int n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); if(n < 0) - *--start = lcast_char_constants::minus; + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } return true; } - template - inline bool lexical_stream_limited_src::operator<<(long n) + template + inline bool lexical_stream_limited_src::operator<<( + long n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); if(n < 0) - *--start = lcast_char_constants::minus; + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } return true; } #if defined(BOOST_HAS_LONG_LONG) - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( boost::long_long_type n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); if(n < 0) - *--start = lcast_char_constants::minus; + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } return true; } #elif defined(BOOST_HAS_MS_INT64) - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( __int64 n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); if(n < 0) - *--start = lcast_char_constants::minus; + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } return true; } #endif - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( unsigned short n) { - start = lcast_put_unsigned(+n, finish); + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); return true; } - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( unsigned int n) { - start = lcast_put_unsigned(n, finish); + start = lcast_put_unsigned(n, finish); return true; } - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( unsigned long n) { - start = lcast_put_unsigned(n, finish); + start = lcast_put_unsigned(n, finish); return true; } #if defined(BOOST_HAS_LONG_LONG) - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( boost::ulong_long_type n) { - start = lcast_put_unsigned(n, finish); + start = lcast_put_unsigned(n, finish); return true; } #elif defined(BOOST_HAS_MS_INT64) - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( unsigned __int64 n) { - start = lcast_put_unsigned(n, finish); + start = lcast_put_unsigned(n, finish); return true; } #endif - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( float val) { return this->lcast_put(val); } - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( double val) { return this->lcast_put(val); } - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( long double val) { return this->lcast_put(val); } - template - inline bool lexical_stream_limited_src::operator<<( + template + inline bool lexical_stream_limited_src::operator<<( CharT const* str) { start = const_cast(str); - finish = start + std::char_traits::length(str); + finish = start + Traits::length(str); return true; } - template - inline bool lexical_stream_limited_src::operator>>( + template + inline bool lexical_stream_limited_src::operator>>( CharT& output) { bool const ok = (finish - start == 1); if(ok) - output = *start; + Traits::assign(output, *start); return ok; } #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template - inline bool lexical_stream_limited_src::operator>>( + template + inline bool lexical_stream_limited_src::operator>>( std::string& str) { str.assign(start, finish); @@ -899,8 +995,8 @@ namespace boost } #ifndef DISABLE_WIDE_CHAR_SUPPORT - template - inline bool lexical_stream_limited_src::operator>>( + template + inline bool lexical_stream_limited_src::operator>>( std::wstring& str) { str.assign(start, finish); @@ -1021,6 +1117,9 @@ namespace boost BOOST_DEDUCED_TYPENAME boost::call_traits::param_type arg, CharT* buf, std::size_t src_len) { + typedef BOOST_DEDUCED_TYPENAME + deduce_char_traits::type traits; + typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c< lcast_streambuf_for_target::value || lcast_streambuf_for_source::value @@ -1030,8 +1129,8 @@ namespace boost BOOST_DEDUCED_TYPENAME boost::mpl::if_c< Unlimited - , detail::lexical_stream - , detail::lexical_stream_limited_src + , detail::lexical_stream + , detail::lexical_stream_limited_src >::type interpreter(buf, buf + src_len); // The original form, reproduced below, is more elegant @@ -1078,7 +1177,13 @@ namespace boost template Target lexical_cast(Source arg) { - detail::lexical_stream interpreter; + typedef typename detail::widest_char< + BOOST_DEDUCED_TYPENAME detail::stream_char::type + , BOOST_DEDUCED_TYPENAME detail::stream_char::type + >::type char_type; + + typedef std::char_traits traits; + detail::lexical_stream interpreter; Target result; if(!(interpreter << arg && interpreter >> result)) diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 6ba26a3..04478e0 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -24,6 +24,9 @@ #include #include +#include +#include + #if defined(BOOST_NO_STRINGSTREAM) || \ defined(BOOST_NO_STD_WSTRING) || \ defined(BOOST_NO_STD_LOCALE) @@ -35,6 +38,16 @@ #define LCAST_TEST_LONGLONG #endif +template +struct my_traits : std::char_traits +{ +}; + +template +struct my_allocator : std::allocator +{ +}; + // Test all 65536 values if true: bool const lcast_test_small_integral_types_completely = false; @@ -57,15 +70,21 @@ void test_conversion_from_wstring(); void test_conversion_to_wstring(); void test_bad_lexical_cast(); void test_no_whitespace_stripping(); -void test_conversion_from_short(); -void test_conversion_from_ushort(); -void test_conversion_from_int(); -void test_conversion_from_uint(); -void test_conversion_from_long(); -void test_conversion_from_ulong(); +void test_conversion_from_to_short(); +void test_conversion_from_to_ushort(); +void test_conversion_from_to_int(); +void test_conversion_from_to_uint(); +void test_conversion_from_to_long(); +void test_conversion_from_to_ulong(); #ifdef LCAST_TEST_LONGLONG -void test_conversion_from_longlong(); -void test_conversion_from_ulonglong(); +void test_conversion_from_to_longlong(); +void test_conversion_from_to_ulonglong(); +#endif +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +void test_traits(); +void test_wtraits(); +void test_allocator(); +void test_wallocator(); #endif unit_test::test_suite *init_unit_test_suite(int, char *[]) @@ -87,15 +106,21 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) #endif suite->add(BOOST_TEST_CASE(test_bad_lexical_cast)); suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_short)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_ushort)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_int)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_uint)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_ulong)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_long)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_short)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ushort)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_int)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uint)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulong)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_long)); #ifdef LCAST_TEST_LONGLONG - suite->add(BOOST_TEST_CASE(&test_conversion_from_longlong)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_ulonglong)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong)); + #endif + #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + suite->add(BOOST_TEST_CASE(&test_traits)); + suite->add(BOOST_TEST_CASE(&test_wtraits)); + suite->add(BOOST_TEST_CASE(&test_allocator)); + suite->add(BOOST_TEST_CASE(&test_wallocator)); #endif return suite; @@ -129,10 +154,15 @@ void test_conversion_to_int() BOOST_CHECK_EQUAL(0, lexical_cast('0')); BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); BOOST_CHECK_EQUAL(1, lexical_cast(1)); + BOOST_CHECK_EQUAL(1, lexical_cast(1.0)); + BOOST_CHECK_EQUAL( (std::numeric_limits::max)(), lexical_cast((std::numeric_limits::max)())); - BOOST_CHECK_EQUAL(1, lexical_cast(1.0)); + + BOOST_CHECK_EQUAL( + (std::numeric_limits::min)(), + lexical_cast((std::numeric_limits::min)())); BOOST_CHECK_THROW(lexical_cast(1.23), bad_lexical_cast); @@ -407,7 +437,7 @@ void test_conversion_from_integral_to_char(CharT zero) BOOST_CHECK_THROW(lexical_cast(static_cast(10)), bad_lexical_cast); - T t = std::numeric_limits::max(); + T t = (std::numeric_limits::max)(); BOOST_CHECK_THROW(lexical_cast(t), bad_lexical_cast); } @@ -427,10 +457,10 @@ void test_conversion_from_integral_to_integral() BOOST_CHECK(lexical_cast(t) == st); BOOST_CHECK(lexical_cast(t) == ut); - t = std::numeric_limits::max(); + t = (std::numeric_limits::max)(); BOOST_CHECK(lexical_cast(t) == t); - t = std::numeric_limits::min(); + t = (std::numeric_limits::min)(); BOOST_CHECK(lexical_cast(t) == t); } @@ -442,19 +472,20 @@ void test_conversion_from_integral_to_string(CharT) T t; - t = limits::min(); + t = (limits::min)(); BOOST_CHECK(lexical_cast(t) == to_str(t)); - t = limits::max(); + t = (limits::max)(); BOOST_CHECK(lexical_cast(t) == to_str(t)); if(limits::digits <= 16 && lcast_test_small_integral_types_completely) - for(t = 1 + limits::min(); t != limits::max(); ++t) + // min and max have already been tested. + for(t = 1 + (limits::min)(); t != (limits::max)(); ++t) BOOST_CHECK(lexical_cast(t) == to_str(t)); else { - T const min_val = limits::min(); - T const max_val = limits::max(); + T const min_val = (limits::min)(); + T const max_val = (limits::max)(); T const half_max_val = max_val / 2; T const cnt = lcast_integral_test_counter; // to supress warnings unsigned int const counter = cnt < half_max_val ? cnt : half_max_val; @@ -480,20 +511,75 @@ void test_conversion_from_integral_to_string(CharT) T ten_power = 100; for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10) { - // I believe that (ten_power + 100) never overflows + // ten_power + 100 probably never overflows for(t = ten_power - 100; t != ten_power + 100; ++t) BOOST_CHECK(lexical_cast(t) == to_str(t)); } } } +template +void test_conversion_from_string_to_integral(CharT) +{ + typedef std::numeric_limits limits; + + T t; + + t = (limits::min)(); + BOOST_CHECK(lexical_cast(to_str(t)) == t); + + t = (limits::max)(); + BOOST_CHECK(lexical_cast(to_str(t)) == t); + + if(limits::digits <= 16 && lcast_test_small_integral_types_completely) + // min and max have already been tested. + for(t = 1 + (limits::min)(); t != (limits::max)(); ++t) + BOOST_CHECK(lexical_cast(to_str(t)) == t); + else + { + T const min_val = (limits::min)(); + T const max_val = (limits::max)(); + T const half_max_val = max_val / 2; + T const cnt = lcast_integral_test_counter; // to supress warnings + unsigned int const counter = cnt < half_max_val ? cnt : half_max_val; + + unsigned int i; + + // Test values around min: + t = min_val; + for(i = 0; i < counter; ++i, ++t) + BOOST_CHECK(lexical_cast(to_str(t)) == t); + + // Test values around max: + t = max_val; + for(i = 0; i < counter; ++i, --t) + BOOST_CHECK(lexical_cast(to_str(t)) == t); + + // Test values around zero: + if(limits::is_signed) + for(t = -counter; t < static_cast(counter); ++t) + BOOST_CHECK(lexical_cast(to_str(t)) == t); + + // Test values around 100, 1000, 10000, ... + T ten_power = 100; + for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10) + { + // ten_power + 100 probably never overflows + for(t = ten_power - 100; t != ten_power + 100; ++t) + BOOST_CHECK(lexical_cast(to_str(t)) == t); + } + } +} + template -void test_conversion_from_integral_for_locale() +void test_conversion_from_to_integral_for_locale() { test_conversion_from_integral_to_integral(); test_conversion_from_integral_to_string('0'); + test_conversion_from_string_to_integral('0'); #if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) test_conversion_from_integral_to_string(L'0'); + test_conversion_from_string_to_integral(L'0'); #endif } @@ -504,7 +590,7 @@ struct restore_oldloc }; template -void test_conversion_from_integral() +void test_conversion_from_to_integral() { char const zero = '0'; signed char const szero = '0'; @@ -517,7 +603,7 @@ void test_conversion_from_integral() test_conversion_from_integral_to_char(wzero); #endif - // test_conversion_from_integral_for_locale + // test_conversion_from_to_integral_for_locale typedef std::numpunct numpunct; @@ -527,7 +613,7 @@ void test_conversion_from_integral() std::string grouping1 = BOOST_USE_FACET(numpunct, oldloc).grouping(); std::string grouping2(grouping1); - test_conversion_from_integral_for_locale(); + test_conversion_from_to_integral_for_locale(); try { @@ -544,64 +630,121 @@ void test_conversion_from_integral() } if(grouping1 != grouping2) - test_conversion_from_integral_for_locale(); + test_conversion_from_to_integral_for_locale(); if(grouping1.empty() && grouping2.empty()) BOOST_TEST_MESSAGE("Formatting with thousands_sep has not been tested"); } -void test_conversion_from_short() +void test_conversion_from_to_short() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_ushort() +void test_conversion_from_to_ushort() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_int() +void test_conversion_from_to_int() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_uint() +void test_conversion_from_to_uint() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_ulong() +void test_conversion_from_to_ulong() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_long() +void test_conversion_from_to_long() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } #if defined(BOOST_HAS_LONG_LONG) -void test_conversion_from_longlong() +void test_conversion_from_to_longlong() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } -void test_conversion_from_ulonglong() +void test_conversion_from_to_ulonglong() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); } #elif defined(LCAST_TEST_LONGLONG) -void test_conversion_from_longlong() +void test_conversion_from_to_longlong() { - test_conversion_from_integral<__int64>(); + test_conversion_from_to_integral<__int64>(); } -void test_conversion_from_ulonglong() +void test_conversion_from_to_ulonglong() { - test_conversion_from_integral(); + test_conversion_from_to_integral(); +} + +#endif + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +void test_traits() +{ + typedef std::basic_string > my_string; + + my_string const s("s"); + BOOST_CHECK(boost::lexical_cast(s) == s[0]); + BOOST_CHECK(boost::lexical_cast(s) == s); + BOOST_CHECK(boost::lexical_cast(-1) == "-1"); +} + +void test_wtraits() +{ + typedef std::basic_string > my_string; + + my_string const s(L"s"); + BOOST_CHECK(boost::lexical_cast(s) == s[0]); + BOOST_CHECK(boost::lexical_cast(s) == s); + //BOOST_CHECK(boost::lexical_cast(-1) == L"-1"); + // Commented out because gcc 3.3 doesn't support this: + // basic_ostream > o; o << -1; +} + +void test_allocator() +{ + typedef std::basic_string< char + , std::char_traits + , my_allocator + > my_string; + + my_string s("s"); + BOOST_CHECK(boost::lexical_cast(s) == s[0]); + BOOST_CHECK(boost::lexical_cast(s) == "s"); + BOOST_CHECK(boost::lexical_cast(s) == s); + BOOST_CHECK(boost::lexical_cast(1) == "1"); + BOOST_CHECK(boost::lexical_cast("s") == s); + BOOST_CHECK(boost::lexical_cast(std::string("s")) == s); +} + +void test_wallocator() +{ + typedef std::basic_string< wchar_t + , std::char_traits + , my_allocator + > my_string; + + my_string s(L"s"); + BOOST_CHECK(boost::lexical_cast(s) == s[0]); + BOOST_CHECK(boost::lexical_cast(s) == L"s"); + BOOST_CHECK(boost::lexical_cast(s) == s); + BOOST_CHECK(boost::lexical_cast(1) == L"1"); + BOOST_CHECK(boost::lexical_cast(L"s") == s); + BOOST_CHECK(boost::lexical_cast(std::wstring(L"s")) == s); } #endif From 95e7d06560cfa7e3c159f6e648a71c5d8ea05684 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 19 Dec 2007 22:46:16 +0000 Subject: [PATCH 054/138] Merged revisions 42067-42179 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r42067 | johnmaddock | 2007-12-15 04:32:18 -0800 (Sat, 15 Dec 2007) | 1 line MSVC warning suppression. ........ r42069 | bemandawes | 2007-12-15 06:26:16 -0800 (Sat, 15 Dec 2007) | 1 line Correct misspelling of library name ........ r42074 | johnmaddock | 2007-12-15 09:10:03 -0800 (Sat, 15 Dec 2007) | 1 line Fix error messages so they work with Boost.Format. ........ r42076 | johnmaddock | 2007-12-15 09:36:31 -0800 (Sat, 15 Dec 2007) | 1 line Trivial patches to silence MSVC warnings. ........ r42078 | johnmaddock | 2007-12-15 10:29:29 -0800 (Sat, 15 Dec 2007) | 1 line Disable long double tests if there's no long double support. ........ r42080 | johnmaddock | 2007-12-15 10:49:13 -0800 (Sat, 15 Dec 2007) | 1 line Yet another MSVC warning suppression. ........ r42082 | bgubenko | 2007-12-15 10:53:01 -0800 (Sat, 15 Dec 2007) | 1 line mark up Boost.Test tests for Linux ia64 gcc; make Boost.Interprocess unsupported on Linux ia64 gcc and PA-RISC ........ r42086 | anthonyw | 2007-12-15 14:34:30 -0800 (Sat, 15 Dec 2007) | 1 line added timed_wait overloads that take a duration ........ r42087 | anthonyw | 2007-12-15 14:36:43 -0800 (Sat, 15 Dec 2007) | 1 line explicit move functions for threads, with a test ........ r42105 | andreas_huber69 | 2007-12-16 06:58:24 -0800 (Sun, 16 Dec 2007) | 1 line Removed markup for now passing Sandia tests. ........ r42112 | bemandawes | 2007-12-16 14:39:32 -0800 (Sun, 16 Dec 2007) | 1 line Add intel-win-10.0 as required ........ r42116 | djowel | 2007-12-17 01:27:42 -0800 (Mon, 17 Dec 2007) | 1 line fixed documentation bug ........ r42117 | anthonyw | 2007-12-17 03:24:13 -0800 (Mon, 17 Dec 2007) | 1 line Updated move function test to be fair to Borland ........ r42118 | anthonyw | 2007-12-17 04:52:50 -0800 (Mon, 17 Dec 2007) | 1 line boost::move support for locks ........ r42119 | chris_kohlhoff | 2007-12-17 05:04:30 -0800 (Mon, 17 Dec 2007) | 2 lines Fixes for older HP-UX. ........ r42120 | chris_kohlhoff | 2007-12-17 05:08:10 -0800 (Mon, 17 Dec 2007) | 2 lines Bump version number. ........ r42121 | chris_kohlhoff | 2007-12-17 05:17:46 -0800 (Mon, 17 Dec 2007) | 2 lines Documentation fixes. ........ r42127 | bgubenko | 2007-12-17 10:06:11 -0800 (Mon, 17 Dec 2007) | 1 line markup test library test prg_exec_fail2 for PA-RISC ........ r42138 | johnmaddock | 2007-12-18 08:37:23 -0800 (Tue, 18 Dec 2007) | 1 line Fixes #1525. ........ r42141 | marshall | 2007-12-18 10:33:55 -0800 (Tue, 18 Dec 2007) | 1 line Patches to fixe #1423 and #1473 ........ r42145 | fmhess | 2007-12-18 12:14:01 -0800 (Tue, 18 Dec 2007) | 4 lines Prevented "classname"/"methodname"/etc. elements inside "type" elements inside "static-constant" elements from getting dropped. ........ r42164 | djowel | 2007-12-19 02:33:14 -0800 (Wed, 19 Dec 2007) | 1 line bug fix for end_impl. ........ r42165 | djowel | 2007-12-19 02:33:39 -0800 (Wed, 19 Dec 2007) | 1 line bug fix for end_impl. (test) ........ r42166 | anthonyw | 2007-12-19 02:39:45 -0800 (Wed, 19 Dec 2007) | 1 line Updated thread ID, and added tests ........ r42167 | djowel | 2007-12-19 02:42:04 -0800 (Wed, 19 Dec 2007) | 1 line tweakbug fix for end_impl (tweak). ........ r42168 | anthonyw | 2007-12-19 02:45:01 -0800 (Wed, 19 Dec 2007) | 1 line Implement hardware_concurrency for pthread ........ r42169 | johnmaddock | 2007-12-19 08:41:54 -0800 (Wed, 19 Dec 2007) | 1 line Fix graph title. ........ [SVN r42185] --- include/boost/lexical_cast.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 2794c86..44c7a66 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -3,7 +3,7 @@ // Boost lexical_cast.hpp header -------------------------------------------// // -// See http://www.boost.org/libs/converston for documentation. +// See http://www.boost.org/libs/conversion for documentation. // See end of this header for rights and permissions. // // what: lexical_cast custom keyword cast From 49c0b2f333fb1da92127d994d9cb3bd1253ced11 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 10 Feb 2008 16:39:38 +0000 Subject: [PATCH 055/138] Merged revisions 43206,43208-43213 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r43206 | danieljames | 2008-02-10 09:55:03 +0000 (Sun, 10 Feb 2008) | 1 line Fix some broken links. ........ r43209 | danieljames | 2008-02-10 14:56:22 +0000 (Sun, 10 Feb 2008) | 1 line Link to people pages on the website, as they've been removed from the download. ........ r43210 | danieljames | 2008-02-10 15:02:17 +0000 (Sun, 10 Feb 2008) | 1 line Point links to the pages that used to be in 'more' to the site. ........ r43212 | danieljames | 2008-02-10 16:10:16 +0000 (Sun, 10 Feb 2008) | 1 line Fix links on the home page as well. ........ r43213 | danieljames | 2008-02-10 16:21:22 +0000 (Sun, 10 Feb 2008) | 1 line Generated documentation which is no longer generated. ........ [SVN r43214] --- cast.htm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cast.htm b/cast.htm index 587d08a..cb8add6 100644 --- a/cast.htm +++ b/cast.htm @@ -120,10 +120,10 @@ void f( Fruit * fruit ) {

    polymorphic_cast was suggested by Bjarne Stroustrup in "The C++ Programming Language".
    polymorphic_downcast was contributed by Dave Abrahams.
    + "http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams.
    An old numeric_cast
    that was contributed by Kevlin Henney is now superseeded by the Boost Numeric Conversion Library

    + "http://www.boost.org/people/kevlin_henney.htm">Kevlin Henney is now superseeded by the Boost Numeric Conversion Library


    Revised From b8c0c988a7b9bcb4275aefc6c8751d23553bdf00 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 5 Mar 2008 20:37:04 +0000 Subject: [PATCH 056/138] Merged revisions 42451-43517 via svnmerge from https://svn.boost.org/svn/boost/trunk ................ r42455 | johnmaddock | 2008-01-04 08:54:35 -0800 (Fri, 04 Jan 2008) | 1 line Fix typos. ................ r42456 | eric_niebler | 2008-01-04 09:14:53 -0800 (Fri, 04 Jan 2008) | 1 line mark up borland and sun accumulators failures ................ r42459 | andreas_huber69 | 2008-01-04 10:23:18 -0800 (Fri, 04 Jan 2008) | 1 line This should fix template parameter shadowing errors for gcc and Intel compilers. ................ r42462 | bgubenko | 2008-01-04 15:55:43 -0800 (Fri, 04 Jan 2008) | 1 line mark Accumulators tests for gcc 4.2.1 affected by GCC Bugzilla Bug 33580 ................ r42471 | turkanis | 2008-01-04 20:51:49 -0800 (Fri, 04 Jan 2008) | 1 line merged changes from iostreams_dev, revisions 42441-42469; added 'std::' for Intel on Linux/Darwin; added STDCXX workaround for codecvt; fixed docs for invert.hpp ................ r42473 | turkanis | 2008-01-04 23:35:44 -0800 (Fri, 04 Jan 2008) | 1 line new iostreams expected failures: stream_offset_64bit_test.cpp on Borland, and wide stream tests on gcc-3.4.2_hpux_pa_risc ................ r42475 | andreas_huber69 | 2008-01-05 04:42:02 -0800 (Sat, 05 Jan 2008) | 1 line Added defaults for in_state_reaction template parameters and updated tests accordingly. ................ r42476 | bemandawes | 2008-01-05 06:41:55 -0800 (Sat, 05 Jan 2008) | 1 line Disable Microsoft "secure" overloads in Dinkumware libraries since they cause compile errors with Intel versions 9 and 10 ................ r42478 | jurko | 2008-01-05 07:19:53 -0800 (Sat, 05 Jan 2008) | 1 line Typo corrections. Minor stylistic changes. ................ r42479 | jurko | 2008-01-05 08:53:03 -0800 (Sat, 05 Jan 2008) | 1 line Updated Boost.Jam command line option texts. Minor stylistic changes. ................ r42480 | jurko | 2008-01-05 08:55:36 -0800 (Sat, 05 Jan 2008) | 1 line Typo corrections. Minor stylistic changes. ................ r42481 | jurko | 2008-01-05 08:56:42 -0800 (Sat, 05 Jan 2008) | 1 line Typo correction. Corrected an invalid command-line option name. ................ r42482 | jurko | 2008-01-05 08:57:17 -0800 (Sat, 05 Jan 2008) | 1 line Corrected an invalid command-line option name reference. ................ r42483 | jurko | 2008-01-05 08:58:01 -0800 (Sat, 05 Jan 2008) | 1 line Corrected an out-of-date comment listing all command-line options. ................ r42484 | jurko | 2008-01-05 09:11:50 -0800 (Sat, 05 Jan 2008) | 1 line Corrected the used file suffix for the VERBATIM file type. Now the documentation is in sync with the 'customization' example. This also closes the Trac ticket 134. Minor stylistic changes. ................ r42485 | jurko | 2008-01-05 09:46:45 -0800 (Sat, 05 Jan 2008) | 1 line Stylistic comment changes & typo corrections. ................ r42486 | jurko | 2008-01-05 09:52:31 -0800 (Sat, 05 Jan 2008) | 1 line Stylistic comment changes & typo corrections in several files. Corrected an incorrect error message in boost-build/build/project.jam displayed when a --build-dir command-line option and a non top-level project build-dir attribute are specified. ................ r42487 | jurko | 2008-01-05 09:54:02 -0800 (Sat, 05 Jan 2008) | 1 line Cleaned up some import rule calls. ................ r42488 | jurko | 2008-01-05 10:02:23 -0800 (Sat, 05 Jan 2008) | 1 line Documentation wording cleaned up a bit. ................ r42489 | jurko | 2008-01-05 10:13:10 -0800 (Sat, 05 Jan 2008) | 1 line Removed or simplified some import calls. Comment updates. Minor stylistic changes. ................ r42490 | jurko | 2008-01-05 10:14:20 -0800 (Sat, 05 Jan 2008) | 2 lines Simplified the used make rules. Removed some dead code. Minor stylistic changes. ................ r42492 | jurko | 2008-01-05 10:29:36 -0800 (Sat, 05 Jan 2008) | 1 line Removed trailing spaces and some empty lines. ................ r42494 | jurko | 2008-01-05 12:02:24 -0800 (Sat, 05 Jan 2008) | 1 line Minor stylistic changes such as: comment typo corrections, wrapping lines to 80 characters, indentations, removing trailing spaces, etc. ................ r42495 | jurko | 2008-01-05 12:06:15 -0800 (Sat, 05 Jan 2008) | 2 lines Cleaned up where the stage module is imported in tools/builtin.jam. Added a missing import in tools/stage.jam that causes errors with the previous fix. Minor stylistic changes in tools/stage.jam. ................ r42496 | jurko | 2008-01-05 12:14:48 -0800 (Sat, 05 Jan 2008) | 1 line Comment cleanup. ................ r42497 | jurko | 2008-01-05 12:37:44 -0800 (Sat, 05 Jan 2008) | 1 line Minor stylistic changes - cleaned up import calls, wrapped much text at 80 characters updated comments, typo corrections, removed trailing spaces, etc. ................ r42498 | jurko | 2008-01-05 12:48:50 -0800 (Sat, 05 Jan 2008) | 1 line Renamed some Jamfile and project-root.jam references to Jamfile.jam and Jamroot.jam respectively. ................ r42499 | jurko | 2008-01-05 13:37:15 -0800 (Sat, 05 Jan 2008) | 1 line Test code cleaned up a bit. No functional changes. ................ r42502 | hkaiser | 2008-01-05 14:44:28 -0800 (Sat, 05 Jan 2008) | 1 line Wave: updated copyright messages to include the year 2008 (merged from release branch). ................ r42504 | jurko | 2008-01-05 15:18:17 -0800 (Sat, 05 Jan 2008) | 1 line Refactored the test into two separate test functions. Made the 'directory names with dots' test use the expect_output_line() tool instead of a manual find, causing a better diagnostic to be displayed in case of a failure. Made one of the test Jam scripts more compact. Made the test use the Jamroot.jam file instead of project-root.jam. ................ r42505 | bgubenko | 2008-01-05 15:35:05 -0800 (Sat, 05 Jan 2008) | 1 line mark up accumulators library test weighted_kurtosis for acc toolset ................ r42506 | jurko | 2008-01-05 16:25:48 -0800 (Sat, 05 Jan 2008) | 1 line No functional changes but only stylistic changes such as: comment typo corrections, wrapping lines to 80 characters, indentations, removing trailing spaces, removing empty lines, made tests use Jamfile.jam and Jamroot.jam Boost Build script names, removed unnecessary module imports, etc. ................ r42507 | jurko | 2008-01-05 16:53:09 -0800 (Sat, 05 Jan 2008) | 1 line No functional changes but only stylistic changes such as: comment typo corrections, wrapping lines to 80 characters, indentations, removing trailing spaces, removing empty lines, removed unnecessary module imports, etc. ................ r42508 | jurko | 2008-01-05 22:15:39 -0800 (Sat, 05 Jan 2008) | 5 lines Refactored build-system.jam. Added many detailed comments. Test configuration module now gets loaded the same as all other configuration modules. In addition to being able to specify which user configuration to load, user may now also prevent loading the user configuration by specifying an empty file name for it. ................ r42509 | jurko | 2008-01-05 22:50:56 -0800 (Sat, 05 Jan 2008) | 1 line Added a --test-config command-line option for specifying where the test configuration file should be loaded from instead of always being looked up in Boost Build's test folder. This allows non-test builds to not use test config when it exists on the system and different tests to use different test configurations when needed. ................ r42510 | jurko | 2008-01-05 22:58:24 -0800 (Sat, 05 Jan 2008) | 1 line Specifying that a build uses test configuration no longer prevents toolset auto-configuration and therefore no longer causes --toolset options to be ignored. ................ r42511 | jurko | 2008-01-05 23:13:28 -0800 (Sat, 05 Jan 2008) | 1 line Minor stylistic comment changes. ................ r42512 | jurko | 2008-01-05 23:17:08 -0800 (Sat, 05 Jan 2008) | 1 line Added support for choosing the toolset and toolset version to be used 'by default' by Boost Build. Allows testing of default toolset functionality. ................ r42513 | jurko | 2008-01-05 23:26:46 -0800 (Sat, 05 Jan 2008) | 1 line Upgraded the tool for testing that a certain line exists in the given output support so that it now also knows how to test that a certain line does not exist in the given output. ................ r42514 | jurko | 2008-01-05 23:28:47 -0800 (Sat, 05 Jan 2008) | 1 line Added the --ignore-site-config option telling Boost.Build not to load the site configuration file. ................ r42516 | jurko | 2008-01-06 00:16:34 -0800 (Sun, 06 Jan 2008) | 1 line Stylistic changes: typo corrections, comment alignments, output string updates, no functional changes, etc. ................ r42527 | andreas_huber69 | 2008-01-06 05:49:31 -0800 (Sun, 06 Jan 2008) | 1 line Various doc updates. ................ r42528 | danieljames | 2008-01-06 08:47:16 -0800 (Sun, 06 Jan 2008) | 2 lines Add Boost.Unordered and add to the documentation. Not fully integrated yet. ................ r42529 | danieljames | 2008-01-06 08:48:36 -0800 (Sun, 06 Jan 2008) | 1 line Add more libraries that use Boost.Hash to its intro. ................ r42530 | danieljames | 2008-01-06 08:49:11 -0800 (Sun, 06 Jan 2008) | 1 line Add Boost.Unordered to Boost.Hash's intro. ................ r42531 | danieljames | 2008-01-06 08:59:18 -0800 (Sun, 06 Jan 2008) | 1 line Combine the 'container' and 'unordered' tests. ................ r42532 | danieljames | 2008-01-06 08:59:49 -0800 (Sun, 06 Jan 2008) | 1 line Give the unordered exception test suite its own name. ................ r42533 | danieljames | 2008-01-06 09:13:15 -0800 (Sun, 06 Jan 2008) | 1 line Add the contents of compile_tests.cpp to set_compile.cpp and map_compile.cpp ................ r42534 | danieljames | 2008-01-06 09:16:51 -0800 (Sun, 06 Jan 2008) | 1 line Rename the test-suites to match other libraries' style. ................ r42535 | danieljames | 2008-01-06 09:23:16 -0800 (Sun, 06 Jan 2008) | 2 lines Add forwarding html files for Boost.Unordered. ................ r42536 | danieljames | 2008-01-06 09:40:32 -0800 (Sun, 06 Jan 2008) | 1 line Add Boost.Unordered to the regression tests. ................ r42537 | eric_niebler | 2008-01-06 09:44:06 -0800 (Sun, 06 Jan 2008) | 1 line add myself as maintainer of accumulators ................ r42538 | danieljames | 2008-01-06 09:45:18 -0800 (Sun, 06 Jan 2008) | 2 lines Add library identification. ................ r42539 | danieljames | 2008-01-06 09:48:11 -0800 (Sun, 06 Jan 2008) | 2 lines Add the unordered library to the maintainers list. ................ r42540 | danieljames | 2008-01-06 09:56:06 -0800 (Sun, 06 Jan 2008) | 2 lines Add unordered to the library list. ................ r42544 | turkanis | 2008-01-06 10:32:05 -0800 (Sun, 06 Jan 2008) | 18 lines copy.hpp: fix for Visual Age: std::min was passed arguments of different types; replaced std:: min with conditional detail/streambuf/indirect_streambuf.hpp: removed trailing comma in enum definition test/combine_test.cpp: test/symmetric_filter_test.cpp: test/compose_test.cpp: test/close_test.cpp: test/invert_test.cpp: test/tee_test.cpp: test/restrict_test.cpp: test/Jamfile.v2: moved tests for close() into the test files for various adapters ................ r42546 | jurko | 2008-01-06 12:06:33 -0800 (Sun, 06 Jan 2008) | 1 line Corrected a bug with the customized default toolset being read from the toolset module but defined in the build-system module. Effect was that customized default toolsets were getting ignored. ................ r42547 | jurko | 2008-01-06 12:37:55 -0800 (Sun, 06 Jan 2008) | 1 line Simple code cleanup. Typo corrections. ................ r42548 | jurko | 2008-01-06 12:43:25 -0800 (Sun, 06 Jan 2008) | 1 line Added support for tests configuring whether they want their Boost Build to ignore toolset requirements instead of always ignoring them. Minor stylistic changes. ................ r42549 | jurko | 2008-01-06 12:56:20 -0800 (Sun, 06 Jan 2008) | 1 line Added new tests related to Boost Build's default toolset handling. They test that the correct default toolset gets use and that when it gets used that has no different status than any other explicitly specified toolset. ................ r42563 | turkanis | 2008-01-06 17:26:52 -0800 (Sun, 06 Jan 2008) | 1 line marked restrict_test.cpp as failing on vacpp and stream_offset_64bit_test as failing on sun (iostreams) ................ r42564 | turkanis | 2008-01-06 17:32:29 -0800 (Sun, 06 Jan 2008) | 1 line alphabetized the iostreams failures ................ r42565 | turkanis | 2008-01-06 21:20:32 -0800 (Sun, 06 Jan 2008) | 5 lines merged changes from branches/iostreams_dev, revisions 42544-42544 - added "slice" as an alias for "restrict", for platforms on which "restrict" is a keyword - attempted to configure file_descriptor for __IBMCPP__ - added better error output to stream_offset_64bit_test.cpp ................ r42566 | jurko | 2008-01-07 09:00:59 -0800 (Mon, 07 Jan 2008) | 1 line Corrected explicitly specified user-config file handling. Was not looking for the specified file in the regular path instead of the current folder and did not work with absolute paths. ................ r42567 | jurko | 2008-01-07 10:15:13 -0800 (Mon, 07 Jan 2008) | 1 line Code cleanup. Converted to using True/False instead of 1/0. Changed to obey documented coding conventions regarding whitespace and function parameters. Renamed private member functions to use the __ name prefix. ................ r42568 | jurko | 2008-01-07 10:38:28 -0800 (Mon, 07 Jan 2008) | 1 line Added a new configuration test making sure that the bug with not being able to process absolute user-config configuration file references never rears its ugly head again. ................ r42570 | eric_niebler | 2008-01-07 11:06:31 -0800 (Mon, 07 Jan 2008) | 1 line s/order/tail/ ................ r42571 | eric_niebler | 2008-01-07 11:08:16 -0800 (Mon, 07 Jan 2008) | 1 line add missing includes, fix signed/unsigned warnings, clean-up trailing whitespace, fixes #1552 ................ r42572 | danieljames | 2008-01-07 11:40:32 -0800 (Mon, 07 Jan 2008) | 1 line Rename the exception tests so that they don't clash with the normal tests. ................ r42573 | danieljames | 2008-01-07 11:41:05 -0800 (Mon, 07 Jan 2008) | 1 line Remove some development code. ................ r42575 | danieljames | 2008-01-07 11:44:13 -0800 (Mon, 07 Jan 2008) | 3 lines Add missing 'use namespace std'. Which I should have done when I was told about them before. Sorry. ................ r42576 | danieljames | 2008-01-07 11:46:27 -0800 (Mon, 07 Jan 2008) | 1 line Add support for multiple copyrights in the library info. ................ r42578 | danieljames | 2008-01-07 11:51:02 -0800 (Mon, 07 Jan 2008) | 1 line Reneame the set and map compile tests so they'll be adjacent in the test results. ................ r42580 | danieljames | 2008-01-07 12:06:15 -0800 (Mon, 07 Jan 2008) | 1 line Avoid some uses of an invalid pointer. ................ r42581 | danieljames | 2008-01-07 12:07:12 -0800 (Mon, 07 Jan 2008) | 1 line Use the default location for the reference documentation. ................ r42587 | danieljames | 2008-01-07 13:05:42 -0800 (Mon, 07 Jan 2008) | 5 lines Fix a bug which was causing the memory area stuff to fail. I should probably try to be less clever and use memory area's lower bounds as the key, and do the extra work required to get that working. ................ r42588 | danieljames | 2008-01-07 13:07:43 -0800 (Mon, 07 Jan 2008) | 1 line Fix an off by one error. ................ r42591 | danieljames | 2008-01-07 13:47:24 -0800 (Mon, 07 Jan 2008) | 1 line Merge in spell check. ................ r42596 | turkanis | 2008-01-07 15:13:26 -0800 (Mon, 07 Jan 2008) | 5 lines merged changes from branches/iostreams_dev, revisions 42565-42595: - Simplified implementation with the help to the C-runtime function _get_osfhandle so that on Windows only a single HANDLE is stored and the POSIX-style implementation is never needed; added the handle_type on POSIX systems (typedef for int) and a function returning the underlying handle as an instance of handle_type - fixed the bug described in ticket Ticket #1551 (stream_buffer::seekpos ignores openmode parameter) - fixed test/operation_sequence_test.cpp file description ................ r42598 | grafik | 2008-01-07 18:49:25 -0800 (Mon, 07 Jan 2008) | 1 line Mostly fix bad path calc for direct html from doxygen doc generation. (fixes #1562) ................ r42600 | turkanis | 2008-01-07 19:49:23 -0800 (Mon, 07 Jan 2008) | 1 line merged changes from branches/iostreams_dev revisions 42595-42599; applied Dinkumware implementation of positioning functions to IBM Visual Age; simplified and corrected implementation ................ r42602 | turkanis | 2008-01-07 20:20:38 -0800 (Mon, 07 Jan 2008) | 1 line removed unneeded headers, one of which (restrict.hpp) causes failures on IBM Visual Age ................ r42603 | turkanis | 2008-01-07 20:52:54 -0800 (Mon, 07 Jan 2008) | 1 line removed spurious '.cpp' extension from test names (iostreams) ................ r42612 | danieljames | 2008-01-08 05:59:01 -0800 (Tue, 08 Jan 2008) | 3 lines Merge in latest unordered developments (revisions 42607-42611). ................ r42613 | jurko | 2008-01-08 06:40:24 -0800 (Tue, 08 Jan 2008) | 1 line Added a new test making sure properties conditioned on multiple different feature values are handled correctly. This especially includes testing the case when one of those features is and the value given for it includes a toolset version. ................ r42614 | jurko | 2008-01-08 07:21:15 -0800 (Tue, 08 Jan 2008) | 1 line Made some debugging messages more consistent. ................ r42615 | eric_niebler | 2008-01-08 09:42:20 -0800 (Tue, 08 Jan 2008) | 1 line support for LaTeX formulas in Doxygen comments ................ r42616 | eric_niebler | 2008-01-08 09:43:34 -0800 (Tue, 08 Jan 2008) | 1 line automatically generate png files from LaTeX formulas using doxygen ................ r42617 | jurko | 2008-01-08 09:51:30 -0800 (Tue, 08 Jan 2008) | 1 line Comment correction. ................ r42619 | danieljames | 2008-01-08 10:15:01 -0800 (Tue, 08 Jan 2008) | 1 line Merge: Another missing 'using namespace std' ................ r42620 | eric_niebler | 2008-01-08 10:43:43 -0800 (Tue, 08 Jan 2008) | 1 line fix signed/unsigned warnings, clean up trailing whitespace ................ r42624 | eric_niebler | 2008-01-08 13:40:52 -0800 (Tue, 08 Jan 2008) | 1 line disable iterator debugging for all msvc versions ................ r42625 | turkanis | 2008-01-08 14:25:01 -0800 (Tue, 08 Jan 2008) | 1 line merged changes from branches/iostreams_dev, revisions 42602-42624: adding missing included to fix #1550; fix for positioning on IBM; fix for file_descriptor on POSIX; restructed the version range for the Borland workaround in large_file_test.cpp ................ r42626 | jurko | 2008-01-08 17:09:26 -0800 (Tue, 08 Jan 2008) | 1 line Minor stylistic code indentation changes. ................ r42627 | jurko | 2008-01-08 17:11:03 -0800 (Tue, 08 Jan 2008) | 1 line Tried trailing spaces. Minor comment typo corrections. ................ r42628 | jurko | 2008-01-08 17:18:38 -0800 (Tue, 08 Jan 2008) | 1 line Remove trailing spaces. Removed an empty line. ................ r42629 | jurko | 2008-01-08 20:05:29 -0800 (Tue, 08 Jan 2008) | 8 lines Updated the __ACTION_RULE__ to not return its action command output as a single string but instead split it into a list of output lines. This allows Jam code using this output to work correctly independently of what newline character combinations are in use. This was causing problems with Boost Build unit tests which can now be updated to pass. Consequences & checks: * Final __ACTION_RULE__ rule parameter has changed from output ? to output-lines *. * Updated corresponding Jam documentation. * Updated the all related Boost Build code. * No code on the Boost trunk uses this rule except for Boost Build itself. ................ r42630 | jurko | 2008-01-08 20:15:35 -0800 (Tue, 08 Jan 2008) | 1 line Fixed a failing test by making it access action output using the __ACTION_RULE__ rule so it would not be affected by the level of debug output given by Boost Build/Jam. ................ r42631 | jurko | 2008-01-08 20:30:25 -0800 (Tue, 08 Jan 2008) | 1 line Fixed a failing test by making it access its action results using the __ACTION_RULE__ rule. Now it works with the default debug level settings (i.e. no action output displayed). ................ r42632 | grafik | 2008-01-08 20:31:58 -0800 (Tue, 08 Jan 2008) | 1 line Revert various changes that break backward compatibility, and also some minor edits. ................ r42633 | grafik | 2008-01-08 20:34:12 -0800 (Tue, 08 Jan 2008) | 1 line Revert various changes that break backward compatibility, and also some minor edits. ................ r42637 | jurko | 2008-01-09 06:36:37 -0800 (Wed, 09 Jan 2008) | 1 line Updated the test so it passes on Windows. Had to change it to enable action output logging and compensate for the fact that now action names are sent to the output as well. Minor stylistic changes. ................ r42639 | jurko | 2008-01-09 09:03:45 -0800 (Wed, 09 Jan 2008) | 1 line Updated the test so it passes on Windows. Had to change it to enable action output logging and compensate for the fact that now action names are sent to the output as well. Minor stylistic changes. ................ r42641 | eric_niebler | 2008-01-09 12:21:51 -0800 (Wed, 09 Jan 2008) | 1 line copy the png files to where fop will look for them when building pdf ................ r42642 | eric_niebler | 2008-01-09 12:33:05 -0800 (Wed, 09 Jan 2008) | 1 line fix more signed/unsigned warnings ................ r42644 | turkanis | 2008-01-09 15:13:57 -0800 (Wed, 09 Jan 2008) | 1 line marked stream_offset_64bit_test as an expected failure on vacpp (iostreams) ................ r42645 | turkanis | 2008-01-09 15:16:17 -0800 (Wed, 09 Jan 2008) | 1 line replaced 2 occurrences of the identifier 'restrict' with BOOST_IOSTREAMS_RESTRICT ................ r42646 | turkanis | 2008-01-09 19:27:51 -0800 (Wed, 09 Jan 2008) | 1 line added expected failures for Sun and IBM; removed a Borland intermittent failure; removed some obsolete toolsets (iostreams) ................ r42647 | troyer | 2008-01-10 01:49:16 -0800 (Thu, 10 Jan 2008) | 1 line Optimizations for Boost.MPI ................ r42648 | troyer | 2008-01-10 03:54:36 -0800 (Thu, 10 Jan 2008) | 1 line Undid backward-compatibility breaking change in pair serialization ................ r42651 | johnmaddock | 2008-01-10 04:10:37 -0800 (Thu, 10 Jan 2008) | 1 line Apply patch from Issue #1187. ................ r42657 | anthonyw | 2008-01-10 06:19:36 -0800 (Thu, 10 Jan 2008) | 1 line removed references to NULL ................ r42658 | turkanis | 2008-01-10 10:50:19 -0800 (Thu, 10 Jan 2008) | 1 line marked up two moe expected failures for sun-5.7-5.8 (iostreams) ................ r42664 | bgubenko | 2008-01-10 13:13:42 -0800 (Thu, 10 Jan 2008) | 1 line marked iostreams library compose_test for gcc-3.4.6_linux_ia64 : linking exceeds 10 min. limit ................ r42665 | danieljames | 2008-01-10 14:25:35 -0800 (Thu, 10 Jan 2008) | 2 lines Initialise svnmerge for merging changes for unordered. ................ r42666 | danieljames | 2008-01-10 14:30:46 -0800 (Thu, 10 Jan 2008) | 6 lines Merge latest unordered developments: Make simple_test test a little more. Use doubles for calculating max load factor. Some workarounds, mostly for Borland and running the tests. ................ r42670 | turkanis | 2008-01-10 16:02:36 -0800 (Thu, 10 Jan 2008) | 1 line merged changes from branches/iostreams_dev, revisions 42645=42660; fix for Intel-darwin; removed dependence of file_descriptor_test and mapped_file_test on library boost_iostreams ................ r42672 | turkanis | 2008-01-10 17:35:46 -0800 (Thu, 10 Jan 2008) | 1 line force static runtime-link for intel-darwin ................ r42674 | johnmaddock | 2008-01-11 01:55:43 -0800 (Fri, 11 Jan 2008) | 1 line Fix bugs reported by Will Drewry: certain invalid regexes can cause the library to access invalid memory, changed to ensure that the correct exception is thrown long before this happens. ................ r42676 | jurko | 2008-01-11 05:44:51 -0800 (Fri, 11 Jan 2008) | 1 line Removed the manual boost-build.jam file creation since that file already exists in the SVN repository and this only overwrote it with the same content minus the copyright notice. Removed a reference to the no longer existing boost_build_v2.html file. ................ r42677 | johnmaddock | 2008-01-11 05:48:57 -0800 (Fri, 11 Jan 2008) | 1 line Update for Intel-10.1. ................ r42684 | turkanis | 2008-01-11 11:12:22 -0800 (Fri, 11 Jan 2008) | 1 line another attempt to fix linking for compression tests on intel-darwin ................ r42688 | turkanis | 2008-01-11 14:58:21 -0800 (Fri, 11 Jan 2008) | 1 line merged changes from iostreams_dev; fixes for IBM and more documentation ................ r42689 | turkanis | 2008-01-11 18:45:55 -0800 (Fri, 11 Jan 2008) | 1 line more detailed note for vacpp (iostreams) ................ r42691 | eric_niebler | 2008-01-11 22:43:28 -0800 (Fri, 11 Jan 2008) | 1 line new style transforms a-la proto v3 ................ r42693 | nesotto | 2008-01-12 04:38:57 -0800 (Sat, 12 Jan 2008) | 1 line doc fixes ................ r42698 | danieljames | 2008-01-12 06:43:40 -0800 (Sat, 12 Jan 2008) | 9 lines Merge the latest unordered changes. These are concerned with getting the tests working on more compilers. The biggest change is that the exception tests have been changed to use a very simple exception testing mechanism on top of lightweight_test. This was because Boost.Test exception testing isn't working on several platforms. I'm trying to set this up so that I can use Boost.Test on compilers which it completely supports, and lightweight test on others. Boost.Test tests more than my simple exception testing code ever will so it's worth using where I can. ................ r42700 | eric_niebler | 2008-01-12 09:09:17 -0800 (Sat, 12 Jan 2008) | 1 line missing includes ................ r42701 | eric_niebler | 2008-01-12 09:40:40 -0800 (Sat, 12 Jan 2008) | 1 line more msvc-7.1-friendly default_context implementation, more missing headers ................ r42706 | turkanis | 2008-01-12 12:19:42 -0800 (Sat, 12 Jan 2008) | 1 line corrected use of feature detection macros for AIX; simplified implementation slightly; updated docs ................ r42707 | turkanis | 2008-01-12 12:20:35 -0800 (Sat, 12 Jan 2008) | 1 line removed intel-darwin sepcific code, since it didn't work ................ r42708 | eric_niebler | 2008-01-12 13:19:45 -0800 (Sat, 12 Jan 2008) | 1 line port toy_spirit example to proto v3 ................ r42713 | turkanis | 2008-01-12 23:17:07 -0800 (Sat, 12 Jan 2008) | 1 line improved docs ................ r42715 | nesotto | 2008-01-13 03:37:41 -0800 (Sun, 13 Jan 2008) | 1 line fixed #if to #ifdef ................ r42722 | bgubenko | 2008-01-13 07:52:12 -0800 (Sun, 13 Jan 2008) | 1 line better note for iostreams library test compose_test on gcc-3.4.6_linux_ia64 ................ r42723 | bgubenko | 2008-01-13 08:12:37 -0800 (Sun, 13 Jan 2008) | 1 line marked up random library test random_test for gcc-3.4.6_linux_ia64 ................ r42724 | danieljames | 2008-01-13 08:19:26 -0800 (Sun, 13 Jan 2008) | 3 lines Merge in latest changes to Boost.Unordered. Some compiler workarounds and starting to clean up the tests a little. ................ r42729 | eric_niebler | 2008-01-13 11:39:54 -0800 (Sun, 13 Jan 2008) | 1 line work around msvc-7.1 bug ................ r42741 | eric_niebler | 2008-01-13 13:56:56 -0800 (Sun, 13 Jan 2008) | 1 line boost template instantiation depth on darwin ................ r42745 | johnmaddock | 2008-01-14 01:46:12 -0800 (Mon, 14 Jan 2008) | 1 line Ooops, fix broken escape sequence. ................ r42747 | johnmaddock | 2008-01-14 01:58:36 -0800 (Mon, 14 Jan 2008) | 1 line Fix documentation typos. ................ r42750 | chris_kohlhoff | 2008-01-14 05:13:35 -0800 (Mon, 14 Jan 2008) | 2 lines Fix concept name in comment. ................ r42751 | johnmaddock | 2008-01-14 05:17:09 -0800 (Mon, 14 Jan 2008) | 1 line Patch regex concept checks and TR1 library to work with VC9 + MS TR1 feature pack. ................ r42752 | chris_kohlhoff | 2008-01-14 05:20:06 -0800 (Mon, 14 Jan 2008) | 2 lines Add missing broken pipe error. ................ r42753 | chris_kohlhoff | 2008-01-14 05:21:37 -0800 (Mon, 14 Jan 2008) | 3 lines Don't include sys/time.h when compiling with aCC, as that header does not supply pselect(), which is needed for HP-UX/aCC to work correctly. ................ r42754 | chris_kohlhoff | 2008-01-14 05:22:21 -0800 (Mon, 14 Jan 2008) | 2 lines Disable noisy and incorrect /Wp64 warnings generated by MSVC. ................ r42755 | chris_kohlhoff | 2008-01-14 05:24:28 -0800 (Mon, 14 Jan 2008) | 3 lines Don't call epoll_wait/kevent if there are no old operations (where old means added prior to the last epoll_wait/kevent call) needing to be demultiplexed. ................ r42756 | chris_kohlhoff | 2008-01-14 05:25:24 -0800 (Mon, 14 Jan 2008) | 2 lines Silence some integer truncation warnings. ................ r42758 | chris_kohlhoff | 2008-01-14 05:27:52 -0800 (Mon, 14 Jan 2008) | 8 lines Silence some integer truncation warnings. Only perform the windows-bug workaround where we use a short timeout with GetQueuedCompletionStatus from one thread, i.e. the timer thread. Keep track of the number of OVERLAPPED-derived operations to ensure that they all get cleaned up when the io_service is destroyed. ................ r42759 | chris_kohlhoff | 2008-01-14 05:29:08 -0800 (Mon, 14 Jan 2008) | 5 lines Check for truncation when converting buffer size from size_t to openssl's int argument. Try to fix possible thread-safety issues in SSL wrapper. ................ r42766 | eric_niebler | 2008-01-14 08:49:32 -0800 (Mon, 14 Jan 2008) | 1 line register mpl::bool_ with typeof ................ r42767 | dgregor | 2008-01-14 09:01:26 -0800 (Mon, 14 Jan 2008) | 1 line Improved suggestion for dealing with Qt MOC, from Niels Dekker ................ r42771 | niels_dekker | 2008-01-14 10:17:30 -0800 (Mon, 14 Jan 2008) | 1 line Documented value_init workaround to compiler issues, added new introduction, updated to 2003 edition of C++ Standard -- reviewed by Fernando Cacciola ................ r42773 | guwi17 | 2008-01-14 11:04:43 -0800 (Mon, 14 Jan 2008) | 2 lines - fixed typo ................ r42776 | eric_niebler | 2008-01-14 12:26:58 -0800 (Mon, 14 Jan 2008) | 1 line add skip(), for specifying a skip regex ................ r42778 | turkanis | 2008-01-14 12:47:17 -0800 (Mon, 14 Jan 2008) | 1 line overhaul of dual_use filters: close() is now called just once; suppressed Borland/Dinkumware warnings in mapped_file.hpp ................ r42779 | niels_dekker | 2008-01-14 13:46:20 -0800 (Mon, 14 Jan 2008) | 1 line Minor "beautifications" of value_init documentation, inc. placing references in order of appearance ................ r42780 | lbourdev | 2008-01-14 14:06:07 -0800 (Mon, 14 Jan 2008) | 3 lines Changed size_t to std::size_t ................ r42781 | lbourdev | 2008-01-14 15:25:10 -0800 (Mon, 14 Jan 2008) | 3 lines GIL: Changing size_t to std::size_t ................ r42788 | eric_niebler | 2008-01-14 22:46:39 -0800 (Mon, 14 Jan 2008) | 1 line code clean-up, begin updating the transform section in proto's docs ................ r42789 | eric_niebler | 2008-01-14 23:46:51 -0800 (Mon, 14 Jan 2008) | 1 line try disabling iterator debugging for intel-win toolset ................ r42797 | t_schwinger | 2008-01-15 11:46:10 -0800 (Tue, 15 Jan 2008) | 3 lines adds missing #include ................ r42798 | niels_dekker | 2008-01-15 11:53:28 -0800 (Tue, 15 Jan 2008) | 1 line value_init doc + test: Added revision date. ................ r42801 | jurko | 2008-01-15 13:13:52 -0800 (Tue, 15 Jan 2008) | 1 line Minor stylistic comment changes. Removed trailing spaces. ................ r42804 | eric_niebler | 2008-01-15 14:06:51 -0800 (Tue, 15 Jan 2008) | 1 line document call<>, make<> and bind<> ................ r42807 | turkanis | 2008-01-15 14:54:40 -0800 (Tue, 15 Jan 2008) | 1 line rewrote treatment of result_of in terms of a new (hopefully temporary) config macro BOOST_IOSTREAMS_NO_RESULT_OF; fixed docs ................ r42811 | turkanis | 2008-01-15 17:14:04 -0800 (Tue, 15 Jan 2008) | 1 line reverted last change except for doc fixes; regression was result of test runner's local patch ................ r42813 | turkanis | 2008-01-15 17:16:36 -0800 (Tue, 15 Jan 2008) | 1 line botched last commit ................ r42814 | djenkins | 2008-01-15 22:39:34 -0800 (Tue, 15 Jan 2008) | 1 line missing include ................ r42815 | niels_dekker | 2008-01-16 01:35:12 -0800 (Wed, 16 Jan 2008) | 1 line Added convenience class initialized_value, as announced at http://article.gmane.org/gmane.comp.lib.boost.devel/169833 ................ r42816 | niels_dekker | 2008-01-16 01:37:25 -0800 (Wed, 16 Jan 2008) | 1 line Added test and documentation for convenience class initialized_value, that was added with changeset [42815] ................ r42817 | chris_kohlhoff | 2008-01-16 05:46:01 -0800 (Wed, 16 Jan 2008) | 2 lines Set the openssl callback function for getting a thread ID. ................ r42818 | anthonyw | 2008-01-16 07:23:36 -0800 (Wed, 16 Jan 2008) | 1 line Provide tss_cleanup_implemented as a dummy function on Windows CE to allow tests to run ................ r42821 | t_schwinger | 2008-01-16 11:16:37 -0800 (Wed, 16 Jan 2008) | 3 lines works around MSVC7.1 problems (hopefully) ................ r42822 | t_schwinger | 2008-01-16 11:17:09 -0800 (Wed, 16 Jan 2008) | 3 lines attempts to fix Borland regressions ................ r42823 | eric_niebler | 2008-01-16 11:24:33 -0800 (Wed, 16 Jan 2008) | 1 line document when<> and is_callable<> ................ r42825 | turkanis | 2008-01-16 12:46:56 -0800 (Wed, 16 Jan 2008) | 1 line replaced __IBMCPP__ with _AIX ................ r42827 | turkanis | 2008-01-16 16:50:14 -0800 (Wed, 16 Jan 2008) | 1 line added pgi to toolsets expected to fail seekawble_file_test (iostreams) ................ r42836 | eric_niebler | 2008-01-17 14:47:54 -0800 (Thu, 17 Jan 2008) | 1 line stl_iterator does better error handling ................ r42837 | jurko | 2008-01-17 17:14:17 -0800 (Thu, 17 Jan 2008) | 1 line Stylistic changes. Removed trailing spaces. Removed empty lines. Corrected comment typos and wording. ................ r42839 | eric_niebler | 2008-01-17 23:56:31 -0800 (Thu, 17 Jan 2008) | 1 line tweaks for better doxygen-ated output ................ r42840 | eric_niebler | 2008-01-17 23:56:59 -0800 (Thu, 17 Jan 2008) | 1 line updated reference section ................ r42841 | eric_niebler | 2008-01-17 23:58:48 -0800 (Thu, 17 Jan 2008) | 1 line add back reference section, document user-defined transforms ................ r42843 | t_schwinger | 2008-01-18 06:37:41 -0800 (Fri, 18 Jan 2008) | 3 lines makes member object support work with BCC ................ r42851 | johnmaddock | 2008-01-18 08:56:57 -0800 (Fri, 18 Jan 2008) | 1 line Add needed include. ................ r42852 | johnmaddock | 2008-01-18 09:05:35 -0800 (Fri, 18 Jan 2008) | 1 line We don't have a tr1::hash functor if the std lib is the Apache version. ................ r42853 | hkaiser | 2008-01-18 09:56:53 -0800 (Fri, 18 Jan 2008) | 1 line Wave: removed T_DEFINED token id from the library. ................ r42855 | johnmaddock | 2008-01-18 10:18:17 -0800 (Fri, 18 Jan 2008) | 1 line Needs to #include in order to use std::memset. ................ r42856 | danieljames | 2008-01-18 11:35:55 -0800 (Fri, 18 Jan 2008) | 2 lines Merge in some changes to the unordered tests. ................ r42857 | t_schwinger | 2008-01-18 12:05:56 -0800 (Fri, 18 Jan 2008) | 3 lines simplifies function_types markup ................ r42858 | t_schwinger | 2008-01-18 12:52:06 -0800 (Fri, 18 Jan 2008) | 3 lines attempts to fix BCB 5.9 regression in synthesis/mem_func_ptr_cv_ptr_to_this test ................ r42859 | t_schwinger | 2008-01-18 13:06:44 -0800 (Fri, 18 Jan 2008) | 3 lines attempts to fix pathscale failure ................ r42868 | niels_dekker | 2008-01-19 12:21:18 -0800 (Sat, 19 Jan 2008) | 1 line value_init_test now works around Borland 5.82 bug ("Error E2015: Ambiguity..." when using initialized_value), that is fixed with a newer compiler version ................ r42869 | niels_dekker | 2008-01-19 12:52:04 -0800 (Sat, 19 Jan 2008) | 1 line Removed local named variable from value_initialized::operator=, as Fernando Cacciola suggested me to avoid unnecessary named variables. ................ r42873 | bemandawes | 2008-01-19 18:01:35 -0800 (Sat, 19 Jan 2008) | 1 line Remove extraneous defines since they are inherited from library build Jamfile ................ r42877 | johnmaddock | 2008-01-20 01:42:35 -0800 (Sun, 20 Jan 2008) | 1 line Add include of for msvc. ................ r42878 | igaztanaga | 2008-01-20 03:54:47 -0800 (Sun, 20 Jan 2008) | 5 lines Updated Interprocess and Intrusive: -> Added linear slist to intrusive -> Updated all allocators to version 2 allocators in Interprocess -> Optimized rbtree_best_fit size overhead to 1 std:size_t. ................ r42881 | danieljames | 2008-01-20 09:37:21 -0800 (Sun, 20 Jan 2008) | 1 line Include to get std::bad_alloc. ................ r42882 | danieljames | 2008-01-20 10:55:57 -0800 (Sun, 20 Jan 2008) | 22 lines Merged revisions 42856-42881 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r42880 | danieljames | 2008-01-20 16:10:43 +0000 (Sun, 20 Jan 2008) | 17 lines Simplify the tests a little: Add a parameter to random_values to control what sort of values it generates. This means that instead of using equivalent_object to test collisions (which was a total hack) we now just need another parameter. This requires some meta programming to act differently for maps and sets. Because of this pairs no longer need to be generated so remove the code for doing that (which doesn't work on some compilers). Remove the generator object, just call generate directly. Remove some of the tests using int containers, they didn't really add to anthing other than the compile time (some tests are timing out). ........ ................ r42884 | jurko | 2008-01-20 12:18:50 -0800 (Sun, 20 Jan 2008) | 5 lines Minor stylistic changes: * Removed trailing spaces. * Added a comment for code discovering the user's home-directories. * Removed a stale regex import. * Removed an old corpse 'identity' rule found inside the __test__ rule. ................ r42890 | johnmaddock | 2008-01-21 01:41:17 -0800 (Mon, 21 Jan 2008) | 1 line Only disable wide character support for HP aCC: for gcc the logic is already taken care of in libstdcpp3.hpp. ................ r42897 | hkaiser | 2008-01-21 08:13:31 -0800 (Mon, 21 Jan 2008) | 1 line Removed a duplicate entry. ................ r42898 | rogeeff | 2008-01-21 09:02:53 -0800 (Mon, 21 Jan 2008) | 1 line changed output of booleans ................ r42899 | johnmaddock | 2008-01-21 10:11:09 -0800 (Mon, 21 Jan 2008) | 1 line Updated type traits library so that everything compiles with -Wall -pedantic with GCC. ................ r42904 | davedeakins | 2008-01-21 11:38:44 -0800 (Mon, 21 Jan 2008) | 1 line Don't include for WinCE (since WinCE does not have this header) ................ r42906 | eric_niebler | 2008-01-21 12:39:35 -0800 (Mon, 21 Jan 2008) | 1 line minor clean-up ................ r42909 | rogeeff | 2008-01-21 19:41:23 -0800 (Mon, 21 Jan 2008) | 1 line missing header ................ r42911 | igaztanaga | 2008-01-22 08:49:22 -0800 (Tue, 22 Jan 2008) | 1 line Refactor some allocation code and fix instantiation problem in 64 bit platforms ................ r42916 | eric_niebler | 2008-01-22 12:42:18 -0800 (Tue, 22 Jan 2008) | 1 line add concepts section to proto reference ................ r42917 | hljin | 2008-01-22 14:10:48 -0800 (Tue, 22 Jan 2008) | 1 line GIL: fixed the problem with std::hex by adding #include ................ r42918 | eric_niebler | 2008-01-22 18:23:15 -0800 (Tue, 22 Jan 2008) | 1 line proto works with boost 1.34.1 ................ r42929 | johnmaddock | 2008-01-23 08:08:44 -0800 (Wed, 23 Jan 2008) | 1 line Applies fix for issue #1598: added missing #include. ................ r42931 | igaztanaga | 2008-01-23 11:34:39 -0800 (Wed, 23 Jan 2008) | 1 line Ticket #1593: [interprocess] 'streamoff' : is not a member of 'std' ................ r42934 | andreas_huber69 | 2008-01-23 13:46:58 -0800 (Wed, 23 Jan 2008) | 1 line Fixes #1594 ................ r42935 | eric_niebler | 2008-01-23 13:57:47 -0800 (Wed, 23 Jan 2008) | 1 line fix dependency issue in Jamfile ................ r42938 | jano_gaspar | 2008-01-23 15:04:57 -0800 (Wed, 23 Jan 2008) | 1 line circular_buffer: updated documentation ................ r42939 | eric_niebler | 2008-01-23 15:25:24 -0800 (Wed, 23 Jan 2008) | 1 line fix quickbook scanner to recognize the [import ...] block ................ r42943 | danieljames | 2008-01-23 15:39:59 -0800 (Wed, 23 Jan 2008) | 60 lines Merged revisions 42882-42941 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ................ r42887 | danieljames | 2008-01-20 21:32:04 +0000 (Sun, 20 Jan 2008) | 10 lines Merged revisions 42590-42664,42667-42697,42699-42723,42725-42855,42857-42881 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r42881 | danieljames | 2008-01-20 17:37:21 +0000 (Sun, 20 Jan 2008) | 1 line Include to get std::bad_alloc. ........ ................ r42892 | danieljames | 2008-01-21 13:03:16 +0000 (Mon, 21 Jan 2008) | 1 line On some compilers the Rogue Wave/Apache stdcxx library doesn't have the normal std::distance, but instead has a variant that takes the result as the third parameter so it doesn't have to work out the type from the iterator. ................ r42893 | danieljames | 2008-01-21 13:07:58 +0000 (Mon, 21 Jan 2008) | 1 line Fix a typo in the last commit. ................ r42895 | danieljames | 2008-01-21 13:33:29 +0000 (Mon, 21 Jan 2008) | 1 line Remove tabs from the last checkin. ................ r42896 | danieljames | 2008-01-21 15:51:40 +0000 (Mon, 21 Jan 2008) | 1 line Use Boost config to tell when we have a std::distance function. Also, no need for a macro. ................ r42908 | danieljames | 2008-01-21 21:37:04 +0000 (Mon, 21 Jan 2008) | 1 line Use boost::long_long_type and boost::ulong_long_type. ................ r42921 | danieljames | 2008-01-23 11:43:35 +0000 (Wed, 23 Jan 2008) | 1 line Remove some tabs. ................ r42922 | danieljames | 2008-01-23 11:46:28 +0000 (Wed, 23 Jan 2008) | 2 lines Add missing include. Refs #1596 ................ r42923 | danieljames | 2008-01-23 11:52:47 +0000 (Wed, 23 Jan 2008) | 2 lines Always use void const* for the second parameter of allocate. Refs #1596. ................ r42936 | danieljames | 2008-01-23 22:22:16 +0000 (Wed, 23 Jan 2008) | 1 line Use Boost style library name in the documentation. ................ r42937 | danieljames | 2008-01-23 22:22:32 +0000 (Wed, 23 Jan 2008) | 1 line More tabs. ................ r42941 | danieljames | 2008-01-23 23:35:01 +0000 (Wed, 23 Jan 2008) | 1 line Fix all the allocators. ................ ................ r42948 | turkanis | 2008-01-23 22:50:32 -0800 (Wed, 23 Jan 2008) | 1 line merged changes from iostreams_dev, revisions 42825-42947 ................ r42950 | t_schwinger | 2008-01-24 10:56:27 -0800 (Thu, 24 Jan 2008) | 3 lines correctsbroken compiler support for MPL ................ r42951 | eric_niebler | 2008-01-24 13:06:23 -0800 (Thu, 24 Jan 2008) | 1 line peeker optimization looks inside independent sub-expressions ................ r42952 | nesotto | 2008-01-24 14:22:35 -0800 (Thu, 24 Jan 2008) | 1 line test of output iterators ................ r42953 | nesotto | 2008-01-24 14:26:36 -0800 (Thu, 24 Jan 2008) | 1 line output iterator test ................ r42954 | nesotto | 2008-01-24 14:27:27 -0800 (Thu, 24 Jan 2008) | 1 line output iterators for ptr_containers ................ r42957 | t_schwinger | 2008-01-24 16:26:16 -0800 (Thu, 24 Jan 2008) | 3 lines simplifies preprocessing code ................ r42958 | t_schwinger | 2008-01-24 16:28:15 -0800 (Thu, 24 Jan 2008) | 3 lines touched ................ r42960 | noel_belcourt | 2008-01-24 20:41:16 -0800 (Thu, 24 Jan 2008) | 6 lines Changed the -soname and -shared options in intel-darwin.jam to use -dynamiclib and -install_name, as done in darwin.jam. Apparently the Intel compilers on the Mac support the same options as gcc for setting the internal dynamic library name. ................ r42963 | nesotto | 2008-01-24 23:52:14 -0800 (Thu, 24 Jan 2008) | 1 line renaming ... ................ r42964 | nesotto | 2008-01-24 23:52:56 -0800 (Thu, 24 Jan 2008) | 1 line renaming ................ r42965 | nesotto | 2008-01-24 23:54:28 -0800 (Thu, 24 Jan 2008) | 1 line renaming ................ r42970 | turkanis | 2008-01-25 09:56:25 -0800 (Fri, 25 Jan 2008) | 1 line merged changes from iostreams_dev, revisions 42947-42962: fixed tickets 1003, 1139, 1140, 1149 ................ r42971 | noel_belcourt | 2008-01-25 11:52:47 -0800 (Fri, 25 Jan 2008) | 2 lines Fixed a typo to yesterdays patch. ................ r42972 | dgregor | 2008-01-25 13:07:14 -0800 (Fri, 25 Jan 2008) | 2 lines Include to get std::boolalpha. Fixes #1586 ................ r42974 | igaztanaga | 2008-01-25 15:07:51 -0800 (Fri, 25 Jan 2008) | 4 lines 1)Fixed gcc release mode warnings. 2)Replaced throw with BOOST_RETHROW when BOOST_TRY is used. 3)Fixed issues with singly linked lists ................ r42976 | hkaiser | 2008-01-25 17:24:21 -0800 (Fri, 25 Jan 2008) | 2 lines Wave: Fixed a problem in flex_string::compare() (#include_next was non-functional). ................ r42977 | hkaiser | 2008-01-25 17:36:20 -0800 (Fri, 25 Jan 2008) | 1 line Wave: Added new testcase. ................ r42980 | hkaiser | 2008-01-25 17:44:32 -0800 (Fri, 25 Jan 2008) | 1 line Wave: Tweaked new testcase. ................ r42982 | igaztanaga | 2008-01-26 03:52:25 -0800 (Sat, 26 Jan 2008) | 1 line Refactored common slist functions in a single class ................ r42984 | noel_belcourt | 2008-01-26 10:35:59 -0800 (Sat, 26 Jan 2008) | 7 lines Fixes #416 Fixed spelling of Jack Edmonds name and renamed files where necessary. Updated the documentation as well. Tested changes by building/running tests in libs/graph/test. ................ r42985 | noel_belcourt | 2008-01-26 10:51:28 -0800 (Sat, 26 Jan 2008) | 5 lines Fixes #640 Corrected the mpl push_front html documentation. ................ r42986 | eric_niebler | 2008-01-26 11:38:44 -0800 (Sat, 26 Jan 2008) | 1 line optimize repeated searches with patterns that have leading repeats ................ r42987 | t_schwinger | 2008-01-26 13:50:14 -0800 (Sat, 26 Jan 2008) | 3 lines attempts to allow some preprocessing with VACPP (IBM) ................ r42988 | noel_belcourt | 2008-01-26 14:21:57 -0800 (Sat, 26 Jan 2008) | 5 lines Fixes #1539 Fixed typo in the random documentation. ................ r42989 | noel_belcourt | 2008-01-26 15:06:24 -0800 (Sat, 26 Jan 2008) | 6 lines Fixes #965 Patched the XML and will check to ensure the html page reflects this change. ................ r42990 | eric_niebler | 2008-01-26 21:56:46 -0800 (Sat, 26 Jan 2008) | 1 line updated vcproj ................ r42991 | eric_niebler | 2008-01-26 21:57:08 -0800 (Sat, 26 Jan 2008) | 1 line fix typo ................ r42992 | johnmaddock | 2008-01-27 10:43:35 -0800 (Sun, 27 Jan 2008) | 1 line Extended leading repeat optimization to more cases. ................ r42997 | vladimir_prus | 2008-01-28 09:59:27 -0800 (Mon, 28 Jan 2008) | 1 line Correct speliing of --build-dir in --help output ................ r43000 | eric_niebler | 2008-01-28 12:03:41 -0800 (Mon, 28 Jan 2008) | 1 line update acknowledgement of john maddock ................ r43001 | bgubenko | 2008-01-28 13:27:13 -0800 (Mon, 28 Jan 2008) | 1 line marked 2 asio library tests for gcc-4.2.1_hpux_ia64 (HP-UX 11.23 with gcc) ................ r43002 | eric_niebler | 2008-01-28 14:55:30 -0800 (Mon, 28 Jan 2008) | 1 line doc more concepts, misc clean-up ................ r43003 | eric_niebler | 2008-01-28 14:56:46 -0800 (Mon, 28 Jan 2008) | 1 line proto doxygen comments, misc clean-up ................ r43006 | eric_niebler | 2008-01-28 18:20:45 -0800 (Mon, 28 Jan 2008) | 1 line more proto doxygen comments, update copyright ................ r43007 | vladimir_prus | 2008-01-28 22:28:09 -0800 (Mon, 28 Jan 2008) | 1 line Retain top-level boost-build.jam ................ r43008 | vladimir_prus | 2008-01-28 22:40:06 -0800 (Mon, 28 Jan 2008) | 4 lines Disable relinking when is either windows or cygwin. Fixes #1062. ................ r43009 | eric_niebler | 2008-01-28 23:03:03 -0800 (Mon, 28 Jan 2008) | 1 line add tests for deep_copy, make_expr, unpack_expr; fix bugs; update more copyrights ................ r43012 | djenkins | 2008-01-29 08:41:12 -0800 (Tue, 29 Jan 2008) | 1 line fix typo ................ r43013 | djenkins | 2008-01-29 08:43:51 -0800 (Tue, 29 Jan 2008) | 1 line update copyright and misc cleanup ................ r43014 | bgubenko | 2008-01-29 09:47:01 -0800 (Tue, 29 Jan 2008) | 1 line marked interprocess library unusable on gcc-4.2.1_hpux_ia64 (until it is ported to HP-UX platform) ................ r43016 | eric_niebler | 2008-01-29 13:02:52 -0800 (Tue, 29 Jan 2008) | 1 line make_expr and unpack_expr improvements, fix scary transform::arg_c bug ................ r43018 | djenkins | 2008-01-29 19:39:02 -0800 (Tue, 29 Jan 2008) | 1 line use skip directive to simplify example ................ r43023 | eric_niebler | 2008-01-30 14:10:13 -0800 (Wed, 30 Jan 2008) | 1 line finally, a make_expr() I can live with ................ r43024 | eric_niebler | 2008-01-30 14:26:34 -0800 (Wed, 30 Jan 2008) | 1 line regenerated boostbook reference ................ r43025 | niels_dekker | 2008-01-30 14:42:23 -0800 (Wed, 30 Jan 2008) | 1 line value_init: Removed aligned_storage::address() calls, to improve TR1 compatibility, as confirmed by John Maddock. Added internal helper function, wrapper_address(), as discussed with Fernando. ................ r43026 | eric_niebler | 2008-01-30 15:03:36 -0800 (Wed, 30 Jan 2008) | 1 line minor tweak to make_expr result_of return type calculation ................ r43031 | eric_niebler | 2008-01-30 23:36:28 -0800 (Wed, 30 Jan 2008) | 1 line simplify make_expr.hpp, user docs for make_expr() ................ r43035 | eric_niebler | 2008-01-31 10:44:17 -0800 (Thu, 31 Jan 2008) | 1 line minor tweak to fusion value_of and value_at for expressions, for better interop with proto::unpack_expr ................ r43037 | vladimir_prus | 2008-01-31 11:47:12 -0800 (Thu, 31 Jan 2008) | 1 line Build in MT mode (as long as wave links to boost.thread) ................ r43038 | hkaiser | 2008-01-31 12:57:47 -0800 (Thu, 31 Jan 2008) | 1 line Wave: fixed expanding_function_like_macro() ................ r43040 | eric_niebler | 2008-01-31 13:12:44 -0800 (Thu, 31 Jan 2008) | 1 line finish documentation for expression construction utilities ................ r43041 | hkaiser | 2008-01-31 14:33:43 -0800 (Thu, 31 Jan 2008) | 1 line Wave: Added additional configuration possibility to allow control threading support. ................ r43042 | hkaiser | 2008-01-31 14:48:56 -0800 (Thu, 31 Jan 2008) | 1 line Wave: Added additional configuration possibility to allow control threading support. Updated the documentation. ................ r43043 | jurko | 2008-01-31 16:27:31 -0800 (Thu, 31 Jan 2008) | 1 line Reverted changes made in rev 43038 which seem to have been committed by mistake and include some user specific settings in it local to the comitter's environment while this file is intended to be used as generic template for actual user-config.jam files and do nothing in case user does not specify his own settings there. ................ r43044 | jurko | 2008-01-31 16:44:23 -0800 (Thu, 31 Jan 2008) | 1 line Minor stylistic spacing changes. Remove trailing spaces. ................ r43045 | jurko | 2008-01-31 16:46:50 -0800 (Thu, 31 Jan 2008) | 1 line Corrected outputting native Windows paths so that it works correctly for absolute paths without the drive letter being explicitly specified, e.g. \aaa\bbb or /aaa/bbb. ................ r43046 | jurko | 2008-01-31 17:49:16 -0800 (Thu, 31 Jan 2008) | 1 line Added the missing end-of-line character when outputting DEBUG_SEARCH debug messages from file_build1(). This cleans up the -d+6 bjam output a lot. ................ r43050 | eric_niebler | 2008-02-01 12:30:29 -0800 (Fri, 01 Feb 2008) | 1 line add future group example ................ r43052 | noel_belcourt | 2008-02-01 18:41:23 -0800 (Fri, 01 Feb 2008) | 4 lines Fix a typo in pgi.jam that prevented shared libraries from being built correctly. ................ r43054 | chris_kohlhoff | 2008-02-02 03:37:45 -0800 (Sat, 02 Feb 2008) | 4 lines Ensure that the workaround for the MSVC secure iterator problem is only used when compiling with MSVC. The workaround causes g++'s library debug mode to report errors due to the assignment from a singular iterator. ................ r43055 | chris_kohlhoff | 2008-02-02 03:39:17 -0800 (Sat, 02 Feb 2008) | 2 lines Fix "possible loss of data" warning when building for Windows 2000 targets. ................ r43056 | chris_kohlhoff | 2008-02-02 04:02:23 -0800 (Sat, 02 Feb 2008) | 3 lines The latest Windows SDKs don't support IPv6 when building for Windows 2000, so we need to use the SDK emulation in that case. ................ r43057 | eric_niebler | 2008-02-02 04:27:16 -0800 (Sat, 02 Feb 2008) | 1 line port test to boost version 1.34.1 ................ r43061 | turkanis | 2008-02-02 14:10:46 -0800 (Sat, 02 Feb 2008) | 1 line merged changes from iostreams_dev, revisions 42962-43059: updated copyright notices ................ r43080 | eric_niebler | 2008-02-03 10:40:03 -0800 (Sun, 03 Feb 2008) | 1 line fix bug found by L. Evans re: fusion and stateful function objects ................ r43083 | johnmaddock | 2008-02-04 01:13:36 -0800 (Mon, 04 Feb 2008) | 1 line Added missing file. ................ r43085 | johnmaddock | 2008-02-04 01:17:35 -0800 (Mon, 04 Feb 2008) | 1 line Removed dead file. ................ r43087 | johnmaddock | 2008-02-04 01:20:46 -0800 (Mon, 04 Feb 2008) | 1 line Removed dead files. ................ r43089 | johnmaddock | 2008-02-04 01:23:28 -0800 (Mon, 04 Feb 2008) | 1 line Removed dead files. ................ r43094 | anthonyw | 2008-02-04 05:16:32 -0800 (Mon, 04 Feb 2008) | 1 line added test for duration overloads of timed_lock, and added missing implementation to win32 version ................ r43101 | hkaiser | 2008-02-04 11:21:46 -0800 (Mon, 04 Feb 2008) | 1 line Wave: trying to fix stdcxx_gcc regression. ................ r43103 | matias | 2008-02-04 13:01:06 -0800 (Mon, 04 Feb 2008) | 1 line hooking --> additional information in html docs ................ r43106 | eric_niebler | 2008-02-04 18:09:51 -0800 (Mon, 04 Feb 2008) | 1 line fleshing out evaluation.qbk, document transforms of if_, not_, and_ and or_ ................ r43107 | eric_niebler | 2008-02-04 21:33:12 -0800 (Mon, 04 Feb 2008) | 1 line eliminate warnings under msvc's -W4 ................ r43111 | eric_niebler | 2008-02-04 22:03:01 -0800 (Mon, 04 Feb 2008) | 1 line fix typo ................ r43112 | marshall | 2008-02-05 08:07:19 -0800 (Tue, 05 Feb 2008) | 1 line Fix typo (bug #1434) ................ r43113 | marshall | 2008-02-05 08:15:35 -0800 (Tue, 05 Feb 2008) | 1 line Applied patch (fixes bug #1307) ................ r43117 | dgregor | 2008-02-05 12:51:23 -0800 (Tue, 05 Feb 2008) | 1 line Fix add_vertex and add_vertices when the CSR graph has vertex properties ................ r43118 | danieljames | 2008-02-05 12:57:02 -0800 (Tue, 05 Feb 2008) | 13 lines Merged revisions 42942-43116 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r42975 | danieljames | 2008-01-26 00:29:32 +0000 (Sat, 26 Jan 2008) | 1 line Typedef some types before using them, to make life easier for Borland. ........ r43116 | danieljames | 2008-02-05 20:47:44 +0000 (Tue, 05 Feb 2008) | 1 line Some compilers and libraries combinations have problems with deques of non-assingable types. Using a list instead. ........ ................ r43120 | eric_niebler | 2008-02-05 13:07:31 -0800 (Tue, 05 Feb 2008) | 1 line add missing #include ................ r43121 | bemandawes | 2008-02-05 18:01:46 -0800 (Tue, 05 Feb 2008) | 1 line Add circular_buffer to the alphabetic list ................ r43125 | t_schwinger | 2008-02-06 05:00:08 -0800 (Wed, 06 Feb 2008) | 3 lines attempts to make synthesis metafunctions work with sun compiler ................ r43129 | danieljames | 2008-02-06 11:02:38 -0800 (Wed, 06 Feb 2008) | 2 lines In the boostbook navbar, link FAQ and people to the website. ................ r43130 | eric_niebler | 2008-02-06 11:57:51 -0800 (Wed, 06 Feb 2008) | 1 line untabify ................ r43132 | nesotto | 2008-02-06 14:46:19 -0800 (Wed, 06 Feb 2008) | 1 line cleanup to pass inspection report ................ r43133 | nesotto | 2008-02-06 14:46:31 -0800 (Wed, 06 Feb 2008) | 1 line cleanup to pass inspection report ................ r43134 | eric_niebler | 2008-02-06 14:57:57 -0800 (Wed, 06 Feb 2008) | 1 line add handy get() accessors on literal<> wrapper ................ r43135 | nesotto | 2008-02-06 15:12:21 -0800 (Wed, 06 Feb 2008) | 1 line cleanup to pass inspection tool ................ r43136 | eric_niebler | 2008-02-06 16:05:01 -0800 (Wed, 06 Feb 2008) | 1 line reasonably complete user docs for expression evaluation ................ r43138 | eric_niebler | 2008-02-07 00:06:29 -0800 (Thu, 07 Feb 2008) | 1 line tweaks for doxygen 1.5.4, document matches<> ................ r43141 | johnmaddock | 2008-02-07 01:55:41 -0800 (Thu, 07 Feb 2008) | 1 line Fix last checked version. ................ r43143 | johnmaddock | 2008-02-07 02:03:16 -0800 (Thu, 07 Feb 2008) | 1 line Remove tabs. ................ r43145 | johnmaddock | 2008-02-07 02:13:31 -0800 (Thu, 07 Feb 2008) | 1 line Fix min/max usage violation. ................ r43147 | vladimir_prus | 2008-02-07 02:17:03 -0800 (Thu, 07 Feb 2008) | 2 lines Attempt to unbreak ................ r43148 | johnmaddock | 2008-02-07 02:24:29 -0800 (Thu, 07 Feb 2008) | 1 line Added comment to suppress inspect warning. ................ r43150 | johnmaddock | 2008-02-07 02:29:59 -0800 (Thu, 07 Feb 2008) | 1 line Added fix for inspection report. ................ r43152 | vladimir_prus | 2008-02-07 03:04:30 -0800 (Thu, 07 Feb 2008) | 4 lines Fix with no path. Patch from Jon Olsson. ................ r43154 | bemandawes | 2008-02-07 05:22:34 -0800 (Thu, 07 Feb 2008) | 1 line Remove obsolete CVS scripts, add 1.35.0 SVN scripts, beginning of docs page ................ r43155 | nesotto | 2008-02-07 06:41:04 -0800 (Thu, 07 Feb 2008) | 6 lines iterator_range disables msvc warning 4996 [range] sub_range assignment issue ................ r43156 | nesotto | 2008-02-07 06:46:19 -0800 (Thu, 07 Feb 2008) | 1 line test ................ r43157 | joaquin | 2008-02-07 08:29:27 -0800 (Thu, 07 Feb 2008) | 1 line updated according to latest regression tests results, fixed a broken link, typo ................ r43159 | turkanis | 2008-02-07 09:07:28 -0800 (Thu, 07 Feb 2008) | 1 line added missing 'self.' qualification ................ r43165 | dgregor | 2008-02-07 13:08:09 -0800 (Thu, 07 Feb 2008) | 1 line Support for non-blocking MPI operations in Python, from Andreas Kloeckner ................ r43166 | dgregor | 2008-02-07 13:09:38 -0800 (Thu, 07 Feb 2008) | 1 line Note addition of nonblocking operations to the Python interface ................ r43171 | nesotto | 2008-02-08 01:58:35 -0800 (Fri, 08 Feb 2008) | 1 line silence of warnings for unused arguments ................ r43175 | nesotto | 2008-02-08 07:25:01 -0800 (Fri, 08 Feb 2008) | 1 line missing ) fixed ................ r43176 | noel_belcourt | 2008-02-08 08:32:35 -0800 (Fri, 08 Feb 2008) | 14 lines Force PPC Darwin to use fork instead of vfork. This change requires both the parent and child process to explicitly set the process group id. Vfork guarantees the child process runs to the exec before it releases the parent process. Now that we use fork instead of vfork, it's possible for the parent to wait on the child process without having the child setpgid on itself. This eliminates spurious hangs on ppc darwin caused by either a race condition between vfork and execvp, or a bug in the vfork implementation. Added a test to ensure we don't try to read from the stderr pipe descriptor if the descriptor's not valid. ................ r43177 | eric_niebler | 2008-02-08 09:11:57 -0800 (Fri, 08 Feb 2008) | 1 line reserve some c_type bits for dinkumware on windows, fixes #1625 ................ r43179 | noel_belcourt | 2008-02-08 09:53:50 -0800 (Fri, 08 Feb 2008) | 13 lines I've added the -single_module option to the intel-darwin.link.dll action to fix this linker error when linking dylibs: ld: common symbols not allowed with MH_DYLIB output format with the -multi_module option boost/bin.v2/libs/system/build/intel-darwin-9.1/debug/macosx-version-10.4/error_code.o definition of common __ZGVZNK5boost6system14error_category7messageEiE1s (size 16) boost/bin.v2/libs/system/build/intel-darwin-9.1/debug/macosx-version-10.4/error_code.o definition of common __ZZNK5boost6system14error_category7messageEiE1s (size 16) though I would note that the common symbols problem occurs in a number of other libraries (test, graph, spirit, ...) as well. ................ r43188 | danieljames | 2008-02-09 04:29:02 -0800 (Sat, 09 Feb 2008) | 2 lines Fix a link in the intrusive redirect. ................ r43189 | danieljames | 2008-02-09 04:37:00 -0800 (Sat, 09 Feb 2008) | 1 line Fix another redirect link. ................ r43190 | danieljames | 2008-02-09 04:38:19 -0800 (Sat, 09 Feb 2008) | 1 line Update link to Jamfile, to link to the version 2 jamfile. ................ r43191 | danieljames | 2008-02-09 04:39:06 -0800 (Sat, 09 Feb 2008) | 1 line Fix a link. ................ r43192 | danieljames | 2008-02-09 04:45:32 -0800 (Sat, 09 Feb 2008) | 2 lines Add a forwarding header for hash/custom.html as Boost.Bimap links to it. ................ r43193 | danieljames | 2008-02-09 05:02:45 -0800 (Sat, 09 Feb 2008) | 1 line Fix the link to the license. ................ r43199 | eric_niebler | 2008-02-09 12:32:27 -0800 (Sat, 09 Feb 2008) | 1 line more doxygen comments, const-correctness tweak for fusion::at() on proto expression ................ r43200 | eric_niebler | 2008-02-09 12:34:33 -0800 (Sat, 09 Feb 2008) | 1 line document how to access children of proto expressions ................ r43204 | eric_niebler | 2008-02-09 22:57:24 -0800 (Sat, 09 Feb 2008) | 1 line fix oops in proto fusion interface ................ r43205 | eric_niebler | 2008-02-09 23:02:54 -0800 (Sat, 09 Feb 2008) | 1 line suppress msvc warning ................ r43206 | danieljames | 2008-02-10 01:55:03 -0800 (Sun, 10 Feb 2008) | 1 line Fix some broken links. ................ r43207 | vladimir_prus | 2008-02-10 05:13:41 -0800 (Sun, 10 Feb 2008) | 4 lines Tolerate argc being zero. Patch from C. K. Jester-Young. ................ r43209 | danieljames | 2008-02-10 06:56:22 -0800 (Sun, 10 Feb 2008) | 1 line Link to people pages on the website, as they've been removed from the download. ................ r43210 | danieljames | 2008-02-10 07:02:17 -0800 (Sun, 10 Feb 2008) | 1 line Point links to the pages that used to be in 'more' to the site. ................ r43212 | danieljames | 2008-02-10 08:10:16 -0800 (Sun, 10 Feb 2008) | 1 line Fix links on the home page as well. ................ r43213 | danieljames | 2008-02-10 08:21:22 -0800 (Sun, 10 Feb 2008) | 1 line Generated documentation which is no longer generated. ................ r43220 | eric_niebler | 2008-02-10 19:48:41 -0800 (Sun, 10 Feb 2008) | 1 line include config.hpp and workaround.hpp before uses of BOOST_WORKAROUND and BOOST_MSVC ................ r43221 | chris_kohlhoff | 2008-02-11 05:59:44 -0800 (Mon, 11 Feb 2008) | 2 lines Need to define _XOPEN_SOURCE_EXTENDED when compiling for HP-UX. ................ r43226 | djenkins | 2008-02-11 12:49:19 -0800 (Mon, 11 Feb 2008) | 1 line cleanup using local<> and skip() ................ r43239 | turkanis | 2008-02-12 21:43:39 -0800 (Tue, 12 Feb 2008) | 1 line fixed return value of read(), to correctly handle eof ................ r43240 | turkanis | 2008-02-12 21:47:44 -0800 (Tue, 12 Feb 2008) | 1 line merged changes from iostreams_dev, revisions 43059-43238: better debug output for mapped file; fixed large_file_test.cpp under UNICODE on Windows ................ r43241 | turkanis | 2008-02-13 11:38:52 -0800 (Wed, 13 Feb 2008) | 1 line added markup for stdcxx failures (iostreams) ................ r43243 | turkanis | 2008-02-13 11:42:10 -0800 (Wed, 13 Feb 2008) | 1 line switched from to , for stdcxx (which is conforming in this case) ................ r43246 | matias | 2008-02-14 09:33:12 -0800 (Thu, 14 Feb 2008) | 1 line remove local admonitions ................ r43247 | matias | 2008-02-14 09:43:52 -0800 (Thu, 14 Feb 2008) | 1 line optional docs fixes ................ r43248 | matias | 2008-02-14 09:44:21 -0800 (Thu, 14 Feb 2008) | 1 line redirect optional docs to new version ................ r43251 | matias | 2008-02-14 10:08:16 -0800 (Thu, 14 Feb 2008) | 1 line conversion docs fixes ................ r43252 | matias | 2008-02-14 10:09:34 -0800 (Thu, 14 Feb 2008) | 1 line redirect to new conversion docs ................ r43253 | matias | 2008-02-14 10:19:34 -0800 (Thu, 14 Feb 2008) | 1 line redirect optional and numeric/conversion docs to new version ................ r43254 | matias | 2008-02-14 11:03:55 -0800 (Thu, 14 Feb 2008) | 1 line bimap doc fixes ................ r43255 | matias | 2008-02-14 11:05:04 -0800 (Thu, 14 Feb 2008) | 1 line fix tabs in files ................ r43256 | matias | 2008-02-14 11:22:15 -0800 (Thu, 14 Feb 2008) | 1 line fix tabs in files ................ r43260 | matias | 2008-02-14 13:24:11 -0800 (Thu, 14 Feb 2008) | 1 line add missing images ................ r43262 | hkaiser | 2008-02-14 14:01:54 -0800 (Thu, 14 Feb 2008) | 1 line Fixed a whitespace insertion glitch, where whitespace got inserted unconditionally between two operators even if one of these was a comma. ................ r43264 | hkaiser | 2008-02-14 15:52:33 -0800 (Thu, 14 Feb 2008) | 1 line Wave: More fixes to whitespace insertion engine. ................ r43266 | hkaiser | 2008-02-15 06:35:36 -0800 (Fri, 15 Feb 2008) | 1 line Wave: More fixes to whitespace insertion engine. ................ r43269 | pdimov | 2008-02-15 10:40:36 -0800 (Fri, 15 Feb 2008) | 1 line Added support for &&, || ................ r43272 | andreas_huber69 | 2008-02-16 02:13:08 -0800 (Sat, 16 Feb 2008) | 1 line Updated statechart markup ................ r43274 | andreas_huber69 | 2008-02-16 02:19:49 -0800 (Sat, 16 Feb 2008) | 2 lines Silenced GCC 4.0.1 warning (patch supplied by Euan) ................ r43280 | jurko | 2008-02-16 08:50:42 -0800 (Sat, 16 Feb 2008) | 1 line Corrected comments related to the allowed linker & linker-type values. Minor stylistic changes. ................ r43281 | jurko | 2008-02-16 08:53:33 -0800 (Sat, 16 Feb 2008) | 1 line Added support for compiling C++ programs without RTTI support using the gcc toolset. ................ r43282 | jurko | 2008-02-16 09:03:54 -0800 (Sat, 16 Feb 2008) | 1 line Made the msvc toolset always explicitly enable or disable rtti support based on the feature value instead of only setting it if on and depending on it being disabled by default. The original behaviour did not work well with msvc 8.0 for which there was not way to disable rtti support as that compiler enables rtti support by default. ................ r43283 | bemandawes | 2008-02-16 18:01:32 -0800 (Sat, 16 Feb 2008) | 1 line Show output of example program ................ r43290 | hkaiser | 2008-02-17 08:45:08 -0800 (Sun, 17 Feb 2008) | 1 line Wave: Extended a workaround to newest Intel compiler version (Linux V10.1) ................ r43292 | nesotto | 2008-02-17 08:49:38 -0800 (Sun, 17 Feb 2008) | 1 line support for comparinson operators ................ r43293 | nesotto | 2008-02-17 08:50:02 -0800 (Sun, 17 Feb 2008) | 1 line support for comparison operators ................ r43294 | hkaiser | 2008-02-17 09:00:20 -0800 (Sun, 17 Feb 2008) | 1 line Wave: Fixed test cases to reflect recent changes to whitespace insertion. ................ r43296 | eric_niebler | 2008-02-17 12:53:18 -0800 (Sun, 17 Feb 2008) | 1 line proto documentation improvements ................ r43299 | turkanis | 2008-02-17 21:48:13 -0800 (Sun, 17 Feb 2008) | 1 line merged changes from iostreams_dev, revisions 43243-43298: overhaul of category_of and close(): stringstream is now dual_seekable; standard file streams and string streams are closable; public Boost.Iostreams streams and streambufs are closable; close() pops filtering streams and streambufs ................ r43300 | eric_niebler | 2008-02-17 22:16:27 -0800 (Sun, 17 Feb 2008) | 1 line remove dependence on boost.lambda, make numeric function objects work with std binders ................ r43301 | chris_kohlhoff | 2008-02-18 05:31:26 -0800 (Mon, 18 Feb 2008) | 2 lines Fix printing of error messages. ................ r43302 | chris_kohlhoff | 2008-02-18 05:33:23 -0800 (Mon, 18 Feb 2008) | 2 lines Only define _XOPEN_SOURCE_EXTENDED when building with gcc on HP-UX. ................ r43303 | chris_kohlhoff | 2008-02-18 05:35:15 -0800 (Mon, 18 Feb 2008) | 3 lines Add missing #include of socket_types.hpp needed for the SSL unit tests to compile successfully on Windows. ................ r43306 | eric_niebler | 2008-02-18 10:29:29 -0800 (Mon, 18 Feb 2008) | 1 line remove post_construct docs, fix link to boost.parameter library ................ r43308 | niels_dekker | 2008-02-18 14:11:19 -0800 (Mon, 18 Feb 2008) | 1 line Fixed the assignment of value_initialized for T being a C-style array. (The previous version would trigger a compile error in this case.) ................ r43309 | niels_dekker | 2008-02-18 14:13:21 -0800 (Mon, 18 Feb 2008) | 1 line Tested the assignment of value_initialized, for T being a C-style array. Related to the fix of changeset [43308] ................ r43310 | eric_niebler | 2008-02-18 15:03:23 -0800 (Mon, 18 Feb 2008) | 1 line some doxygen comments for proto/traits.hpp ................ r43311 | eric_niebler | 2008-02-18 21:56:52 -0800 (Mon, 18 Feb 2008) | 1 line more proto documentation tweaks, remove unnecessary result_of::arg_c instantiation ................ r43312 | eric_niebler | 2008-02-18 23:14:37 -0800 (Mon, 18 Feb 2008) | 1 line fix droppable accumulators ................ r43314 | eric_niebler | 2008-02-18 23:33:30 -0800 (Mon, 18 Feb 2008) | 1 line darn, back out bad droppable changes ................ r43316 | pdimov | 2008-02-19 05:18:58 -0800 (Tue, 19 Feb 2008) | 1 line Fixes #1590. ................ r43317 | pdimov | 2008-02-19 06:01:13 -0800 (Tue, 19 Feb 2008) | 1 line Fixes #1444. ................ r43318 | pdimov | 2008-02-19 06:26:36 -0800 (Tue, 19 Feb 2008) | 1 line Fix #398, as long as the macros BOOST_NO_STD_TYPEINFO and BOOST_NO_IOSTREAM are defined. I don't know how Boost.Config needs to be changed to autodetect eVC4 and set these on its own. ................ r43319 | pdimov | 2008-02-19 06:51:10 -0800 (Tue, 19 Feb 2008) | 1 line Fix #1641. ................ r43320 | pdimov | 2008-02-19 06:59:28 -0800 (Tue, 19 Feb 2008) | 1 line Fix #1646. ................ r43321 | pdimov | 2008-02-19 07:09:10 -0800 (Tue, 19 Feb 2008) | 1 line Fix #1642. ................ r43322 | nesotto | 2008-02-19 07:10:05 -0800 (Tue, 19 Feb 2008) | 1 line fixed problem with operator()() when the value_type was abstract. ................ r43323 | pdimov | 2008-02-19 07:40:58 -0800 (Tue, 19 Feb 2008) | 1 line Fix #1643. ................ r43325 | turkanis | 2008-02-19 11:34:07 -0800 (Tue, 19 Feb 2008) | 1 line stringstreams are no longer closable; the semantics of close() for these devices was illconsidered ................ r43328 | turkanis | 2008-02-19 16:09:06 -0800 (Tue, 19 Feb 2008) | 1 line menu fix from iostreams_dev ................ r43329 | turkanis | 2008-02-19 19:20:17 -0800 (Tue, 19 Feb 2008) | 1 line markup for pgi-7.0 (iostreams) ................ r43330 | bemandawes | 2008-02-20 05:46:49 -0800 (Wed, 20 Feb 2008) | 1 line Add .z7 archive generation ................ r43332 | grafik | 2008-02-20 09:32:09 -0800 (Wed, 20 Feb 2008) | 1 line New readme page for now standalone release. ................ r43334 | grafik | 2008-02-20 11:15:16 -0800 (Wed, 20 Feb 2008) | 1 line Fix link to getting started docs. ................ r43335 | grafik | 2008-02-20 14:50:03 -0800 (Wed, 20 Feb 2008) | 1 line Add the to all requirements to allow other toolsets to use the currently configured python instead of relying on python being in the path. ................ r43336 | grafik | 2008-02-20 15:01:43 -0800 (Wed, 20 Feb 2008) | 1 line Use the configured python interpreter instead of assuming it's in the path. ................ r43337 | grafik | 2008-02-20 15:03:28 -0800 (Wed, 20 Feb 2008) | 1 line Add missing, and assumed, white background for screen rendering. ................ r43338 | grafik | 2008-02-20 15:26:58 -0800 (Wed, 20 Feb 2008) | 1 line Doc cleanups. ................ r43344 | eric_niebler | 2008-02-20 23:18:24 -0800 (Wed, 20 Feb 2008) | 1 line More Proto documentation ................ r43346 | johnmaddock | 2008-02-21 02:37:59 -0800 (Thu, 21 Feb 2008) | 3 lines Fix typo in example. Added links to PDF versions of the docs. Regenerated all the docs to fix people links. ................ r43347 | johnmaddock | 2008-02-21 03:53:59 -0800 (Thu, 21 Feb 2008) | 1 line Update main overview page. ................ r43349 | bemandawes | 2008-02-21 04:46:11 -0800 (Thu, 21 Feb 2008) | 1 line Fix typo; .z7 should be .7z ................ r43351 | johnmaddock | 2008-02-21 04:58:15 -0800 (Thu, 21 Feb 2008) | 1 line Added link to PDF docs, and regenerated. ................ r43354 | johnmaddock | 2008-02-21 05:51:18 -0800 (Thu, 21 Feb 2008) | 1 line Added link to PDF docs, and regenerated. ................ r43357 | johnmaddock | 2008-02-21 08:49:59 -0800 (Thu, 21 Feb 2008) | 1 line Added link to PDF docs. ................ r43359 | johnmaddock | 2008-02-21 09:01:26 -0800 (Thu, 21 Feb 2008) | 1 line Regenerated docs to fix links. ................ r43361 | bemandawes | 2008-02-21 12:11:32 -0800 (Thu, 21 Feb 2008) | 1 line Fix still another typo ................ r43362 | eric_niebler | 2008-02-21 12:12:02 -0800 (Thu, 21 Feb 2008) | 1 line doxygen comments for proto::when<> ................ r43363 | eric_niebler | 2008-02-21 16:42:12 -0800 (Thu, 21 Feb 2008) | 1 line fix crash when actions are in keep() expressions ................ r43364 | eric_niebler | 2008-02-21 18:01:46 -0800 (Thu, 21 Feb 2008) | 1 line doxygen comments ................ r43365 | grafik | 2008-02-21 21:26:39 -0800 (Thu, 21 Feb 2008) | 1 line Rename readme.html to index.html, and add forwarding index.htm for backward compatibility. ................ r43368 | danieljames | 2008-02-22 01:21:22 -0800 (Fri, 22 Feb 2008) | 2 lines Update the index.html link in the navbar. ................ r43371 | grafik | 2008-02-22 08:25:21 -0800 (Fri, 22 Feb 2008) | 1 line Remove obsolete getting started files. They where replaced by more/getting_started/*. ................ r43377 | chris_kohlhoff | 2008-02-22 14:43:54 -0800 (Fri, 22 Feb 2008) | 2 lines Use the correct vector of timer queues when dispatching timers. ................ r43390 | turkanis | 2008-02-22 16:05:49 -0800 (Fri, 22 Feb 2008) | 2 lines Ported change from iostreams_dev ................ r43391 | turkanis | 2008-02-22 16:06:24 -0800 (Fri, 22 Feb 2008) | 2 lines Ported changes from iostreams_dev ................ r43392 | turkanis | 2008-02-22 16:07:13 -0800 (Fri, 22 Feb 2008) | 1 line merged changes from iostreams_dev, revisions 43327-43389 ................ r43393 | turkanis | 2008-02-22 16:11:07 -0800 (Fri, 22 Feb 2008) | 1 line merged changes from iostreams_dev ................ r43395 | turkanis | 2008-02-22 22:07:59 -0800 (Fri, 22 Feb 2008) | 1 line updated to test close() on filtering streambufs ................ r43399 | turkanis | 2008-02-22 23:44:58 -0800 (Fri, 22 Feb 2008) | 1 line merged changes from iostreams_dev ................ r43402 | bemandawes | 2008-02-23 06:04:02 -0800 (Sat, 23 Feb 2008) | 1 line Give the 1st and 2nd level index.html files a common look-and-feel. ................ r43405 | vladimir_prus | 2008-02-24 04:59:04 -0800 (Sun, 24 Feb 2008) | 3 lines Recognize that fact, for that for intel-win, matters and should be added to the library name. ................ r43409 | bemandawes | 2008-02-24 16:53:26 -0800 (Sun, 24 Feb 2008) | 1 line Fix html boo boo ................ r43410 | schoepflin | 2008-02-25 00:37:10 -0800 (Mon, 25 Feb 2008) | 1 line Added missing template keyword. ................ r43411 | t_schwinger | 2008-02-25 03:45:51 -0800 (Mon, 25 Feb 2008) | 3 lines removes unnecessary escaping ................ r43412 | t_schwinger | 2008-02-25 03:47:59 -0800 (Mon, 25 Feb 2008) | 3 lines removes unnecessary comment ................ r43416 | hkaiser | 2008-02-26 11:25:05 -0800 (Tue, 26 Feb 2008) | 1 line Wave: Fixed expanding_function_like_macro preprocessing hook. ................ r43417 | danieljames | 2008-02-26 14:04:55 -0800 (Tue, 26 Feb 2008) | 2 lines Fix a link to Boost.Bimap. ................ r43418 | danieljames | 2008-02-26 14:07:25 -0800 (Tue, 26 Feb 2008) | 2 lines Change another link that's no longer in the repository to link to the website. ................ r43419 | hkaiser | 2008-02-26 14:36:36 -0800 (Tue, 26 Feb 2008) | 1 line Fixed a compilation problem on pathscale ................ r43421 | eric_niebler | 2008-02-27 10:48:22 -0800 (Wed, 27 Feb 2008) | 1 line partially revert breaking change to independent sub-expressions until I can make a proper fix ................ r43422 | danieljames | 2008-02-27 10:51:14 -0800 (Wed, 27 Feb 2008) | 1 line Fix broken copyright urls. Fixes #1573. ................ r43423 | danieljames | 2008-02-27 11:22:01 -0800 (Wed, 27 Feb 2008) | 1 line Fix incorrect links to copyright of the form 'http:#www.boost.org ................ r43424 | eric_niebler | 2008-02-27 11:39:43 -0800 (Wed, 27 Feb 2008) | 1 line fix bug in use_simple_repeat calculation ................ r43428 | eric_niebler | 2008-02-27 16:03:15 -0800 (Wed, 27 Feb 2008) | 1 line add test case for use_simple_repeat fix ................ r43433 | eric_niebler | 2008-02-28 14:47:12 -0800 (Thu, 28 Feb 2008) | 1 line fix oops ................ r43434 | johnmaddock | 2008-02-29 01:49:42 -0800 (Fri, 29 Feb 2008) | 1 line Apply fixes to issue #1658 which fixes some broken URL's. ................ r43435 | johnmaddock | 2008-02-29 01:58:30 -0800 (Fri, 29 Feb 2008) | 1 line Fix broken link as per report #1658. ................ r43437 | chris_kohlhoff | 2008-02-29 04:57:57 -0800 (Fri, 29 Feb 2008) | 2 lines Add missing tie(). ................ r43438 | schoepflin | 2008-02-29 07:13:41 -0800 (Fri, 29 Feb 2008) | 2 lines Added expected failure markup for the test weighted_tail_variate_means on Tru64/CXX. ................ r43441 | eric_niebler | 2008-03-01 11:32:56 -0800 (Sat, 01 Mar 2008) | 1 line add map_assign example ................ r43458 | turkanis | 2008-03-02 22:20:14 -0800 (Sun, 02 Mar 2008) | 1 line merged changes from iostreams_dev, revisions 43399-43457 ................ r43461 | anthonyw | 2008-03-03 00:44:42 -0800 (Mon, 03 Mar 2008) | 1 line Test and fix for issue #1665 ................ r43464 | anthonyw | 2008-03-03 02:52:44 -0800 (Mon, 03 Mar 2008) | 1 line thread constructor now accepts up to three additional arguments to pass to thread function ................ r43467 | danieljames | 2008-03-03 04:10:35 -0800 (Mon, 03 Mar 2008) | 2 lines Tell subversion that date_time.doc is a text file, not a word document. ................ r43468 | danieljames | 2008-03-03 04:11:25 -0800 (Mon, 03 Mar 2008) | 1 line Fix license link in date_time.doc ................ r43469 | chris_kohlhoff | 2008-03-03 05:21:05 -0800 (Mon, 03 Mar 2008) | 4 lines Disable use of CancelIo by default, due to the possibility of silent failure on some system configurations. Swallow error returned by CancelIoEx if there are no operations to be cancelled. ................ r43470 | chris_kohlhoff | 2008-03-03 05:27:06 -0800 (Mon, 03 Mar 2008) | 2 lines Add missing 'boost_' prefix to helper namespace. ................ r43471 | chris_kohlhoff | 2008-03-03 05:36:35 -0800 (Mon, 03 Mar 2008) | 2 lines Regenerate documentation. ................ r43472 | chris_kohlhoff | 2008-03-03 06:05:35 -0800 (Mon, 03 Mar 2008) | 1 line Update copyright notices. ................ r43473 | chris_kohlhoff | 2008-03-03 06:13:01 -0800 (Mon, 03 Mar 2008) | 2 lines Update copyright notices. ................ r43476 | eric_niebler | 2008-03-03 11:44:54 -0800 (Mon, 03 Mar 2008) | 1 line add Map Assign example to documentation ................ r43478 | eric_niebler | 2008-03-03 11:47:47 -0800 (Mon, 03 Mar 2008) | 1 line second attempt at fixing actions in independent expressions ................ r43484 | eric_niebler | 2008-03-03 15:48:17 -0800 (Mon, 03 Mar 2008) | 1 line handle static regexes with actions nested in dynamic independent subexpressions ................ r43485 | emildotchevski | 2008-03-03 17:41:17 -0800 (Mon, 03 Mar 2008) | 1 line boost exception ................ r43496 | eric_niebler | 2008-03-04 10:51:07 -0800 (Tue, 04 Mar 2008) | 1 line rename numeric::empty to numeric::default_, fixes #1650 ................ r43501 | eric_niebler | 2008-03-04 11:31:57 -0800 (Tue, 04 Mar 2008) | 1 line eliminate msvc level 4 warnings, fixes #1631 ................ r43502 | eric_niebler | 2008-03-04 11:42:36 -0800 (Tue, 04 Mar 2008) | 1 line add Dave Jenkin's evil static/dynamic actions in keep test case ................ r43503 | eric_niebler | 2008-03-04 13:09:47 -0800 (Tue, 04 Mar 2008) | 1 line work around msvc bug 331418, fixes #1652 ................ r43506 | eric_niebler | 2008-03-04 15:01:17 -0800 (Tue, 04 Mar 2008) | 1 line fix bad interaction between boyer-moore optimization and partial match feature, fixes #1564 ................ r43508 | eric_niebler | 2008-03-04 22:32:39 -0800 (Tue, 04 Mar 2008) | 1 line add BOOST_REVERSE_FOREACH, fixes #1071 ................ r43509 | eric_niebler | 2008-03-04 23:12:03 -0800 (Tue, 04 Mar 2008) | 1 line fix bug iterating over abstract base ................ [SVN r43519] --- cast.htm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cast.htm b/cast.htm index 587d08a..cb8add6 100644 --- a/cast.htm +++ b/cast.htm @@ -120,10 +120,10 @@ void f( Fruit * fruit ) {

    polymorphic_cast was suggested by Bjarne Stroustrup in "The C++ Programming Language".
    polymorphic_downcast was contributed by Dave Abrahams.
    + "http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams.
    An old numeric_cast
    that was contributed by Kevlin Henney is now superseeded by the Boost Numeric Conversion Library

    + "http://www.boost.org/people/kevlin_henney.htm">Kevlin Henney is now superseeded by the Boost Numeric Conversion Library


    Revised From 978c39d8881de10e95ee6d01edd505b3ae4fe429 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sat, 5 Apr 2008 18:00:00 +0000 Subject: [PATCH 057/138] post-review proto version [SVN r44061] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From 7df8ff783b0031f3b557746503c25e934712d64c Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Mon, 14 Apr 2008 05:45:24 +0000 Subject: [PATCH 058/138] really screwy merge trancking behavior, starting over [SVN r44394] From d394a0555641b3c265a3f1bdaf86a4d7a243f32c Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 17 Apr 2008 21:50:51 +0000 Subject: [PATCH 059/138] Merged revisions 44452,44472-44484,44486-44493,44495-44497,44499,44506-44507 via svnmerge from https://svn.boost.org/svn/boost/trunk ................ r44452 | johnmaddock | 2008-04-16 04:57:29 -0700 (Wed, 16 Apr 2008) | 1 line Reinstated real_cast to that STLPort tests can pass. ................ r44472 | emildotchevski | 2008-04-16 11:24:17 -0700 (Wed, 16 Apr 2008) | 1 line Added #define NOMINMAX to preserve standard behavior of std::min and std::max. Is including here necessary? ................ r44473 | emildotchevski | 2008-04-16 11:36:30 -0700 (Wed, 16 Apr 2008) | 1 line Reverting previous change... #define NOMINMAX isn't a good idea either. ................ r44474 | nasonov | 2008-04-16 14:13:25 -0700 (Wed, 16 Apr 2008) | 1 line Use make_unsigned and get rid of gcc warnings when -DBOOST_LEXICAL_CAST_ASSUME_C_LOCALE ................ r44475 | hkaiser | 2008-04-16 15:50:47 -0700 (Wed, 16 Apr 2008) | 1 line Spirit V2: started to address regression test failures ................ r44476 | emildotchevski | 2008-04-16 15:55:19 -0700 (Wed, 16 Apr 2008) | 1 line minor documentation fixes. ................ r44477 | hkaiser | 2008-04-16 15:56:15 -0700 (Wed, 16 Apr 2008) | 1 line Wave: fixed a newly introduced compilation error specific to certain platforms. ................ r44478 | hkaiser | 2008-04-16 16:17:24 -0700 (Wed, 16 Apr 2008) | 1 line Spirit V2: Fixed more regression problems. ................ r44479 | hkaiser | 2008-04-16 16:18:18 -0700 (Wed, 16 Apr 2008) | 1 line Wave: minor edits... ................ r44480 | jurko | 2008-04-16 17:20:33 -0700 (Wed, 16 Apr 2008) | 1 line Added a workaround for a compilation failure when including some Boost Serialization headers before some Boost Pool headers using MSVC 7.1 or 8.0. Source of the problem is a compiler bug fixed in MSVC 9.0 and workaround consists of referencing some Windows API identifiers using their fully qualified names. Added a related regression test for the Boost Pool library. See the test code comments for more detailed information on the bug. ................ r44481 | jurko | 2008-04-16 17:27:30 -0700 (Wed, 16 Apr 2008) | 1 line Corrected the documentation related to installing new internal property types. ................ r44482 | hkaiser | 2008-04-16 18:04:19 -0700 (Wed, 16 Apr 2008) | 1 line Wave: minor edits... ................ r44483 | hkaiser | 2008-04-16 18:56:25 -0700 (Wed, 16 Apr 2008) | 1 line Wave: Fixed slex test ................ r44484 | hkaiser | 2008-04-16 19:00:20 -0700 (Wed, 16 Apr 2008) | 2 lines Wave: Fixed slex test ................ r44486 | danieljames | 2008-04-17 00:34:15 -0700 (Thu, 17 Apr 2008) | 35 lines Movable unordered containers, full support only for compilers with rvalue references. Merged revisions 44076-44414 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r44076 | danieljames | 2008-04-06 20:41:19 +0100 (Sun, 06 Apr 2008) | 1 line Move semantics for compilers with rvalue references. ........ r44077 | danieljames | 2008-04-06 20:48:59 +0100 (Sun, 06 Apr 2008) | 1 line Do move assignment 'properly'. ........ r44085 | danieljames | 2008-04-06 22:46:04 +0100 (Sun, 06 Apr 2008) | 1 line Use normal references for the move members, reset the source buckets_ pointer to stop the buckets getting deleted, and remove a superflous pointer check. ........ r44109 | danieljames | 2008-04-07 23:49:36 +0100 (Mon, 07 Apr 2008) | 1 line Add missing tests. ........ r44366 | danieljames | 2008-04-13 12:59:46 +0100 (Sun, 13 Apr 2008) | 1 line Avoid using rvalue references in the implementation files. ........ r44368 | danieljames | 2008-04-13 15:13:33 +0100 (Sun, 13 Apr 2008) | 6 lines Use a cut down version of the work in progress move library to implement move semantics on more compilers. Unfortunately the move constructor with allocator isn't really practical at the moment, since in the case where the container can't be moved, and the allocators aren't equal it will copy the container twice. ........ ................ r44487 | danieljames | 2008-04-17 00:39:24 -0700 (Thu, 17 Apr 2008) | 13 lines Use Boost.Test's minimal test library for unordered & hash. It's closer to Boster.Test which makes it easier to switch to take advantage of Boost.Test's extra testing facilities. Merged revisions 44420 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r44420 | danieljames | 2008-04-14 19:02:03 +0100 (Mon, 14 Apr 2008) | 1 line Use Boost.Test's minimal test library. ........ ................ r44488 | danieljames | 2008-04-17 00:42:47 -0700 (Thu, 17 Apr 2008) | 19 lines A few tweaks for the unordered tests. Merged revisions 44461-44462,44466 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r44461 | danieljames | 2008-04-16 18:34:48 +0100 (Wed, 16 Apr 2008) | 2 lines Try to get some more tests working on Borland. ........ r44462 | danieljames | 2008-04-16 18:34:59 +0100 (Wed, 16 Apr 2008) | 2 lines Write out the number of copies when the unnecessary copy test fails. ........ r44466 | danieljames | 2008-04-16 18:35:44 +0100 (Wed, 16 Apr 2008) | 2 lines Add compile test for get_allocator. ........ ................ r44489 | danieljames | 2008-04-17 00:45:20 -0700 (Thu, 17 Apr 2008) | 36 lines Refactor the hash table implementation a little bit. Some of the changes are to make implementing emplace easier. Merged revisions 44458-44460,44463-44465 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r44458 | danieljames | 2008-04-16 18:31:35 +0100 (Wed, 16 Apr 2008) | 2 lines Pull out the buffered functions. ........ r44459 | danieljames | 2008-04-16 18:31:45 +0100 (Wed, 16 Apr 2008) | 4 lines Inline construct_node and create_node into copy_group - these used to be used in the implementation of insert but aren't now because of insert's exception requirements, so keeping them around was just confusing. ........ r44460 | danieljames | 2008-04-16 18:31:54 +0100 (Wed, 16 Apr 2008) | 4 lines Change link_node so that it takes a node_constructor containing a constructed node instead of a node - this makes the code a little cleaner and also simplifies exception safety. ........ r44463 | danieljames | 2008-04-16 18:35:11 +0100 (Wed, 16 Apr 2008) | 2 lines Explicitly name the different insert overloads. ........ r44464 | danieljames | 2008-04-16 18:35:22 +0100 (Wed, 16 Apr 2008) | 2 lines Explicitly name the different erase overloads. ........ r44465 | danieljames | 2008-04-16 18:35:33 +0100 (Wed, 16 Apr 2008) | 2 lines Call the erase methods in hash_table_data directly. ........ ................ r44490 | danieljames | 2008-04-17 00:49:45 -0700 (Thu, 17 Apr 2008) | 11 lines Fix an error on compilers without SFINAE. Merged revisions 44470 via svnmerge from https://svn.boost.org/svn/boost/branches/unordered/trunk ........ r44470 | danieljames | 2008-04-16 18:36:26 +0100 (Wed, 16 Apr 2008) | 2 lines Missing semi-colon. ........ ................ r44491 | djowel | 2008-04-17 02:01:51 -0700 (Thu, 17 Apr 2008) | 1 line char-sets ................ r44492 | djowel | 2008-04-17 02:02:03 -0700 (Thu, 17 Apr 2008) | 1 line char-sets ................ r44493 | djowel | 2008-04-17 02:44:31 -0700 (Thu, 17 Apr 2008) | 1 line fixed redundancy in namespace qi::detail::detail ................ r44495 | jurko | 2008-04-17 04:56:16 -0700 (Thu, 17 Apr 2008) | 1 line Removed an extra unused 'executed' feature attribute. ................ r44496 | hkaiser | 2008-04-17 05:22:33 -0700 (Thu, 17 Apr 2008) | 1 line Spirit V2: Fixed a gcc complaint ................ r44497 | hkaiser | 2008-04-17 05:29:18 -0700 (Thu, 17 Apr 2008) | 1 line Spirit V2: Fixed a gcc complaint ................ r44499 | fmhess | 2008-04-17 06:40:44 -0700 (Thu, 17 Apr 2008) | 3 lines Added another BOOST_ASSERT to enable_shared_from_this::_internal_accept_owner. ................ r44506 | johnmaddock | 2008-04-17 08:49:39 -0700 (Thu, 17 Apr 2008) | 1 line Change include so that it still works when Boost.TR1 is in the include path. ................ r44507 | johnmaddock | 2008-04-17 09:21:04 -0700 (Thu, 17 Apr 2008) | 1 line Try and fix the remaining Intel-Linux failures. ................ [SVN r44523] --- include/boost/lexical_cast.hpp | 58 +++++++++++----------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 44c7a66..a1276d6 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -461,36 +462,16 @@ namespace boost // C4146: unary minus operator applied to unsigned type, result still unsigned # pragma warning( disable : 4146 ) #endif - - inline unsigned int lcast_to_unsigned(int value) + template + inline + BOOST_DEDUCED_TYPENAME make_unsigned::type lcast_to_unsigned(T value) { - unsigned int uval = value; - return value < 0 ? -uval : uval; + typedef BOOST_DEDUCED_TYPENAME make_unsigned::type result_type; + result_type uvalue = static_cast(value); + return value < 0 ? -uvalue : uvalue; } - - inline unsigned long lcast_to_unsigned(long value) - { - unsigned long uval = value; - return value < 0 ? -uval : uval; - } - -#if defined(BOOST_HAS_LONG_LONG) - inline boost::ulong_long_type lcast_to_unsigned(boost::long_long_type v) - { - boost::ulong_long_type uval = v; - return v < 0 ? -uval : uval; - } -#elif defined(BOOST_HAS_MS_INT64) - inline unsigned __int64 lcast_to_unsigned(__int64 value) - { - unsigned __int64 uval = value; - return value < 0 ? -uval : uval; - } -#endif - #if (defined _MSC_VER) -# pragma warning( pop ) // C4146: unary minus operator applied to unsigned type, - // result still unsigned +# pragma warning( pop ) #endif } @@ -502,22 +483,14 @@ namespace boost #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); #endif - CharT thousands_sep = 0; -#ifdef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE - char const* grouping = ""; - std::size_t const grouping_size = 0; -#else +#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE std::locale loc; typedef std::numpunct numpunct; numpunct const& np = BOOST_USE_FACET(numpunct, loc); std::string const& grouping = np.grouping(); std::string::size_type const grouping_size = grouping.size(); - - if(grouping_size) - thousands_sep = np.thousands_sep(); -#endif - + CharT thousands_sep = grouping_size ? np.thousands_sep() : 0; std::string::size_type group = 0; // current group number char last_grp_size = grouping[0] <= 0 ? CHAR_MAX : grouping[0]; // a) Since grouping is const, grouping[grouping.size()] returns 0. @@ -526,14 +499,17 @@ namespace boost #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT(std::numeric_limits::digits10 < CHAR_MAX); #endif + + char left = last_grp_size; +#endif + typedef typename Traits::int_type int_type; CharT const czero = lcast_char_constants::zero; int_type const zero = Traits::to_int_type(czero); - char left = last_grp_size; - do { +#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE if(left == 0) { ++group; @@ -549,6 +525,8 @@ namespace boost } --left; +#endif + --finish; int_type const digit = static_cast(n % 10U); Traits::assign(*finish, Traits::to_char_type(zero + digit)); @@ -907,7 +885,7 @@ namespace boost inline bool lexical_stream_limited_src::operator<<( unsigned short n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(n, finish); return true; } From 5db4fabba75efc3a90e4d24d461c65965218320b Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 19 Apr 2008 14:48:18 +0000 Subject: [PATCH 060/138] Create a branch for documentation work. [SVN r44584] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From da2d8cd8df10e381e11883cc2261d5778643be6a Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 8 May 2008 21:41:48 +0000 Subject: [PATCH 061/138] merged from trunk [SVN r45230] --- include/boost/lexical_cast.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index a1276d6..fc3f742 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -30,6 +29,10 @@ #include #include +#ifndef BOOST_NO_STD_LOCALE +#include +#endif + #ifdef BOOST_NO_STRINGSTREAM #include #else @@ -485,6 +488,7 @@ namespace boost #endif #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE + // TODO: use BOOST_NO_STD_LOCALE std::locale loc; typedef std::numpunct numpunct; numpunct const& np = BOOST_USE_FACET(numpunct, loc); @@ -651,6 +655,7 @@ namespace boost #ifndef DISABLE_WIDE_CHAR_SUPPORT static void widen_and_assign(wchar_t* p, char ch) { + // TODO: use BOOST_NO_STD_LOCALE std::locale loc; wchar_t w = BOOST_USE_FACET(std::ctype, loc).widen(ch); Traits::assign(*p, w); From d0bac6af0ac0aab68f3ccb58d93b966c9afc8b49 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 28 May 2008 00:03:07 +0000 Subject: [PATCH 062/138] merged from trunk [SVN r45844] --- include/boost/lexical_cast.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index fc3f742..9fddb70 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,7 @@ #include #include #include +#include #ifndef BOOST_NO_STD_LOCALE #include @@ -49,6 +51,12 @@ namespace boost { // exception used to indicate runtime lexical_cast failure class bad_lexical_cast : public std::bad_cast + +#if defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, < 0x560 ) + // under bcc32 5.5.1 bad_cast doesn't derive from exception + , public std::exception +#endif + { public: bad_lexical_cast() : From cb4221abcca760fd8b63ed0e5ab37a004d3be582 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Thu, 19 Jun 2008 18:57:10 +0000 Subject: [PATCH 063/138] Branch at revision 46530 [SVN r46531] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From 379866271c0ad6b0c310d3a340a540dcc93b4f19 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 12 Jul 2008 09:06:42 +0000 Subject: [PATCH 064/138] Save state before 1.36 merges. [SVN r47337] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From 2ce20c872e49d0cfc85be1db56d17b47e12fdd86 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 7 Aug 2008 22:12:31 +0000 Subject: [PATCH 065/138] Fix link to numeric conversion library Merged revisions 48003 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r48003 | danieljames | 2008-08-06 16:28:17 +0100 (Wed, 06 Aug 2008) | 1 line Fix link to numeric conversion library. ........ [SVN r48026] --- cast.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cast.htm b/cast.htm index cb8add6..a1580c3 100644 --- a/cast.htm +++ b/cast.htm @@ -123,7 +123,7 @@ void f( Fruit * fruit ) { "http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams.
    An old numeric_cast
    that was contributed by Kevlin Henney is now superseeded by the Boost Numeric Conversion Library

    + "http://www.boost.org/people/kevlin_henney.htm">Kevlin Henney is now superseeded by the Boost Numeric Conversion Library


    Revised From 8fba6804dc40eab7bff46334a79945c220b9784c Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Fri, 8 Aug 2008 09:14:18 +0000 Subject: [PATCH 066/138] merged from trunk [SVN r48028] --- cast.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cast.htm b/cast.htm index cb8add6..a1580c3 100644 --- a/cast.htm +++ b/cast.htm @@ -123,7 +123,7 @@ void f( Fruit * fruit ) { "http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams.
    An old numeric_cast
    that was contributed by Kevlin Henney is now superseeded by the Boost Numeric Conversion Library

    + "http://www.boost.org/people/kevlin_henney.htm">Kevlin Henney is now superseeded by the Boost Numeric Conversion Library


    Revised From 9058a2472934d94af7a0bf72a8566f8d89705ecf Mon Sep 17 00:00:00 2001 From: Nicola Musatti Date: Sun, 28 Sep 2008 21:23:55 +0000 Subject: [PATCH 067/138] Merge from trunk [SVN r48991] --- lexical_cast.htm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lexical_cast.htm b/lexical_cast.htm index 6e38014..4bbdc8e 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -81,7 +81,7 @@ conversions, such as where precision or formatting need tighter control than is offered by the default behavior of lexical_cast, the conventional stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast + numeric to numeric, numeric_cast may offer more reasonable behavior than lexical_cast.

    For a good discussion of the options and issues involved in string-based @@ -213,9 +213,9 @@ Eliminate an overhead of std::locale if your program runs in the "C Lexical conversion to these types is simply reading a byte from source but since the source has more than one byte, the exception is thrown.

    Please use other integer types such as int or short int. If bounds checking - is important, you can also call numeric_cast: + is important, you can also call numeric_cast: -

    numeric_cast<int8_t>(lexical_cast<int>("127"));
    +
    numeric_cast<int8_t>(lexical_cast<int>("127"));

    Q: What does lexical_cast<std::string> of an int8_t or uint8_t not do what I expect?
    A: As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid this, cast to an integer type first: From 6202d68105cbbef105abca5a40ecf3d7de614e53 Mon Sep 17 00:00:00 2001 From: Nicola Musatti Date: Mon, 29 Sep 2008 21:48:52 +0000 Subject: [PATCH 068/138] CodeGear patch [SVN r49051] --- include/boost/lexical_cast.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 9fddb70..e23b082 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -472,6 +472,8 @@ namespace boost # pragma warning( push ) // C4146: unary minus operator applied to unsigned type, result still unsigned # pragma warning( disable : 4146 ) +#elif defined( __BORLANDC__ ) +# pragma option push -w-8041 #endif template inline @@ -483,6 +485,8 @@ namespace boost } #if (defined _MSC_VER) # pragma warning( pop ) +#elif defined( __BORLANDC__ ) +# pragma option pop #endif } From 3fb54557d29562dab14fd43f954a69f807a7150b Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Sun, 5 Oct 2008 01:47:33 +0000 Subject: [PATCH 069/138] merged from trunk [SVN r49133] --- lexical_cast.htm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lexical_cast.htm b/lexical_cast.htm index 6e38014..4bbdc8e 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -81,7 +81,7 @@ conversions, such as where precision or formatting need tighter control than is offered by the default behavior of lexical_cast, the conventional stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast + numeric to numeric, numeric_cast may offer more reasonable behavior than lexical_cast.

    For a good discussion of the options and issues involved in string-based @@ -213,9 +213,9 @@ Eliminate an overhead of std::locale if your program runs in the "C Lexical conversion to these types is simply reading a byte from source but since the source has more than one byte, the exception is thrown.

    Please use other integer types such as int or short int. If bounds checking - is important, you can also call numeric_cast: + is important, you can also call numeric_cast: -

    numeric_cast<int8_t>(lexical_cast<int>("127"));
    +
    numeric_cast<int8_t>(lexical_cast<int>("127"));

    Q: What does lexical_cast<std::string> of an int8_t or uint8_t not do what I expect?
    A: As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid this, cast to an integer type first: From 39329bc5b99a8c36d3c7bbb0c7ad7c207ffea4af Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 10 Oct 2008 09:29:21 +0000 Subject: [PATCH 070/138] Merge quickbook workaround and fix some links. Merged revisions 48987,49230-49231 via svnmerge from https://svn.boost.org/svn/boost/trunk ........ r48987 | danieljames | 2008-09-28 13:21:39 +0100 (Sun, 28 Sep 2008) | 1 line Clean up some link errors. ........ r49230 | danieljames | 2008-10-09 23:13:48 +0100 (Thu, 09 Oct 2008) | 1 line position_iterator is meant to be a forward iterator, so avoid using operator+ with it. ........ r49231 | danieljames | 2008-10-09 23:14:14 +0100 (Thu, 09 Oct 2008) | 4 lines Work around the problems with window newlines in position_iterator. (I'm about to fix them, but this will get quickbook working immediately). Fixes #2155 ........ [SVN r49242] --- lexical_cast.htm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lexical_cast.htm b/lexical_cast.htm index 2a08541..c9d37be 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -81,7 +81,7 @@ conversions, such as where precision or formatting need tighter control than is offered by the default behavior of lexical_cast, the conventional stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast + numeric to numeric, numeric_cast may offer more reasonable behavior than lexical_cast.

    For a good discussion of the options and issues involved in string-based @@ -202,9 +202,9 @@ public: Lexical conversion to these types is simply reading a byte from source but since the source has more than one byte, the exception is thrown.

    Please use other integer types such as int or short int. If bounds checking - is important, you can also call numeric_cast: + is important, you can also call numeric_cast: -

    numeric_cast<int8_t>(lexical_cast<int>("127"));
    +
    numeric_cast<int8_t>(lexical_cast<int>("127"));

    Q: What does lexical_cast<std::string> of an int8_t or uint8_t not do what I expect?
    A: As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid this, cast to an integer type first: From 0c54d6a0377ec91f724ae6f50eccc59cfdb40308 Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Mon, 13 Oct 2008 23:54:01 +0000 Subject: [PATCH 071/138] Merge lexical_cast from trunk r49262 [SVN r49325] --- include/boost/lexical_cast.hpp | 158 ++++++++++++++++----------------- 1 file changed, 77 insertions(+), 81 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 44c7a66..bc678fa 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -17,17 +17,23 @@ #include #include #include -#include #include #include +#include #include #include #include #include #include +#include #include #include #include +#include + +#ifndef BOOST_NO_STD_LOCALE +#include +#endif #ifdef BOOST_NO_STRINGSTREAM #include @@ -38,13 +44,19 @@ #if defined(BOOST_NO_STRINGSTREAM) || \ defined(BOOST_NO_STD_WSTRING) || \ defined(BOOST_NO_STD_LOCALE) -#define DISABLE_WIDE_CHAR_SUPPORT +#define BOOST_LCAST_NO_WCHAR_T #endif namespace boost { // exception used to indicate runtime lexical_cast failure class bad_lexical_cast : public std::bad_cast + +#if defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, < 0x560 ) + // under bcc32 5.5.1 bad_cast doesn't derive from exception + , public std::exception +#endif + { public: bad_lexical_cast() : @@ -94,7 +106,7 @@ namespace boost }; #endif -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T #ifndef BOOST_NO_INTRINSIC_WCHAR_T template<> struct stream_char @@ -219,7 +231,7 @@ namespace boost // lcast_src_length // lcast_src_length -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_src_length { @@ -258,7 +270,7 @@ namespace boost static void check_coverage() {} }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_src_length { @@ -289,7 +301,7 @@ namespace boost static void check_coverage() {} }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_src_length< wchar_t, std::basic_string > { @@ -327,34 +339,35 @@ namespace boost #endif }; -#define BOOST_AUX_LEXICAL_CAST_DEF1(CharT, T) template<> \ - struct lcast_src_length : lcast_src_length_integral \ +#define BOOST_LCAST_DEF1(CharT, T) \ + template<> struct lcast_src_length \ + : lcast_src_length_integral \ { static void check_coverage() {} }; -#ifdef DISABLE_WIDE_CHAR_SUPPORT -#define BOOST_AUX_LEXICAL_CAST_DEF(T) BOOST_AUX_LEXICAL_CAST_DEF1(char, T) +#ifdef BOOST_LCAST_NO_WCHAR_T +#define BOOST_LCAST_DEF(T) BOOST_LCAST_DEF1(char, T) #else -#define BOOST_AUX_LEXICAL_CAST_DEF(T) \ - BOOST_AUX_LEXICAL_CAST_DEF1(char, T) \ - BOOST_AUX_LEXICAL_CAST_DEF1(wchar_t, T) +#define BOOST_LCAST_DEF(T) \ + BOOST_LCAST_DEF1(char, T) \ + BOOST_LCAST_DEF1(wchar_t, T) #endif - BOOST_AUX_LEXICAL_CAST_DEF(short) - BOOST_AUX_LEXICAL_CAST_DEF(unsigned short) - BOOST_AUX_LEXICAL_CAST_DEF(int) - BOOST_AUX_LEXICAL_CAST_DEF(unsigned int) - BOOST_AUX_LEXICAL_CAST_DEF(long) - BOOST_AUX_LEXICAL_CAST_DEF(unsigned long) + BOOST_LCAST_DEF(short) + BOOST_LCAST_DEF(unsigned short) + BOOST_LCAST_DEF(int) + BOOST_LCAST_DEF(unsigned int) + BOOST_LCAST_DEF(long) + BOOST_LCAST_DEF(unsigned long) #if defined(BOOST_HAS_LONG_LONG) - BOOST_AUX_LEXICAL_CAST_DEF(boost::ulong_long_type) - BOOST_AUX_LEXICAL_CAST_DEF(boost::long_long_type ) + BOOST_LCAST_DEF(boost::ulong_long_type) + BOOST_LCAST_DEF(boost::long_long_type ) #elif defined(BOOST_HAS_MS_INT64) - BOOST_AUX_LEXICAL_CAST_DEF(unsigned __int64) - BOOST_AUX_LEXICAL_CAST_DEF( __int64) + BOOST_LCAST_DEF(unsigned __int64) + BOOST_LCAST_DEF( __int64) #endif -#undef BOOST_AUX_LEXICAL_CAST_DEF -#undef BOOST_AUX_LEXICAL_CAST_DEF1 +#undef BOOST_LCAST_DEF +#undef BOOST_LCAST_DEF1 #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION // Helper for floating point types. @@ -400,7 +413,7 @@ namespace boost static void check_coverage() {} }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_src_length : lcast_src_length_floating @@ -422,7 +435,7 @@ namespace boost static void check_coverage() {} }; -#endif // #ifndef DISABLE_WIDE_CHAR_SUPPORT +#endif // #ifndef BOOST_LCAST_NO_WCHAR_T #endif // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION } @@ -437,7 +450,7 @@ namespace boost BOOST_STATIC_CONSTANT(char, minus = '-'); }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_char_constants { @@ -460,37 +473,21 @@ namespace boost # pragma warning( push ) // C4146: unary minus operator applied to unsigned type, result still unsigned # pragma warning( disable : 4146 ) +#elif defined( __BORLANDC__ ) +# pragma option push -w-8041 #endif - - inline unsigned int lcast_to_unsigned(int value) + template + inline + BOOST_DEDUCED_TYPENAME make_unsigned::type lcast_to_unsigned(T value) { - unsigned int uval = value; - return value < 0 ? -uval : uval; + typedef BOOST_DEDUCED_TYPENAME make_unsigned::type result_type; + result_type uvalue = static_cast(value); + return value < 0 ? -uvalue : uvalue; } - - inline unsigned long lcast_to_unsigned(long value) - { - unsigned long uval = value; - return value < 0 ? -uval : uval; - } - -#if defined(BOOST_HAS_LONG_LONG) - inline boost::ulong_long_type lcast_to_unsigned(boost::long_long_type v) - { - boost::ulong_long_type uval = v; - return v < 0 ? -uval : uval; - } -#elif defined(BOOST_HAS_MS_INT64) - inline unsigned __int64 lcast_to_unsigned(__int64 value) - { - unsigned __int64 uval = value; - return value < 0 ? -uval : uval; - } -#endif - #if (defined _MSC_VER) -# pragma warning( pop ) // C4146: unary minus operator applied to unsigned type, - // result still unsigned +# pragma warning( pop ) +#elif defined( __BORLANDC__ ) +# pragma option pop #endif } @@ -502,22 +499,15 @@ namespace boost #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); #endif - CharT thousands_sep = 0; -#ifdef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE - char const* grouping = ""; - std::size_t const grouping_size = 0; -#else +#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE + // TODO: use BOOST_NO_STD_LOCALE std::locale loc; typedef std::numpunct numpunct; numpunct const& np = BOOST_USE_FACET(numpunct, loc); std::string const& grouping = np.grouping(); std::string::size_type const grouping_size = grouping.size(); - - if(grouping_size) - thousands_sep = np.thousands_sep(); -#endif - + CharT thousands_sep = grouping_size ? np.thousands_sep() : 0; std::string::size_type group = 0; // current group number char last_grp_size = grouping[0] <= 0 ? CHAR_MAX : grouping[0]; // a) Since grouping is const, grouping[grouping.size()] returns 0. @@ -526,14 +516,17 @@ namespace boost #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT(std::numeric_limits::digits10 < CHAR_MAX); #endif + + char left = last_grp_size; +#endif + typedef typename Traits::int_type int_type; CharT const czero = lcast_char_constants::zero; int_type const zero = Traits::to_int_type(czero); - char left = last_grp_size; - do { +#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE if(left == 0) { ++group; @@ -549,6 +542,8 @@ namespace boost } --left; +#endif + --finish; int_type const digit = static_cast(n % 10U); Traits::assign(*finish, Traits::to_char_type(zero + digit)); @@ -614,7 +609,7 @@ namespace boost stream.str().swap(output); return true; } - #ifndef DISABLE_WIDE_CHAR_SUPPORT + #ifndef BOOST_LCAST_NO_WCHAR_T bool operator>>(std::wstring &output) { stream.str().swap(output); @@ -670,9 +665,10 @@ namespace boost Traits::assign(*p, ch); } -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T static void widen_and_assign(wchar_t* p, char ch) { + // TODO: use BOOST_NO_STD_LOCALE std::locale loc; wchar_t w = BOOST_USE_FACET(std::ctype, loc).widen(ch); Traits::assign(*p, w); @@ -703,9 +699,9 @@ namespace boost public: - lexical_stream_limited_src(CharT* start, CharT* finish) - : start(start) - , finish(finish) + lexical_stream_limited_src(CharT* sta, CharT* fin) + : start(sta) + , finish(fin) {} public: // output @@ -720,7 +716,7 @@ namespace boost bool operator<<(bool); bool operator<<(char); -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) bool operator<<(wchar_t); #endif bool operator<<(CharT const*); @@ -785,7 +781,7 @@ namespace boost bool operator>>(std::string&); -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T bool operator>>(std::wstring&); #endif @@ -820,7 +816,7 @@ namespace boost return true; } -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) template inline bool lexical_stream_limited_src::operator<<( wchar_t ch) @@ -907,7 +903,7 @@ namespace boost inline bool lexical_stream_limited_src::operator<<( unsigned short n) { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + start = lcast_put_unsigned(n, finish); return true; } @@ -994,7 +990,7 @@ namespace boost return true; } -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template inline bool lexical_stream_limited_src::operator>>( std::wstring& str) @@ -1049,7 +1045,7 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = false); }; -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) template<> struct lcast_streambuf_for_target { @@ -1065,7 +1061,7 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = false); }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template struct lcast_streambuf_for_target< std::basic_string > @@ -1080,7 +1076,7 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = false); }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_streambuf_for_target { @@ -1201,5 +1197,5 @@ namespace boost // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#undef DISABLE_WIDE_CHAR_SUPPORT +#undef BOOST_LCAST_NO_WCHAR_T #endif From d8819d1b8e06eceed100984ce7b4afe03bbf0d41 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 22 Oct 2008 20:32:22 +0000 Subject: [PATCH 072/138] merged from trunk [SVN r49439] --- include/boost/lexical_cast.hpp | 85 ++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 9fddb70..bc678fa 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -44,7 +44,7 @@ #if defined(BOOST_NO_STRINGSTREAM) || \ defined(BOOST_NO_STD_WSTRING) || \ defined(BOOST_NO_STD_LOCALE) -#define DISABLE_WIDE_CHAR_SUPPORT +#define BOOST_LCAST_NO_WCHAR_T #endif namespace boost @@ -106,7 +106,7 @@ namespace boost }; #endif -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T #ifndef BOOST_NO_INTRINSIC_WCHAR_T template<> struct stream_char @@ -231,7 +231,7 @@ namespace boost // lcast_src_length // lcast_src_length -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_src_length { @@ -270,7 +270,7 @@ namespace boost static void check_coverage() {} }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_src_length { @@ -301,7 +301,7 @@ namespace boost static void check_coverage() {} }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_src_length< wchar_t, std::basic_string > { @@ -339,34 +339,35 @@ namespace boost #endif }; -#define BOOST_AUX_LEXICAL_CAST_DEF1(CharT, T) template<> \ - struct lcast_src_length : lcast_src_length_integral \ +#define BOOST_LCAST_DEF1(CharT, T) \ + template<> struct lcast_src_length \ + : lcast_src_length_integral \ { static void check_coverage() {} }; -#ifdef DISABLE_WIDE_CHAR_SUPPORT -#define BOOST_AUX_LEXICAL_CAST_DEF(T) BOOST_AUX_LEXICAL_CAST_DEF1(char, T) +#ifdef BOOST_LCAST_NO_WCHAR_T +#define BOOST_LCAST_DEF(T) BOOST_LCAST_DEF1(char, T) #else -#define BOOST_AUX_LEXICAL_CAST_DEF(T) \ - BOOST_AUX_LEXICAL_CAST_DEF1(char, T) \ - BOOST_AUX_LEXICAL_CAST_DEF1(wchar_t, T) +#define BOOST_LCAST_DEF(T) \ + BOOST_LCAST_DEF1(char, T) \ + BOOST_LCAST_DEF1(wchar_t, T) #endif - BOOST_AUX_LEXICAL_CAST_DEF(short) - BOOST_AUX_LEXICAL_CAST_DEF(unsigned short) - BOOST_AUX_LEXICAL_CAST_DEF(int) - BOOST_AUX_LEXICAL_CAST_DEF(unsigned int) - BOOST_AUX_LEXICAL_CAST_DEF(long) - BOOST_AUX_LEXICAL_CAST_DEF(unsigned long) + BOOST_LCAST_DEF(short) + BOOST_LCAST_DEF(unsigned short) + BOOST_LCAST_DEF(int) + BOOST_LCAST_DEF(unsigned int) + BOOST_LCAST_DEF(long) + BOOST_LCAST_DEF(unsigned long) #if defined(BOOST_HAS_LONG_LONG) - BOOST_AUX_LEXICAL_CAST_DEF(boost::ulong_long_type) - BOOST_AUX_LEXICAL_CAST_DEF(boost::long_long_type ) + BOOST_LCAST_DEF(boost::ulong_long_type) + BOOST_LCAST_DEF(boost::long_long_type ) #elif defined(BOOST_HAS_MS_INT64) - BOOST_AUX_LEXICAL_CAST_DEF(unsigned __int64) - BOOST_AUX_LEXICAL_CAST_DEF( __int64) + BOOST_LCAST_DEF(unsigned __int64) + BOOST_LCAST_DEF( __int64) #endif -#undef BOOST_AUX_LEXICAL_CAST_DEF -#undef BOOST_AUX_LEXICAL_CAST_DEF1 +#undef BOOST_LCAST_DEF +#undef BOOST_LCAST_DEF1 #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION // Helper for floating point types. @@ -412,7 +413,7 @@ namespace boost static void check_coverage() {} }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_src_length : lcast_src_length_floating @@ -434,7 +435,7 @@ namespace boost static void check_coverage() {} }; -#endif // #ifndef DISABLE_WIDE_CHAR_SUPPORT +#endif // #ifndef BOOST_LCAST_NO_WCHAR_T #endif // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION } @@ -449,7 +450,7 @@ namespace boost BOOST_STATIC_CONSTANT(char, minus = '-'); }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_char_constants { @@ -472,6 +473,8 @@ namespace boost # pragma warning( push ) // C4146: unary minus operator applied to unsigned type, result still unsigned # pragma warning( disable : 4146 ) +#elif defined( __BORLANDC__ ) +# pragma option push -w-8041 #endif template inline @@ -483,6 +486,8 @@ namespace boost } #if (defined _MSC_VER) # pragma warning( pop ) +#elif defined( __BORLANDC__ ) +# pragma option pop #endif } @@ -604,7 +609,7 @@ namespace boost stream.str().swap(output); return true; } - #ifndef DISABLE_WIDE_CHAR_SUPPORT + #ifndef BOOST_LCAST_NO_WCHAR_T bool operator>>(std::wstring &output) { stream.str().swap(output); @@ -660,7 +665,7 @@ namespace boost Traits::assign(*p, ch); } -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T static void widen_and_assign(wchar_t* p, char ch) { // TODO: use BOOST_NO_STD_LOCALE @@ -694,9 +699,9 @@ namespace boost public: - lexical_stream_limited_src(CharT* start, CharT* finish) - : start(start) - , finish(finish) + lexical_stream_limited_src(CharT* sta, CharT* fin) + : start(sta) + , finish(fin) {} public: // output @@ -711,7 +716,7 @@ namespace boost bool operator<<(bool); bool operator<<(char); -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) bool operator<<(wchar_t); #endif bool operator<<(CharT const*); @@ -776,7 +781,7 @@ namespace boost bool operator>>(std::string&); -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T bool operator>>(std::wstring&); #endif @@ -811,7 +816,7 @@ namespace boost return true; } -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) template inline bool lexical_stream_limited_src::operator<<( wchar_t ch) @@ -985,7 +990,7 @@ namespace boost return true; } -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template inline bool lexical_stream_limited_src::operator>>( std::wstring& str) @@ -1040,7 +1045,7 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = false); }; -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) template<> struct lcast_streambuf_for_target { @@ -1056,7 +1061,7 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = false); }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template struct lcast_streambuf_for_target< std::basic_string > @@ -1071,7 +1076,7 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = false); }; -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T template<> struct lcast_streambuf_for_target { @@ -1192,5 +1197,5 @@ namespace boost // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#undef DISABLE_WIDE_CHAR_SUPPORT +#undef BOOST_LCAST_NO_WCHAR_T #endif From c28088c912318fa444d647470d0bb360cdccb798 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 6 Nov 2008 00:15:47 +0000 Subject: [PATCH 073/138] merged from trunk [SVN r49607] --- CMakeLists.txt | 22 ++++++++++++++++++++++ test/CMakeLists.txt | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9006501 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +#---------------------------------------------------------------------------- +# This file was automatically generated from the original CMakeLists.txt file +# Add a variable to hold the headers for the library +set (lib_headers + +) + +# Add a library target to the build system +boost_library_project( + conversion + # SRCDIRS + TESTDIRS test + # HEADERS ${lib_headers} + # DOCDIRS + DESCRIPTION "Polymorphic and lexical casts" + # MODULARIZED + AUTHORS "David Abrahams " + "Kevlin Henney" + # MAINTAINERS +) + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..38fbbdd --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,12 @@ +boost_test_run(implicit_cast) +boost_test_compile_fail(implicit_cast_fail) +boost_test_run(cast_test ../cast_test.cpp) +boost_test_run(numeric_cast_test ../numeric_cast_test.cpp) +boost_test_run( + lexical_cast_test + ../lexical_cast_test.cpp + DEPENDS boost_unit_test_framework +) + + + From 98a67d93f3f1b253e22c743f82bd48df5107e1d1 Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Thu, 4 Dec 2008 23:18:50 +0000 Subject: [PATCH 074/138] Fixes #1220: lexical_cast requires RTTI [SVN r50124] --- include/boost/lexical_cast.hpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index bc678fa..0da0d3d 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -60,15 +60,21 @@ namespace boost { public: bad_lexical_cast() : - source(&typeid(void)), target(&typeid(void)) +#ifndef BOOST_NO_TYPEID + source(&typeid(void)), target(&typeid(void)) +#else + source(0), target(0) // this breaks getters +#endif { } + bad_lexical_cast( const std::type_info &source_type_arg, const std::type_info &target_type_arg) : source(&source_type_arg), target(&target_type_arg) { } + const std::type_info &source_type() const { return *source; @@ -77,6 +83,7 @@ namespace boost { return *target; } + virtual const char *what() const throw() { return "bad lexical cast: " @@ -1144,7 +1151,11 @@ namespace boost if (interpreter >> result) return result; } +#ifndef BOOST_NO_TYPEID throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); +#else + throw_exception(bad_lexical_cast()); +#endif return Target(); // normally never reached (throw_exception) } } @@ -1183,7 +1194,11 @@ namespace boost Target result; if(!(interpreter << arg && interpreter >> result)) +#ifndef BOOST_NO_TYPEID throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); +#else + throw_exception(bad_lexical_cast()); +#endif return result; } From fb681bb0eabdd75ee60eff434eb949cb6965890a Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 24 Jan 2009 18:57:20 +0000 Subject: [PATCH 075/138] merge of cmake build files from trunk per beman [SVN r50756] --- CMakeLists.txt | 22 ++++++++++++++++++++++ test/CMakeLists.txt | 14 ++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9006501 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +#---------------------------------------------------------------------------- +# This file was automatically generated from the original CMakeLists.txt file +# Add a variable to hold the headers for the library +set (lib_headers + +) + +# Add a library target to the build system +boost_library_project( + conversion + # SRCDIRS + TESTDIRS test + # HEADERS ${lib_headers} + # DOCDIRS + DESCRIPTION "Polymorphic and lexical casts" + # MODULARIZED + AUTHORS "David Abrahams " + "Kevlin Henney" + # MAINTAINERS +) + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..11227a8 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,14 @@ +boost_additional_test_dependencies(conversion BOOST_DEPENDS test detail numeric) + +boost_test_run(implicit_cast) +boost_test_compile_fail(implicit_cast_fail) +boost_test_run(cast_test ../cast_test.cpp) +boost_test_run(numeric_cast_test ../numeric_cast_test.cpp) +boost_test_run( + lexical_cast_test + ../lexical_cast_test.cpp + DEPENDS boost_unit_test_framework +) + + + From 528e4efa11e64f18b6854066ee7e655f8aab20b9 Mon Sep 17 00:00:00 2001 From: Sebastian Redl Date: Fri, 15 May 2009 15:15:42 +0000 Subject: [PATCH 076/138] Branch for big updates, so that I can have broken intermediate states. [SVN r53026] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From 3829ff5728858e2a22a2ce9a4fffe0008a20e95e Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 28 May 2009 17:15:17 +0000 Subject: [PATCH 077/138] Phoenix Reloaded [SVN r53348] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From a3e690da32118bc0cb720b8b2e9576adeb71baad Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Wed, 22 Jul 2009 21:51:01 +0000 Subject: [PATCH 078/138] Add basic copyright/license to keep cmake out of the inspection report [SVN r55095] --- CMakeLists.txt | 6 ++++++ test/CMakeLists.txt | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9006501..3badd19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# #---------------------------------------------------------------------------- # This file was automatically generated from the original CMakeLists.txt file # Add a variable to hold the headers for the library diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 11227a8..7b10f31 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# boost_additional_test_dependencies(conversion BOOST_DEPENDS test detail numeric) boost_test_run(implicit_cast) From 9e764f3e4920e37153cfb8299081ef92d20e68a5 Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Sat, 12 Sep 2009 22:11:01 +0000 Subject: [PATCH 079/138] [lexical_cast] Merge from trunk: r56158 (fix warning on MSVC warning level 4) and r53668 (avoid C style casts). [SVN r56159] --- include/boost/lexical_cast.hpp | 47 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 0da0d3d..094caec 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -47,6 +47,13 @@ #define BOOST_LCAST_NO_WCHAR_T #endif +#ifdef BOOST_NO_TYPEID +#define BOOST_LCAST_THROW_BAD_CAST(S, T) throw_exception(bad_lexical_cast()) +#else +#define BOOST_LCAST_THROW_BAD_CAST(Source, Target) \ + throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))) +#endif + namespace boost { // exception used to indicate runtime lexical_cast failure @@ -577,7 +584,7 @@ namespace boost lexical_stream(char_type* = 0, char_type* = 0) { stream.unsetf(std::ios::skipws); - lcast_set_precision(stream, (Source*)0, (Target*)0); + lcast_set_precision(stream, static_cast(0), static_cast(0) ); } ~lexical_stream() { @@ -694,7 +701,7 @@ namespace boost { this->setp(start, finish); std::basic_ostream stream(static_cast(this)); - lcast_set_precision(stream, (OutputStreamable*)0); + lcast_set_precision(stream, static_cast(0)); bool const result = !(stream << input).fail(); finish = this->pptr(); return result; @@ -764,7 +771,7 @@ namespace boost this->setg(start, start, finish); std::basic_istream stream(static_cast(this)); stream.unsetf(std::ios::skipws); - lcast_set_precision(stream, (InputStreamable*)0); + lcast_set_precision(stream, static_cast(0)); #if (defined _MSC_VER) # pragma warning( pop ) #endif @@ -1111,6 +1118,12 @@ namespace boost typedef const T * type; }; +#if (defined _MSC_VER) +# pragma warning( push ) +# pragma warning( disable : 4701 ) // possible use of ... before initialization +# pragma warning( disable : 4702 ) // unreachable code +#endif + template< typename Target , typename Source , bool Unlimited // string representation of Source is unlimited @@ -1136,28 +1149,14 @@ namespace boost , detail::lexical_stream_limited_src >::type interpreter(buf, buf + src_len); - // The original form, reproduced below, is more elegant - // but yields a spurious C4701 warning ("possible use of - // "result" before initialization") with VC7.1 (/W4). -// -// Target result; -// -// if(!(interpreter << arg && interpreter >> result)) -// throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); -// return result; - - if(interpreter << arg) { - Target result; - if (interpreter >> result) - return result; - } -#ifndef BOOST_NO_TYPEID - throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); -#else - throw_exception(bad_lexical_cast()); -#endif - return Target(); // normally never reached (throw_exception) + Target result; + if(!(interpreter << arg && interpreter >> result)) + BOOST_LCAST_THROW_BAD_CAST(Source, Target); + return result; } +#if (defined _MSC_VER) +# pragma warning( pop ) +#endif } template From 5055e842cffff200b2c5cf32185aecf898d5f633 Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Sat, 12 Sep 2009 22:24:35 +0000 Subject: [PATCH 080/138] Merge from trunk r56160 (Can't compile without header, boost::lexical_cast problem). [SVN r56161] --- include/boost/lexical_cast.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 094caec..d7d9052 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -41,9 +41,7 @@ #include #endif -#if defined(BOOST_NO_STRINGSTREAM) || \ - defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) #define BOOST_LCAST_NO_WCHAR_T #endif From 23949682c14858fcafd8851cb56674b897b5e506 Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Sun, 13 Sep 2009 15:03:52 +0000 Subject: [PATCH 081/138] [lexical_cast] Merge from trunk r56170 (#2295 Inconsistent behavior when using 64 bit integer types) and r56171 (Add a test for uintmax_t). [SVN r56172] --- lexical_cast_test.cpp | 48 +++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 04478e0..44b9b5f 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -21,6 +21,7 @@ #include +#include #include #include @@ -76,6 +77,8 @@ void test_conversion_from_to_int(); void test_conversion_from_to_uint(); void test_conversion_from_to_long(); void test_conversion_from_to_ulong(); +void test_conversion_from_to_intmax_t(); +void test_conversion_from_to_uintmax_t(); #ifdef LCAST_TEST_LONGLONG void test_conversion_from_to_longlong(); void test_conversion_from_to_ulonglong(); @@ -110,8 +113,10 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ushort)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_int)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uint)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulong)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_long)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulong)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_intmax_t)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uintmax_t)); #ifdef LCAST_TEST_LONGLONG suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong)); @@ -522,27 +527,38 @@ template void test_conversion_from_string_to_integral(CharT) { typedef std::numeric_limits limits; + typedef std::basic_string string_type; - T t; + string_type s; + string_type const zero = to_str(0); + string_type const nine = to_str(9); + T const min_val = (limits::min)(); + T const max_val = (limits::max)(); - t = (limits::min)(); - BOOST_CHECK(lexical_cast(to_str(t)) == t); + s = to_str(min_val); + BOOST_CHECK_EQUAL(lexical_cast(s), min_val); + if(limits::is_signed) + { + BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); + } - t = (limits::max)(); - BOOST_CHECK(lexical_cast(to_str(t)) == t); + s = to_str(max_val); + BOOST_CHECK_EQUAL(lexical_cast(s), max_val); + BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); if(limits::digits <= 16 && lcast_test_small_integral_types_completely) // min and max have already been tested. - for(t = 1 + (limits::min)(); t != (limits::max)(); ++t) + for(T t = 1 + min_val; t != max_val; ++t) BOOST_CHECK(lexical_cast(to_str(t)) == t); else { - T const min_val = (limits::min)(); - T const max_val = (limits::max)(); T const half_max_val = max_val / 2; T const cnt = lcast_integral_test_counter; // to supress warnings unsigned int const counter = cnt < half_max_val ? cnt : half_max_val; + T t; unsigned int i; // Test values around min: @@ -656,14 +672,24 @@ void test_conversion_from_to_uint() test_conversion_from_to_integral(); } +void test_conversion_from_to_long() +{ + test_conversion_from_to_integral(); +} + void test_conversion_from_to_ulong() { test_conversion_from_to_integral(); } -void test_conversion_from_to_long() +void test_conversion_from_to_intmax_t() { - test_conversion_from_to_integral(); + test_conversion_from_to_integral(); +} + +void test_conversion_from_to_uintmax_t() +{ + test_conversion_from_to_integral(); } #if defined(BOOST_HAS_LONG_LONG) From dc151d2b5a46e0d5a21a48b0caac27c0400e8c38 Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Tue, 15 Sep 2009 22:53:27 +0000 Subject: [PATCH 082/138] DISABLE_WIDE_CHAR_SUPPORT -> BOOST_LCAST_NO_WCHAR_T. [SVN r56227] --- lexical_cast_test.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 44b9b5f..81faa5c 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -28,12 +28,6 @@ #include #include -#if defined(BOOST_NO_STRINGSTREAM) || \ - defined(BOOST_NO_STD_WSTRING) || \ - defined(BOOST_NO_STD_LOCALE) -#define DISABLE_WIDE_CHAR_SUPPORT -#endif - #if (defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)) \ && !(defined(BOOST_MSVC) && BOOST_MSVC < 1300) #define LCAST_TEST_LONGLONG @@ -101,7 +95,7 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(test_conversion_from_to_wchar_t_alias)); suite->add(BOOST_TEST_CASE(test_conversion_to_pointer)); suite->add(BOOST_TEST_CASE(test_conversion_to_string)); - #ifndef DISABLE_WIDE_CHAR_SUPPORT + #ifndef BOOST_LCAST_NO_WCHAR_T suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t)); suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t)); suite->add(BOOST_TEST_CASE(test_conversion_from_wstring)); @@ -268,14 +262,14 @@ void test_conversion_from_to_wchar_t_alias() void test_conversion_to_pointer() { BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #ifndef DISABLE_WIDE_CHAR_SUPPORT + #ifndef BOOST_LCAST_NO_WCHAR_T BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); #endif } void test_conversion_from_wchar_t() { -#ifndef DISABLE_WIDE_CHAR_SUPPORT +#ifndef BOOST_LCAST_NO_WCHAR_T #if !defined(BOOST_NO_INTRINSIC_WCHAR_T) BOOST_CHECK_EQUAL(1, lexical_cast(L'1')); BOOST_CHECK_THROW(lexical_cast(L'A'), bad_lexical_cast); @@ -308,7 +302,7 @@ void test_conversion_from_wchar_t() void test_conversion_to_wchar_t() { -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) BOOST_CHECK_EQUAL(L'1', lexical_cast(1)); BOOST_CHECK_EQUAL(L'0', lexical_cast(0)); BOOST_CHECK_EQUAL(L'1', lexical_cast('1')); @@ -335,7 +329,7 @@ void test_conversion_to_wchar_t() void test_conversion_from_wstring() { - #ifndef DISABLE_WIDE_CHAR_SUPPORT + #ifndef BOOST_LCAST_NO_WCHAR_T BOOST_CHECK_EQUAL(123, lexical_cast(std::wstring(L"123"))); BOOST_CHECK_THROW( lexical_cast(std::wstring(L"")), bad_lexical_cast); @@ -353,7 +347,7 @@ void test_conversion_from_wstring() void test_conversion_to_wstring() { - #ifndef DISABLE_WIDE_CHAR_SUPPORT + #ifndef BOOST_LCAST_NO_WCHAR_T wchar_t buf[] = L"hello"; wchar_t* str = buf; BOOST_CHECK(str == lexical_cast(str)); @@ -593,7 +587,7 @@ void test_conversion_from_to_integral_for_locale() test_conversion_from_integral_to_integral(); test_conversion_from_integral_to_string('0'); test_conversion_from_string_to_integral('0'); -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) test_conversion_from_integral_to_string(L'0'); test_conversion_from_string_to_integral(L'0'); #endif @@ -614,7 +608,7 @@ void test_conversion_from_to_integral() test_conversion_from_integral_to_char(zero); test_conversion_from_integral_to_char(szero); test_conversion_from_integral_to_char(uzero); -#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) wchar_t const wzero = L'0'; test_conversion_from_integral_to_char(wzero); #endif From 65328d9716900a6ea18a8b1418745f222460b299 Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Tue, 15 Sep 2009 23:41:02 +0000 Subject: [PATCH 083/138] Add new test libs/conversion/test/lexical_cast_vc8_bug_test.cpp. [SVN r56230] --- lexical_cast_test.cpp | 20 ++++++++--- test/Jamfile.v2 | 1 + test/lexical_cast_vc8_bug_test.cpp | 53 ++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 test/lexical_cast_vc8_bug_test.cpp diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 81faa5c..b61db0d 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -533,14 +533,26 @@ void test_conversion_from_string_to_integral(CharT) BOOST_CHECK_EQUAL(lexical_cast(s), min_val); if(limits::is_signed) { - BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); +#if defined(BOOST_MSVC) && BOOST_MSVC == 1400 + // VC++ 8.0 bug, see libs/conversion/test/lexical_cast_vc8_bug_test.cpp + if(sizeof(T) < sizeof(boost::intmax_t)) +#endif + { + BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); + } } s = to_str(max_val); BOOST_CHECK_EQUAL(lexical_cast(s), max_val); - BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); +#if defined(BOOST_MSVC) && BOOST_MSVC == 1400 + // VC++ 8.0 bug, see libs/conversion/test/lexical_cast_vc8_bug_test.cpp + if(sizeof(T) != sizeof(boost::intmax_t)) +#endif + { + BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); + } if(limits::digits <= 16 && lcast_test_small_integral_types_completely) // min and max have already been tested. diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index af68510..1fea2fb 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -24,6 +24,7 @@ test-suite conversion [ run lexical_cast_loopback_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_abstract_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_noncopyable_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_vc8_bug_test.cpp ../../test/build//boost_unit_test_framework/static ] ; diff --git a/test/lexical_cast_vc8_bug_test.cpp b/test/lexical_cast_vc8_bug_test.cpp new file mode 100644 index 0000000..843bea8 --- /dev/null +++ b/test/lexical_cast_vc8_bug_test.cpp @@ -0,0 +1,53 @@ +#include +#include +#include +#include + +#include + +using namespace boost; + +// See also test_conversion_from_string_to_integral(CharT) +// in libs/conversion/lexical_cast_test.cpp +template +void test_too_long_number(CharT zero) +{ + typedef std::numeric_limits limits; + + std::basic_string s; + + std::basic_ostringstream o; + o << (limits::max)() << zero; + s = o.str(); + BOOST_CHECK_THROW(lexical_cast(s), bad_lexical_cast); + s[s.size()-1] += 9; // '0' -> '9' + BOOST_CHECK_THROW(lexical_cast(s), bad_lexical_cast); + + if(limits::is_signed) + { + std::basic_ostringstream o; + o << (limits::min)() << zero; + s = o.str(); + BOOST_CHECK_THROW(lexical_cast(s), bad_lexical_cast); + s[s.size()-1] += 9; // '0' -> '9' + BOOST_CHECK_THROW(lexical_cast(s), bad_lexical_cast); + } +} + +void test_vc8_bug() +{ + test_too_long_number('0'); + test_too_long_number('0'); +#if !defined(BOOST_LCAST_NO_WCHAR_T) + test_too_long_number(L'0'); + test_too_long_number(L'0'); +#endif +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test_framework::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast vc8 bug unit test"); + suite->add(BOOST_TEST_CASE(test_vc8_bug)); + return suite; +} From 04f73e5a89184ca13199c6e83a9ff5ca46591ac7 Mon Sep 17 00:00:00 2001 From: Alexander Nasonov Date: Tue, 15 Sep 2009 23:55:47 +0000 Subject: [PATCH 084/138] Decrease indent of #if and #endif lines and test string<->integral conversons when BOOST_NO_INTRINSIC_WCHAR_T is defined. [SVN r56231] --- lexical_cast_test.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index b61db0d..12e9deb 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -95,12 +95,12 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(test_conversion_from_to_wchar_t_alias)); suite->add(BOOST_TEST_CASE(test_conversion_to_pointer)); suite->add(BOOST_TEST_CASE(test_conversion_to_string)); - #ifndef BOOST_LCAST_NO_WCHAR_T +#ifndef BOOST_LCAST_NO_WCHAR_T suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t)); suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t)); suite->add(BOOST_TEST_CASE(test_conversion_from_wstring)); suite->add(BOOST_TEST_CASE(test_conversion_to_wstring)); - #endif +#endif suite->add(BOOST_TEST_CASE(test_bad_lexical_cast)); suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_short)); @@ -111,16 +111,16 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulong)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_intmax_t)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uintmax_t)); - #ifdef LCAST_TEST_LONGLONG +#ifdef LCAST_TEST_LONGLONG suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong)); - #endif - #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +#endif +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION suite->add(BOOST_TEST_CASE(&test_traits)); suite->add(BOOST_TEST_CASE(&test_wtraits)); suite->add(BOOST_TEST_CASE(&test_allocator)); suite->add(BOOST_TEST_CASE(&test_wallocator)); - #endif +#endif return suite; } @@ -262,9 +262,9 @@ void test_conversion_from_to_wchar_t_alias() void test_conversion_to_pointer() { BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #ifndef BOOST_LCAST_NO_WCHAR_T +#ifndef BOOST_LCAST_NO_WCHAR_T BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - #endif +#endif } void test_conversion_from_wchar_t() @@ -324,12 +324,12 @@ void test_conversion_to_wchar_t() lexical_cast(std::wstring(L"")), bad_lexical_cast); BOOST_CHECK_THROW( lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - #endif +#endif } void test_conversion_from_wstring() { - #ifndef BOOST_LCAST_NO_WCHAR_T +#ifndef BOOST_LCAST_NO_WCHAR_T BOOST_CHECK_EQUAL(123, lexical_cast(std::wstring(L"123"))); BOOST_CHECK_THROW( lexical_cast(std::wstring(L"")), bad_lexical_cast); @@ -342,12 +342,12 @@ void test_conversion_from_wstring() lexical_cast(std::wstring(L"")), bad_lexical_cast); BOOST_CHECK_THROW( lexical_cast(std::wstring(L"Test")), bad_lexical_cast); - #endif +#endif } void test_conversion_to_wstring() { - #ifndef BOOST_LCAST_NO_WCHAR_T +#ifndef BOOST_LCAST_NO_WCHAR_T wchar_t buf[] = L"hello"; wchar_t* str = buf; BOOST_CHECK(str == lexical_cast(str)); @@ -367,7 +367,7 @@ void test_conversion_to_wstring() BOOST_CHECK(L"Test" == lexical_cast(std::wstring(L"Test"))); BOOST_CHECK(L" " == lexical_cast(std::wstring(L" "))); BOOST_CHECK(L"" == lexical_cast(std::wstring(L""))); - #endif +#endif } void test_bad_lexical_cast() @@ -599,7 +599,7 @@ void test_conversion_from_to_integral_for_locale() test_conversion_from_integral_to_integral(); test_conversion_from_integral_to_string('0'); test_conversion_from_string_to_integral('0'); -#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) +#if !defined(BOOST_LCAST_NO_WCHAR_T) test_conversion_from_integral_to_string(L'0'); test_conversion_from_string_to_integral(L'0'); #endif From 5b6e39b2b84a8b8da7a497ed1f062d25ed52cb3f Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 17 Oct 2009 01:10:45 +0000 Subject: [PATCH 085/138] rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release. [SVN r56941] --- CMakeLists.txt | 28 ---------------------------- test/CMakeLists.txt | 20 -------------------- 2 files changed, 48 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 3badd19..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -#---------------------------------------------------------------------------- -# This file was automatically generated from the original CMakeLists.txt file -# Add a variable to hold the headers for the library -set (lib_headers - -) - -# Add a library target to the build system -boost_library_project( - conversion - # SRCDIRS - TESTDIRS test - # HEADERS ${lib_headers} - # DOCDIRS - DESCRIPTION "Polymorphic and lexical casts" - # MODULARIZED - AUTHORS "David Abrahams " - "Kevlin Henney" - # MAINTAINERS -) - - diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 7b10f31..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -boost_additional_test_dependencies(conversion BOOST_DEPENDS test detail numeric) - -boost_test_run(implicit_cast) -boost_test_compile_fail(implicit_cast_fail) -boost_test_run(cast_test ../cast_test.cpp) -boost_test_run(numeric_cast_test ../numeric_cast_test.cpp) -boost_test_run( - lexical_cast_test - ../lexical_cast_test.cpp - DEPENDS boost_unit_test_framework -) - - - From 21ab509eca64d76e8ebd8a387da3e0b319150af9 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 18 Nov 2009 14:58:26 +0000 Subject: [PATCH 086/138] Release 1.41.0 [SVN r57747] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From 257ab58a8d4d5768b0d364d35f8c766bcdbde6c5 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 19 Nov 2009 06:09:27 +0000 Subject: [PATCH 087/138] Create maintenance branch for 1.41. [SVN r57781] From b5583b88fa88bf4d9402e35d6d2d167ff1b393f9 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 14 Feb 2010 16:31:21 +0000 Subject: [PATCH 088/138] Merge some detail changes. - [53670] Avoid C style casts. - [55604] Fix #3346 boost/detail/scoped_enum_emulation.hpp enum_t conflict with Unix rpc/types.h - Don't foward declare containers when using gcc's parallel library and add a macro to disable forward declaration. Fixes #3866. [SVN r59679] --- include/boost/detail/lcast_precision.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/detail/lcast_precision.hpp b/include/boost/detail/lcast_precision.hpp index d40ca21..93abce1 100644 --- a/include/boost/detail/lcast_precision.hpp +++ b/include/boost/detail/lcast_precision.hpp @@ -173,8 +173,8 @@ inline void lcast_set_precision(std::ios_base& stream, T*) template inline void lcast_set_precision(std::ios_base& stream, Source*, Target*) { - std::streamsize const s = lcast_get_precision((Source*)0); - std::streamsize const t = lcast_get_precision((Target*)0); + std::streamsize const s = lcast_get_precision(static_cast(0)); + std::streamsize const t = lcast_get_precision(static_cast(0)); stream.precision(s > t ? s : t); } From 8cf6f553544ccc532a1d1ad82bda18771d947755 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Sun, 28 Feb 2010 19:19:07 +0000 Subject: [PATCH 089/138] Create a branch for autoprefixing [SVN r59996] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From 942057aa79d643c142a8befeada674515eb5084e Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 21 Jan 2011 09:17:08 +0000 Subject: [PATCH 090/138] Branch to work on filename handling without disturbing trunk. [SVN r68345] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From cf5989e7796d274b2bbf323de8337f60b467cbfd Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 27 Mar 2011 10:17:05 +0000 Subject: [PATCH 091/138] Quickbook: New branch for development. From now on this will be my development branch. [SVN r70613] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From 701d5f0bf0cf0236d6e5ded5253b0526ff8ec01c Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Fri, 13 May 2011 17:44:51 +0000 Subject: [PATCH 092/138] Merged from trunk revision 71922. Most part of this modifications of lexical_cast library were made and successfully tested during the year 2009. Later commits affected only documentation bugs. [SVN r71923] --- include/boost/lexical_cast.hpp | 24 +++++----- lexical_cast.htm | 84 ++++++++++++++++++++++++++-------- lexical_cast_test.cpp | 7 +++ 3 files changed, 86 insertions(+), 29 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index d7d9052..fdc5898 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -55,7 +55,13 @@ namespace boost { // exception used to indicate runtime lexical_cast failure - class bad_lexical_cast : public std::bad_cast + class bad_lexical_cast : + // workaround MSVC bug with std::bad_cast when _HAS_EXCEPTIONS == 0 +#if defined(BOOST_MSVC) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS + public std::exception +#else + public std::bad_cast +#endif #if defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, < 0x560 ) // under bcc32 5.5.1 bad_cast doesn't derive from exception @@ -521,11 +527,10 @@ namespace boost std::string::size_type const grouping_size = grouping.size(); CharT thousands_sep = grouping_size ? np.thousands_sep() : 0; std::string::size_type group = 0; // current group number - char last_grp_size = grouping[0] <= 0 ? CHAR_MAX : grouping[0]; - // a) Since grouping is const, grouping[grouping.size()] returns 0. - // b) It's safe to assume here and below that CHAR_MAX - // is equivalent to unlimited grouping: + char last_grp_size = + grouping_size == 0 || grouping[0] <= 0 ? CHAR_MAX : grouping[0]; #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + // Check that ulimited group is unreachable: BOOST_STATIC_ASSERT(std::numeric_limits::digits10 < CHAR_MAX); #endif @@ -1120,6 +1125,7 @@ namespace boost # pragma warning( push ) # pragma warning( disable : 4701 ) // possible use of ... before initialization # pragma warning( disable : 4702 ) // unreachable code +# pragma warning( disable : 4267 ) // conversion from 'size_t' to 'unsigned int' #endif template< typename Target @@ -1149,7 +1155,7 @@ namespace boost Target result; if(!(interpreter << arg && interpreter >> result)) - BOOST_LCAST_THROW_BAD_CAST(Source, Target); + BOOST_LCAST_THROW_BAD_CAST(Source, Target); return result; } #if (defined _MSC_VER) @@ -1191,11 +1197,7 @@ namespace boost Target result; if(!(interpreter << arg && interpreter >> result)) -#ifndef BOOST_NO_TYPEID - throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); -#else - throw_exception(bad_lexical_cast()); -#endif + BOOST_LCAST_THROW_BAD_CAST(Source, Target); return result; } diff --git a/lexical_cast.htm b/lexical_cast.htm index c9d37be..5457a33 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -194,32 +194,74 @@ public:

    Exception used to indicate runtime lexical_cast failure. -
    -

    Frequently Asked Questions

    -

    Q: Why does lexical_cast<int8_t>("127") throw bad_lexical_cast? -
    A: The type int8_t is a typedef to char or signed char. +


    + + + +

    Frequently Asked Questions

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Question:Why does lexical_cast<int8_t>("127") throw bad_lexical_cast?
    Answer:The type int8_t is a typedef to char or signed char. Lexical conversion to these types is simply reading a byte from source but since the source has more than one byte, the exception is thrown. -

    Please use other integer types such as int or short int. If bounds checking + Please use other integer types such as int or short int. If bounds checking is important, you can also call numeric_cast: -

    numeric_cast<int8_t>(lexical_cast<int>("127"));
    +
    Question:What does lexical_cast<std::string> of an int8_t or uint8_t not do what I expect?
    Answer:As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid this, cast to an integer type first: +
    lexical_cast<std::string>(static_cast<int>(n));
    +
    Question:The implementation always resets the ios_base::skipws flag of an underlying stream object. It breaks my operator>> that works only in presence of this flag. Can you remove code that resets the flag?
    Answer:May be in a future version. There is no requirement in [N1973] to reset the flag but remember that [N1973] is not yet accepted by the committee. By the way, it's a great opportunity to make your operator>> conform to the standard. Read a good C++ book, study std::sentry and ios_state_saver. +
    Question:Why std::cout << boost::lexical_cast<unsigned int>("-1"); does not throw, but outputs 4294967295?
    Answer:boost::lexical_cast has the behavior of stringstream, which uses num_get functions of std::locale to convert numbers. If we look at the [22.2.2.1.2] of Programming languages — C++, we'll see, that num_get uses the rules of scanf for conversions. And in the C99 standard for unsigned input value minus sign is optional, so if a negative number is read, no errors will arise and the result will be the two's complement. +
    -

    Q: What does lexical_cast<std::string> of an int8_t or uint8_t not do what I expect? -
    A: As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid this, cast to an integer type first: - -

    lexical_cast<std::string>(static_cast<int>(n));
    - -

    Q: The implementation always resets the ios_base::skipws flag of an underlying stream object. It breaks my operator>> that works only in presence of this flag. Can you remove code that resets the flag? -
    A: May be in a future version. There is no requirement in [N1973] to reset the flag but remember that [N1973] is not yet accepted by the committee. By the way, it's a great opportunity to make your operator>> conform to the standard. Read a good C++ book, study std::sentry and ios_state_saver. - -

    References

    +

    References

      -
    • [N1973] Kevlin Henney, Beman Dawes, Lexical Conversion Library Proposal for TR2, +
    • [N1973] Kevlin Henney, Beman Dawes, Lexical Conversion Library Proposal for TR2, N1973.
    • [Tuning] Alexander Nasonov, Fine Tuning for lexical_cast, - Overload #74, + Overload #74 (PDF), August 2006.

    Changes

    @@ -265,6 +307,12 @@ public:


    -
    © Copyright Kevlin Henney, 2000–2005
    +
    Copyright © Kevlin Henney, 2000-2005
    +
    Copyright © Alexander Nasonov, 2006-2010
    +
    Copyright © Antony Polukhin, 2011
    +
    + 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) +
    diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 12e9deb..a994d13 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -11,6 +11,13 @@ // // Note: The unit test no longer compile on MSVC 6, but lexical_cast itself works for it. +// +// We need this #define before any #includes: otherwise msvc will emit warnings +// deep within std::string, resulting from our (perfectly legal) use of basic_string +// with a custom traits class: +// +#define _SCL_SECURE_NO_WARNINGS + #include #if defined(__INTEL_COMPILER) From a385c3ec99d99c2376b916c6f67f8e5070f0411d Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 26 May 2011 16:27:53 +0000 Subject: [PATCH 093/138] Merge from trunk: r72184 (a lot of optimizations, new tests, fix inspection warnings). [SVN r72185] --- include/boost/lexical_cast.hpp | 561 +++++++++++++++++++++++++++-- lexical_cast.htm | 8 +- lexical_cast_test.cpp | 163 ++++++++- test/lexical_cast_vc8_bug_test.cpp | 14 + 4 files changed, 702 insertions(+), 44 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index fdc5898..6875b16 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -11,8 +11,8 @@ // enhanced with contributions from Terje Slettebo, // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, -// Alexander Nasonov and other Boosters -// when: November 2000, March 2003, June 2005, June 2006 +// Alexander Nasonov, Antony Polukhin and other Boosters +// when: November 2000, March 2003, June 2005, June 2006, March 2011 #include #include @@ -20,12 +20,18 @@ #include #include #include +#include #include #include #include #include #include +#include +#include +#include +#include #include +#include #include #include #include @@ -457,7 +463,7 @@ namespace boost #endif // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION } - namespace detail // '0' and '-' constants + namespace detail // '0', '+' and '-' constants { template struct lcast_char_constants; @@ -466,6 +472,7 @@ namespace boost { BOOST_STATIC_CONSTANT(char, zero = '0'); BOOST_STATIC_CONSTANT(char, minus = '-'); + BOOST_STATIC_CONSTANT(char, plus = '+'); }; #ifndef BOOST_LCAST_NO_WCHAR_T @@ -474,6 +481,7 @@ namespace boost { BOOST_STATIC_CONSTANT(wchar_t, zero = L'0'); BOOST_STATIC_CONSTANT(wchar_t, minus = L'-'); + BOOST_STATIC_CONSTANT(wchar_t, plus = L'+'); }; #endif } @@ -571,6 +579,86 @@ namespace boost } } + namespace detail // lcast_ret_unsigned + { + template + inline bool lcast_ret_unsigned(T& value, const CharT* const begin, const CharT* end) + { +#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS + BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); +#endif + typedef typename Traits::int_type int_type; + CharT const czero = lcast_char_constants::zero; + --end; + value = 0; + + if ( *end < czero || *end >= czero + 10 || begin > end) + return false; + value = *end - czero; + --end; + T multiplier = 1; + +#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE + // TODO: use BOOST_NO_STD_LOCALE + std::locale loc; + typedef std::numpunct numpunct; + numpunct const& np = BOOST_USE_FACET(numpunct, loc); + std::string const& grouping = np.grouping(); + std::string::size_type const grouping_size = grouping.size(); + + /* According to [22.2.2.1.2] of Programming languages - C++ + * we MUST check for correct grouping + */ + if (grouping_size) + { + unsigned char current_grouping = 0; + CharT const thousands_sep = grouping_size ? np.thousands_sep() : 0; + char remained = grouping[current_grouping] - 1; + + for(;end>=begin; --end) + { + if (remained) { + T const new_sub_value = multiplier * 10 * (*end - czero); + + if (*end < czero || *end >= czero + 10 + /* detecting overflow */ + || new_sub_value/10 != multiplier * (*end - czero) + || static_cast((std::numeric_limits::max)()-new_sub_value) < value + ) + return false; + + value += new_sub_value; + multiplier *= 10; + --remained; + } else { + if ( !Traits::eq(*end, thousands_sep) || begin == end ) return false; + if (current_grouping < grouping_size-1 ) ++current_grouping; + remained = grouping[current_grouping]; + } + } + } else +#endif + { + while ( begin <= end ) + { + T const new_sub_value = multiplier * 10 * (*end - czero); + + if (*end < czero || *end >= czero + 10 + /* detecting overflow */ + || new_sub_value/10 != multiplier * (*end - czero) + || static_cast((std::numeric_limits::max)()-new_sub_value) < value + ) + return false; + + value += new_sub_value; + multiplier *= 10; + --end; + } + } + return true; + } + } + namespace detail // stream wrapper for handling lexical conversions { template @@ -756,8 +844,178 @@ namespace boost bool operator<<(double); bool operator<<(long double); + private: + + template + bool input_operator_helper_unsigned(Type& output) + { + CharT const minus = lcast_char_constants::minus; + CharT const plus = lcast_char_constants::plus; + bool has_minus = false; + + /* We won`t use `start' any more, so no need in decrementing it after */ + if ( Traits::eq(minus,*start) ) + { + ++start; + has_minus = true; + } else if ( Traits::eq( plus, *start ) ) + { + ++start; + } + + bool const succeed = lcast_ret_unsigned(output, start, finish); +#if (defined _MSC_VER) +# pragma warning( push ) +// C4146: unary minus operator applied to unsigned type, result still unsigned +# pragma warning( disable : 4146 ) +#elif defined( __BORLANDC__ ) +# pragma option push -w-8041 +#endif + if (has_minus) output = static_cast(-output); +#if (defined _MSC_VER) +# pragma warning( pop ) +#elif defined( __BORLANDC__ ) +# pragma option pop +#endif + return succeed; + } + + template + bool input_operator_helper_signed(Type& output) + { + CharT const minus = lcast_char_constants::minus; + CharT const plus = lcast_char_constants::plus; + typedef BOOST_DEDUCED_TYPENAME make_unsigned::type utype; + utype out_tmp =0; + bool has_minus = false; + + /* We won`t use `start' any more, so no need in decrementing it after */ + if ( Traits::eq(minus,*start) ) + { + ++start; + has_minus = true; + } else if ( Traits::eq(plus, *start) ) + { + ++start; + } + + bool succeed = lcast_ret_unsigned(out_tmp, start, finish); + if (has_minus) { +#if (defined _MSC_VER) +# pragma warning( push ) +// C4146: unary minus operator applied to unsigned type, result still unsigned +# pragma warning( disable : 4146 ) +#elif defined( __BORLANDC__ ) +# pragma option push -w-8041 +#endif + utype const comp_val = static_cast(-(std::numeric_limits::min)()); + succeed = succeed && out_tmp<=comp_val; + output = -out_tmp; +#if (defined _MSC_VER) +# pragma warning( pop ) +#elif defined( __BORLANDC__ ) +# pragma option pop +#endif + } else { + utype const comp_val = static_cast((std::numeric_limits::max)()); + succeed = succeed && out_tmp<=comp_val; + output = out_tmp; + } + return succeed; + } + public: // input + bool operator>>(unsigned short& output) + { + return input_operator_helper_unsigned(output); + } + + bool operator>>(unsigned int& output) + { + return input_operator_helper_unsigned(output); + } + + bool operator>>(unsigned long int& output) + { + return input_operator_helper_unsigned(output); + } + + bool operator>>(short& output) + { + return input_operator_helper_signed(output); + } + + bool operator>>(int& output) + { + return input_operator_helper_signed(output); + } + + bool operator>>(long int& output) + { + return input_operator_helper_signed(output); + } + + +#if defined(BOOST_HAS_LONG_LONG) + bool operator>>( boost::ulong_long_type& output) + { + return input_operator_helper_unsigned(output); + } + + bool operator>>(boost::long_long_type& output) + { + return input_operator_helper_signed(output); + } + +#elif defined(BOOST_HAS_MS_INT64) + bool operator>>(unsigned __int64& output) + { + return input_operator_helper_unsigned(output); + } + + bool operator>>(__int64& output) + { + return input_operator_helper_signed(output); + } + +#endif + + /* + * case "-0" || "0" || "+0" : output = false; return true; + * case "1" || "+1": output = true; return true; + * default: return false; + */ + bool operator>>(bool& output) + { + CharT const zero = lcast_char_constants::zero; + CharT const plus = lcast_char_constants::plus; + CharT const minus = lcast_char_constants::minus; + + switch(finish-start) + { + case 1: + output = Traits::eq(start[0], zero+1); + return output || Traits::eq(start[0], zero ); + case 2: + if ( Traits::eq( plus, *start) ) + { + ++start; + output = Traits::eq(start[0], zero +1); + return output || Traits::eq(start[0], zero ); + } else + { + output = false; + return Traits::eq( minus, *start) + && Traits::eq( zero, start[1]); + } + default: + output = false; // Suppress warning about uninitalized variable + return false; + } + } + + // Generic istream-based algorithm. // lcast_streambuf_for_target::value is true. template @@ -1053,23 +1311,17 @@ namespace boost template struct lcast_streambuf_for_target { - BOOST_STATIC_CONSTANT(bool, value = true); + BOOST_STATIC_CONSTANT(bool, value = + ( + ::boost::type_traits::ice_or< + ::boost::type_traits::ice_not< is_integral::value >::value, + is_same::value, + is_same::value + >::value + ) + ); }; - template<> - struct lcast_streambuf_for_target - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; - -#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - template<> - struct lcast_streambuf_for_target - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; -#endif - #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template struct lcast_streambuf_for_target< @@ -1161,23 +1413,273 @@ namespace boost #if (defined _MSC_VER) # pragma warning( pop ) #endif + + template + struct is_stdstring + { + BOOST_STATIC_CONSTANT(bool, value = false ); + }; + + template + struct is_stdstring< std::basic_string > + { + BOOST_STATIC_CONSTANT(bool, value = true ); + }; + + template + struct is_char_or_wchar + { +#ifndef BOOST_LCAST_NO_WCHAR_T + BOOST_STATIC_CONSTANT(bool, value = + ( + ::boost::type_traits::ice_or< + is_same< T, char >::value, + is_same< T, wchar_t >::value, + is_same< T, unsigned char >::value, + is_same< T, signed char >::value + >::value + ) + ); +#else + BOOST_STATIC_CONSTANT(bool, value = + ( + ::boost::type_traits::ice_or< + is_same< T, char >::value, + is_same< T, unsigned char >::value, + is_same< T, signed char >::value + >::value + ) + ); +#endif + }; + + template + struct is_arithmetic_and_not_xchars + { + BOOST_STATIC_CONSTANT(bool, value = + ( + ::boost::type_traits::ice_and< + is_arithmetic::value, + is_arithmetic::value, + ::boost::type_traits::ice_not< + detail::is_char_or_wchar::value + >::value, + ::boost::type_traits::ice_not< + detail::is_char_or_wchar::value + >::value + >::value + ) + ); + }; + + template + struct is_xchar_to_xchar + { + BOOST_STATIC_CONSTANT(bool, value = + ( + ::boost::type_traits::ice_and< + is_same::value, + is_char_or_wchar::value + >::value + ) + ); + }; + + template + struct is_char_array_to_stdstring + { + BOOST_STATIC_CONSTANT(bool, value = false ); + }; + + template + struct is_char_array_to_stdstring< std::basic_string, CharT* > + { + BOOST_STATIC_CONSTANT(bool, value = true ); + }; + + template + struct is_char_array_to_stdstring< std::basic_string, const CharT* > + { + BOOST_STATIC_CONSTANT(bool, value = true ); + }; + + template + struct lexical_cast_do_cast + { + static inline Target lexical_cast_impl(const Source &arg) + { + typedef typename detail::array_to_pointer_decay::type src; + + typedef typename detail::widest_char< + typename detail::stream_char::type + , typename detail::stream_char::type + >::type char_type; + + typedef detail::lcast_src_length lcast_src_length; + std::size_t const src_len = lcast_src_length::value; + char_type buf[src_len + 1]; + lcast_src_length::check_coverage(); + return detail::lexical_cast(arg, buf, src_len); + } + }; + + template + struct lexical_cast_copy + { + static inline Source lexical_cast_impl(const Source &arg) + { + return arg; + } + }; + + class precision_loss_error : public boost::numeric::bad_numeric_cast + { + public: + virtual const char * what() const throw() + { return "bad numeric conversion: precision loss error"; } + }; + + template + struct throw_on_precision_loss + { + typedef boost::numeric::Trunc Rounder; + typedef S source_type ; + + typedef typename mpl::if_< is_arithmetic,S,S const&>::type argument_type ; + + static source_type nearbyint ( argument_type s ) + { + source_type orig_div_round = s / Rounder::nearbyint(s); + + if ( (orig_div_round > 1 ? orig_div_round - 1 : 1 - orig_div_round) > std::numeric_limits::epsilon() ) + BOOST_THROW_EXCEPTION( precision_loss_error() ); + return s ; + } + + typedef typename Rounder::round_style round_style; + } ; + + template + struct lexical_cast_dynamic_num_not_ignoring_minus + { + static inline Target lexical_cast_impl(const Source &arg) + { + try{ + typedef boost::numeric::converter< + Target, + Source, + boost::numeric::conversion_traits, + boost::numeric::def_overflow_handler, + throw_on_precision_loss + > Converter ; + + return Converter::convert(arg); + } catch( ::boost::numeric::bad_numeric_cast const& ) { + BOOST_LCAST_THROW_BAD_CAST(Source, Target); + } + } + }; + + template + struct lexical_cast_dynamic_num_ignoring_minus + { + static inline Target lexical_cast_impl(const Source &arg) + { + try{ + typedef boost::numeric::converter< + Target, + Source, + boost::numeric::conversion_traits, + boost::numeric::def_overflow_handler, + throw_on_precision_loss + > Converter ; + + bool has_minus = ( arg < 0); + if ( has_minus ) { + return static_cast(-Converter::convert(-arg)); + } else { + return Converter::convert(arg); + } + } catch( ::boost::numeric::bad_numeric_cast const& ) { + BOOST_LCAST_THROW_BAD_CAST(Source, Target); + } + } + }; + + /* + * lexical_cast_dynamic_num follows the rules: + * 1) If Source can be converted to Target without precision loss and + * without overflows, then assign Source to Target and return + * + * 2) If Source is less than 0 and Target is an unsigned integer, + * then negate Source, check the requirements of rule 1) and if + * successful, assign static_casted Source to Target and return + * + * 3) Otherwise throw a bad_lexical_cast exception + * + * + * Rule 2) required because boost::lexical_cast has the behavior of + * stringstream, which uses the rules of scanf for conversions. And + * in the C99 standard for unsigned input value minus sign is + * optional, so if a negative number is read, no errors will arise + * and the result will be the two's complement. + */ + template + struct lexical_cast_dynamic_num + { + static inline Target lexical_cast_impl(const Source &arg) + { + typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< + ::boost::type_traits::ice_and< + ::boost::type_traits::ice_or< + ::boost::is_signed::value, + ::boost::is_float::value + >::value, + ::boost::type_traits::ice_not< + is_same::value + >::value, + ::boost::type_traits::ice_not< + is_same::value + >::value, + ::boost::is_unsigned::value + >::value, + lexical_cast_dynamic_num_ignoring_minus, + lexical_cast_dynamic_num_not_ignoring_minus + >::type caster_type; + + return caster_type::lexical_cast_impl(arg); + } + }; } template inline Target lexical_cast(const Source &arg) { - typedef typename detail::array_to_pointer_decay::type src; + typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay::type src; - typedef typename detail::widest_char< - typename detail::stream_char::type - , typename detail::stream_char::type - >::type char_type; + typedef BOOST_DEDUCED_TYPENAME ::boost::type_traits::ice_or< + detail::is_xchar_to_xchar::value, + detail::is_char_array_to_stdstring::value, + ::boost::type_traits::ice_and< + is_same::value, + detail::is_stdstring::value + >::value + > do_copy_type; - typedef detail::lcast_src_length lcast_src_length; - std::size_t const src_len = lcast_src_length::value; - char_type buf[src_len + 1]; - lcast_src_length::check_coverage(); - return detail::lexical_cast(arg, buf, src_len); + typedef BOOST_DEDUCED_TYPENAME + detail::is_arithmetic_and_not_xchars do_copy_with_dynamic_check_type; + + typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< + do_copy_type::value, + detail::lexical_cast_copy, + BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< + do_copy_with_dynamic_check_type::value, + detail::lexical_cast_dynamic_num, + detail::lexical_cast_do_cast + >::type + >::type caster_type; + + return caster_type::lexical_cast_impl(arg); } #else @@ -1205,7 +1707,8 @@ namespace boost } // Copyright Kevlin Henney, 2000-2005. -// Copyright Alexander Nasonov, 2006-2007. +// Copyright Alexander Nasonov, 2006-2010. +// Copyright Antony Polukhin, 2011. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/lexical_cast.htm b/lexical_cast.htm index 5457a33..3372618 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -265,6 +265,12 @@ Eliminate an overhead of std::locale if your program runs in the "C August 2006.

    Changes

    +

    May 2011:

    +
      +
    • Better performance and less memory usage for conversions to arithmetic types.
    • +
    • Better performance and less memory usage for conversions from arithmetic type to arithmetic type.
    • +
    • Directly construct Target from Source on some conversions (like conversions from string to string, from char array to string, from char to char and others).
    • +

    August, October 2006:

    • Better performance for many combinations of Source and Target @@ -312,7 +318,7 @@ Eliminate an overhead of std::locale if your program runs in the "C
      Copyright © Antony Polukhin, 2011
      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) + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
      diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index a994d13..f366eb2 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -2,8 +2,9 @@ // // See http://www.boost.org for most recent version, including documentation. // -// Copyright Terje Slettebø and Kevlin Henney, 2005. +// Copyright Terje Sletteb and Kevlin Henney, 2005. // Copyright Alexander Nasonov, 2006. +// Copyright Antony Polukhin, 2011. // // Distributed under the Boost // Software License, Version 1.0. (See accompanying file @@ -32,6 +33,7 @@ #include #include +#include #include #include @@ -84,6 +86,9 @@ void test_conversion_from_to_uintmax_t(); void test_conversion_from_to_longlong(); void test_conversion_from_to_ulonglong(); #endif +void test_conversion_from_to_float(); +void test_conversion_from_to_double(); +void test_conversion_from_to_long_double(); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION void test_traits(); void test_wtraits(); @@ -122,6 +127,9 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong)); #endif + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_float)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_double)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_long_double)); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION suite->add(BOOST_TEST_CASE(&test_traits)); suite->add(BOOST_TEST_CASE(&test_wtraits)); @@ -229,10 +237,24 @@ void test_conversion_to_bool() BOOST_CHECK_EQUAL(false, lexical_cast("0")); BOOST_CHECK_EQUAL(true, lexical_cast(std::string("1"))); BOOST_CHECK_EQUAL(false, lexical_cast(std::string("0"))); + + BOOST_CHECK_THROW(lexical_cast(1.0001L), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(2), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(2u), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(-1), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(-2), bad_lexical_cast); + + BOOST_CHECK_THROW( lexical_cast(std::string("")), bad_lexical_cast); BOOST_CHECK_THROW( lexical_cast(std::string("Test")), bad_lexical_cast); + + BOOST_CHECK(lexical_cast("+1") == true ); + BOOST_CHECK(lexical_cast("+0") == false ); + BOOST_CHECK(lexical_cast("-0") == false ); + BOOST_CHECK_THROW(lexical_cast("--0"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("-+-0"), bad_lexical_cast); } void test_conversion_to_string() @@ -447,6 +469,24 @@ void test_conversion_from_integral_to_char(CharT zero) BOOST_CHECK_THROW(lexical_cast(t), bad_lexical_cast); } +template +void test_conversion_from_char_to_integral(CharT zero) +{ + BOOST_CHECK(lexical_cast( static_cast(zero + 0)) == static_cast(0) ); + BOOST_CHECK(lexical_cast( static_cast(zero + 1)) == static_cast(1) ); + BOOST_CHECK(lexical_cast( static_cast(zero + 2)) == static_cast(2) ); + BOOST_CHECK(lexical_cast( static_cast(zero + 3)) == static_cast(3) ); + BOOST_CHECK(lexical_cast( static_cast(zero + 4)) == static_cast(4) ); + BOOST_CHECK(lexical_cast( static_cast(zero + 5)) == static_cast(5) ); + BOOST_CHECK(lexical_cast( static_cast(zero + 6)) == static_cast(6) ); + BOOST_CHECK(lexical_cast( static_cast(zero + 7)) == static_cast(7) ); + BOOST_CHECK(lexical_cast( static_cast(zero + 8)) == static_cast(8) ); + BOOST_CHECK(lexical_cast( static_cast(zero + 9)) == static_cast(9) ); + + BOOST_CHECK_THROW(lexical_cast( static_cast(zero + 10)), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast( static_cast(zero - 1)), bad_lexical_cast); +} + template void test_conversion_from_integral_to_integral() { @@ -540,25 +580,46 @@ void test_conversion_from_string_to_integral(CharT) BOOST_CHECK_EQUAL(lexical_cast(s), min_val); if(limits::is_signed) { -#if defined(BOOST_MSVC) && BOOST_MSVC == 1400 - // VC++ 8.0 bug, see libs/conversion/test/lexical_cast_vc8_bug_test.cpp - if(sizeof(T) < sizeof(boost::intmax_t)) -#endif - { - BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); - } + BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); } s = to_str(max_val); BOOST_CHECK_EQUAL(lexical_cast(s), max_val); -#if defined(BOOST_MSVC) && BOOST_MSVC == 1400 - // VC++ 8.0 bug, see libs/conversion/test/lexical_cast_vc8_bug_test.cpp - if(sizeof(T) != sizeof(boost::intmax_t)) -#endif { BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); + + s = to_str(max_val); + for (int i =1; i <=10; ++i) { + s[s.size()-1] += 1; + BOOST_CHECK_THROW(lexical_cast( s ), bad_lexical_cast); + } + + s = to_str(max_val); + std::locale loc; + typedef std::numpunct numpunct; + if ( BOOST_USE_FACET(numpunct, loc).grouping().empty() ) { + // Following tests work well for locale C + BOOST_CHECK_EQUAL(lexical_cast(to_str(0)+s), max_val); + BOOST_CHECK_EQUAL(lexical_cast(to_str(0)+to_str(0)+s), max_val); + BOOST_CHECK_EQUAL(lexical_cast(to_str(0)+to_str(0)+to_str(0)+s), max_val); + } + + for (int i =1; i <=256; ++i) { + BOOST_CHECK_THROW(lexical_cast( to_str(i)+s ), bad_lexical_cast); + } + + typedef BOOST_DEDUCED_TYPENAME boost::integral_promotion::type promoted; + if ( !(boost::is_same::value) ) + { + promoted prom = max_val; + s = to_str(max_val); + for (int i =1; i <=256; ++i) { + BOOST_CHECK_THROW(lexical_cast( to_str(prom+i) ), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast( to_str(i)+s ), bad_lexical_cast); + } + } } if(limits::digits <= 16 && lcast_test_small_integral_types_completely) @@ -603,6 +664,18 @@ void test_conversion_from_string_to_integral(CharT) template void test_conversion_from_to_integral_for_locale() { + std::locale current_locale; + typedef std::numpunct numpunct; + numpunct const& np = BOOST_USE_FACET(numpunct, current_locale); + if ( !np.grouping().empty() ) + { + BOOST_CHECK_THROW( + lexical_cast( std::string("100") + np.thousands_sep() + np.thousands_sep() + "0" ) + , bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast( std::string("100") + np.thousands_sep() ), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast( np.thousands_sep() + std::string("100") ), bad_lexical_cast); + } + test_conversion_from_integral_to_integral(); test_conversion_from_integral_to_string('0'); test_conversion_from_string_to_integral('0'); @@ -625,13 +698,38 @@ void test_conversion_from_to_integral() signed char const szero = '0'; unsigned char const uzero = '0'; test_conversion_from_integral_to_char(zero); + test_conversion_from_char_to_integral(zero); test_conversion_from_integral_to_char(szero); + test_conversion_from_char_to_integral(szero); test_conversion_from_integral_to_char(uzero); + test_conversion_from_char_to_integral(uzero); #if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) wchar_t const wzero = L'0'; test_conversion_from_integral_to_char(wzero); + test_conversion_from_char_to_integral(wzero); #endif + BOOST_CHECK(lexical_cast("-1") == static_cast(-1)); + BOOST_CHECK(lexical_cast("-9") == static_cast(-9)); + BOOST_CHECK(lexical_cast(-1) == static_cast(-1)); + BOOST_CHECK(lexical_cast(-9) == static_cast(-9)); + + BOOST_CHECK_THROW(lexical_cast("-1.0"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("-9.0"), bad_lexical_cast); + BOOST_CHECK(lexical_cast(-1.0) == static_cast(-1)); + BOOST_CHECK(lexical_cast(-9.0) == static_cast(-9)); + + BOOST_CHECK(lexical_cast(static_cast(1)) == static_cast(1)); + BOOST_CHECK(lexical_cast(static_cast(9)) == static_cast(9)); + BOOST_CHECK_THROW(lexical_cast(1.1f), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(1.1), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(1.1L), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(1.0001f), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(1.0001), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(1.0001L), bad_lexical_cast); + + BOOST_CHECK(lexical_cast("+1") == static_cast(1) ); + BOOST_CHECK(lexical_cast("+9") == static_cast(9) ); // test_conversion_from_to_integral_for_locale typedef std::numpunct numpunct; @@ -665,6 +763,30 @@ void test_conversion_from_to_integral() BOOST_TEST_MESSAGE("Formatting with thousands_sep has not been tested"); } +template +void test_conversion_from_to_float() +{ + char const zero = '0'; + signed char const szero = '0'; + unsigned char const uzero = '0'; + test_conversion_from_integral_to_char(zero); + test_conversion_from_char_to_integral(zero); + test_conversion_from_integral_to_char(szero); + test_conversion_from_char_to_integral(szero); + test_conversion_from_integral_to_char(uzero); + test_conversion_from_char_to_integral(uzero); +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + wchar_t const wzero = L'0'; + test_conversion_from_integral_to_char(wzero); + test_conversion_from_char_to_integral(wzero); +#endif + + test_conversion_from_integral_to_integral(); + + BOOST_CHECK_CLOSE(lexical_cast("+1"), 1, std::numeric_limits::epsilon() ); + BOOST_CHECK_CLOSE(lexical_cast("+9"), 9, std::numeric_limits::epsilon()*9 ); +} + void test_conversion_from_to_short() { test_conversion_from_to_integral(); @@ -705,6 +827,19 @@ void test_conversion_from_to_uintmax_t() test_conversion_from_to_integral(); } +void test_conversion_from_to_float() +{ + test_conversion_from_to_float(); +} +void test_conversion_from_to_double() +{ + test_conversion_from_to_float(); +} +void test_conversion_from_to_long_double() +{ + test_conversion_from_to_float(); +} + #if defined(BOOST_HAS_LONG_LONG) void test_conversion_from_to_longlong() @@ -717,7 +852,7 @@ void test_conversion_from_to_ulonglong() test_conversion_from_to_integral(); } -#elif defined(LCAST_TEST_LONGLONG) +#elif defined(BOOST_HAS_MS_INT64) void test_conversion_from_to_longlong() { diff --git a/test/lexical_cast_vc8_bug_test.cpp b/test/lexical_cast_vc8_bug_test.cpp index 843bea8..151e4f8 100644 --- a/test/lexical_cast_vc8_bug_test.cpp +++ b/test/lexical_cast_vc8_bug_test.cpp @@ -1,3 +1,17 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Alexander Nasonov, 2007. +// +// 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 tests now must pass on vc8, because lexical_cast +// implementation has changed and it does not use stringstream for casts +// to integral types + #include #include #include From 1f7147d24b4081731cbd7d4dc1d0f1e4d88f722f Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sun, 29 May 2011 19:21:28 +0000 Subject: [PATCH 094/138] mereged lexical_cast from trunk r72267 (more optimizations, updated documentation, added tests) [SVN r72268] --- include/boost/lexical_cast.hpp | 211 +++++++++++++++++++++++++-------- lexical_cast.htm | 31 ++++- lexical_cast_test.cpp | 53 +++++++++ 3 files changed, 243 insertions(+), 52 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 6875b16..c1b083b 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -247,13 +247,42 @@ namespace boost static void check_coverage() {} }; - // No specializations for: - // lcast_src_length - // lcast_src_length - // lcast_src_length - // lcast_src_length - // lcast_src_length - // lcast_src_length + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; + template<> + struct lcast_src_length + { + BOOST_STATIC_CONSTANT(std::size_t, value = 1); + static void check_coverage() {} + }; #ifndef BOOST_LCAST_NO_WCHAR_T template<> @@ -526,6 +555,10 @@ namespace boost BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); #endif + typedef typename Traits::int_type int_type; + CharT const czero = lcast_char_constants::zero; + int_type const zero = Traits::to_int_type(czero); + #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE // TODO: use BOOST_NO_STD_LOCALE std::locale loc; @@ -533,47 +566,54 @@ namespace boost numpunct const& np = BOOST_USE_FACET(numpunct, loc); std::string const& grouping = np.grouping(); std::string::size_type const grouping_size = grouping.size(); - CharT thousands_sep = grouping_size ? np.thousands_sep() : 0; - std::string::size_type group = 0; // current group number - char last_grp_size = - grouping_size == 0 || grouping[0] <= 0 ? CHAR_MAX : grouping[0]; + + if ( grouping_size && grouping[0] > 0 ) + { + #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS // Check that ulimited group is unreachable: BOOST_STATIC_ASSERT(std::numeric_limits::digits10 < CHAR_MAX); #endif + CharT thousands_sep = np.thousands_sep(); + std::string::size_type group = 0; // current group number + char last_grp_size = grouping[0]; + char left = last_grp_size; - char left = last_grp_size; -#endif - - typedef typename Traits::int_type int_type; - CharT const czero = lcast_char_constants::zero; - int_type const zero = Traits::to_int_type(czero); - - do - { -#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE - if(left == 0) + do { - ++group; - if(group < grouping_size) + if(left == 0) { - char const grp_size = grouping[group]; - last_grp_size = grp_size <= 0 ? CHAR_MAX : grp_size; + ++group; + if(group < grouping_size) + { + char const grp_size = grouping[group]; + last_grp_size = grp_size <= 0 ? CHAR_MAX : grp_size; + } + + left = last_grp_size; + --finish; + Traits::assign(*finish, thousands_sep); } - left = last_grp_size; + --left; + --finish; - Traits::assign(*finish, thousands_sep); - } + int_type const digit = static_cast(n % 10U); + Traits::assign(*finish, Traits::to_char_type(zero + digit)); + n /= 10; + } while(n); - --left; + } else #endif - - --finish; - int_type const digit = static_cast(n % 10U); - Traits::assign(*finish, Traits::to_char_type(zero + digit)); - n /= 10; - } while(n); + { + do + { + --finish; + int_type const digit = static_cast(n % 10U); + Traits::assign(*finish, Traits::to_char_type(zero + digit)); + n /= 10; + } while(n); + } return finish; } @@ -609,10 +649,10 @@ namespace boost /* According to [22.2.2.1.2] of Programming languages - C++ * we MUST check for correct grouping */ - if (grouping_size) + if (grouping_size && grouping[0] > 0) { unsigned char current_grouping = 0; - CharT const thousands_sep = grouping_size ? np.thousands_sep() : 0; + CharT const thousands_sep = np.thousands_sep(); char remained = grouping[current_grouping] - 1; for(;end>=begin; --end) @@ -821,9 +861,13 @@ namespace boost bool operator<<(bool); bool operator<<(char); + bool operator<<(unsigned char); + bool operator<<(signed char); #if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) bool operator<<(wchar_t); #endif + bool operator<<(unsigned char const*); + bool operator<<(signed char const*); bool operator<<(CharT const*); bool operator<<(short); bool operator<<(int); @@ -1050,6 +1094,8 @@ namespace boost } bool operator>>(CharT&); + bool operator>>(unsigned char&); + bool operator>>(signed char&); #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION // This #if is in sync with lcast_streambuf_for_target @@ -1091,6 +1137,34 @@ namespace boost return true; } + template + inline bool lexical_stream_limited_src::operator<<( + unsigned char ch) + { + return ((*this) << static_cast(ch)); + } + + template + inline bool lexical_stream_limited_src::operator<<( + signed char ch) + { + return ((*this) << static_cast(ch)); + } + + template + inline bool lexical_stream_limited_src::operator<<( + unsigned char const* ch) + { + return ((*this) << reinterpret_cast(ch)); + } + + template + inline bool lexical_stream_limited_src::operator<<( + signed char const* ch) + { + return ((*this) << reinterpret_cast(ch)); + } + #if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) template inline bool lexical_stream_limited_src::operator<<( @@ -1256,6 +1330,34 @@ namespace boost return ok; } + template + inline bool lexical_stream_limited_src::operator>>( + unsigned char& output) + { + BOOST_STATIC_ASSERT( sizeof(CharT) == sizeof(unsigned char) ); + bool const ok = (finish - start == 1); + if(ok) { + CharT out; + Traits::assign(out, *start); + output = static_cast(out); + } + return ok; + } + + template + inline bool lexical_stream_limited_src::operator>>( + signed char& output) + { + BOOST_STATIC_ASSERT( sizeof(CharT) == sizeof(signed char) ); + bool const ok = (finish - start == 1); + if(ok) { + CharT out; + Traits::assign(out, *start); + output = static_cast(out); + } + return ok; + } + #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template inline bool lexical_stream_limited_src::operator>>( @@ -1312,13 +1414,9 @@ namespace boost struct lcast_streambuf_for_target { BOOST_STATIC_CONSTANT(bool, value = - ( - ::boost::type_traits::ice_or< - ::boost::type_traits::ice_not< is_integral::value >::value, - is_same::value, - is_same::value - >::value - ) + ( + ::boost::type_traits::ice_not< is_integral::value >::value + ) ); }; @@ -1472,16 +1570,29 @@ namespace boost ); }; + /* + * is_xchar_to_xchar::value is true, when + * Target and Souce are the same char types, or when + * Target and Souce are char types of the same size. + */ template struct is_xchar_to_xchar { BOOST_STATIC_CONSTANT(bool, value = - ( - ::boost::type_traits::ice_and< - is_same::value, - is_char_or_wchar::value + ( + ::boost::type_traits::ice_or< + ::boost::type_traits::ice_and< + is_same::value, + is_char_or_wchar::value + >::value, + ::boost::type_traits::ice_and< + ::boost::type_traits::ice_eq< sizeof(char),sizeof(Target)>::value, + ::boost::type_traits::ice_eq< sizeof(char),sizeof(Source)>::value, + is_char_or_wchar::value, + is_char_or_wchar::value + >::value >::value - ) + ) ); }; diff --git a/lexical_cast.htm b/lexical_cast.htm index 3372618..7929dd4 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -26,6 +26,8 @@ References
    • Changes
    • +
    • + Performance

    Motivation

    @@ -87,7 +89,7 @@ For a good discussion of the options and issues involved in string-based formatting, including comparison of stringstream, lexical_cast, and others, see Herb Sutter's article, - The String Formatters of Manor Farm. + The String Formatters of Manor Farm. Also, take a look at the Performance section.


    Examples

    @@ -267,6 +269,8 @@ Eliminate an overhead of std::locale if your program runs in the "C

    Changes

    May 2011:

      +
    • Optimizations for "C" and other locales without number grouping.
    • +
    • Better performance and less memory usage for unsigned char and signed char conversions.
    • Better performance and less memory usage for conversions to arithmetic types.
    • Better performance and less memory usage for conversions from arithmetic type to arithmetic type.
    • Directly construct Target from Source on some conversions (like conversions from string to string, from char array to string, from char to char and others).
    • @@ -312,7 +316,30 @@ Eliminate an overhead of std::locale if your program runs in the "C


    - + +

    Performance

    +This table shows the execution time in milliseconds for 100000 calls of the following string formatters: + + + + + + + + + + + + + + + + + +
    From->To lexical_cast std::stringstream
    with construction
    std::stringstream
    without construction
    sscanf/sprintf
    string->char<191710
    string->int71152318
    string->unsigned int71172217
    string->bool<11041910
    string->float851726033
    char->string71051612
    int->string151312117
    unsigned int->string141252117
    bool->string71222412
    float->string12422311548
    char*->string912320---
    int->int<112026---
    float->float<1262142---
    + +Fastest results are highlitened with green. +
    Copyright © Kevlin Henney, 2000-2005
    Copyright © Alexander Nasonov, 2006-2010
    Copyright © Antony Polukhin, 2011
    diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index f366eb2..f88017f 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -95,6 +95,7 @@ void test_wtraits(); void test_allocator(); void test_wallocator(); #endif +void test_char_types_conversions(); unit_test::test_suite *init_unit_test_suite(int, char *[]) { @@ -137,6 +138,8 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(&test_wallocator)); #endif + suite->add(BOOST_TEST_CASE(&test_char_types_conversions)); + return suite; } @@ -730,6 +733,12 @@ void test_conversion_from_to_integral() BOOST_CHECK(lexical_cast("+1") == static_cast(1) ); BOOST_CHECK(lexical_cast("+9") == static_cast(9) ); + BOOST_CHECK(lexical_cast("+10") == static_cast(10) ); + BOOST_CHECK(lexical_cast("+90") == static_cast(90) ); + BOOST_CHECK_THROW(lexical_cast("++1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("-+9"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("--1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("+-9"), bad_lexical_cast); // test_conversion_from_to_integral_for_locale typedef std::numpunct numpunct; @@ -785,6 +794,11 @@ void test_conversion_from_to_float() BOOST_CHECK_CLOSE(lexical_cast("+1"), 1, std::numeric_limits::epsilon() ); BOOST_CHECK_CLOSE(lexical_cast("+9"), 9, std::numeric_limits::epsilon()*9 ); + + BOOST_CHECK_THROW(lexical_cast("++1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("-+9"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("--1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("+-9"), bad_lexical_cast); } void test_conversion_from_to_short() @@ -923,3 +937,42 @@ void test_wallocator() #endif +void test_char_types_conversions() +{ + const char c_arr[] = "Test array of chars"; + const unsigned char uc_arr[] = "Test array of chars"; + const signed char sc_arr[] = "Test array of chars"; + + BOOST_CHECK(boost::lexical_cast(c_arr) == std::string(c_arr)); + BOOST_CHECK(boost::lexical_cast(uc_arr) == std::string(c_arr)); + BOOST_CHECK(boost::lexical_cast(sc_arr) == std::string(c_arr)); + + BOOST_CHECK(boost::lexical_cast(c_arr[0]) == c_arr[0]); + BOOST_CHECK(boost::lexical_cast(uc_arr[0]) == c_arr[0]); + BOOST_CHECK(boost::lexical_cast(sc_arr[0]) == c_arr[0]); + + BOOST_CHECK(boost::lexical_cast(c_arr[0]) == uc_arr[0]); + BOOST_CHECK(boost::lexical_cast(uc_arr[0]) == uc_arr[0]); + BOOST_CHECK(boost::lexical_cast(sc_arr[0]) == uc_arr[0]); + + BOOST_CHECK(boost::lexical_cast(c_arr[0]) == sc_arr[0]); + BOOST_CHECK(boost::lexical_cast(uc_arr[0]) == sc_arr[0]); + BOOST_CHECK(boost::lexical_cast(sc_arr[0]) == sc_arr[0]); + +#ifndef BOOST_LCAST_NO_WCHAR_T + const wchar_t wc_arr[]=L"Test array of chars"; + + BOOST_CHECK(boost::lexical_cast(wc_arr) == std::wstring(wc_arr)); + BOOST_CHECK(boost::lexical_cast(c_arr) == std::wstring(wc_arr)); + + BOOST_CHECK(boost::lexical_cast(sc_arr) != std::wstring(wc_arr) ); + BOOST_CHECK(boost::lexical_cast(uc_arr) != std::wstring(wc_arr) ); + + BOOST_CHECK(boost::lexical_cast(c_arr[0]) == wc_arr[0]); + BOOST_CHECK(boost::lexical_cast(wc_arr[0]) == wc_arr[0]); + + BOOST_CHECK_THROW(boost::lexical_cast(uc_arr[0]), bad_lexical_cast); + BOOST_CHECK_THROW(boost::lexical_cast(sc_arr[0]), bad_lexical_cast); + +#endif +} From 6c5f31e7a50fd71710b9927863dc9bbef563669e Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 2 Jun 2011 16:20:36 +0000 Subject: [PATCH 095/138] lexical-cast mereged from trunk r72347 (allow "C" locale grouping for other locales) [SVN r72348] --- include/boost/lexical_cast.hpp | 28 ++++++++++++++++++++++++---- lexical_cast_test.cpp | 3 +++ test/lexical_cast_abstract_test.cpp | 2 +- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index c1b083b..ddd7398 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -654,6 +654,7 @@ namespace boost unsigned char current_grouping = 0; CharT const thousands_sep = np.thousands_sep(); char remained = grouping[current_grouping] - 1; + bool shall_we_return = true; for(;end>=begin; --end) { @@ -671,12 +672,31 @@ namespace boost multiplier *= 10; --remained; } else { - if ( !Traits::eq(*end, thousands_sep) || begin == end ) return false; - if (current_grouping < grouping_size-1 ) ++current_grouping; - remained = grouping[current_grouping]; + if ( !Traits::eq(*end, thousands_sep) ) //|| begin == end ) return false; + { + /* + * According to Programming languages - C++ + * Digit grouping is checked. That is, the positions of discarded + * separators is examined for consistency with + * use_facet >(loc ).grouping() + * + * BUT what if there is no separators at all and grouping() + * is not empty? Well, we have no extraced separators, so we + * won`t check them for consistency. This will allow us to + * work with "C" locale from other locales + */ + shall_we_return = false; + break; + } else { + if ( begin == end ) return false; + if (current_grouping < grouping_size-1 ) ++current_grouping; + remained = grouping[current_grouping]; + } } } - } else + + if (shall_we_return) return true; + } #endif { while ( begin <= end ) diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index f88017f..f20994e 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -677,6 +677,9 @@ void test_conversion_from_to_integral_for_locale() , bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast( std::string("100") + np.thousands_sep() ), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast( np.thousands_sep() + std::string("100") ), bad_lexical_cast); + + // Exception must not be thrown, when we are using no separators at all + BOOST_CHECK( lexical_cast("10000") == static_cast(10000) ); } test_conversion_from_integral_to_integral(); diff --git a/test/lexical_cast_abstract_test.cpp b/test/lexical_cast_abstract_test.cpp index 207d3a5..4b92e49 100644 --- a/test/lexical_cast_abstract_test.cpp +++ b/test/lexical_cast_abstract_test.cpp @@ -51,7 +51,7 @@ std::ostream &operator<<(std::ostream &O, const A &a) { a.out(O); return O; -}; +} void test_abstract() { From 00f1246fafebda2572e205215651af8c7b6613dd Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Wed, 17 Aug 2011 18:43:10 +0000 Subject: [PATCH 096/138] Merge from trunk r73850 * Compile time optimizations * Float types optimizations * Source code refactoring * Parsing and writing inf and nan values according to the standart * Fixed some bugs and warnings * New tests * New documentation [SVN r73851] --- include/boost/lexical_cast.hpp | 1671 +++++++++++++----------- index.html | 2 +- lexical_cast.htm | 357 +---- lexical_cast_test.cpp | 143 +- test/Jamfile.v2 | 3 + test/lexical_cast_float_types_test.cpp | 513 ++++++++ test/lexical_cast_inf_nan_test.cpp | 180 +++ test/lexical_cast_loopback_test.cpp | 6 - test/lexical_cast_wchars_test.cpp | 56 + 9 files changed, 1735 insertions(+), 1196 deletions(-) create mode 100755 test/lexical_cast_float_types_test.cpp create mode 100755 test/lexical_cast_inf_nan_test.cpp create mode 100755 test/lexical_cast_wchars_test.cpp diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index ddd7398..6479e5d 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1,6 +1,12 @@ #ifndef BOOST_LEXICAL_CAST_INCLUDED #define BOOST_LEXICAL_CAST_INCLUDED +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + // Boost lexical_cast.hpp header -------------------------------------------// // // See http://www.boost.org/libs/conversion for documentation. @@ -18,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -28,17 +36,26 @@ #include #include #include +#include #include #include #include #include -#include +#include +#include #include #include #include +#include + #ifndef BOOST_NO_STD_LOCALE -#include +# include +#else +# ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE +# warning "Unable to use header. boost::lexical_cast will use the 'C' locale." +# define BOOST_LEXICAL_CAST_ASSUME_C_LOCALE +# endif #endif #ifdef BOOST_NO_STRINGSTREAM @@ -214,156 +231,17 @@ namespace boost namespace detail // lcast_src_length { // Return max. length of string representation of Source; - // 0 if unlimited (with exceptions for some types, see below). - // Values with limited string representation are placed to - // the buffer locally defined in lexical_cast function. - // 1 is returned for few types such as CharT const* or - // std::basic_string that already have an internal - // buffer ready to be reused by lexical_stream_limited_src. - // Each specialization should have a correspondent operator<< - // defined in lexical_stream_limited_src. template< class CharT // A result of widest_char transformation. , class Source // Source type of lexical_cast. > struct lcast_src_length { - BOOST_STATIC_CONSTANT(std::size_t, value = 0); + BOOST_STATIC_CONSTANT(std::size_t, value = 1); // To check coverage, build the test with // bjam --v2 profile optimization=off static void check_coverage() {} }; - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - -#ifndef BOOST_LCAST_NO_WCHAR_T - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - -#ifndef BOOST_NO_INTRINSIC_WCHAR_T - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; -#endif -#endif - - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - -#ifndef BOOST_LCAST_NO_WCHAR_T - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - - template<> - struct lcast_src_length - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; -#endif - -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template - struct lcast_src_length< CharT, std::basic_string > - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; -#else - template<> - struct lcast_src_length< char, std::basic_string > - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; - -#ifndef BOOST_LCAST_NO_WCHAR_T - template<> - struct lcast_src_length< wchar_t, std::basic_string > - { - BOOST_STATIC_CONSTANT(std::size_t, value = 1); - static void check_coverage() {} - }; -#endif -#endif - // Helper for integral types. // Notes on length calculation: // Max length for 32bit int with grouping "\1" and thousands_sep ',': @@ -383,7 +261,7 @@ namespace boost #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_CONSTANT(std::size_t, value = std::numeric_limits::is_signed + - std::numeric_limits::is_specialized + // == 1 + std::numeric_limits::is_specialized + /* == 1 */ std::numeric_limits::digits10 * 2 ); #else @@ -502,6 +380,9 @@ namespace boost BOOST_STATIC_CONSTANT(char, zero = '0'); BOOST_STATIC_CONSTANT(char, minus = '-'); BOOST_STATIC_CONSTANT(char, plus = '+'); + BOOST_STATIC_CONSTANT(char, lowercase_e = 'e'); + BOOST_STATIC_CONSTANT(char, capital_e = 'E'); + BOOST_STATIC_CONSTANT(char, c_decimal_separator = '.'); }; #ifndef BOOST_LCAST_NO_WCHAR_T @@ -511,17 +392,13 @@ namespace boost BOOST_STATIC_CONSTANT(wchar_t, zero = L'0'); BOOST_STATIC_CONSTANT(wchar_t, minus = L'-'); BOOST_STATIC_CONSTANT(wchar_t, plus = L'+'); + BOOST_STATIC_CONSTANT(wchar_t, lowercase_e = L'e'); + BOOST_STATIC_CONSTANT(wchar_t, capital_e = L'E'); + BOOST_STATIC_CONSTANT(wchar_t, c_decimal_separator = L'.'); }; #endif } - namespace detail // lexical_streambuf_fake - { - struct lexical_streambuf_fake - { - }; - } - namespace detail // lcast_to_unsigned { #if (defined _MSC_VER) @@ -560,7 +437,6 @@ namespace boost int_type const zero = Traits::to_int_type(czero); #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE - // TODO: use BOOST_NO_STD_LOCALE std::locale loc; typedef std::numpunct numpunct; numpunct const& np = BOOST_USE_FACET(numpunct, loc); @@ -639,14 +515,13 @@ namespace boost T multiplier = 1; #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE - // TODO: use BOOST_NO_STD_LOCALE std::locale loc; typedef std::numpunct numpunct; numpunct const& np = BOOST_USE_FACET(numpunct, loc); std::string const& grouping = np.grouping(); std::string::size_type const grouping_size = grouping.size(); - /* According to [22.2.2.1.2] of Programming languages - C++ + /* According to Programming languages - C++ * we MUST check for correct grouping */ if (grouping_size && grouping[0] > 0) @@ -719,158 +594,613 @@ namespace boost } } - namespace detail // stream wrapper for handling lexical conversions + namespace detail { - template - class lexical_stream + /* Returns true and sets the correct value if found NaN or Inf. */ + template + inline bool parse_inf_nan_impl(const CharT* begin, const CharT* end, T& value + , const CharT* lc_NAN, const CharT* lc_nan + , const CharT* lc_INFINITY, const CharT* lc_infinity + , const CharT opening_brace, const CharT closing_brace) { - private: - typedef typename widest_char< - typename stream_char::type, - typename stream_char::type>::type char_type; + using namespace std; + const wchar_t minus = lcast_char_constants::minus; + const wchar_t plus = lcast_char_constants::plus; + const int inifinity_size = 8; - typedef Traits traits_type; + bool has_minus = false; + /* Parsing +/- */ + if( *begin == minus) + { + ++ begin; + has_minus = true; + } + else if( *begin == plus ) ++begin; - public: - lexical_stream(char_type* = 0, char_type* = 0) + if( end-begin < 3 ) return false; + if( !memcmp(begin, lc_nan, 3*sizeof(CharT)) || !memcmp(begin, lc_NAN, 3*sizeof(CharT)) ) { - stream.unsetf(std::ios::skipws); - lcast_set_precision(stream, static_cast(0), static_cast(0) ); + begin += 3; + if (end != begin) /* It is 'nan(...)' or some bad input*/ + { + if(end-begin<2) return false; // bad input + -- end; + if( *begin != opening_brace || *end != closing_brace) return false; // bad input + } + + if( !has_minus ) value = std::numeric_limits::quiet_NaN(); + else value = (boost::math::changesign) (std::numeric_limits::quiet_NaN()); + return true; + } else + if (( /* 'INF' or 'inf' */ + end-begin==3 + && + (!memcmp(begin, lc_infinity, 3*sizeof(CharT)) || !memcmp(begin, lc_INFINITY, 3*sizeof(CharT))) + ) + || + ( /* 'INFINITY' or 'infinity' */ + end-begin==inifinity_size + && + (!memcmp(begin, lc_infinity, inifinity_size)|| !memcmp(begin, lc_INFINITY, inifinity_size)) + ) + ) + { + if( !has_minus ) value = std::numeric_limits::infinity(); + else value = (boost::math::changesign) (std::numeric_limits::infinity()); + return true; } - ~lexical_stream() - { - #if defined(BOOST_NO_STRINGSTREAM) - stream.freeze(false); - #endif - } - bool operator<<(const Source &input) - { - return !(stream << input).fail(); - } - template - bool operator>>(InputStreamable &output) - { - return !is_pointer::value && - stream >> output && - stream.get() == -#if defined(__GNUC__) && (__GNUC__<3) && defined(BOOST_NO_STD_WSTRING) -// GCC 2.9x lacks std::char_traits<>::eof(). -// We use BOOST_NO_STD_WSTRING to filter out STLport and libstdc++-v3 -// configurations, which do provide std::char_traits<>::eof(). - - EOF; -#else - traits_type::eof(); + + return false; + } + +#ifndef BOOST_LCAST_NO_WCHAR_T + template + bool parse_inf_nan(const wchar_t* begin, const wchar_t* end, T& value) + { + return parse_inf_nan_impl(begin, end, value + , L"NAN", L"nan" + , L"INFINITY", L"infinity" + , L'(', L')'); + } #endif - } -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - - bool operator>>(std::string &output) + template + bool parse_inf_nan(const CharT* begin, const CharT* end, T& value) + { + return parse_inf_nan_impl(begin, end, value + , "NAN", "nan" + , "INFINITY", "infinity" + , '(', ')'); + } +#ifndef BOOST_LCAST_NO_WCHAR_T + template + bool put_inf_nan(wchar_t* begin, wchar_t*& end, const T& value) + { + using namespace std; + if ( (boost::math::isnan)(value) ) { - #if defined(BOOST_NO_STRINGSTREAM) - stream << '\0'; - #endif - stream.str().swap(output); + if ( (boost::math::signbit)(value) ) + { + memcpy(begin,L"-nan", sizeof(L"-nan")); + end = begin + 4; + } else + { + memcpy(begin,L"nan", sizeof(L"nan")); + end = begin + 3; + } return true; - } - #ifndef BOOST_LCAST_NO_WCHAR_T - bool operator>>(std::wstring &output) + } else if ( (boost::math::isinf)(value) ) { - stream.str().swap(output); - return true; - } - #endif - -#else - bool operator>>(std::basic_string& output) - { - stream.str().swap(output); + if ( (boost::math::signbit)(value) ) + { + memcpy(begin,L"-inf", sizeof(L"-inf")); + end = begin + 4; + } else + { + memcpy(begin,L"inf", sizeof(L"inf")); + end = begin + 3; + } return true; } - template - bool operator>>(std::basic_string& out) - { - std::basic_string str(stream.str()); - out.assign(str.begin(), str.end()); - return true; - } + return false; + } #endif - private: - #if defined(BOOST_NO_STRINGSTREAM) - std::strstream stream; - #elif defined(BOOST_NO_STD_LOCALE) - std::stringstream stream; - #else - std::basic_stringstream stream; - #endif + template + bool put_inf_nan(CharT* begin, CharT*& end, const T& value) + { + using namespace std; + if ( (boost::math::isnan)(value) ) + { + if ( (boost::math::signbit)(value) ) + { + memcpy(begin,"-nan", sizeof("-nan")); + end = begin + 4; + } else + { + memcpy(begin,"nan", sizeof("nan")); + end = begin + 3; + } + return true; + } else if ( (boost::math::isinf)(value) ) + { + if ( (boost::math::signbit)(value) ) + { + memcpy(begin,"-inf", sizeof("-inf")); + end = begin + 4; + } else + { + memcpy(begin,"inf", sizeof("inf")); + end = begin + 3; + } + return true; + } + + return false; + } + + } + + + namespace detail // lcast_ret_float + { + template + struct mantissa_holder_type + { + /* Can not be used with this type */ }; + + template <> + struct mantissa_holder_type + { + typedef unsigned int type; + }; + + template <> + struct mantissa_holder_type + { +#if defined(BOOST_HAS_LONG_LONG) + typedef boost::ulong_long_type type; +#elif defined(BOOST_HAS_MS_INT64) + typedef unsigned __int64 type; +#endif + }; + + template + inline bool lcast_ret_float(T& value, const CharT* begin, const CharT* end) + { + +#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE + std::locale loc; + typedef std::numpunct numpunct; + numpunct const& np = BOOST_USE_FACET(numpunct, loc); + std::string const& grouping = np.grouping(); + std::string::size_type const grouping_size = grouping.size(); + CharT const thousands_sep = grouping_size ? np.thousands_sep() : 0; + CharT const decimal_point = np.decimal_point(); + bool found_grouping = false; + unsigned int last_grouping_pos = grouping_size - 1; +#else + CharT const decimal_point = lcast_char_constants::c_decimal_separator; +#endif + + CharT const czero = lcast_char_constants::zero; + CharT const minus = lcast_char_constants::minus; + CharT const plus = lcast_char_constants::plus; + CharT const capital_e = lcast_char_constants::capital_e; + CharT const lowercase_e = lcast_char_constants::lowercase_e; + + value = 0.0; + + if (parse_inf_nan(begin, end, value)) return true; + + typedef typename Traits::int_type int_type; + typedef BOOST_DEDUCED_TYPENAME mantissa_holder_type::type mantissa_type; + int_type const zero = Traits::to_int_type(czero); + if (begin == end) return false; + + /* Getting the plus/minus sign */ + bool has_minus = false; + if ( *begin == minus ) { + ++ begin; + has_minus = true; + if (begin == end) return false; + } else if ( *begin == plus ) { + ++begin; + if (begin == end) return false; + } + + bool found_decimal = false; + bool found_number_before_exp = false; + int pow_of_10 = 0; + mantissa_type mantissa=0; + bool is_mantissa_full = false; + + char length_since_last_delim = 0; + + while ( begin != end ) + { + if (found_decimal) { + /* We allow no thousand_separators after decimal point */ + + mantissa_type tmp_mantissa = mantissa * 10u; + if ( *begin == lowercase_e || *begin == capital_e ) break; + if ( *begin < czero || *begin >= czero + 10 ) return false; + if ( is_mantissa_full + || tmp_mantissa / 10u != mantissa + || (std::numeric_limits::max)()-(*begin - zero) < tmp_mantissa + ) { + is_mantissa_full = true; + ++ begin; + continue; + } + + -- pow_of_10; + mantissa = tmp_mantissa; + mantissa += *begin - zero; + + found_number_before_exp = true; + } else { + + if (*begin >= czero && *begin < czero + 10) { + + /* Checking for mantissa overflow. If overflow will + * occur, them we only increase multiplyer + */ + mantissa_type tmp_mantissa = mantissa * 10u; + if( !is_mantissa_full + && tmp_mantissa / 10u == mantissa + && (std::numeric_limits::max)()-(*begin - zero) >= tmp_mantissa + ) + { + mantissa = tmp_mantissa; + mantissa += *begin - zero; + } else + { + is_mantissa_full = true; + ++ pow_of_10; + } + + found_number_before_exp = true; + ++ length_since_last_delim; + } else if ( *begin == decimal_point || *begin == lowercase_e || *begin == capital_e) { +#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE + /* If ( we need to check grouping + * and ( grouping missmatches + * or grouping position is incorrect + * or we are using the grouping position 0 twice + * ) + * ) then return error + */ + if( grouping_size && found_grouping + && ( + length_since_last_delim != grouping[0] + || last_grouping_pos>1 + || (last_grouping_pos==0 && grouping_size>1) + ) + ) return false; +#endif + + if(*begin == decimal_point){ + ++ begin; + found_decimal = true; + continue; + }else { + if (!found_number_before_exp) return false; + break; + } + } +#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE + else if (grouping_size && *begin == thousands_sep){ + if(found_grouping) + { + /* It is not he first time, when we find thousands separator, + * so we need to chek, is the distance between two groupings + * equal to grouping[last_grouping_pos] */ + + if (length_since_last_delim != grouping[last_grouping_pos] ) + { + if (!last_grouping_pos) return false; + else + { + -- last_grouping_pos; + if (length_since_last_delim != grouping[last_grouping_pos]) return false; + } + } else + /* We are calling the grouping[0] twice, when grouping size is more than 1 */ + if (grouping_size>1u && last_grouping_pos+1 grouping[last_grouping_pos] ) return false; + } + + length_since_last_delim = 0; + ++ begin; + + /* Delimiter at the end '100,' */ + if (begin == end) return false; + continue; + } +#endif + else return false; + } + + ++begin; + } + + // Exponent found + if ( begin != end && ( *begin == lowercase_e || *begin == capital_e ) ) { + ++ begin; + if ( begin == end ) return false; + + bool exp_has_minus = false; + if( *begin == minus ) { + exp_has_minus = true; + ++ begin; + if ( begin == end ) return false; + } else if (*begin == plus ) { + ++ begin; + if ( begin == end ) return false; + } + + int exp_pow_of_10 = 0; + while ( begin != end ) + { + if ( *begin < czero + || *begin >= czero + 10 + || exp_pow_of_10 * 10 < exp_pow_of_10) /* Overflows are checked lower more precisely*/ + return false; + + exp_pow_of_10 *= 10; + exp_pow_of_10 += *begin - zero; + ++ begin; + }; + + if ( exp_pow_of_10 ) { + /* Overflows are checked lower */ + if ( exp_has_minus ) { + pow_of_10 -= exp_pow_of_10; + } else { + pow_of_10 += exp_pow_of_10; + } + } + } + + /* We need a more accurate algorithm... We can not use current algorithm + * with long doubles (and with doubles if sizeof(double)==sizeof(long double)). + */ + long double result = std::pow(10.0L, pow_of_10) * mantissa; + value = static_cast( has_minus ? (boost::math::changesign)(result) : result); + + if ( (boost::math::isinf)(value) || (boost::math::isnan)(value) ) return false; + + return true; + } + } + + namespace detail // stl_buf_unlocker + { + template< class BufferType, class CharT > + class stl_buf_unlocker: public BufferType{ + public: + typedef BufferType base_class; +#ifndef BOOST_NO_USING_TEMPLATE + using base_class::pptr; + using base_class::pbase; + using base_class::setg; + using base_class::setp; +#else + CharT* pptr() const { return base_class::pptr(); } + CharT* pbase() const { return base_class::pbase(); } + void setg(CharT* gbeg, CharT* gnext, CharT* gend){ return base_class::setg(gbeg, gnext, gend); } + void setp(CharT* pbeg, CharT* pend) { return setp(pbeg, pend); } +#endif + }; + } + + namespace detail + { + struct do_not_construct_stringbuffer_t{}; } namespace detail // optimized stream wrapper { // String representation of Source has an upper limit. template< class CharT // a result of widest_char transformation - , class Base // lexical_streambuf_fake or basic_streambuf , class Traits // usually char_traits + , bool RequiresStringbuffer > - class lexical_stream_limited_src : public Base + class lexical_stream_limited_src { + typedef stl_buf_unlocker, CharT > local_streambuffer_t; + +#if defined(BOOST_NO_STRINGSTREAM) + typedef stl_buf_unlocker local_stringbuffer_t; +#elif defined(BOOST_NO_STD_LOCALE) + typedef stl_buf_unlocker local_stringbuffer_t; +#else + typedef stl_buf_unlocker, CharT > local_stringbuffer_t; +#endif + typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< + RequiresStringbuffer, + local_stringbuffer_t, + do_not_construct_stringbuffer_t + >::type deduced_stringbuffer_t; + // A string representation of Source is written to [start, finish). - // Currently, it is assumed that [start, finish) is big enough - // to hold a string representation of any Source value. CharT* start; CharT* finish; - - private: - - static void widen_and_assign(char*p, char ch) - { - Traits::assign(*p, ch); - } - -#ifndef BOOST_LCAST_NO_WCHAR_T - static void widen_and_assign(wchar_t* p, char ch) - { - // TODO: use BOOST_NO_STD_LOCALE - std::locale loc; - wchar_t w = BOOST_USE_FACET(std::ctype, loc).widen(ch); - Traits::assign(*p, w); - } - - static void widen_and_assign(wchar_t* p, wchar_t ch) - { - Traits::assign(*p, ch); - } - - static void widen_and_assign(char*, wchar_t ch); // undefined -#endif - - template - bool lcast_put(const OutputStreamable& input) - { - this->setp(start, finish); - std::basic_ostream stream(static_cast(this)); - lcast_set_precision(stream, static_cast(0)); - bool const result = !(stream << input).fail(); - finish = this->pptr(); - return result; - } - - // Undefined: - lexical_stream_limited_src(lexical_stream_limited_src const&); - void operator=(lexical_stream_limited_src const&); + deduced_stringbuffer_t stringbuffer; public: - lexical_stream_limited_src(CharT* sta, CharT* fin) : start(sta) , finish(fin) {} - public: // output + private: + // Undefined: + lexical_stream_limited_src(lexical_stream_limited_src const&); + void operator=(lexical_stream_limited_src const&); +/************************************ HELPER FUNCTIONS FOR OPERATORS << ( ... ) ********************************/ + bool shl_char(CharT ch) + { + Traits::assign(*start, ch); + finish = start + 1; + return true; + } + +#ifndef BOOST_LCAST_NO_WCHAR_T + template + bool shl_char(T ch) + { + BOOST_STATIC_ASSERT_MSG(( sizeof(T) <= sizeof(CharT)) , + "boost::lexical_cast does not support conversions from whar_t to char types." + "Use boost::locale instead" ); +#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE + std::locale loc; + wchar_t w = BOOST_USE_FACET(std::ctype, loc).widen(ch); +#else + wchar_t w = ch; +#endif + Traits::assign(*start, w); + finish = start + 1; + return true; + } +#endif + + bool shl_char_array(CharT const* str) + { + start = const_cast(str); + finish = start + Traits::length(str); + return true; + } + +#ifndef BOOST_LCAST_NO_WCHAR_T + template + bool shl_char_array(T const* str) + { + BOOST_STATIC_ASSERT_MSG(( sizeof(T) <= sizeof(CharT)), + "boost::lexical_cast does not support conversions from wchar_t to char types." + "Use boost::locale instead" ); + return shl_input_streamable(str); + } +#endif + + template + bool shl_input_streamable(InputStreamable& input) + { + std::basic_ostream stream(&stringbuffer); + bool const result = !(stream << input).fail(); + start = stringbuffer.pbase(); + finish = stringbuffer.pptr(); + return result; + } + + template + inline bool shl_signed(T n) + { + start = lcast_put_unsigned(lcast_to_unsigned(n), finish); + if(n < 0) + { + --start; + CharT const minus = lcast_char_constants::minus; + Traits::assign(*start, minus); + } + return true; + } + +#if (defined _MSC_VER) +# pragma warning( push ) +// C4996: This function or variable may be unsafe. Consider using sprintf_s instead +# pragma warning( disable : 4996 ) +#endif + + template + bool shl_float(float val,T* out) + { using namespace std; + if (put_inf_nan(start,finish,val)) return true; + finish = start + sprintf(out,"%.*g", static_cast(boost::detail::lcast_get_precision()), val ); + return finish > start; + } + + template + bool shl_double(double val,T* out) + { using namespace std; + if (put_inf_nan(start,finish,val)) return true; + finish = start + sprintf(out,"%.*lg", static_cast(boost::detail::lcast_get_precision()), val ); + return finish > start; + } +#ifndef __MINGW32__ + template + bool shl_long_double(long double val,T* out) + { using namespace std; + if (put_inf_nan(start,finish,val)) return true; + finish = start + sprintf(out,"%.*Lg", static_cast(boost::detail::lcast_get_precision()), val ); + return finish > start; + } +#endif + +#if (defined _MSC_VER) +# pragma warning( pop ) +#endif + + +#ifndef BOOST_LCAST_NO_WCHAR_T + bool shl_float(float val,wchar_t* out) + { using namespace std; + if (put_inf_nan(start,finish,val)) return true; + finish = start + swprintf(out, +#if !defined(__MINGW32__) && !defined(UNDER_CE) + finish-start, +#endif + L"%.*g", static_cast(boost::detail::lcast_get_precision()), val ); + + return finish > start; + } + + + bool shl_double(double val,wchar_t* out) + { using namespace std; + if (put_inf_nan(start,finish,val)) return true; + /* __MINGW32__ is defined for both mingw.org and for mingw-w64. + * For mingw-w64, __MINGW64__ is defined, too, when targetting + * 64 bits. + * + * swprintf realization in MinGW and under WinCE does not conform + * to the ISO C + * Standard. + */ + finish = start + swprintf(out, +#if !defined(__MINGW32__) && !defined(UNDER_CE) + finish-start, +#endif + L"%.*lg", static_cast(boost::detail::lcast_get_precision()), val ); + return finish > start; + } + +#ifndef __MINGW32__ + bool shl_long_double(long double val,wchar_t* out) + { using namespace std; + if (put_inf_nan(start,finish,val)) return true; + finish = start + swprintf(out, +#if !defined(UNDER_CE) + finish-start, +#endif + L"%.*Lg", static_cast(boost::detail::lcast_get_precision()), val ); + return finish > start; + } +#endif + +#endif + +/************************************ OPERATORS << ( ... ) ********************************/ + public: template bool operator<<(std::basic_string const& str) { @@ -879,39 +1209,61 @@ namespace boost return true; } - bool operator<<(bool); - bool operator<<(char); - bool operator<<(unsigned char); - bool operator<<(signed char); -#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - bool operator<<(wchar_t); + bool operator<<(bool value) + { + CharT const czero = lcast_char_constants::zero; + Traits::assign(*start, Traits::to_char_type(czero + value)); + finish = start + 1; + return true; + } + + bool operator<<(char ch) { return shl_char(ch); } + bool operator<<(unsigned char ch) { return ((*this) << static_cast(ch)); } + bool operator<<(signed char ch) { return ((*this) << static_cast(ch)); } +#if !defined(BOOST_LCAST_NO_WCHAR_T) + bool operator<<(wchar_t const* str) { return shl_char_array(str); } + bool operator<<(wchar_t * str) { return shl_char_array(str); } +#ifndef BOOST_NO_INTRINSIC_WCHAR_T + bool operator<<(wchar_t ch) { return shl_char(ch); } #endif - bool operator<<(unsigned char const*); - bool operator<<(signed char const*); - bool operator<<(CharT const*); - bool operator<<(short); - bool operator<<(int); - bool operator<<(long); - bool operator<<(unsigned short); - bool operator<<(unsigned int); - bool operator<<(unsigned long); +#endif + bool operator<<(unsigned char const* ch) { return ((*this) << reinterpret_cast(ch)); } + bool operator<<(unsigned char * ch) { return ((*this) << reinterpret_cast(ch)); } + bool operator<<(signed char const* ch) { return ((*this) << reinterpret_cast(ch)); } + bool operator<<(signed char * ch) { return ((*this) << reinterpret_cast(ch)); } + bool operator<<(char const* str) { return shl_char_array(str); } + bool operator<<(char* str) { return shl_char_array(str); } + bool operator<<(short n) { return shl_signed(n); } + bool operator<<(int n) { return shl_signed(n); } + bool operator<<(long n) { return shl_signed(n); } + bool operator<<(unsigned short n) { start = lcast_put_unsigned(n, finish); return true; } + bool operator<<(unsigned int n) { start = lcast_put_unsigned(n, finish); return true; } + bool operator<<(unsigned long n) { start = lcast_put_unsigned(n, finish); return true; } + #if defined(BOOST_HAS_LONG_LONG) - bool operator<<(boost::ulong_long_type); - bool operator<<(boost::long_long_type ); + bool operator<<(boost::ulong_long_type n) { start = lcast_put_unsigned(n, finish); return true; } + bool operator<<(boost::long_long_type n) { return shl_signed(n); } #elif defined(BOOST_HAS_MS_INT64) - bool operator<<(unsigned __int64); - bool operator<<( __int64); + bool operator<<(unsigned __int64 n) { start = lcast_put_unsigned(n, finish); return true; } + bool operator<<( __int64 n) { return shl_signed(n); } #endif - // These three operators use ostream and streambuf. - // lcast_streambuf_for_source::value is true. - bool operator<<(float); - bool operator<<(double); - bool operator<<(long double); + bool operator<<(float val) { return shl_float(val,start); } + bool operator<<(double val) { return shl_double(val,start); } + bool operator<<(long double val) { +#ifndef __MINGW32__ + return shl_long_double(val,start); +#else + return shl_double(val,start); +#endif + } + template + bool operator<<(const InStreamable& input) { return shl_input_streamable(input); } + +/************************************ HELPER FUNCTIONS FOR OPERATORS >> ( ... ) ********************************/ private: - template - bool input_operator_helper_unsigned(Type& output) + bool shr_unsigned(Type& output) { CharT const minus = lcast_char_constants::minus; CharT const plus = lcast_char_constants::plus; @@ -945,7 +1297,7 @@ namespace boost } template - bool input_operator_helper_signed(Type& output) + bool shr_signed(Type& output) { CharT const minus = lcast_char_constants::minus; CharT const plus = lcast_char_constants::plus; @@ -988,63 +1340,81 @@ namespace boost return succeed; } - public: // input - - bool operator>>(unsigned short& output) + template + bool shr_using_base_class(InputStreamable& output) { - return input_operator_helper_unsigned(output); +#if (defined _MSC_VER) +# pragma warning( push ) + // conditional expression is constant +# pragma warning( disable : 4127 ) +#endif + if(is_pointer::value) + return false; + + local_streambuffer_t bb; + bb.setg(start, start, finish); + std::basic_istream stream(&bb); + stream.unsetf(std::ios::skipws); + lcast_set_precision(stream, static_cast(0)); +#if (defined _MSC_VER) +# pragma warning( pop ) +#endif + return stream >> output && + stream.get() == +#if defined(__GNUC__) && (__GNUC__<3) && defined(BOOST_NO_STD_WSTRING) + // GCC 2.9x lacks std::char_traits<>::eof(). + // We use BOOST_NO_STD_WSTRING to filter out STLport and libstdc++-v3 + // configurations, which do provide std::char_traits<>::eof(). + + EOF; +#else + Traits::eof(); +#endif } - bool operator>>(unsigned int& output) + template + inline bool shr_xchar(T& output) { - return input_operator_helper_unsigned(output); + BOOST_STATIC_ASSERT_MSG(( sizeof(CharT) == sizeof(T) ), + "boost::lexical_cast does not support conversions from whar_t to char types." + "Use boost::locale instead" ); + bool const ok = (finish - start == 1); + if(ok) { + CharT out; + Traits::assign(out, *start); + output = static_cast(out); + } + return ok; } - bool operator>>(unsigned long int& output) - { - return input_operator_helper_unsigned(output); - } - - bool operator>>(short& output) - { - return input_operator_helper_signed(output); - } - - bool operator>>(int& output) - { - return input_operator_helper_signed(output); - } - - bool operator>>(long int& output) - { - return input_operator_helper_signed(output); - } - - +/************************************ OPERATORS >> ( ... ) ********************************/ + public: + bool operator>>(unsigned short& output) { return shr_unsigned(output); } + bool operator>>(unsigned int& output) { return shr_unsigned(output); } + bool operator>>(unsigned long int& output) { return shr_unsigned(output); } + bool operator>>(short& output) { return shr_signed(output); } + bool operator>>(int& output) { return shr_signed(output); } + bool operator>>(long int& output) { return shr_signed(output); } #if defined(BOOST_HAS_LONG_LONG) - bool operator>>( boost::ulong_long_type& output) - { - return input_operator_helper_unsigned(output); - } - - bool operator>>(boost::long_long_type& output) - { - return input_operator_helper_signed(output); - } - + bool operator>>(boost::ulong_long_type& output) { return shr_unsigned(output); } + bool operator>>(boost::long_long_type& output) { return shr_signed(output); } #elif defined(BOOST_HAS_MS_INT64) - bool operator>>(unsigned __int64& output) - { - return input_operator_helper_unsigned(output); - } - - bool operator>>(__int64& output) - { - return input_operator_helper_signed(output); - } + bool operator>>(unsigned __int64& output) { return shr_unsigned(output); } + bool operator>>(__int64& output) { return shr_signed(output); } #endif - + bool operator>>(CharT& output) { return shr_xchar(output); } + bool operator>>(unsigned char& output) { return shr_xchar(output); } + bool operator>>(signed char& output) { return shr_xchar(output); } +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + bool operator>>(std::string& str) { str.assign(start, finish); return true; } +# ifndef BOOST_LCAST_NO_WCHAR_T + bool operator>>(std::wstring& str) { str.assign(start, finish); return true; } +# endif +#else + template + bool operator>>(std::basic_string& str) { str.assign(start, finish); return true; } +#endif /* * case "-0" || "0" || "+0" : output = false; return true; * case "1" || "+1": output = true; return true; @@ -1079,401 +1449,78 @@ namespace boost } } + bool operator>>(float& output) { return lcast_ret_float(output,start,finish); } + + private: + // Not optimised converter + template + bool float_types_converter_internal(T& output, int /*tag*/) { + if (parse_inf_nan(start, finish, output)) return true; + bool return_value = shr_using_base_class(output); + + /* Some compilers and libraries successfully + * parse 'inf', 'INFINITY', '1.0E', '1.0E-'... + * We are trying to provide a unified behaviour, + * so we just forbid such conversions (as some + * of the most popular compilers/libraries do) + * */ + CharT const minus = lcast_char_constants::minus; + CharT const plus = lcast_char_constants::plus; + CharT const capital_e = lcast_char_constants::capital_e; + CharT const lowercase_e = lcast_char_constants::lowercase_e; + if ( return_value && + ( + *(finish-1) == lowercase_e // 1.0e + || *(finish-1) == capital_e // 1.0E + || *(finish-1) == minus // 1.0e- or 1.0E- + || *(finish-1) == plus // 1.0e+ or 1.0E+ + ) + ) return false; + + return return_value; + } + + // Optimised converter + bool float_types_converter_internal(double& output,char /*tag*/) { + return lcast_ret_float(output,start,finish); + } + public: + + bool operator>>(double& output) + { + /* + * Some compilers implement long double as double. In that case these types have + * same size, same precision, same max and min values... And it means, + * that current implementation of lcast_ret_float cannot be used for type + * double, because it will give a big precision loss. + * */ + boost::mpl::if_c< +#if defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64) + ::boost::type_traits::ice_eq< sizeof(double), sizeof(long double) >::value, +#else + 0 +#endif + int, + char + >::type tag = 0; + + return float_types_converter_internal(output, tag); + } + + bool operator>>(long double& output) + { + int tag = 0; + return float_types_converter_internal(output, tag); + } // Generic istream-based algorithm. // lcast_streambuf_for_target::value is true. template - bool operator>>(InputStreamable& output) - { -#if (defined _MSC_VER) -# pragma warning( push ) - // conditional expression is constant -# pragma warning( disable : 4127 ) -#endif - if(is_pointer::value) - return false; - - this->setg(start, start, finish); - std::basic_istream stream(static_cast(this)); - stream.unsetf(std::ios::skipws); - lcast_set_precision(stream, static_cast(0)); -#if (defined _MSC_VER) -# pragma warning( pop ) -#endif - return stream >> output && - stream.get() == -#if defined(__GNUC__) && (__GNUC__<3) && defined(BOOST_NO_STD_WSTRING) - // GCC 2.9x lacks std::char_traits<>::eof(). - // We use BOOST_NO_STD_WSTRING to filter out STLport and libstdc++-v3 - // configurations, which do provide std::char_traits<>::eof(). - - EOF; -#else - Traits::eof(); -#endif - } - - bool operator>>(CharT&); - bool operator>>(unsigned char&); - bool operator>>(signed char&); - -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -// This #if is in sync with lcast_streambuf_for_target - - bool operator>>(std::string&); - -#ifndef BOOST_LCAST_NO_WCHAR_T - bool operator>>(std::wstring&); -#endif - -#else - template - bool operator>>(std::basic_string& str) - { - str.assign(start, finish); - return true; - } -#endif - }; - - template - inline bool lexical_stream_limited_src::operator<<( - bool value) - { - typedef typename Traits::int_type int_type; - CharT const czero = lcast_char_constants::zero; - int_type const zero = Traits::to_int_type(czero); - Traits::assign(*start, Traits::to_char_type(zero + value)); - finish = start + 1; - return true; - } - - template - inline bool lexical_stream_limited_src::operator<<( - char ch) - { - widen_and_assign(start, ch); - finish = start + 1; - return true; - } - - template - inline bool lexical_stream_limited_src::operator<<( - unsigned char ch) - { - return ((*this) << static_cast(ch)); - } - - template - inline bool lexical_stream_limited_src::operator<<( - signed char ch) - { - return ((*this) << static_cast(ch)); - } - - template - inline bool lexical_stream_limited_src::operator<<( - unsigned char const* ch) - { - return ((*this) << reinterpret_cast(ch)); - } - - template - inline bool lexical_stream_limited_src::operator<<( - signed char const* ch) - { - return ((*this) << reinterpret_cast(ch)); - } - -#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - template - inline bool lexical_stream_limited_src::operator<<( - wchar_t ch) - { - widen_and_assign(start, ch); - finish = start + 1; - return true; - } -#endif - - template - inline bool lexical_stream_limited_src::operator<<( - short n) - { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); - if(n < 0) - { - --start; - CharT const minus = lcast_char_constants::minus; - Traits::assign(*start, minus); - } - return true; - } - - template - inline bool lexical_stream_limited_src::operator<<( - int n) - { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); - if(n < 0) - { - --start; - CharT const minus = lcast_char_constants::minus; - Traits::assign(*start, minus); - } - return true; - } - - template - inline bool lexical_stream_limited_src::operator<<( - long n) - { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); - if(n < 0) - { - --start; - CharT const minus = lcast_char_constants::minus; - Traits::assign(*start, minus); - } - return true; - } - -#if defined(BOOST_HAS_LONG_LONG) - template - inline bool lexical_stream_limited_src::operator<<( - boost::long_long_type n) - { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); - if(n < 0) - { - --start; - CharT const minus = lcast_char_constants::minus; - Traits::assign(*start, minus); - } - return true; - } -#elif defined(BOOST_HAS_MS_INT64) - template - inline bool lexical_stream_limited_src::operator<<( - __int64 n) - { - start = lcast_put_unsigned(lcast_to_unsigned(n), finish); - if(n < 0) - { - --start; - CharT const minus = lcast_char_constants::minus; - Traits::assign(*start, minus); - } - return true; - } -#endif - - template - inline bool lexical_stream_limited_src::operator<<( - unsigned short n) - { - start = lcast_put_unsigned(n, finish); - return true; - } - - template - inline bool lexical_stream_limited_src::operator<<( - unsigned int n) - { - start = lcast_put_unsigned(n, finish); - return true; - } - - template - inline bool lexical_stream_limited_src::operator<<( - unsigned long n) - { - start = lcast_put_unsigned(n, finish); - return true; - } - -#if defined(BOOST_HAS_LONG_LONG) - template - inline bool lexical_stream_limited_src::operator<<( - boost::ulong_long_type n) - { - start = lcast_put_unsigned(n, finish); - return true; - } -#elif defined(BOOST_HAS_MS_INT64) - template - inline bool lexical_stream_limited_src::operator<<( - unsigned __int64 n) - { - start = lcast_put_unsigned(n, finish); - return true; - } -#endif - - template - inline bool lexical_stream_limited_src::operator<<( - float val) - { - return this->lcast_put(val); - } - - template - inline bool lexical_stream_limited_src::operator<<( - double val) - { - return this->lcast_put(val); - } - - template - inline bool lexical_stream_limited_src::operator<<( - long double val) - { - return this->lcast_put(val); - } - - template - inline bool lexical_stream_limited_src::operator<<( - CharT const* str) - { - start = const_cast(str); - finish = start + Traits::length(str); - return true; - } - - template - inline bool lexical_stream_limited_src::operator>>( - CharT& output) - { - bool const ok = (finish - start == 1); - if(ok) - Traits::assign(output, *start); - return ok; - } - - template - inline bool lexical_stream_limited_src::operator>>( - unsigned char& output) - { - BOOST_STATIC_ASSERT( sizeof(CharT) == sizeof(unsigned char) ); - bool const ok = (finish - start == 1); - if(ok) { - CharT out; - Traits::assign(out, *start); - output = static_cast(out); - } - return ok; - } - - template - inline bool lexical_stream_limited_src::operator>>( - signed char& output) - { - BOOST_STATIC_ASSERT( sizeof(CharT) == sizeof(signed char) ); - bool const ok = (finish - start == 1); - if(ok) { - CharT out; - Traits::assign(out, *start); - output = static_cast(out); - } - return ok; - } - -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template - inline bool lexical_stream_limited_src::operator>>( - std::string& str) - { - str.assign(start, finish); - return true; - } - -#ifndef BOOST_LCAST_NO_WCHAR_T - template - inline bool lexical_stream_limited_src::operator>>( - std::wstring& str) - { - str.assign(start, finish); - return true; - } -#endif -#endif - } - - namespace detail // lcast_streambuf_for_source - { - // Returns true if optimized stream wrapper needs ostream for writing. - template - struct lcast_streambuf_for_source - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; - - template<> - struct lcast_streambuf_for_source - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - - template<> - struct lcast_streambuf_for_source - { - BOOST_STATIC_CONSTANT(bool, value = true); - }; - - template<> - struct lcast_streambuf_for_source - { - BOOST_STATIC_CONSTANT(bool, value = true); + bool operator>>(InputStreamable& output) { return shr_using_base_class(output); } }; } - namespace detail // lcast_streambuf_for_target - { - // Returns true if optimized stream wrapper needs istream for reading. - template - struct lcast_streambuf_for_target - { - BOOST_STATIC_CONSTANT(bool, value = - ( - ::boost::type_traits::ice_not< is_integral::value >::value - ) - ); - }; - #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template - struct lcast_streambuf_for_target< - std::basic_string > - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; - -#ifndef BOOST_LCAST_NO_WCHAR_T - template - struct lcast_streambuf_for_target< - std::basic_string > - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; -#endif -#else - template<> - struct lcast_streambuf_for_target - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; - -#ifndef BOOST_LCAST_NO_WCHAR_T - template<> - struct lcast_streambuf_for_target - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; -#endif -#endif - } - - #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION // call-by-const reference version @@ -1491,47 +1538,6 @@ namespace boost typedef const T * type; }; -#if (defined _MSC_VER) -# pragma warning( push ) -# pragma warning( disable : 4701 ) // possible use of ... before initialization -# pragma warning( disable : 4702 ) // unreachable code -# pragma warning( disable : 4267 ) // conversion from 'size_t' to 'unsigned int' -#endif - - template< typename Target - , typename Source - , bool Unlimited // string representation of Source is unlimited - , typename CharT - > - Target lexical_cast( - BOOST_DEDUCED_TYPENAME boost::call_traits::param_type arg, - CharT* buf, std::size_t src_len) - { - typedef BOOST_DEDUCED_TYPENAME - deduce_char_traits::type traits; - - typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c< - lcast_streambuf_for_target::value || - lcast_streambuf_for_source::value - , std::basic_streambuf - , lexical_streambuf_fake - >::type base; - - BOOST_DEDUCED_TYPENAME boost::mpl::if_c< - Unlimited - , detail::lexical_stream - , detail::lexical_stream_limited_src - >::type interpreter(buf, buf + src_len); - - Target result; - if(!(interpreter << arg && interpreter >> result)) - BOOST_LCAST_THROW_BAD_CAST(Source, Target); - return result; - } -#if (defined _MSC_VER) -# pragma warning( pop ) -#endif - template struct is_stdstring { @@ -1634,25 +1640,62 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = true ); }; +#if (defined _MSC_VER) +# pragma warning( push ) +# pragma warning( disable : 4701 ) // possible use of ... before initialization +# pragma warning( disable : 4702 ) // unreachable code +# pragma warning( disable : 4267 ) // conversion from 'size_t' to 'unsigned int' +#endif template struct lexical_cast_do_cast { - static inline Target lexical_cast_impl(const Source &arg) + static inline Target lexical_cast_impl(const Source& arg) { - typedef typename detail::array_to_pointer_decay::type src; + typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay::type src; - typedef typename detail::widest_char< - typename detail::stream_char::type - , typename detail::stream_char::type + typedef BOOST_DEDUCED_TYPENAME detail::widest_char< + BOOST_DEDUCED_TYPENAME detail::stream_char::type + , BOOST_DEDUCED_TYPENAME detail::stream_char::type >::type char_type; typedef detail::lcast_src_length lcast_src_length; std::size_t const src_len = lcast_src_length::value; char_type buf[src_len + 1]; lcast_src_length::check_coverage(); - return detail::lexical_cast(arg, buf, src_len); + + typedef BOOST_DEDUCED_TYPENAME + deduce_char_traits::type traits; + + typedef BOOST_DEDUCED_TYPENAME remove_pointer::type removed_ptr_t; + const bool requires_stringbuf = + !( + ::boost::type_traits::ice_or< + is_stdstring::value, + is_arithmetic::value, + ::boost::type_traits::ice_and< + is_pointer::value, + is_char_or_wchar::value, + ::boost::type_traits::ice_eq< + sizeof(char_type), + sizeof(removed_ptr_t) + >::value + >::value + >::value + ); + + detail::lexical_stream_limited_src + interpreter(buf, buf + src_len); + + Target result; + // Disabling ADL, by directly specifying operators. + if(!(interpreter.operator <<(arg) && interpreter.operator >>(result))) + BOOST_LCAST_THROW_BAD_CAST(Source, Target); + return result; } }; +#if (defined _MSC_VER) +# pragma warning( pop ) +#endif template struct lexical_cast_copy @@ -1708,6 +1751,7 @@ namespace boost } catch( ::boost::numeric::bad_numeric_cast const& ) { BOOST_LCAST_THROW_BAD_CAST(Source, Target); } + BOOST_UNREACHABLE_RETURN(static_cast(0)); } }; @@ -1734,6 +1778,7 @@ namespace boost } catch( ::boost::numeric::bad_numeric_cast const& ) { BOOST_LCAST_THROW_BAD_CAST(Source, Target); } + BOOST_UNREACHABLE_RETURN(static_cast(0)); } }; @@ -1815,6 +1860,78 @@ namespace boost #else + namespace detail // stream wrapper for handling lexical conversions + { + template + class lexical_stream + { + private: + typedef typename widest_char< + typename stream_char::type, + typename stream_char::type>::type char_type; + + typedef Traits traits_type; + + public: + lexical_stream(char_type* = 0, char_type* = 0) + { + stream.unsetf(std::ios::skipws); + lcast_set_precision(stream, static_cast(0), static_cast(0) ); + } + ~lexical_stream() + { + #if defined(BOOST_NO_STRINGSTREAM) + stream.freeze(false); + #endif + } + bool operator<<(const Source &input) + { + return !(stream << input).fail(); + } + template + bool operator>>(InputStreamable &output) + { + return !is_pointer::value && + stream >> output && + stream.get() == +#if defined(__GNUC__) && (__GNUC__<3) && defined(BOOST_NO_STD_WSTRING) +// GCC 2.9x lacks std::char_traits<>::eof(). +// We use BOOST_NO_STD_WSTRING to filter out STLport and libstdc++-v3 +// configurations, which do provide std::char_traits<>::eof(). + + EOF; +#else + traits_type::eof(); +#endif + } + + bool operator>>(std::string &output) + { + #if defined(BOOST_NO_STRINGSTREAM) + stream << '\0'; + #endif + stream.str().swap(output); + return true; + } + #ifndef BOOST_LCAST_NO_WCHAR_T + bool operator>>(std::wstring &output) + { + stream.str().swap(output); + return true; + } + #endif + + private: + #if defined(BOOST_NO_STRINGSTREAM) + std::strstream stream; + #elif defined(BOOST_NO_STD_LOCALE) + std::stringstream stream; + #else + std::basic_stringstream stream; + #endif + }; + } + // call-by-value fallback version (deprecated) template diff --git a/index.html b/index.html index cf8527f..133680c 100644 --- a/index.html +++ b/index.html @@ -24,7 +24,7 @@ supplied by several headers:

    and polymorphic_downcast<> to perform safe casting between polymorphic types.
    -
  • The boost/lexical_cast header provides lexical_cast<> +
  • The boost/lexical_cast header provides lexical_cast<> general literal text conversions, such as an int represented as a string, or vice-versa.
  • diff --git a/lexical_cast.htm b/lexical_cast.htm index 7929dd4..73b6ba5 100644 --- a/lexical_cast.htm +++ b/lexical_cast.htm @@ -1,351 +1,16 @@ - - - - - lexical_cast - - - - -

    boost.png (6897 bytes)Header - boost/lexical_cast.hpp

    - -
    -

    Motivation

    - Sometimes a value must be converted to a literal text form, such as an int - represented as a string, or vice-versa, when a string - is interpreted as an int. Such examples are common when converting - between data types internal to a program and representation external to a - program, such as windows and configuration files. -

    - The standard C and C++ libraries offer a number of facilities for performing - such conversions. However, they vary with their ease of use, extensibility, and - safety. -

    - For instance, there are a number of limitations with the family of standard C - functions typified by atoi: -

      -
    • - Conversion is supported in one direction only: from text to internal data type. - Converting the other way using the C library requires either the inconvenience - and compromised safety of the sprintf function, or the loss of - portability associated with non-standard functions such as itoa. -
    • -
    • - The range of types supported is only a subset of the built-in numeric types, - namely int, long, and double. -
    • -
    • - The range of types cannot be extended in a uniform manner. For instance, - conversion from string representation to complex or rational. -
    • -
    - The standard C functions typified by strtol have the same basic - limitations, but offer finer control over the conversion process. However, for - the common case such control is often either not required or not used. The scanf - family of functions offer even greater control, but also lack safety and ease - of use. -

    - The standard C++ library offers stringstream for the kind of - in-core formatting being discussed. It offers a great deal of control over the - formatting and conversion of I/O to and from arbitrary types through text. - However, for simple conversions direct use of stringstream can be - either clumsy (with the introduction of extra local variables and the loss of - infix-expression convenience) or obscure (where stringstream - objects are created as temporary objects in an expression). Facets provide a - comprehensive concept and facility for controlling textual representation, but - their perceived complexity and high entry level requires an extreme degree of - involvement for simple conversions, and excludes all but a few programmers. -

    - The lexical_cast function template offers a convenient and - consistent form for supporting common conversions to and from arbitrary types - when they are represented as text. The simplification it offers is in - expression-level convenience for such conversions. For more involved - conversions, such as where precision or formatting need tighter control than is - offered by the default behavior of lexical_cast, the conventional - stringstream approach is recommended. Where the conversions are - numeric to numeric, numeric_cast - may offer more reasonable behavior than lexical_cast. -

    - For a good discussion of the options and issues involved in string-based - formatting, including comparison of stringstream, lexical_cast, - and others, see Herb Sutter's article, - The String Formatters of Manor Farm. Also, take a look at the Performance section. -

    -


    -

    Examples

    - The following example treats command line arguments as a sequence of numeric - data:
    -
    int main(int argc, char * argv[])
    -{
    -    using boost::lexical_cast;
    -    using boost::bad_lexical_cast;
     
    -    std::vector<short> args;
    -
    -    while(*++argv)
    -    {
    -        try
    -        {
    -            args.push_back(lexical_cast<short>(*argv));
    -        }
    -        catch(bad_lexical_cast &)
    -        {
    -            args.push_back(0);
    -        }
    -    }
    -    ...
    -}
    -
    -
    The following example uses numeric data in a string expression:
    -
    void log_message(const std::string &);
    -
    -void log_errno(int yoko)
    -{
    -    log_message("Error " + boost::lexical_cast<std::string>(yoko) + ": " + strerror(yoko));
    -}
    -
    -
    -
    -

    Synopsis

    - Library features defined in "boost/lexical_cast.hpp": -
    -
    namespace boost
    -{
    -    class bad_lexical_cast;
    -    template<typename Target, typename Source>
    -      Target lexical_cast(const Source& arg);
    -}
    -
    -
    Unit test defined in "lexical_cast_test.cpp". -

    -


    -

    lexical_cast

    -
    -
    template<typename Target, typename Source>
    -  Target lexical_cast(const Source& arg);
    -
    -
    Returns the result of streaming arg into a - standard library string-based stream and then out as a Target object. - Where Target is either std::string - or std::wstring, stream extraction takes the whole content - of the string, including spaces, rather than relying on the default - operator>> behavior. - If the conversion is unsuccessful, a - bad_lexical_cast exception is thrown. -

    - The requirements on the argument and result types are: -

      -
    • - Source is OutputStreamable, meaning that an operator<< - is defined that takes a std::ostream or std::wostream object on the - left hand side and an instance of the argument type on the right. -
    • -
    • - Target is InputStreamable, meaning that an operator>> - is defined that takes a std::istream or std::wistream object on the left hand side - and an instance of the result type on the right. -
    • -
    • - Target is CopyConstructible [20.1.3]. -
    • -
    • - Target is DefaultConstructible, meaning that it is possible - to default-initialize an object of that type [8.5, 20.1.4]. -
    • -
    - The character type of the underlying stream is assumed to be char unless - either the Source or the Target requires wide-character - streaming, in which case the underlying stream uses wchar_t. - Source types that require wide-character streaming are wchar_t, - wchar_t *, and std::wstring. Target types that - require wide-character streaming are wchar_t and std::wstring. -

    - Where a higher degree of control is required over conversions, std::stringstream - and std::wstringstream offer a more appropriate path. Where non-stream-based conversions are - required, lexical_cast - is the wrong tool for the job and is not special-cased for such scenarios. -

    -


    -

    bad_lexical_cast

    -
    -
    class bad_lexical_cast : public std::bad_cast
    -{
    -public:
    -    ... // same member function interface as std::exception
    -};
    -
    -
    Exception used to indicate runtime lexical_cast - failure. - -
    - - -

    Frequently Asked Questions

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Question:Why does lexical_cast<int8_t>("127") throw bad_lexical_cast?
    Answer:The type int8_t is a typedef to char or signed char. - Lexical conversion to these types is simply reading a byte from source but since the source has - more than one byte, the exception is thrown. - Please use other integer types such as int or short int. If bounds checking - is important, you can also call numeric_cast: -
    numeric_cast<int8_t>(lexical_cast<int>("127"));
    -
    Question:What does lexical_cast<std::string> of an int8_t or uint8_t not do what I expect?
    Answer:As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid this, cast to an integer type first: -
    lexical_cast<std::string>(static_cast<int>(n));
    -
    Question:The implementation always resets the ios_base::skipws flag of an underlying stream object. It breaks my operator>> that works only in presence of this flag. Can you remove code that resets the flag?
    Answer:May be in a future version. There is no requirement in [N1973] to reset the flag but remember that [N1973] is not yet accepted by the committee. By the way, it's a great opportunity to make your operator>> conform to the standard. Read a good C++ book, study std::sentry and ios_state_saver. -
    Question:Why std::cout << boost::lexical_cast<unsigned int>("-1"); does not throw, but outputs 4294967295?
    Answer:boost::lexical_cast has the behavior of stringstream, which uses num_get functions of std::locale to convert numbers. If we look at the [22.2.2.1.2] of Programming languages — C++, we'll see, that num_get uses the rules of scanf for conversions. And in the C99 standard for unsigned input value minus sign is optional, so if a negative number is read, no errors will arise and the result will be the two's complement. -
    - -

    References

    -
      -
    • [N1973] Kevlin Henney, Beman Dawes, Lexical Conversion Library Proposal for TR2, - N1973. -
    • [Tuning] Alexander Nasonov, Fine Tuning for lexical_cast, - Overload #74 (PDF), - August 2006.
    • -
    -

    Changes

    -

    May 2011:

    -
      -
    • Optimizations for "C" and other locales without number grouping.
    • -
    • Better performance and less memory usage for unsigned char and signed char conversions.
    • -
    • Better performance and less memory usage for conversions to arithmetic types.
    • -
    • Better performance and less memory usage for conversions from arithmetic type to arithmetic type.
    • -
    • Directly construct Target from Source on some conversions (like conversions from string to string, from char array to string, from char to char and others).
    • -
    -

    August, October 2006:

    -
      -
    • Better performance for many combinations of Source and Target - types. Refer to [Tuning] for more details. -
    • -
    -

    June 2005:

    -
      -
    • Call-by-const reference for the parameters. This requires partial specialization - of class templates, so it doesn't work for MSVC 6, and it uses the original - pass by value there.
      -
    • -
    • The MSVC 6 support is deprecated, and will be removed in a future Boost - version.
    • -
    -

    Earlier:

    - -
      -
    • The previous version of lexical_cast used the default stream - precision for reading and writing floating-point numbers. For numerics that - have a corresponding specialization of std::numeric_limits, the - current version now chooses a precision to match.
      -
    • The previous version of lexical_cast did not support conversion - to or from any wide-character-based types. For compilers with full language - and library support for wide characters, lexical_cast now supports - conversions from wchar_t, wchar_t *, and std::wstring - and to wchar_t and std::wstring.
      -
    • The previous version of lexical_cast assumed that the conventional - stream extractor operators were sufficient for reading values. However, string - I/O is asymmetric, with the result that spaces play the role of I/O separators - rather than string content. The current version fixes this error for std::string - and, where supported, std::wstring: lexical_cast<std::string>("Hello, - World") succeeds instead of failing with a bad_lexical_cast - exception.
      -
    • The previous version of lexical_cast allowed unsafe and meaningless - conversions to pointers. The current version now throws a bad_lexical_cast - for conversions to pointers: lexical_cast<char *>("Goodbye, World") - now throws an exception instead of causing undefined behavior. -
    -

    -


    - -

    Performance

    -This table shows the execution time in milliseconds for 100000 calls of the following string formatters: - - - - - - - - - - - - - - - - - -
    From->To lexical_cast std::stringstream
    with construction
    std::stringstream
    without construction
    sscanf/sprintf
    string->char<191710
    string->int71152318
    string->unsigned int71172217
    string->bool<11041910
    string->float851726033
    char->string71051612
    int->string151312117
    unsigned int->string141252117
    bool->string71222412
    float->string12422311548
    char*->string912320---
    int->int<112026---
    float->float<1262142---
    - -Fastest results are highlitened with green. -
    -
    Copyright © Kevlin Henney, 2000-2005
    -
    Copyright © Alexander Nasonov, 2006-2010
    -
    Copyright © Antony Polukhin, 2011
    -
    - 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) -
    - + + + + + +Automatic redirection failed, please go to +../../doc/html/boost_lexical_cast.html + diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index f20994e..f07926b 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #if (defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)) \ @@ -42,6 +43,10 @@ #define LCAST_TEST_LONGLONG #endif +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) +#define BOOST_LCAST_NO_WCHAR_T +#endif + template struct my_traits : std::char_traits { @@ -65,6 +70,7 @@ void test_conversion_to_char(); void test_conversion_to_int(); void test_conversion_to_double(); void test_conversion_to_bool(); +void test_conversion_with_nonconst_char(); void test_conversion_to_string(); void test_conversion_from_to_wchar_t_alias(); void test_conversion_to_pointer(); @@ -86,9 +92,6 @@ void test_conversion_from_to_uintmax_t(); void test_conversion_from_to_longlong(); void test_conversion_from_to_ulonglong(); #endif -void test_conversion_from_to_float(); -void test_conversion_from_to_double(); -void test_conversion_from_to_long_double(); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION void test_traits(); void test_wtraits(); @@ -96,6 +99,7 @@ void test_allocator(); void test_wallocator(); #endif void test_char_types_conversions(); +void operators_overload_test(); unit_test::test_suite *init_unit_test_suite(int, char *[]) { @@ -108,6 +112,7 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(test_conversion_from_to_wchar_t_alias)); suite->add(BOOST_TEST_CASE(test_conversion_to_pointer)); suite->add(BOOST_TEST_CASE(test_conversion_to_string)); + suite->add(BOOST_TEST_CASE(test_conversion_with_nonconst_char)); #ifndef BOOST_LCAST_NO_WCHAR_T suite->add(BOOST_TEST_CASE(test_conversion_from_wchar_t)); suite->add(BOOST_TEST_CASE(test_conversion_to_wchar_t)); @@ -128,9 +133,6 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong)); #endif - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_float)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_double)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_long_double)); #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION suite->add(BOOST_TEST_CASE(&test_traits)); suite->add(BOOST_TEST_CASE(&test_wtraits)); @@ -139,6 +141,7 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) #endif suite->add(BOOST_TEST_CASE(&test_char_types_conversions)); + suite->add(BOOST_TEST_CASE(&operators_overload_test)); return suite; } @@ -201,19 +204,45 @@ void test_conversion_to_int() lexical_cast(std::string("Test")), bad_lexical_cast); } +void test_conversion_with_nonconst_char() +{ + std::vector buffer; + buffer.push_back('1'); + buffer.push_back('\0'); + BOOST_CHECK_EQUAL(boost::lexical_cast(&buffer[0]), 1); + + std::vector buffer2; + buffer2.push_back('1'); + buffer2.push_back('\0'); + BOOST_CHECK_EQUAL(boost::lexical_cast(&buffer2[0]), 1); + + std::vector buffer3; + buffer3.push_back('1'); + buffer3.push_back('\0'); + BOOST_CHECK_EQUAL(boost::lexical_cast(&buffer3[0]), 1); + +#ifndef BOOST_LCAST_NO_WCHAR_T + std::vector buffer4; + buffer4.push_back(L'1'); + buffer4.push_back(L'\0'); + BOOST_CHECK_EQUAL(boost::lexical_cast(&buffer4[0]), 1); +#endif +} + void test_conversion_to_double() { - BOOST_CHECK_CLOSE(1.0, lexical_cast('1'), (std::numeric_limits::epsilon())); + BOOST_CHECK_CLOSE_FRACTION(1.0, lexical_cast('1'), (std::numeric_limits::epsilon())); BOOST_CHECK_THROW(lexical_cast('A'), bad_lexical_cast); - BOOST_CHECK_CLOSE(1.0, lexical_cast(1), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.23, lexical_cast(1.23), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.234567890, 1.234567890, std::numeric_limits::epsilon()); - BOOST_CHECK_CLOSE(1.0, lexical_cast(true), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(0.0, lexical_cast(false), (std::numeric_limits::epsilon())); - BOOST_CHECK_CLOSE(1.23, lexical_cast("1.23"), (std::numeric_limits::epsilon())); + BOOST_CHECK_CLOSE_FRACTION(1.0, lexical_cast(1), (std::numeric_limits::epsilon())); + BOOST_CHECK_CLOSE_FRACTION(1.23, lexical_cast(1.23), (std::numeric_limits::epsilon())); + BOOST_CHECK_CLOSE_FRACTION(1.234567890, lexical_cast(1.234567890), std::numeric_limits::epsilon()); + BOOST_CHECK_CLOSE_FRACTION(1.234567890, lexical_cast("1.234567890"), std::numeric_limits::epsilon()); + BOOST_CHECK_CLOSE_FRACTION(1.0, lexical_cast(true), (std::numeric_limits::epsilon())); + BOOST_CHECK_CLOSE_FRACTION(0.0, lexical_cast(false), (std::numeric_limits::epsilon())); + BOOST_CHECK_CLOSE_FRACTION(1.23, lexical_cast("1.23"), (std::numeric_limits::epsilon())); BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("Test"), bad_lexical_cast); - BOOST_CHECK_CLOSE(1.23, lexical_cast(std::string("1.23")), (std::numeric_limits::epsilon())); + BOOST_CHECK_CLOSE_FRACTION(1.23, lexical_cast(std::string("1.23")), (std::numeric_limits::epsilon())); BOOST_CHECK_THROW( lexical_cast(std::string("")), bad_lexical_cast); BOOST_CHECK_THROW( @@ -679,7 +708,7 @@ void test_conversion_from_to_integral_for_locale() BOOST_CHECK_THROW(lexical_cast( np.thousands_sep() + std::string("100") ), bad_lexical_cast); // Exception must not be thrown, when we are using no separators at all - BOOST_CHECK( lexical_cast("10000") == static_cast(10000) ); + BOOST_CHECK( lexical_cast("30000") == static_cast(30000) ); } test_conversion_from_integral_to_integral(); @@ -775,35 +804,6 @@ void test_conversion_from_to_integral() BOOST_TEST_MESSAGE("Formatting with thousands_sep has not been tested"); } -template -void test_conversion_from_to_float() -{ - char const zero = '0'; - signed char const szero = '0'; - unsigned char const uzero = '0'; - test_conversion_from_integral_to_char(zero); - test_conversion_from_char_to_integral(zero); - test_conversion_from_integral_to_char(szero); - test_conversion_from_char_to_integral(szero); - test_conversion_from_integral_to_char(uzero); - test_conversion_from_char_to_integral(uzero); -#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - wchar_t const wzero = L'0'; - test_conversion_from_integral_to_char(wzero); - test_conversion_from_char_to_integral(wzero); -#endif - - test_conversion_from_integral_to_integral(); - - BOOST_CHECK_CLOSE(lexical_cast("+1"), 1, std::numeric_limits::epsilon() ); - BOOST_CHECK_CLOSE(lexical_cast("+9"), 9, std::numeric_limits::epsilon()*9 ); - - BOOST_CHECK_THROW(lexical_cast("++1"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("-+9"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("--1"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("+-9"), bad_lexical_cast); -} - void test_conversion_from_to_short() { test_conversion_from_to_integral(); @@ -844,19 +844,6 @@ void test_conversion_from_to_uintmax_t() test_conversion_from_to_integral(); } -void test_conversion_from_to_float() -{ - test_conversion_from_to_float(); -} -void test_conversion_from_to_double() -{ - test_conversion_from_to_float(); -} -void test_conversion_from_to_long_double() -{ - test_conversion_from_to_float(); -} - #if defined(BOOST_HAS_LONG_LONG) void test_conversion_from_to_longlong() @@ -966,16 +953,40 @@ void test_char_types_conversions() const wchar_t wc_arr[]=L"Test array of chars"; BOOST_CHECK(boost::lexical_cast(wc_arr) == std::wstring(wc_arr)); - BOOST_CHECK(boost::lexical_cast(c_arr) == std::wstring(wc_arr)); - - BOOST_CHECK(boost::lexical_cast(sc_arr) != std::wstring(wc_arr) ); - BOOST_CHECK(boost::lexical_cast(uc_arr) != std::wstring(wc_arr) ); - - BOOST_CHECK(boost::lexical_cast(c_arr[0]) == wc_arr[0]); BOOST_CHECK(boost::lexical_cast(wc_arr[0]) == wc_arr[0]); - BOOST_CHECK_THROW(boost::lexical_cast(uc_arr[0]), bad_lexical_cast); - BOOST_CHECK_THROW(boost::lexical_cast(sc_arr[0]), bad_lexical_cast); - #endif } + + + +struct foo_operators_test +{ + foo_operators_test() : f(2) {} + int f; +}; + +template +OStream& operator<<(OStream& ostr, const foo_operators_test& foo) +{ + ostr << foo.f; + return ostr; +} + +template +IStream& operator>>(IStream& istr, foo_operators_test& foo) +{ + istr >> foo.f; + return istr; +} + +void operators_overload_test() +{ + foo_operators_test foo; + BOOST_CHECK_EQUAL(boost::lexical_cast(foo), "2"); + BOOST_CHECK_EQUAL((boost::lexical_cast("2")).f, 2); + + // Must compile + (void)boost::lexical_cast(foo); +} + diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1fea2fb..2dd3500 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -25,6 +25,9 @@ test-suite conversion [ run lexical_cast_abstract_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_noncopyable_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_vc8_bug_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_wchars_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_float_types_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_inf_nan_test.cpp ../../test/build//boost_unit_test_framework/static ] ; diff --git a/test/lexical_cast_float_types_test.cpp b/test/lexical_cast_float_types_test.cpp new file mode 100755 index 0000000..72279bb --- /dev/null +++ b/test/lexical_cast_float_types_test.cpp @@ -0,0 +1,513 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2011. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include + +#include +#include +#include + +void test_conversion_from_to_float(); +void test_conversion_from_to_double(); +void test_conversion_from_to_long_double(); + +using namespace boost; + + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test_framework::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast float types unit test"); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_float)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_double)); + suite->add(BOOST_TEST_CASE(&test_conversion_from_to_long_double)); + + return suite; +} + + +// Replace "-,999" with "-999". +template +std::basic_string to_str_gcc_workaround(std::basic_string str) +{ + std::locale loc; + std::numpunct const& np = BOOST_USE_FACET(std::numpunct, loc); + std::ctype const& ct = BOOST_USE_FACET(std::ctype, loc); + + if(np.grouping().empty()) + return str; + + CharT prefix[3] = { ct.widen('-'), np.thousands_sep(), CharT() }; + + if(str.find(prefix) != 0) + return str; + + prefix[1] = CharT(); + str.replace(0, 2, prefix); + return str; +} + +template +std::basic_string to_str(T t) +{ + std::basic_ostringstream o; + o << t; + return to_str_gcc_workaround(o.str()); +} + + +template +void test_conversion_from_to_float_for_locale() +{ + std::locale current_locale; + typedef std::numpunct numpunct; + numpunct const& np = BOOST_USE_FACET(numpunct, current_locale); + if ( !np.grouping().empty() ) + { + BOOST_CHECK_THROW( + lexical_cast( std::string("100") + np.thousands_sep() + np.thousands_sep() + "0" ) + , bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast( std::string("100") + np.thousands_sep() ), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast( np.thousands_sep() + std::string("100") ), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast( std::string("1") + np.thousands_sep() + np.decimal_point() + "e10" ), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast( std::string("1e10") + np.thousands_sep() ), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast( std::string("1") + np.thousands_sep() + "e10" ), bad_lexical_cast); + + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( to_str< char >(100000) ), 100000, (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( to_str< char >(10000000u) ), 10000000u, (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( to_str< char >(100) ), 100, (std::numeric_limits::epsilon()) ); +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( to_str< wchar_t >(100000) ), 100000, (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( to_str< wchar_t >(10000000u) ), 10000000u, (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( to_str< wchar_t >(100) ), 100, (std::numeric_limits::epsilon()) ); +#endif + // Exception must not be thrown, when we are using no separators at all + BOOST_CHECK_CLOSE_FRACTION( lexical_cast("30000"), static_cast(30000), (std::numeric_limits::epsilon()) ); + } +} + + + + +/* + * Converts char* [and wchar_t] to float number type and checks, that generated + * number is in interval [base_value-epsilon, base_value+epsilon]. + */ +#ifndef BOOST_LCAST_NO_WCHAR_T +#define CHECK_CLOSE_ABS_DIFF(VAL,PREFIX) \ + converted_val = lexical_cast(#VAL); \ + BOOST_CHECK_CLOSE_FRACTION( (VAL ## L? VAL ## L : std::numeric_limits::epsilon()), \ + (converted_val ? converted_val : std::numeric_limits::epsilon()), \ + std::numeric_limits::epsilon() \ + ); \ + BOOST_CHECK_EQUAL(converted_val, lexical_cast(L## #VAL) ); + +#else +#define CHECK_CLOSE_ABS_DIFF(VAL,TYPE) \ + converted_val = lexical_cast(#VAL); \ + BOOST_CHECK_CLOSE_FRACTION( (VAL ## L? VAL ## L : std::numeric_limits::epsilon()), \ + (converted_val ? converted_val : std::numeric_limits::epsilon()), \ + std::numeric_limits::epsilon() \ + ); +#endif + +template +void test_converion_to_float_types() +{ + typedef TestType test_t; + test_t converted_val; + + BOOST_CHECK_CLOSE_FRACTION(1.0, lexical_cast('1'), (std::numeric_limits::epsilon())); + BOOST_CHECK_EQUAL(0.0, lexical_cast('0')); + + unsigned char const uc_one = '1'; + unsigned char const uc_zero ='0'; + BOOST_CHECK_CLOSE_FRACTION(1.0, lexical_cast(uc_one), (std::numeric_limits::epsilon())); + BOOST_CHECK_EQUAL(0.0, lexical_cast(uc_zero)); + + signed char const sc_one = '1'; + signed char const sc_zero ='0'; + BOOST_CHECK_CLOSE_FRACTION(1.0, lexical_cast(sc_one), (std::numeric_limits::epsilon())); + BOOST_CHECK_EQUAL(0.0, lexical_cast(sc_zero)); + + BOOST_CHECK_CLOSE_FRACTION(1e34L, lexical_cast( "10000000000000000000000000000000000"), (std::numeric_limits::epsilon()) ); + +// VC failes the next test +// BOOST_CHECK_CLOSE_FRACTION(1e-35L, lexical_cast("0.00000000000000000000000000000000001"), (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION( + 0.1111111111111111111111111111111111111111111111111111111111111111111111111L + , lexical_cast("0.1111111111111111111111111111111111111111111111111111111111111111111111111") + , (std::numeric_limits::epsilon()) ); + + CHECK_CLOSE_ABS_DIFF(1,test_t); + BOOST_CHECK_EQUAL(0,lexical_cast("0")); + CHECK_CLOSE_ABS_DIFF(-1,test_t); + + CHECK_CLOSE_ABS_DIFF(1.0, test_t); + CHECK_CLOSE_ABS_DIFF(0.0, test_t); + CHECK_CLOSE_ABS_DIFF(-1.0,test_t); + + CHECK_CLOSE_ABS_DIFF(1e1, test_t); + CHECK_CLOSE_ABS_DIFF(0e1, test_t); + CHECK_CLOSE_ABS_DIFF(-1e1,test_t); + + CHECK_CLOSE_ABS_DIFF(1.0e1, test_t); + CHECK_CLOSE_ABS_DIFF(0.0e1, test_t); + CHECK_CLOSE_ABS_DIFF(-1.0e1,test_t); + + CHECK_CLOSE_ABS_DIFF(1e-1, test_t); + CHECK_CLOSE_ABS_DIFF(0e-1, test_t); + CHECK_CLOSE_ABS_DIFF(-1e-1,test_t); + + CHECK_CLOSE_ABS_DIFF(1.0e-1, test_t); + CHECK_CLOSE_ABS_DIFF(0.0e-1, test_t); + CHECK_CLOSE_ABS_DIFF(-1.0e-1,test_t); + + CHECK_CLOSE_ABS_DIFF(1E1, test_t); + CHECK_CLOSE_ABS_DIFF(0E1, test_t); + CHECK_CLOSE_ABS_DIFF(-1E1,test_t); + + CHECK_CLOSE_ABS_DIFF(1.0E1, test_t); + CHECK_CLOSE_ABS_DIFF(0.0E1, test_t); + CHECK_CLOSE_ABS_DIFF(-1.0E1,test_t); + + CHECK_CLOSE_ABS_DIFF(1E-1, test_t); + CHECK_CLOSE_ABS_DIFF(0E-1, test_t); + CHECK_CLOSE_ABS_DIFF(-1E-1,test_t); + + CHECK_CLOSE_ABS_DIFF(1.0E-1, test_t); + CHECK_CLOSE_ABS_DIFF(0.0E-1, test_t); + CHECK_CLOSE_ABS_DIFF(-1.0E-1, test_t); + + CHECK_CLOSE_ABS_DIFF(.0E-1, test_t); + CHECK_CLOSE_ABS_DIFF(.0E-1, test_t); + CHECK_CLOSE_ABS_DIFF(-.0E-1, test_t); + + CHECK_CLOSE_ABS_DIFF(10.0, test_t); + CHECK_CLOSE_ABS_DIFF(00.0, test_t); + CHECK_CLOSE_ABS_DIFF(-10.0,test_t); + + CHECK_CLOSE_ABS_DIFF(10e1, test_t); + CHECK_CLOSE_ABS_DIFF(00e1, test_t); + CHECK_CLOSE_ABS_DIFF(-10e1,test_t); + + CHECK_CLOSE_ABS_DIFF(10.0e1, test_t); + CHECK_CLOSE_ABS_DIFF(00.0e1, test_t); + CHECK_CLOSE_ABS_DIFF(-10.0e1,test_t); + + CHECK_CLOSE_ABS_DIFF(10e-1, test_t); + CHECK_CLOSE_ABS_DIFF(00e-1, test_t); + CHECK_CLOSE_ABS_DIFF(-10e-1,test_t); + + CHECK_CLOSE_ABS_DIFF(10.0e-1, test_t); + CHECK_CLOSE_ABS_DIFF(00.0e-1, test_t); + CHECK_CLOSE_ABS_DIFF(-10.0e-1,test_t); + + CHECK_CLOSE_ABS_DIFF(10E1, test_t); + CHECK_CLOSE_ABS_DIFF(00E1, test_t); + CHECK_CLOSE_ABS_DIFF(-10E1,test_t); + + CHECK_CLOSE_ABS_DIFF(10.0E1, test_t); + CHECK_CLOSE_ABS_DIFF(00.0E1, test_t); + CHECK_CLOSE_ABS_DIFF(-10.0E1,test_t); + + CHECK_CLOSE_ABS_DIFF(10E-1, test_t); + CHECK_CLOSE_ABS_DIFF(00E-1, test_t); + CHECK_CLOSE_ABS_DIFF(-10E-1,test_t); + + CHECK_CLOSE_ABS_DIFF(10.0E-1, test_t); + CHECK_CLOSE_ABS_DIFF(00.0E-1, test_t); + CHECK_CLOSE_ABS_DIFF(-10.0E-1, test_t); + + CHECK_CLOSE_ABS_DIFF(-10101.0E-011, test_t); + CHECK_CLOSE_ABS_DIFF(-10101093, test_t); + CHECK_CLOSE_ABS_DIFF(10101093, test_t); + + CHECK_CLOSE_ABS_DIFF(-.34, test_t); + CHECK_CLOSE_ABS_DIFF(.34, test_t); + CHECK_CLOSE_ABS_DIFF(.34e10, test_t); + + BOOST_CHECK_THROW(lexical_cast("-1.e"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("-1.E"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("1.e"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("1.E"), bad_lexical_cast); + + BOOST_CHECK_THROW(lexical_cast("1.0e"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("1.0E"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("10E"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("10e"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("1.0e-"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("1.0E-"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("10E-"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("10e-"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("e1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("e-1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("e-"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(".e"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(".11111111111111111111111111111111111111111111111111111111111111111111ee"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(".11111111111111111111111111111111111111111111111111111111111111111111e-"), bad_lexical_cast); + + BOOST_CHECK_THROW(lexical_cast("-B"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("0xB"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("0x0"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("--1.0"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("1.0e--1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("1.0.0"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("1e1e1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("1.0e-1e-1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(" 1.0"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("1.0 "), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(""), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("-"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast('\0'), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast('-'), bad_lexical_cast); +} + +template +void test_float_typess_for_overflows() +{ + typedef T test_t; + test_t minvalue = (std::numeric_limits::min)(); + std::string s_min_value = lexical_cast(minvalue); + BOOST_CHECK_CLOSE_FRACTION(minvalue, lexical_cast(minvalue), (std::numeric_limits::epsilon())); + BOOST_CHECK_CLOSE_FRACTION(minvalue, lexical_cast(s_min_value), (std::numeric_limits::epsilon())); + + test_t maxvalue = (std::numeric_limits::max)(); + std::string s_max_value = lexical_cast(maxvalue); + BOOST_CHECK_CLOSE_FRACTION(maxvalue, lexical_cast(maxvalue), (std::numeric_limits::epsilon())); + BOOST_CHECK_CLOSE_FRACTION(maxvalue, lexical_cast(s_max_value), (std::numeric_limits::epsilon())); + + BOOST_CHECK_THROW(lexical_cast(s_max_value+"1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(s_max_value+"9"), bad_lexical_cast); + + // VC9 can fail the fllowing tests on floats and doubles when using stingstream... + BOOST_CHECK_THROW(lexical_cast("1"+s_max_value), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("9"+s_max_value), bad_lexical_cast); + + if ( is_same::value ) + { + BOOST_CHECK_THROW(lexical_cast( (std::numeric_limits::max)() ), bad_lexical_cast); + BOOST_CHECK( + (std::numeric_limits::min)() - std::numeric_limits::epsilon() + <= lexical_cast( (std::numeric_limits::min)() ) + && lexical_cast( (std::numeric_limits::min)() ) + <= (std::numeric_limits::min)() + std::numeric_limits::epsilon() + ); + } + + if ( sizeof(test_t) < sizeof(long double) ) + { + BOOST_CHECK_THROW(lexical_cast( (std::numeric_limits::max)() ), bad_lexical_cast); + BOOST_CHECK( + (std::numeric_limits::min)() - std::numeric_limits::epsilon() + <= lexical_cast( (std::numeric_limits::min)() ) + && lexical_cast( (std::numeric_limits::min)() ) + <= (std::numeric_limits::min)() + std::numeric_limits::epsilon() + ); + } +} + +#undef CHECK_CLOSE_ABS_DIFF + +#define TEST_TO_FROM_CAST_AROUND_TYPED(VAL,STRING_TYPE) \ + test_value = VAL + std::numeric_limits::epsilon() * i ; \ + converted_val = lexical_cast( lexical_cast(test_value) ); \ + BOOST_CHECK_CLOSE_FRACTION( \ + test_value, \ + converted_val, \ + std::numeric_limits::epsilon() \ + ); + +/* + * For interval [ from_mult*epsilon+VAL, to_mult*epsilon+VAL ], converts float type + * numbers to string[wstring] and then back to float type, then compares initial + * values and generated. + * Step is epsilon + */ +#ifndef BOOST_LCAST_NO_WCHAR_T +# define TEST_TO_FROM_CAST_AROUND(VAL) \ + for(i=from_mult; i<=to_mult; ++i) { \ + TEST_TO_FROM_CAST_AROUND_TYPED(VAL, std::string) \ + TEST_TO_FROM_CAST_AROUND_TYPED(VAL, std::wstring) \ + } +#else +# define TEST_TO_FROM_CAST_AROUND(VAL) \ + for(i=from_mult; i<=to_mult; ++i) { \ + TEST_TO_FROM_CAST_AROUND_TYPED(VAL, std::string) \ + } +#endif + +template +void test_converion_from_to_float_types() +{ + typedef TestType test_t; + test_t test_value; + test_t converted_val; + + int i; + int from_mult = -50; + int to_mult = 50; + + TEST_TO_FROM_CAST_AROUND( 0.0 ); + + long double val1; + for(val1 = 1.0e-10L; val1 < 1e11; val1*=10 ) + TEST_TO_FROM_CAST_AROUND( val1 ); + + long double val2; + for(val2 = -1.0e-10L; val2 > -1e11; val2*=10 ) + TEST_TO_FROM_CAST_AROUND( val2 ); + + from_mult = -100; + to_mult = 0; + TEST_TO_FROM_CAST_AROUND( (std::numeric_limits::max)() ); + + from_mult = 0; + to_mult = 100; + TEST_TO_FROM_CAST_AROUND( (std::numeric_limits::min)() ); +} + +#undef TEST_TO_FROM_CAST_AROUND +#undef TEST_TO_FROM_CAST_AROUND_TYPED + + +template +void test_conversion_from_float_to_char(CharT zero) +{ + BOOST_CHECK(lexical_cast(static_cast(0)) == zero + 0); + BOOST_CHECK(lexical_cast(static_cast(1)) == zero + 1); + BOOST_CHECK(lexical_cast(static_cast(2)) == zero + 2); + BOOST_CHECK(lexical_cast(static_cast(3)) == zero + 3); + BOOST_CHECK(lexical_cast(static_cast(4)) == zero + 4); + BOOST_CHECK(lexical_cast(static_cast(5)) == zero + 5); + BOOST_CHECK(lexical_cast(static_cast(6)) == zero + 6); + BOOST_CHECK(lexical_cast(static_cast(7)) == zero + 7); + BOOST_CHECK(lexical_cast(static_cast(8)) == zero + 8); + BOOST_CHECK(lexical_cast(static_cast(9)) == zero + 9); + + BOOST_CHECK_THROW(lexical_cast(static_cast(10)), bad_lexical_cast); + + T t = (std::numeric_limits::max)(); + BOOST_CHECK_THROW(lexical_cast(t), bad_lexical_cast); +} + +template +void test_conversion_from_char_to_float(CharT zero) +{ + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( static_cast(zero + 0)), static_cast(0), (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( static_cast(zero + 1)), static_cast(1), (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( static_cast(zero + 2)), static_cast(2), (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( static_cast(zero + 3)), static_cast(3), (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( static_cast(zero + 4)), static_cast(4), (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( static_cast(zero + 5)), static_cast(5), (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( static_cast(zero + 6)), static_cast(6), (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( static_cast(zero + 7)), static_cast(7), (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( static_cast(zero + 8)), static_cast(8), (std::numeric_limits::epsilon()) ); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast( static_cast(zero + 9)), static_cast(9), (std::numeric_limits::epsilon()) ); + + BOOST_CHECK_THROW(lexical_cast( static_cast(zero + 10)), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast( static_cast(zero - 1)), bad_lexical_cast); +} + +struct restore_oldloc +{ + std::locale oldloc; + ~restore_oldloc() { std::locale::global(oldloc); } +}; + +template +void test_conversion_from_to_float() +{ char const zero = '0'; + signed char const szero = '0'; + unsigned char const uzero = '0'; + test_conversion_from_float_to_char(zero); + test_conversion_from_char_to_float(zero); + test_conversion_from_float_to_char(szero); + test_conversion_from_char_to_float(szero); + test_conversion_from_float_to_char(uzero); + test_conversion_from_char_to_float(uzero); + #if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + wchar_t const wzero = L'0'; + test_conversion_from_float_to_char(wzero); + test_conversion_from_char_to_float(wzero); + #endif + + BOOST_CHECK_CLOSE_FRACTION(lexical_cast("+1"), 1, std::numeric_limits::epsilon()); + BOOST_CHECK_CLOSE_FRACTION(lexical_cast("+9"), 9, std::numeric_limits::epsilon()); + + BOOST_CHECK_THROW(lexical_cast("++1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("-+9"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("--1"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("+-9"), bad_lexical_cast); + + test_converion_to_float_types(); + test_float_typess_for_overflows(); + test_converion_from_to_float_types(); + + + typedef std::numpunct numpunct; + + restore_oldloc guard; + std::locale const& oldloc = guard.oldloc; + + std::string grouping1 = BOOST_USE_FACET(numpunct, oldloc).grouping(); + std::string grouping2(grouping1); + + test_conversion_from_to_float_for_locale(); + + try + { + std::locale newloc(""); + std::locale::global(newloc); + + grouping2 = BOOST_USE_FACET(numpunct, newloc).grouping(); + } + catch(std::exception const& ex) + { + std::string msg("Failed to set system locale: "); + msg += ex.what(); + BOOST_TEST_MESSAGE(msg); + } + + if(grouping1 != grouping2) + test_conversion_from_to_float_for_locale(); + + if(grouping1.empty() && grouping2.empty()) + BOOST_TEST_MESSAGE("Formatting with thousands_sep has not been tested"); +} + + +void test_conversion_from_to_float() +{ + test_conversion_from_to_float(); +} +void test_conversion_from_to_double() +{ + test_conversion_from_to_float(); +} +void test_conversion_from_to_long_double() +{ + test_conversion_from_to_float(); +} + + + + + + + diff --git a/test/lexical_cast_inf_nan_test.cpp b/test/lexical_cast_inf_nan_test.cpp new file mode 100755 index 0000000..4617d5e --- /dev/null +++ b/test/lexical_cast_inf_nan_test.cpp @@ -0,0 +1,180 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2011. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include + + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) +#define BOOST_LCAST_NO_WCHAR_T +#endif + +using namespace boost; + +template +bool is_pos_inf(T value) +{ + return (boost::math::isinf)(value) && !(boost::math::signbit)(value); +} + +template +bool is_neg_inf(T value) +{ + return (boost::math::isinf)(value) && (boost::math::signbit)(value); +} + +template +bool is_pos_nan(T value) +{ + return (boost::math::isnan)(value) && !(boost::math::signbit)(value); +} + +template +bool is_neg_nan(T value) +{ + /* There is some strange behaviour on Itanium platform with -nan nuber for long double. + * It is a IA64 feature, or it is a boost::math feature, not a lexical_cast bug */ +#if defined(__ia64__) || defined(_M_IA64) + return (boost::math::isnan)(value) + && ( boost::is_same::value || (boost::math::signbit)(value) ); +#else + return (boost::math::isnan)(value) && (boost::math::signbit)(value); +#endif +} + +template +void test_inf_nan_templated() +{ + typedef T test_t; + + BOOST_CHECK( is_pos_inf( lexical_cast("inf") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast("INF") ) ); + + BOOST_CHECK( is_neg_inf( lexical_cast("-inf") ) ); + BOOST_CHECK( is_neg_inf( lexical_cast("-INF") ) ); + + BOOST_CHECK( is_pos_inf( lexical_cast("+inf") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast("+INF") ) ); + + BOOST_CHECK( is_pos_inf( lexical_cast("infinity") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast("INFINITY") ) ); + + BOOST_CHECK( is_neg_inf( lexical_cast("-infinity") ) ); + BOOST_CHECK( is_neg_inf( lexical_cast("-INFINITY") ) ); + + BOOST_CHECK( is_pos_inf( lexical_cast("+infinity") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast("+INFINITY") ) ); + + BOOST_CHECK( is_pos_nan( lexical_cast("nan") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast("NAN") ) ); + + BOOST_CHECK( is_neg_nan( lexical_cast("-nan") ) ); + BOOST_CHECK( is_neg_nan( lexical_cast("-NAN") ) ); + + BOOST_CHECK( is_pos_nan( lexical_cast("+nan") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast("+NAN") ) ); + + BOOST_CHECK( is_pos_nan( lexical_cast("nan()") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast("NAN(some string)") ) ); + BOOST_CHECK_THROW( lexical_cast("NAN(some string"), bad_lexical_cast ); + + BOOST_CHECK(lexical_cast( (boost::math::changesign)(std::numeric_limits::infinity())) + == "-inf" ); + BOOST_CHECK(lexical_cast( std::numeric_limits::infinity()) == "inf" ); + BOOST_CHECK(lexical_cast( std::numeric_limits::quiet_NaN()) == "nan" ); +#if !defined(__ia64__) && !defined(_M_IA64) + BOOST_CHECK(lexical_cast( + (boost::math::changesign)(std::numeric_limits::quiet_NaN())) + == "-nan" ); +#endif + +#ifndef BOOST_LCAST_NO_WCHAR_T + BOOST_CHECK( is_pos_inf( lexical_cast(L"inf") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast(L"INF") ) ); + + BOOST_CHECK( is_neg_inf( lexical_cast(L"-inf") ) ); + BOOST_CHECK( is_neg_inf( lexical_cast(L"-INF") ) ); + + BOOST_CHECK( is_pos_inf( lexical_cast(L"+inf") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast(L"+INF") ) ); + + BOOST_CHECK( is_pos_inf( lexical_cast(L"infinity") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast(L"INFINITY") ) ); + + BOOST_CHECK( is_neg_inf( lexical_cast(L"-infinity") ) ); + BOOST_CHECK( is_neg_inf( lexical_cast(L"-INFINITY") ) ); + + BOOST_CHECK( is_pos_inf( lexical_cast(L"+infinity") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast(L"+INFINITY") ) ); + + BOOST_CHECK( is_pos_nan( lexical_cast(L"nan") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast(L"NAN") ) ); + + BOOST_CHECK( is_neg_nan( lexical_cast(L"-nan") ) ); + BOOST_CHECK( is_neg_nan( lexical_cast(L"-NAN") ) ); + + BOOST_CHECK( is_pos_nan( lexical_cast(L"+nan") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast(L"+NAN") ) ); + + BOOST_CHECK( is_pos_nan( lexical_cast(L"nan()") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast(L"NAN(some string)") ) ); + BOOST_CHECK_THROW( lexical_cast(L"NAN(some string"), bad_lexical_cast ); + + BOOST_CHECK(lexical_cast( (boost::math::changesign)(std::numeric_limits::infinity())) + == L"-inf" ); + BOOST_CHECK(lexical_cast( std::numeric_limits::infinity()) == L"inf" ); + BOOST_CHECK(lexical_cast( std::numeric_limits::quiet_NaN()) == L"nan" ); +#if !defined(__ia64__) && !defined(_M_IA64) + BOOST_CHECK(lexical_cast( + (boost::math::changesign)(std::numeric_limits::quiet_NaN())) + == L"-nan" ); +#endif + +#endif +} + +void test_inf_nan_float() +{ + test_inf_nan_templated(); +} + +void test_inf_nan_double() +{ + test_inf_nan_templated(); +} + +void test_inf_nan_long_double() +{ + test_inf_nan_templated(); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test_framework::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast inf anf nan parsing unit test"); + suite->add(BOOST_TEST_CASE(&test_inf_nan_float)); + suite->add(BOOST_TEST_CASE(&test_inf_nan_double)); + suite->add(BOOST_TEST_CASE(&test_inf_nan_long_double)); + + return suite; +} diff --git a/test/lexical_cast_loopback_test.cpp b/test/lexical_cast_loopback_test.cpp index cd058fe..5787996 100644 --- a/test/lexical_cast_loopback_test.cpp +++ b/test/lexical_cast_loopback_test.cpp @@ -64,7 +64,6 @@ void test_round_conversion() } -#if defined(BOOST_MSVC) // See bug http://tinyurl.com/vhpvo template void test_msvc_magic_values() @@ -73,7 +72,6 @@ void test_msvc_magic_values() std::string magic_msvc_s = boost::lexical_cast(magic_msvc); BOOST_CHECK(magic_msvc == lexical_cast(magic_msvc_s)); } -#endif void test_round_conversion_float() { @@ -83,16 +81,12 @@ void test_round_conversion_float() void test_round_conversion_double() { test_round_conversion(); -#if defined(BOOST_MSVC) test_msvc_magic_values(); -#endif } void test_round_conversion_long_double() { test_round_conversion(); -#if defined(BOOST_MSVC) test_msvc_magic_values(); -#endif } diff --git a/test/lexical_cast_wchars_test.cpp b/test/lexical_cast_wchars_test.cpp new file mode 100755 index 0000000..14ac461 --- /dev/null +++ b/test/lexical_cast_wchars_test.cpp @@ -0,0 +1,56 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2011. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include + +#include +#include +#include + +using namespace boost; + +void test_char_types_conversions() +{ +#ifndef BOOST_LCAST_NO_WCHAR_T + const char c_arr[] = "Test array of chars"; + const unsigned char uc_arr[] = "Test array of chars"; + const signed char sc_arr[] = "Test array of chars"; + const wchar_t wc_arr[] =L"Test array of chars"; + + // Following tests depend on realization of std::locale + // and pass for popular compilers and STL realizations + BOOST_CHECK(boost::lexical_cast(c_arr[0]) == wc_arr[0]); + BOOST_CHECK(boost::lexical_cast(c_arr) == std::wstring(wc_arr)); + + BOOST_CHECK(boost::lexical_cast(sc_arr) == std::wstring(wc_arr) ); + BOOST_CHECK(boost::lexical_cast(uc_arr) == std::wstring(wc_arr) ); + + BOOST_CHECK_EQUAL(boost::lexical_cast(uc_arr[0]), wc_arr[0]); + BOOST_CHECK_EQUAL(boost::lexical_cast(sc_arr[0]), wc_arr[0]); +#endif + BOOST_CHECK(1); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test_framework::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast char<->wchar_t unit test"); + suite->add(BOOST_TEST_CASE(&test_char_types_conversions)); + + return suite; +} From 8480a6d0837c2ac05e0efebb83565747bfada039 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Wed, 17 Aug 2011 18:44:00 +0000 Subject: [PATCH 097/138] Merge from trunk r73850 * Documentation commited [SVN r73852] --- doc/Jamfile.v2 | 16 + doc/lexical_cast.qbk | 699 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 715 insertions(+) create mode 100644 doc/Jamfile.v2 create mode 100644 doc/lexical_cast.qbk diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 new file mode 100644 index 0000000..b629c6a --- /dev/null +++ b/doc/Jamfile.v2 @@ -0,0 +1,16 @@ +# Copyright Antony Polukhin 2011. Use, modification, and distribution are +# subject to 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) + +using quickbook ; +import boostbook : boostbook ; + +xml lexical_cast : lexical_cast.qbk ; +boostbook standalone + : + lexical_cast + : + boost.root=../../../.. + pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html + ; + diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk new file mode 100644 index 0000000..9fb6cdf --- /dev/null +++ b/doc/lexical_cast.qbk @@ -0,0 +1,699 @@ +[library Boost.Lexical_Cast + [quickbook 1.5] + [version 1.0] + [copyright 2000-2005 Kevlin Henney] + [copyright 2006-2010 Alexander Nasonov] + [copyright 2011 Antony Polukhin] + [category String and text processing] + [category Miscellaneous] + [license + 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]) + ] +] + +[def __numericcast__ [@boost:libs/numeric/conversion/doc/html/boost_numericconversion/improved_numeric_cast__.html `boost::numeric_cast`]] +[def __proposallong__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1973.html Lexical Conversion Library Proposal for TR2, N1973 by Kevlin Henney and Beman Dawes]] +[def __proposalshort__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1973.html Lexical Conversion Library Proposal for TR2, N1973]] + +[section Motivation] +Sometimes a value must be converted to a literal text form, such as an [c++] `int` represented as a `std::string`, or vice-versa, when a `std::string` is interpreted as an `int`. Such examples are common when converting between data types internal to a program and representation external to a program, such as windows and configuration files. + +The standard C and C++ libraries offer a number of facilities for performing such conversions. However, they vary with their ease of use, extensibility, and safety. + +For instance, there are a number of limitations with the family of standard C functions typified by `atoi`: + +* Conversion is supported in one direction only: from text to internal data type. Converting the other way using the C library requires either the inconvenience and compromised safety of the `sprintf` function, or the loss of portability associated with non-standard functions such as `itoa`. +* The range of types supported is only a subset of the built-in numeric types, namely `int`, `long`, and `double`. +* The range of types cannot be extended in a uniform manner. For instance, conversion from string representation to complex or rational. + +The standard C functions typified by `strtol` have the same basic limitations, but offer finer control over the conversion process. However, for the common case such control is often either not required or not used. The `scanf` family of functions offer even greater control, but also lack safety and ease of use. + +The standard C++ library offers `stringstream` for the kind of in-core formatting being discussed. It offers a great deal of control over the formatting and conversion of I/O to and from arbitrary types through text. However, for simple conversions direct use of `stringstream` can be either clumsy (with the introduction of extra local variables and the loss of infix-expression convenience) or obscure (where `stringstream` objects are created as temporary objects in an expression). Facets provide a comprehensive concept and facility for controlling textual representation, but their perceived complexity and high entry level requires an extreme degree of involvement for simple conversions, and excludes all but a few programmers. + +The `lexical_cast` function template offers a convenient and consistent form for supporting common conversions to and from arbitrary types when they are represented as text. The simplification it offers is in expression-level convenience for such conversions. For more involved conversions, such as where precision or formatting need tighter control than is offered by the default behavior of `lexical_cast`, the conventional `std::stringstream` approach is recommended. Where the conversions are numeric to numeric, __numericcast__ may offer more reasonable behavior than `lexical_cast`. + +For a good discussion of the options and issues involved in string-based formatting, including comparison of `stringstream`, `lexical_cast`, and others, see Herb Sutter's article, [@http://www.gotw.ca/publications/mill19.htm The String Formatters of Manor Farm]. Also, take a look at the [link boost_lexical_cast.performance Performance] section. +[endsect] + +[section Examples] +The following example treats command line arguments as a sequence of numeric data: +`` + int main(int argc, char * argv[]) + { + using boost::lexical_cast; + using boost::bad_lexical_cast; + + std::vector args; + + while(*++argv) + { + try + { + args.push_back(lexical_cast(*argv)); + } + catch(bad_lexical_cast &) + { + args.push_back(0); + } + } + ... + } +`` +The following example uses numeric data in a string expression: +`` + void log_message(const std::string &); + + void log_errno(int yoko) + { + log_message("Error " + boost::lexical_cast(yoko) + ": " + strerror(yoko)); + } +`` +[endsect] + +[section Synopsis] +Library features defined in [@boost:boost/lexical_cast.hpp boost/lexical_cast.hpp]: +`` + namespace boost + { + class bad_lexical_cast; + template + Target lexical_cast(const Source& arg); + } +`` + +[section lexical_cast] +`` + template + Target lexical_cast(const Source& arg); +`` +Returns the result of streaming arg into a standard library string-based stream and then out as a Target object. Where Target is either `std::string` or `std::wstring`, stream extraction takes the whole content of the string, including spaces, rather than relying on the default `operator>>` behavior. If the conversion is unsuccessful, a `bad_lexical_cast` exception is thrown. + +The requirements on the argument and result types are: + +* Source is OutputStreamable, meaning that an `operator<<` is defined that takes a `std::ostream` or `std::wostream` object on the left hand side and an instance of the argument type on the right. +* Target is InputStreamable, meaning that an `operator>>` is defined that takes a `std::istream` or `std::wistream` object on the left hand side and an instance of the result type on the right. +* Target is CopyConstructible [20.1.3]. +* Target is DefaultConstructible, meaning that it is possible to default-initialize an object of that type [8.5, 20.1.4]. + +The character type of the underlying stream is assumed to be char unless either the Source or the Target requires wide-character streaming, in which case the underlying stream uses `wchar_t`. Source types that require wide-character streaming are `wchar_t`, `wchar_t *`, and `std::wstring`. Target types that require wide-character streaming are `wchar_t` and `std::wstring`. + +Where a higher degree of control is required over conversions, `std::stringstream` and `std::wstringstream` offer a more appropriate path. Where non-stream-based conversions are required, `lexical_cast` is the wrong tool for the job and is not special-cased for such scenarios. +[endsect] + +[section bad_lexical_cast] +`` + class bad_lexical_cast : public std::bad_cast + { + public: + ... // same member function interface as std::exception + }; +`` +Exception used to indicate runtime lexical_cast failure. +[endsect] + +[endsect] + +[section Frequently Asked Questions] + +* [*Question:] Why does `lexical_cast("127")` throw `bad_lexical_cast`? + * [*Answer:] The type `int8_t` is a `typedef` to `char` or `signed char`. Lexical conversion to these types is simply reading a byte from source but since the source has more than one byte, the exception is thrown. +Please use other integer types such as `int` or `short int`. If bounds checking is important, you can also +call __numericcast__: +`numeric_cast(lexical_cast("127"));` + +[pre +] + +* [*Question:] Why does `lexical_cast("127")` throw `bad_lexical_cast`? + * [*Answer:] Lexical conversion to any char type is simply reading a byte from source. But since the source has more than one byte, the exception is thrown. +Please use other integer types such as `int` or `short int`. If bounds checking is important, you can also +call __numericcast__: +`numeric_cast(lexical_cast("127"));` + +[pre +] + +* [*Question:] What does `lexical_cast` of an `int8_t` or `uint8_t` not do what I expect? + * [*Answer:] As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid +this, cast to an integer type first: `lexical_cast(static_cast(n));` + +[pre +] + +* [*Question:] The implementation always resets the `ios_base::skipws` flag of an underlying stream object. +It breaks my `operator>>` that works only in presence of this flag. Can you remove code that resets the flag? + * [*Answer:] May be in a future version. There is no requirement in +__proposallong__ to reset the flag but +remember that __proposalshort__ is not yet accepted by the committee. By the way, it's a great opportunity to +make your `operator>>` conform to the standard. +Read a good C++ book, study `std::sentry` and [@boost:libs/io/doc/ios_state.html `ios_state_saver`]. + +[pre +] + +* [*Question:] Why `std::cout << boost::lexical_cast("-1");` does not throw, but outputs 4294967295? + * [*Answer:] `boost::lexical_cast` has the behavior of `std::stringstream`, which uses `num_get` functions of +`std::locale` to convert numbers. If we look at the Programming languages — C++, we'll see, that `num_get` uses +the rules of `scanf` for conversions. And in the C99 standard for unsigned input value minus sign is optional, so +if a negative number is read, no errors will arise and the result will be the two's complement. + +[endsect] + +[section Changes] +* [*boost 1.48.0 :] + + * Added code to work with Inf and NaN on any platform. + * Better performance and less memory usage for conversions to float type (and to double type, if `sizeof(double) < sizeof(long double)`). + +* [*boost 1.47.0 :] + + * Optimizations for "C" and other locales without number grouping. + * Better performance and less memory usage for unsigned char and signed char conversions. + * Better performance and less memory usage for conversions to arithmetic types. + * Better performance and less memory usage for conversions from arithmetic type to arithmetic type. + * Directly construct Target from Source on some conversions (like conversions from string to string, from char array to string, from char to char and others). + +* [*boost 1.34.0 :] + + * Better performance for many combinations of Source and Target types. For more details refer to Alexander Nasonovs article [@http://accu.org/index.php/journals/1375 Fine Tuning for lexical_cast, Overload #74, August 2006] [@http://www.accu.org/var/uploads/journals/overload74.pdf (PDF)]. + +* [*boost 1.33.0 :] + + * Call-by-const reference for the parameters. This requires partial specialization of class templates, so it doesn't work for MSVC 6, and it uses the original pass by value there. + * The MSVC 6 support is deprecated, and will be removed in a future Boost version. + +* [*Earlier :] + + * The previous version of lexical_cast used the default stream precision for reading and writing floating-point numbers. For numerics that have a corresponding specialization of `std::numeric_limits`, the current version now chooses a precision to match. + * The previous version of lexical_cast did not support conversion to or from any wide-character-based types. For compilers with full language and library support for wide characters, `lexical_cast` now supports conversions from `wchar_t`, `wchar_t *`, and `std::wstring` and to `wchar_t` and `std::wstring`. + * The previous version of `lexical_cast` assumed that the conventional stream extractor operators were sufficient for reading values. However, string I/O is asymmetric, with the result that spaces play the role of I/O separators rather than string content. The current version fixes this error for `std::string` and, where supported, `std::wstring`: `lexical_cast("Hello, World")` succeeds instead of failing with a `bad_lexical_cast` exception. + * The previous version of `lexical_cast` allowed unsafe and meaningless conversions to pointers. The current version now throws a `bad_lexical_cast` for conversions to pointers: `lexical_cast("Goodbye, World")` now throws an exception instead of causing undefined behavior. + +[endsect] + +[section Performance] + +In most cases `boost::lexical_cast` is faster than `scanf`, `printf`, `std::stringstream`. For more detailed info you can look at the tables below. + +[section Tests description] +All the tests measure execution speed in milliseconds for 10000 iterations of the following code blocks: +[table:legend Tests source code +[[Test name] [Code]] +[[lexical_cast] + [`` + _out = boost::lexical_cast(_in); + ``] + ] +[[std::stringstream with construction] + [`` + std::stringstream ss; + ss << _in; + if (ss.fail()) throw std::logic_error(descr); + ss >> _out; + if (ss.fail()) throw std::logic_error(descr); + ``] + ] +[[std::stringstream without construction] + [`` + ss << _in; // ss is an instance of std::stringstream + if (ss.fail()) throw std::logic_error(descr); + ss >> _out; + if (ss.fail()) throw std::logic_error(descr); + /* reseting std::stringstream to use it again */ + ss.str(std::string()); + ss.clear(); + ``] + ] +[[scanf/printf] + [`` + typename OUTTYPE::value_type buffer[500]; + sprintf( (char*)buffer, conv, _in); + _out = buffer; + ``] + ] +] +Fastest results are highlitened with "!!! *x* !!!". +Do not use this results to compare compilers, because tests were taken on different hardware. + +[endsect] + +[/ BEGIN of section, generated by performance measuring program ] + +[section clang-linux-2.8][table:id Performance Table (clang-linux-2.8) +[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] +[[ string->char ][ !!! *<1* !!! ][ 106 ][ 11 ][ 11 ]] +[[ string->signed char ][ !!! *<1* !!! ][ 102 ][ 8 ][ 8 ]] +[[ string->unsigned char ][ !!! *<1* !!! ][ 83 ][ 7 ][ 15 ]] +[[ string->int ][ !!! *8* !!! ][ 114 ][ 21 ][ 17 ]] +[[ string->short ][ !!! *10* !!! ][ 111 ][ 20 ][ 17 ]] +[[ string->long int ][ !!! *9* !!! ][ 113 ][ 20 ][ 16 ]] +[[ string->long long ][ !!! *9* !!! ][ 112 ][ 21 ][ 16 ]] +[[ string->unsigned int ][ !!! *9* !!! ][ 115 ][ 23 ][ 17 ]] +[[ string->unsigned short ][ !!! *7* !!! ][ 111 ][ 21 ][ 16 ]] +[[ string->unsigned long int ][ !!! *9* !!! ][ 106 ][ 20 ][ 17 ]] +[[ string->unsigned long long ][ !!! *9* !!! ][ 104 ][ 21 ][ 17 ]] +[[ string->bool ][ !!! *<1* !!! ][ 101 ][ 17 ][ 10 ]] +[[ string->float ][ !!! *16* !!! ][ 175 ][ 67 ][ 33 ]] +[[ string->double ][ !!! *18* !!! ][ 196 ][ 91 ][ 56 ]] +[[ string->long double ][ 126 ][ 198 ][ 92 ][ !!! *61* !!! ]] +[[ char->string ][ !!! *12* !!! ][ 101 ][ 16 ][ 12 ]] +[[ unsigned char->string ][ !!! *10* !!! ][ 103 ][ 18 ][ 17 ]] +[[ signed char->string ][ !!! *12* !!! ][ 101 ][ 18 ][ 12 ]] +[[ int->string ][ !!! *19* !!! ][ 124 ][ 25 ][ 19 ]] +[[ short->string ][ 23 ][ 124 ][ 26 ][ !!! *17* !!! ]] +[[ long int->string ][ 20 ][ 123 ][ 23 ][ !!! *17* !!! ]] +[[ long long->string ][ 19 ][ 124 ][ 23 ][ !!! *18* !!! ]] +[[ unsigned int->string ][ 18 ][ 122 ][ 28 ][ !!! *17* !!! ]] +[[ unsigned short->string ][ 36 ][ 160 ][ 31 ][ !!! *17* !!! ]] +[[ unsigned long int->string ][ 22 ][ 123 ][ 28 ][ !!! *18* !!! ]] +[[ unsigned long long->string ][ !!! *23* !!! ][ 137 ][ 32 ][ 23 ]] +[[ bool->string ][ !!! *11* !!! ][ 124 ][ 26 ][ 17 ]] +[[ float->string ][ 178 ][ 273 ][ 124 ][ !!! *57* !!! ]] +[[ double->string ][ 227 ][ 450 ][ 241 ][ !!! *77* !!! ]] +[[ long double->string ][ 249 ][ 331 ][ 185 ][ !!! *85* !!! ]] +[[ char*->char ][ !!! *<1* !!! ][ 109 ][ 9 ][ 11 ]] +[[ char*->signed char ][ !!! *<1* !!! ][ 105 ][ 15 ][ 8 ]] +[[ char*->unsigned char ][ !!! *<1* !!! ][ 111 ][ 11 ][ 20 ]] +[[ char*->int ][ !!! *7* !!! ][ 143 ][ 25 ][ 19 ]] +[[ char*->short ][ !!! *10* !!! ][ 131 ][ 24 ][ 18 ]] +[[ char*->long int ][ !!! *12* !!! ][ 134 ][ 24 ][ 18 ]] +[[ char*->long long ][ !!! *12* !!! ][ 132 ][ 26 ][ 17 ]] +[[ char*->unsigned int ][ !!! *10* !!! ][ 133 ][ 26 ][ 19 ]] +[[ char*->unsigned short ][ !!! *11* !!! ][ 127 ][ 24 ][ 20 ]] +[[ char*->unsigned long int ][ !!! *10* !!! ][ 143 ][ 26 ][ 19 ]] +[[ char*->unsigned long long ][ !!! *12* !!! ][ 137 ][ 26 ][ 19 ]] +[[ char*->bool ][ !!! *2* !!! ][ 138 ][ 27 ][ 13 ]] +[[ char*->float ][ !!! *19* !!! ][ 186 ][ 65 ][ 31 ]] +[[ char*->double ][ !!! *19* !!! ][ 195 ][ 96 ][ 57 ]] +[[ char*->long double ][ 134 ][ 200 ][ 92 ][ !!! *61* !!! ]] +[[ unsigned char*->char ][ !!! *<1* !!! ][ 87 ][ 8 ][ 10 ]] +[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 87 ][ 8 ][ 10 ]] +[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 89 ][ 8 ][ 16 ]] +[[ unsigned char*->int ][ !!! *10* !!! ][ 117 ][ 22 ][ 17 ]] +[[ unsigned char*->short ][ !!! *11* !!! ][ 117 ][ 21 ][ 17 ]] +[[ unsigned char*->long int ][ !!! *10* !!! ][ 116 ][ 22 ][ 17 ]] +[[ unsigned char*->long long ][ !!! *9* !!! ][ 116 ][ 22 ][ 17 ]] +[[ unsigned char*->unsigned int ][ !!! *10* !!! ][ 117 ][ 24 ][ 17 ]] +[[ unsigned char*->unsigned short ][ !!! *11* !!! ][ 119 ][ 22 ][ 17 ]] +[[ unsigned char*->unsigned long int ][ !!! *10* !!! ][ 111 ][ 21 ][ 17 ]] +[[ unsigned char*->unsigned long long ][ !!! *10* !!! ][ 109 ][ 21 ][ 17 ]] +[[ unsigned char*->bool ][ !!! *<1* !!! ][ 105 ][ 18 ][ 10 ]] +[[ unsigned char*->float ][ !!! *17* !!! ][ 174 ][ 66 ][ 33 ]] +[[ unsigned char*->double ][ !!! *19* !!! ][ 198 ][ 91 ][ 56 ]] +[[ unsigned char*->long double ][ 129 ][ 200 ][ 92 ][ !!! *58* !!! ]] +[[ unsigned char*->string ][ !!! *12* !!! ][ 122 ][ 20 ][ --- ]] +[[ signed char*->char ][ !!! *<1* !!! ][ 87 ][ 8 ][ 9 ]] +[[ signed char*->signed char ][ !!! *<1* !!! ][ 86 ][ 8 ][ 10 ]] +[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 93 ][ 8 ][ 16 ]] +[[ signed char*->int ][ !!! *10* !!! ][ 117 ][ 21 ][ 17 ]] +[[ signed char*->short ][ !!! *11* !!! ][ 117 ][ 22 ][ 17 ]] +[[ signed char*->long int ][ !!! *10* !!! ][ 115 ][ 21 ][ 17 ]] +[[ signed char*->long long ][ !!! *10* !!! ][ 115 ][ 24 ][ 17 ]] +[[ signed char*->unsigned int ][ !!! *10* !!! ][ 118 ][ 24 ][ 17 ]] +[[ signed char*->unsigned short ][ !!! *11* !!! ][ 139 ][ 27 ][ 20 ]] +[[ signed char*->unsigned long int ][ !!! *9* !!! ][ 144 ][ 27 ][ 19 ]] +[[ signed char*->unsigned long long ][ !!! *7* !!! ][ 127 ][ 25 ][ 22 ]] +[[ signed char*->bool ][ !!! *<1* !!! ][ 123 ][ 23 ][ 9 ]] +[[ signed char*->float ][ !!! *21* !!! ][ 207 ][ 80 ][ 41 ]] +[[ signed char*->double ][ !!! *23* !!! ][ 255 ][ 115 ][ 68 ]] +[[ signed char*->long double ][ 159 ][ 275 ][ 125 ][ !!! *72* !!! ]] +[[ signed char*->string ][ !!! *16* !!! ][ 155 ][ 27 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 150 ][ 32 ][ --- ]] +[[ float->double ][ !!! *<1* !!! ][ 304 ][ 162 ][ --- ]] +[[ double->double ][ !!! *<1* !!! ][ 298 ][ 168 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 311 ][ 154 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 308 ][ 154 ][ --- ]] +[[ char->unsigned char ][ !!! *<1* !!! ][ 97 ][ 9 ][ --- ]] +[[ char->signed char ][ !!! *<1* !!! ][ 94 ][ 11 ][ --- ]] +[[ unsigned char->char ][ !!! *<1* !!! ][ 106 ][ 8 ][ --- ]] +[[ signed char->char ][ !!! *<1* !!! ][ 111 ][ 8 ][ --- ]] +] +[endsect] +[section gcc-4.3][table:id Performance Table (gcc-4.3) +[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] +[[ string->char ][ !!! *<1* !!! ][ 92 ][ 7 ][ 8 ]] +[[ string->signed char ][ !!! *<1* !!! ][ 92 ][ 7 ][ 8 ]] +[[ string->unsigned char ][ !!! *<1* !!! ][ 92 ][ 7 ][ 13 ]] +[[ string->int ][ !!! *6* !!! ][ 115 ][ 21 ][ 14 ]] +[[ string->short ][ !!! *7* !!! ][ 141 ][ 26 ][ 24 ]] +[[ string->long int ][ !!! *7* !!! ][ 141 ][ 27 ][ 18 ]] +[[ string->long long ][ !!! *7* !!! ][ 153 ][ 28 ][ 17 ]] +[[ string->unsigned int ][ !!! *7* !!! ][ 156 ][ 26 ][ 18 ]] +[[ string->unsigned short ][ !!! *8* !!! ][ 146 ][ 25 ][ 18 ]] +[[ string->unsigned long int ][ !!! *9* !!! ][ 143 ][ 29 ][ 37 ]] +[[ string->unsigned long long ][ !!! *14* !!! ][ 135 ][ 20 ][ 15 ]] +[[ string->bool ][ !!! *<1* !!! ][ 117 ][ 20 ][ 8 ]] +[[ string->float ][ !!! *15* !!! ][ 177 ][ 63 ][ 31 ]] +[[ string->double ][ !!! *15* !!! ][ 198 ][ 89 ][ 54 ]] +[[ string->long double ][ 133 ][ 198 ][ 88 ][ !!! *55* !!! ]] +[[ char->string ][ !!! *10* !!! ][ 108 ][ 16 ][ 12 ]] +[[ unsigned char->string ][ !!! *10* !!! ][ 119 ][ 18 ][ 15 ]] +[[ signed char->string ][ !!! *10* !!! ][ 111 ][ 24 ][ 11 ]] +[[ int->string ][ !!! *14* !!! ][ 129 ][ 22 ][ 15 ]] +[[ short->string ][ !!! *14* !!! ][ 128 ][ 22 ][ 17 ]] +[[ long int->string ][ !!! *14* !!! ][ 127 ][ 21 ][ 17 ]] +[[ long long->string ][ !!! *14* !!! ][ 127 ][ 22 ][ 18 ]] +[[ unsigned int->string ][ !!! *15* !!! ][ 124 ][ 22 ][ 17 ]] +[[ unsigned short->string ][ 16 ][ 125 ][ 22 ][ !!! *15* !!! ]] +[[ unsigned long int->string ][ !!! *15* !!! ][ 125 ][ 22 ][ 17 ]] +[[ unsigned long long->string ][ !!! *18* !!! ][ 138 ][ 34 ][ 23 ]] +[[ bool->string ][ !!! *7* !!! ][ 120 ][ 22 ][ 12 ]] +[[ float->string ][ 136 ][ 229 ][ 110 ][ !!! *48* !!! ]] +[[ double->string ][ 184 ][ 270 ][ 136 ][ !!! *67* !!! ]] +[[ long double->string ][ 198 ][ 264 ][ 148 ][ !!! *69* !!! ]] +[[ char*->char ][ !!! *<1* !!! ][ 98 ][ 8 ][ 8 ]] +[[ char*->signed char ][ !!! *<1* !!! ][ 99 ][ 8 ][ 8 ]] +[[ char*->unsigned char ][ !!! *<1* !!! ][ 96 ][ 8 ][ 14 ]] +[[ char*->int ][ !!! *8* !!! ][ 120 ][ 21 ][ 15 ]] +[[ char*->short ][ !!! *8* !!! ][ 122 ][ 22 ][ 16 ]] +[[ char*->long int ][ !!! *8* !!! ][ 122 ][ 24 ][ 16 ]] +[[ char*->long long ][ !!! *8* !!! ][ 120 ][ 23 ][ 14 ]] +[[ char*->unsigned int ][ !!! *7* !!! ][ 123 ][ 23 ][ 15 ]] +[[ char*->unsigned short ][ !!! *8* !!! ][ 123 ][ 24 ][ 15 ]] +[[ char*->unsigned long int ][ !!! *8* !!! ][ 121 ][ 22 ][ 14 ]] +[[ char*->unsigned long long ][ !!! *7* !!! ][ 116 ][ 20 ][ 16 ]] +[[ char*->bool ][ !!! *<1* !!! ][ 107 ][ 18 ][ 10 ]] +[[ char*->float ][ !!! *14* !!! ][ 181 ][ 67 ][ 32 ]] +[[ char*->double ][ !!! *16* !!! ][ 197 ][ 88 ][ 53 ]] +[[ char*->long double ][ 127 ][ 208 ][ 93 ][ !!! *56* !!! ]] +[[ unsigned char*->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 8 ]] +[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 93 ][ 8 ][ 10 ]] +[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 15 ]] +[[ unsigned char*->int ][ !!! *7* !!! ][ 117 ][ 21 ][ 16 ]] +[[ unsigned char*->short ][ !!! *8* !!! ][ 119 ][ 21 ][ 16 ]] +[[ unsigned char*->long int ][ !!! *7* !!! ][ 117 ][ 22 ][ 16 ]] +[[ unsigned char*->long long ][ !!! *8* !!! ][ 119 ][ 23 ][ 16 ]] +[[ unsigned char*->unsigned int ][ !!! *10* !!! ][ 123 ][ 20 ][ 15 ]] +[[ unsigned char*->unsigned short ][ !!! *8* !!! ][ 122 ][ 24 ][ 15 ]] +[[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 120 ][ 21 ][ 14 ]] +[[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 118 ][ 23 ][ 16 ]] +[[ unsigned char*->bool ][ !!! *1* !!! ][ 108 ][ 18 ][ 8 ]] +[[ unsigned char*->float ][ !!! *13* !!! ][ 182 ][ 63 ][ 30 ]] +[[ unsigned char*->double ][ !!! *16* !!! ][ 204 ][ 87 ][ 53 ]] +[[ unsigned char*->long double ][ 126 ][ 206 ][ 90 ][ !!! *60* !!! ]] +[[ unsigned char*->string ][ !!! *9* !!! ][ 123 ][ 21 ][ --- ]] +[[ signed char*->char ][ !!! *<1* !!! ][ 95 ][ 8 ][ 10 ]] +[[ signed char*->signed char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 10 ]] +[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 15 ]] +[[ signed char*->int ][ !!! *8* !!! ][ 117 ][ 22 ][ 16 ]] +[[ signed char*->short ][ !!! *7* !!! ][ 117 ][ 22 ][ 16 ]] +[[ signed char*->long int ][ !!! *8* !!! ][ 118 ][ 25 ][ 15 ]] +[[ signed char*->long long ][ !!! *7* !!! ][ 117 ][ 24 ][ 16 ]] +[[ signed char*->unsigned int ][ !!! *7* !!! ][ 120 ][ 20 ][ 16 ]] +[[ signed char*->unsigned short ][ !!! *8* !!! ][ 124 ][ 24 ][ 15 ]] +[[ signed char*->unsigned long int ][ !!! *8* !!! ][ 115 ][ 21 ][ 16 ]] +[[ signed char*->unsigned long long ][ !!! *9* !!! ][ 120 ][ 21 ][ 16 ]] +[[ signed char*->bool ][ !!! *1* !!! ][ 112 ][ 19 ][ 8 ]] +[[ signed char*->float ][ !!! *14* !!! ][ 183 ][ 64 ][ 31 ]] +[[ signed char*->double ][ !!! *18* !!! ][ 208 ][ 87 ][ 51 ]] +[[ signed char*->long double ][ 126 ][ 217 ][ 94 ][ !!! *55* !!! ]] +[[ signed char*->string ][ !!! *12* !!! ][ 126 ][ 22 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 146 ][ 23 ][ --- ]] +[[ float->double ][ !!! *<1* !!! ][ 275 ][ 139 ][ --- ]] +[[ double->double ][ !!! *<1* !!! ][ 270 ][ 142 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 281 ][ 145 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 301 ][ 145 ][ --- ]] +[[ char->unsigned char ][ !!! *<1* !!! ][ 96 ][ 7 ][ --- ]] +[[ char->signed char ][ !!! *<1* !!! ][ 95 ][ 7 ][ --- ]] +[[ unsigned char->char ][ !!! *<1* !!! ][ 96 ][ 7 ][ --- ]] +[[ signed char->char ][ !!! *<1* !!! ][ 91 ][ 7 ][ --- ]] +] +[endsect] +[section gcc-4.4][table:id Performance Table (gcc-4.4) +[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] +[[ string->char ][ !!! *<1* !!! ][ 81 ][ 8 ][ 8 ]] +[[ string->signed char ][ !!! *<1* !!! ][ 110 ][ 7 ][ 9 ]] +[[ string->unsigned char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 18 ]] +[[ string->int ][ !!! *9* !!! ][ 125 ][ 25 ][ 15 ]] +[[ string->short ][ !!! *7* !!! ][ 113 ][ 25 ][ 15 ]] +[[ string->long int ][ !!! *8* !!! ][ 112 ][ 24 ][ 15 ]] +[[ string->long long ][ !!! *8* !!! ][ 109 ][ 22 ][ 15 ]] +[[ string->unsigned int ][ !!! *8* !!! ][ 108 ][ 26 ][ 20 ]] +[[ string->unsigned short ][ !!! *9* !!! ][ 125 ][ 22 ][ 18 ]] +[[ string->unsigned long int ][ !!! *11* !!! ][ 125 ][ 32 ][ 17 ]] +[[ string->unsigned long long ][ !!! *10* !!! ][ 119 ][ 23 ][ 19 ]] +[[ string->bool ][ !!! *<1* !!! ][ 132 ][ 24 ][ 11 ]] +[[ string->float ][ !!! *18* !!! ][ 178 ][ 75 ][ 37 ]] +[[ string->double ][ !!! *24* !!! ][ 236 ][ 100 ][ 64 ]] +[[ string->long double ][ 146 ][ 233 ][ 118 ][ !!! *75* !!! ]] +[[ char->string ][ !!! *8* !!! ][ 136 ][ 22 ][ 13 ]] +[[ unsigned char->string ][ !!! *11* !!! ][ 127 ][ 22 ][ 20 ]] +[[ signed char->string ][ !!! *11* !!! ][ 128 ][ 21 ][ 15 ]] +[[ int->string ][ 25 ][ 159 ][ 30 ][ !!! *20* !!! ]] +[[ short->string ][ 25 ][ 151 ][ 30 ][ !!! *20* !!! ]] +[[ long int->string ][ !!! *20* !!! ][ 150 ][ 30 ][ 20 ]] +[[ long long->string ][ !!! *19* !!! ][ 164 ][ 26 ][ 21 ]] +[[ unsigned int->string ][ 35 ][ 147 ][ 27 ][ !!! *20* !!! ]] +[[ unsigned short->string ][ 26 ][ 149 ][ 26 ][ !!! *20* !!! ]] +[[ unsigned long int->string ][ 19 ][ 142 ][ 38 ][ !!! *17* !!! ]] +[[ unsigned long long->string ][ !!! *20* !!! ][ 139 ][ 36 ][ 26 ]] +[[ bool->string ][ !!! *10* !!! ][ 144 ][ 28 ][ 13 ]] +[[ float->string ][ 166 ][ 268 ][ 127 ][ !!! *52* !!! ]] +[[ double->string ][ 192 ][ 285 ][ 170 ][ !!! *90* !!! ]] +[[ long double->string ][ 250 ][ 344 ][ 160 ][ !!! *85* !!! ]] +[[ char*->char ][ !!! *<1* !!! ][ 90 ][ 9 ][ 8 ]] +[[ char*->signed char ][ !!! *<1* !!! ][ 82 ][ 9 ][ 8 ]] +[[ char*->unsigned char ][ !!! *<1* !!! ][ 88 ][ 8 ][ 13 ]] +[[ char*->int ][ !!! *6* !!! ][ 113 ][ 26 ][ 14 ]] +[[ char*->short ][ !!! *6* !!! ][ 114 ][ 25 ][ 14 ]] +[[ char*->long int ][ !!! *6* !!! ][ 123 ][ 38 ][ 17 ]] +[[ char*->long long ][ !!! *7* !!! ][ 126 ][ 37 ][ 17 ]] +[[ char*->unsigned int ][ !!! *6* !!! ][ 134 ][ 26 ][ 18 ]] +[[ char*->unsigned short ][ !!! *8* !!! ][ 126 ][ 24 ][ 17 ]] +[[ char*->unsigned long int ][ !!! *8* !!! ][ 121 ][ 24 ][ 17 ]] +[[ char*->unsigned long long ][ !!! *5* !!! ][ 117 ][ 24 ][ 18 ]] +[[ char*->bool ][ !!! *<1* !!! ][ 116 ][ 24 ][ 9 ]] +[[ char*->float ][ !!! *16* !!! ][ 171 ][ 67 ][ 30 ]] +[[ char*->double ][ !!! *15* !!! ][ 204 ][ 109 ][ 64 ]] +[[ char*->long double ][ 152 ][ 250 ][ 110 ][ !!! *71* !!! ]] +[[ unsigned char*->char ][ !!! *<1* !!! ][ 109 ][ 11 ][ 11 ]] +[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 108 ][ 11 ][ 9 ]] +[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 106 ][ 11 ][ 17 ]] +[[ unsigned char*->int ][ !!! *7* !!! ][ 143 ][ 31 ][ 17 ]] +[[ unsigned char*->short ][ !!! *9* !!! ][ 143 ][ 32 ][ 19 ]] +[[ unsigned char*->long int ][ !!! *8* !!! ][ 153 ][ 30 ][ 18 ]] +[[ unsigned char*->long long ][ !!! *10* !!! ][ 146 ][ 27 ][ 18 ]] +[[ unsigned char*->unsigned int ][ !!! *9* !!! ][ 144 ][ 25 ][ 18 ]] +[[ unsigned char*->unsigned short ][ !!! *9* !!! ][ 138 ][ 26 ][ 17 ]] +[[ unsigned char*->unsigned long int ][ !!! *9* !!! ][ 143 ][ 25 ][ 18 ]] +[[ unsigned char*->unsigned long long ][ !!! *10* !!! ][ 132 ][ 26 ][ 18 ]] +[[ unsigned char*->bool ][ !!! *<1* !!! ][ 102 ][ 18 ][ 9 ]] +[[ unsigned char*->float ][ !!! *13* !!! ][ 171 ][ 65 ][ 31 ]] +[[ unsigned char*->double ][ !!! *14* !!! ][ 197 ][ 89 ][ 53 ]] +[[ unsigned char*->long double ][ 122 ][ 208 ][ 89 ][ !!! *58* !!! ]] +[[ unsigned char*->string ][ !!! *8* !!! ][ 115 ][ 20 ][ --- ]] +[[ signed char*->char ][ !!! *<1* !!! ][ 93 ][ 10 ][ 9 ]] +[[ signed char*->signed char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 8 ]] +[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 90 ][ 10 ][ 15 ]] +[[ signed char*->int ][ !!! *7* !!! ][ 112 ][ 26 ][ 16 ]] +[[ signed char*->short ][ !!! *7* !!! ][ 112 ][ 26 ][ 16 ]] +[[ signed char*->long int ][ !!! *6* !!! ][ 118 ][ 25 ][ 14 ]] +[[ signed char*->long long ][ !!! *13* !!! ][ 114 ][ 25 ][ 14 ]] +[[ signed char*->unsigned int ][ !!! *7* !!! ][ 114 ][ 23 ][ 16 ]] +[[ signed char*->unsigned short ][ !!! *7* !!! ][ 107 ][ 25 ][ 16 ]] +[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 106 ][ 23 ][ 14 ]] +[[ signed char*->unsigned long long ][ !!! *7* !!! ][ 103 ][ 22 ][ 16 ]] +[[ signed char*->bool ][ !!! *<1* !!! ][ 110 ][ 20 ][ 9 ]] +[[ signed char*->float ][ !!! *13* !!! ][ 175 ][ 66 ][ 32 ]] +[[ signed char*->double ][ !!! *14* !!! ][ 203 ][ 90 ][ 53 ]] +[[ signed char*->long double ][ 124 ][ 205 ][ 87 ][ !!! *55* !!! ]] +[[ signed char*->string ][ !!! *8* !!! ][ 120 ][ 20 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 116 ][ 28 ][ --- ]] +[[ float->double ][ !!! *<1* !!! ][ 264 ][ 135 ][ --- ]] +[[ double->double ][ !!! *<1* !!! ][ 260 ][ 140 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 275 ][ 135 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 274 ][ 135 ][ --- ]] +[[ char->unsigned char ][ !!! *<1* !!! ][ 77 ][ 7 ][ --- ]] +[[ char->signed char ][ !!! *<1* !!! ][ 79 ][ 7 ][ --- ]] +[[ unsigned char->char ][ !!! *<1* !!! ][ 78 ][ 8 ][ --- ]] +[[ signed char->char ][ !!! *<1* !!! ][ 83 ][ 7 ][ --- ]] +] +[endsect] +[section gcc-4.5][table:id Performance Table (gcc-4.5) +[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] +[[ string->char ][ !!! *<1* !!! ][ 86 ][ 8 ][ 9 ]] +[[ string->signed char ][ !!! *<1* !!! ][ 88 ][ 9 ][ 9 ]] +[[ string->unsigned char ][ !!! *<1* !!! ][ 87 ][ 8 ][ 15 ]] +[[ string->int ][ !!! *6* !!! ][ 107 ][ 23 ][ 16 ]] +[[ string->short ][ !!! *7* !!! ][ 108 ][ 25 ][ 15 ]] +[[ string->long int ][ !!! *6* !!! ][ 110 ][ 26 ][ 15 ]] +[[ string->long long ][ !!! *7* !!! ][ 110 ][ 26 ][ 15 ]] +[[ string->unsigned int ][ !!! *6* !!! ][ 108 ][ 26 ][ 16 ]] +[[ string->unsigned short ][ !!! *7* !!! ][ 105 ][ 24 ][ 15 ]] +[[ string->unsigned long int ][ !!! *6* !!! ][ 108 ][ 23 ][ 15 ]] +[[ string->unsigned long long ][ !!! *10* !!! ][ 104 ][ 24 ][ 15 ]] +[[ string->bool ][ !!! *<1* !!! ][ 102 ][ 21 ][ 9 ]] +[[ string->float ][ !!! *13* !!! ][ 173 ][ 64 ][ 34 ]] +[[ string->double ][ !!! *15* !!! ][ 196 ][ 89 ][ 53 ]] +[[ string->long double ][ 126 ][ 211 ][ 90 ][ !!! *56* !!! ]] +[[ char->string ][ !!! *8* !!! ][ 107 ][ 20 ][ 10 ]] +[[ unsigned char->string ][ !!! *8* !!! ][ 107 ][ 17 ][ 15 ]] +[[ signed char->string ][ !!! *8* !!! ][ 108 ][ 19 ][ 10 ]] +[[ int->string ][ 16 ][ 129 ][ 25 ][ !!! *15* !!! ]] +[[ short->string ][ !!! *14* !!! ][ 128 ][ 25 ][ 17 ]] +[[ long int->string ][ 20 ][ 128 ][ 24 ][ !!! *15* !!! ]] +[[ long long->string ][ !!! *16* !!! ][ 128 ][ 25 ][ 16 ]] +[[ unsigned int->string ][ !!! *15* !!! ][ 125 ][ 25 ][ 15 ]] +[[ unsigned short->string ][ !!! *14* !!! ][ 125 ][ 24 ][ 15 ]] +[[ unsigned long int->string ][ 16 ][ 125 ][ 25 ][ !!! *15* !!! ]] +[[ unsigned long long->string ][ !!! *18* !!! ][ 140 ][ 32 ][ 22 ]] +[[ bool->string ][ !!! *8* !!! ][ 121 ][ 24 ][ 10 ]] +[[ float->string ][ 137 ][ 226 ][ 108 ][ !!! *48* !!! ]] +[[ double->string ][ 174 ][ 255 ][ 141 ][ !!! *71* !!! ]] +[[ long double->string ][ 208 ][ 268 ][ 144 ][ !!! *72* !!! ]] +[[ char*->char ][ !!! *<1* !!! ][ 93 ][ 8 ][ 9 ]] +[[ char*->signed char ][ !!! *<1* !!! ][ 94 ][ 9 ][ 9 ]] +[[ char*->unsigned char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 15 ]] +[[ char*->int ][ !!! *7* !!! ][ 115 ][ 26 ][ 16 ]] +[[ char*->short ][ !!! *8* !!! ][ 114 ][ 26 ][ 15 ]] +[[ char*->long int ][ !!! *7* !!! ][ 115 ][ 27 ][ 16 ]] +[[ char*->long long ][ !!! *7* !!! ][ 114 ][ 26 ][ 16 ]] +[[ char*->unsigned int ][ !!! *8* !!! ][ 115 ][ 25 ][ 16 ]] +[[ char*->unsigned short ][ !!! *7* !!! ][ 113 ][ 24 ][ 16 ]] +[[ char*->unsigned long int ][ !!! *8* !!! ][ 117 ][ 23 ][ 16 ]] +[[ char*->unsigned long long ][ !!! *8* !!! ][ 107 ][ 25 ][ 16 ]] +[[ char*->bool ][ !!! *<1* !!! ][ 110 ][ 21 ][ 9 ]] +[[ char*->float ][ !!! *17* !!! ][ 170 ][ 67 ][ 34 ]] +[[ char*->double ][ !!! *14* !!! ][ 197 ][ 91 ][ 52 ]] +[[ char*->long double ][ 127 ][ 206 ][ 89 ][ !!! *56* !!! ]] +[[ unsigned char*->char ][ !!! *<1* !!! ][ 83 ][ 8 ][ 9 ]] +[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 83 ][ 10 ][ 9 ]] +[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 83 ][ 8 ][ 15 ]] +[[ unsigned char*->int ][ !!! *7* !!! ][ 113 ][ 26 ][ 16 ]] +[[ unsigned char*->short ][ !!! *7* !!! ][ 112 ][ 24 ][ 16 ]] +[[ unsigned char*->long int ][ !!! *8* !!! ][ 114 ][ 26 ][ 16 ]] +[[ unsigned char*->long long ][ !!! *8* !!! ][ 113 ][ 26 ][ 16 ]] +[[ unsigned char*->unsigned int ][ !!! *8* !!! ][ 114 ][ 25 ][ 16 ]] +[[ unsigned char*->unsigned short ][ !!! *8* !!! ][ 109 ][ 24 ][ 16 ]] +[[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 111 ][ 23 ][ 16 ]] +[[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 106 ][ 25 ][ 16 ]] +[[ unsigned char*->bool ][ !!! *<1* !!! ][ 106 ][ 20 ][ 9 ]] +[[ unsigned char*->float ][ !!! *14* !!! ][ 169 ][ 65 ][ 34 ]] +[[ unsigned char*->double ][ !!! *16* !!! ][ 198 ][ 91 ][ 52 ]] +[[ unsigned char*->long double ][ 127 ][ 205 ][ 88 ][ !!! *56* !!! ]] +[[ unsigned char*->string ][ !!! *10* !!! ][ 123 ][ 21 ][ --- ]] +[[ signed char*->char ][ !!! *<1* !!! ][ 90 ][ 9 ][ 9 ]] +[[ signed char*->signed char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 9 ]] +[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 92 ][ 8 ][ 15 ]] +[[ signed char*->int ][ !!! *7* !!! ][ 116 ][ 26 ][ 16 ]] +[[ signed char*->short ][ !!! *8* !!! ][ 113 ][ 26 ][ 15 ]] +[[ signed char*->long int ][ !!! *8* !!! ][ 113 ][ 24 ][ 16 ]] +[[ signed char*->long long ][ !!! *8* !!! ][ 113 ][ 27 ][ 16 ]] +[[ signed char*->unsigned int ][ !!! *8* !!! ][ 113 ][ 25 ][ 16 ]] +[[ signed char*->unsigned short ][ !!! *7* !!! ][ 107 ][ 24 ][ 16 ]] +[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 111 ][ 23 ][ 17 ]] +[[ signed char*->unsigned long long ][ !!! *8* !!! ][ 105 ][ 25 ][ 16 ]] +[[ signed char*->bool ][ !!! *<1* !!! ][ 106 ][ 21 ][ 9 ]] +[[ signed char*->float ][ !!! *13* !!! ][ 169 ][ 63 ][ 34 ]] +[[ signed char*->double ][ !!! *16* !!! ][ 196 ][ 90 ][ 52 ]] +[[ signed char*->long double ][ 127 ][ 211 ][ 91 ][ !!! *60* !!! ]] +[[ signed char*->string ][ !!! *9* !!! ][ 123 ][ 21 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 120 ][ 29 ][ --- ]] +[[ float->double ][ !!! *<1* !!! ][ 258 ][ 147 ][ --- ]] +[[ double->double ][ !!! *<1* !!! ][ 261 ][ 140 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 266 ][ 138 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 266 ][ 137 ][ --- ]] +[[ char->unsigned char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] +[[ char->signed char ][ !!! *<1* !!! ][ 91 ][ 8 ][ --- ]] +[[ unsigned char->char ][ !!! *<1* !!! ][ 90 ][ 9 ][ --- ]] +[[ signed char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] +] +[endsect] +[section intel-12-linux][table:id Performance Table (intel-12-linux) +[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] +[[ string->char ][ !!! *1* !!! ][ 87 ][ 9 ][ 8 ]] +[[ string->signed char ][ !!! *<1* !!! ][ 90 ][ 9 ][ 8 ]] +[[ string->unsigned char ][ !!! *<1* !!! ][ 99 ][ 9 ][ 20 ]] +[[ string->int ][ !!! *8* !!! ][ 112 ][ 24 ][ 16 ]] +[[ string->short ][ !!! *8* !!! ][ 110 ][ 26 ][ 16 ]] +[[ string->long int ][ !!! *7* !!! ][ 110 ][ 23 ][ 16 ]] +[[ string->long long ][ !!! *10* !!! ][ 114 ][ 31 ][ 16 ]] +[[ string->unsigned int ][ !!! *7* !!! ][ 122 ][ 25 ][ 16 ]] +[[ string->unsigned short ][ !!! *7* !!! ][ 120 ][ 27 ][ 16 ]] +[[ string->unsigned long int ][ !!! *7* !!! ][ 114 ][ 25 ][ 16 ]] +[[ string->unsigned long long ][ !!! *7* !!! ][ 128 ][ 23 ][ 25 ]] +[[ string->bool ][ !!! *1* !!! ][ 103 ][ 20 ][ 9 ]] +[[ string->float ][ !!! *15* !!! ][ 166 ][ 73 ][ 31 ]] +[[ string->double ][ !!! *19* !!! ][ 206 ][ 103 ][ 56 ]] +[[ string->long double ][ 142 ][ 205 ][ 106 ][ !!! *61* !!! ]] +[[ char->string ][ !!! *10* !!! ][ 111 ][ 19 ][ 12 ]] +[[ unsigned char->string ][ !!! *12* !!! ][ 109 ][ 19 ][ 16 ]] +[[ signed char->string ][ !!! *9* !!! ][ 110 ][ 18 ][ 12 ]] +[[ int->string ][ 19 ][ 126 ][ 23 ][ !!! *17* !!! ]] +[[ short->string ][ 20 ][ 127 ][ 23 ][ !!! *18* !!! ]] +[[ long int->string ][ 20 ][ 128 ][ 24 ][ !!! *18* !!! ]] +[[ long long->string ][ !!! *16* !!! ][ 129 ][ 23 ][ 22 ]] +[[ unsigned int->string ][ 20 ][ 126 ][ 23 ][ !!! *17* !!! ]] +[[ unsigned short->string ][ 20 ][ 126 ][ 23 ][ !!! *17* !!! ]] +[[ unsigned long int->string ][ 20 ][ 126 ][ 23 ][ !!! *17* !!! ]] +[[ unsigned long long->string ][ !!! *24* !!! ][ 134 ][ 35 ][ 24 ]] +[[ bool->string ][ !!! *9* !!! ][ 124 ][ 29 ][ 12 ]] +[[ float->string ][ 147 ][ 218 ][ 104 ][ !!! *48* !!! ]] +[[ double->string ][ 202 ][ 245 ][ 128 ][ !!! *68* !!! ]] +[[ long double->string ][ 199 ][ 236 ][ 128 ][ !!! *69* !!! ]] +[[ char*->char ][ !!! *1* !!! ][ 91 ][ 10 ][ 9 ]] +[[ char*->signed char ][ !!! *1* !!! ][ 98 ][ 10 ][ 9 ]] +[[ char*->unsigned char ][ !!! *1* !!! ][ 97 ][ 14 ][ 15 ]] +[[ char*->int ][ !!! *8* !!! ][ 114 ][ 24 ][ 16 ]] +[[ char*->short ][ !!! *8* !!! ][ 112 ][ 27 ][ 15 ]] +[[ char*->long int ][ !!! *8* !!! ][ 117 ][ 28 ][ 16 ]] +[[ char*->long long ][ !!! *8* !!! ][ 123 ][ 30 ][ 16 ]] +[[ char*->unsigned int ][ !!! *8* !!! ][ 120 ][ 26 ][ 16 ]] +[[ char*->unsigned short ][ !!! *8* !!! ][ 122 ][ 30 ][ 16 ]] +[[ char*->unsigned long int ][ !!! *10* !!! ][ 119 ][ 25 ][ 16 ]] +[[ char*->unsigned long long ][ !!! *8* !!! ][ 140 ][ 54 ][ 34 ]] +[[ char*->bool ][ !!! *1* !!! ][ 108 ][ 21 ][ 8 ]] +[[ char*->float ][ !!! *16* !!! ][ 177 ][ 76 ][ 33 ]] +[[ char*->double ][ !!! *18* !!! ][ 271 ][ 104 ][ 56 ]] +[[ char*->long double ][ 142 ][ 207 ][ 106 ][ !!! *61* !!! ]] +[[ unsigned char*->char ][ !!! *1* !!! ][ 91 ][ 10 ][ 9 ]] +[[ unsigned char*->signed char ][ !!! *1* !!! ][ 92 ][ 10 ][ 8 ]] +[[ unsigned char*->unsigned char ][ !!! *1* !!! ][ 92 ][ 10 ][ 15 ]] +[[ unsigned char*->int ][ !!! *8* !!! ][ 111 ][ 24 ][ 16 ]] +[[ unsigned char*->short ][ !!! *9* !!! ][ 113 ][ 27 ][ 16 ]] +[[ unsigned char*->long int ][ !!! *7* !!! ][ 113 ][ 28 ][ 16 ]] +[[ unsigned char*->long long ][ !!! *7* !!! ][ 120 ][ 29 ][ 15 ]] +[[ unsigned char*->unsigned int ][ !!! *7* !!! ][ 119 ][ 24 ][ 15 ]] +[[ unsigned char*->unsigned short ][ !!! *8* !!! ][ 116 ][ 28 ][ 15 ]] +[[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 118 ][ 25 ][ 16 ]] +[[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 116 ][ 25 ][ 16 ]] +[[ unsigned char*->bool ][ !!! *1* !!! ][ 102 ][ 20 ][ 9 ]] +[[ unsigned char*->float ][ !!! *16* !!! ][ 167 ][ 74 ][ 31 ]] +[[ unsigned char*->double ][ !!! *19* !!! ][ 231 ][ 109 ][ 55 ]] +[[ unsigned char*->long double ][ 141 ][ 214 ][ 109 ][ !!! *61* !!! ]] +[[ unsigned char*->string ][ !!! *12* !!! ][ 122 ][ 23 ][ --- ]] +[[ signed char*->char ][ !!! *1* !!! ][ 91 ][ 10 ][ 8 ]] +[[ signed char*->signed char ][ !!! *1* !!! ][ 92 ][ 10 ][ 9 ]] +[[ signed char*->unsigned char ][ !!! *1* !!! ][ 92 ][ 10 ][ 15 ]] +[[ signed char*->int ][ !!! *7* !!! ][ 117 ][ 34 ][ 16 ]] +[[ signed char*->short ][ !!! *8* !!! ][ 117 ][ 25 ][ 15 ]] +[[ signed char*->long int ][ !!! *7* !!! ][ 115 ][ 28 ][ 16 ]] +[[ signed char*->long long ][ !!! *8* !!! ][ 116 ][ 31 ][ 15 ]] +[[ signed char*->unsigned int ][ !!! *8* !!! ][ 123 ][ 27 ][ 16 ]] +[[ signed char*->unsigned short ][ !!! *8* !!! ][ 120 ][ 27 ][ 16 ]] +[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 119 ][ 26 ][ 16 ]] +[[ signed char*->unsigned long long ][ !!! *7* !!! ][ 118 ][ 26 ][ 17 ]] +[[ signed char*->bool ][ !!! *1* !!! ][ 108 ][ 26 ][ 9 ]] +[[ signed char*->float ][ !!! *16* !!! ][ 170 ][ 73 ][ 31 ]] +[[ signed char*->double ][ !!! *18* !!! ][ 210 ][ 112 ][ 55 ]] +[[ signed char*->long double ][ 137 ][ 210 ][ 107 ][ !!! *61* !!! ]] +[[ signed char*->string ][ !!! *14* !!! ][ 121 ][ 23 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 115 ][ 26 ][ --- ]] +[[ float->double ][ !!! *<1* !!! ][ 266 ][ 155 ][ --- ]] +[[ double->double ][ !!! *<1* !!! ][ 267 ][ 157 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 261 ][ 153 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 264 ][ 152 ][ --- ]] +[[ char->unsigned char ][ !!! *<1* !!! ][ 96 ][ 9 ][ --- ]] +[[ char->signed char ][ !!! *<1* !!! ][ 96 ][ 9 ][ --- ]] +[[ unsigned char->char ][ !!! *<1* !!! ][ 93 ][ 9 ][ --- ]] +[[ signed char->char ][ !!! *<1* !!! ][ 87 ][ 9 ][ --- ]] +] +[endsect] + + + +[/ END of section, generated by performance measuring program ] +[endsect] + From e1caac418c1e0086aaaffb8231fe8cd6f8ed5280 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Mon, 12 Sep 2011 18:15:31 +0000 Subject: [PATCH 098/138] Mereged from r74355 Basic support for char16_t and char32_t [SVN r74361] --- include/boost/lexical_cast.hpp | 223 ++++++++++++++++++++------------- lexical_cast_test.cpp | 34 ++++- 2 files changed, 166 insertions(+), 91 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 6479e5d..e536ac5 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -133,60 +133,102 @@ namespace boost namespace detail // selectors for choosing stream character type { - template - struct stream_char - { - typedef char type; - }; + template + struct stream_char + { + typedef char type; + }; #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template - struct stream_char< std::basic_string > - { - typedef CharT type; - }; + template + struct stream_char< std::basic_string > + { + typedef CharT type; + }; #endif #ifndef BOOST_LCAST_NO_WCHAR_T #ifndef BOOST_NO_INTRINSIC_WCHAR_T - template<> - struct stream_char - { - typedef wchar_t type; - }; + template<> + struct stream_char + { + typedef wchar_t type; + }; #endif - template<> - struct stream_char - { - typedef wchar_t type; - }; + template<> + struct stream_char + { + typedef wchar_t type; + }; - template<> - struct stream_char - { - typedef wchar_t type; - }; + template<> + struct stream_char + { + typedef wchar_t type; + }; #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template<> - struct stream_char - { - typedef wchar_t type; - }; + template<> + struct stream_char + { + typedef wchar_t type; + }; #endif #endif + +#ifndef BOOST_NO_CHAR16_T + + template<> + struct stream_char + { + typedef char16_t type; + }; + + template<> + struct stream_char + { + typedef char16_t type; + }; + + template<> + struct stream_char + { + typedef char16_t type; + }; + +#endif + +#ifndef BOOST_NO_CHAR32_T + + template<> + struct stream_char + { + typedef char32_t type; + }; + + template<> + struct stream_char + { + typedef char32_t type; + }; + + template<> + struct stream_char + { + typedef char32_t type; + }; + +#endif + template struct widest_char { - typedef TargetChar type; - }; - - template<> - struct widest_char - { - typedef wchar_t type; + typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c< + (sizeof(TargetChar) > sizeof(SourceChar)) + , TargetChar + , SourceChar >::type type; }; } @@ -231,8 +273,7 @@ namespace boost namespace detail // lcast_src_length { // Return max. length of string representation of Source; - template< class CharT // A result of widest_char transformation. - , class Source // Source type of lexical_cast. + template< class Source // Source type of lexical_cast. > struct lcast_src_length { @@ -269,20 +310,12 @@ namespace boost BOOST_STATIC_ASSERT(sizeof(Source) * CHAR_BIT <= 256); #endif }; - -#define BOOST_LCAST_DEF1(CharT, T) \ - template<> struct lcast_src_length \ +// TODO: FIX for char16_t, char32_t, we can ignore CharT +#define BOOST_LCAST_DEF(T) \ + template<> struct lcast_src_length \ : lcast_src_length_integral \ { static void check_coverage() {} }; -#ifdef BOOST_LCAST_NO_WCHAR_T -#define BOOST_LCAST_DEF(T) BOOST_LCAST_DEF1(char, T) -#else -#define BOOST_LCAST_DEF(T) \ - BOOST_LCAST_DEF1(char, T) \ - BOOST_LCAST_DEF1(wchar_t, T) -#endif - BOOST_LCAST_DEF(short) BOOST_LCAST_DEF(unsigned short) BOOST_LCAST_DEF(int) @@ -298,7 +331,6 @@ namespace boost #endif #undef BOOST_LCAST_DEF -#undef BOOST_LCAST_DEF1 #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION // Helper for floating point types. @@ -324,49 +356,26 @@ namespace boost }; template<> - struct lcast_src_length + struct lcast_src_length : lcast_src_length_floating { static void check_coverage() {} }; template<> - struct lcast_src_length + struct lcast_src_length : lcast_src_length_floating { static void check_coverage() {} }; template<> - struct lcast_src_length + struct lcast_src_length : lcast_src_length_floating { static void check_coverage() {} }; -#ifndef BOOST_LCAST_NO_WCHAR_T - template<> - struct lcast_src_length - : lcast_src_length_floating - { - static void check_coverage() {} - }; - - template<> - struct lcast_src_length - : lcast_src_length_floating - { - static void check_coverage() {} - }; - - template<> - struct lcast_src_length - : lcast_src_length_floating - { - static void check_coverage() {} - }; - -#endif // #ifndef BOOST_LCAST_NO_WCHAR_T #endif // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION } @@ -397,6 +406,32 @@ namespace boost BOOST_STATIC_CONSTANT(wchar_t, c_decimal_separator = L'.'); }; #endif + +#ifndef BOOST_NO_CHAR16_T + template<> + struct lcast_char_constants + { + BOOST_STATIC_CONSTANT(char16_t, zero = u'0'); + BOOST_STATIC_CONSTANT(char16_t, minus = u'-'); + BOOST_STATIC_CONSTANT(char16_t, plus = u'+'); + BOOST_STATIC_CONSTANT(char16_t, lowercase_e = u'e'); + BOOST_STATIC_CONSTANT(char16_t, capital_e = u'E'); + BOOST_STATIC_CONSTANT(char16_t, c_decimal_separator = u'.'); + }; +#endif + +#ifndef BOOST_NO_CHAR32_T + template<> + struct lcast_char_constants + { + BOOST_STATIC_CONSTANT(char32_t, zero = U'0'); + BOOST_STATIC_CONSTANT(char32_t, minus = U'-'); + BOOST_STATIC_CONSTANT(char32_t, plus = U'+'); + BOOST_STATIC_CONSTANT(char32_t, lowercase_e = U'e'); + BOOST_STATIC_CONSTANT(char32_t, capital_e = U'E'); + BOOST_STATIC_CONSTANT(char32_t, c_decimal_separator = U'.'); + }; +#endif } namespace detail // lcast_to_unsigned @@ -1553,28 +1588,38 @@ namespace boost template struct is_char_or_wchar { + private: #ifndef BOOST_LCAST_NO_WCHAR_T - BOOST_STATIC_CONSTANT(bool, value = - ( - ::boost::type_traits::ice_or< - is_same< T, char >::value, - is_same< T, wchar_t >::value, - is_same< T, unsigned char >::value, - is_same< T, signed char >::value - >::value - ) - ); + typedef wchar_t wchar_t_if_supported; #else + typedef char wchar_t_if_supported; +#endif + +#ifndef BOOST_NO_CHAR16_T + typedef char16_t char16_t_if_supported; +#else + typedef char char16_t_if_supported; +#endif + +#ifndef BOOST_NO_CHAR32_T + typedef char32_t char32_t_if_supported; +#else + typedef char char32_t_if_supported; +#endif + public: + BOOST_STATIC_CONSTANT(bool, value = ( ::boost::type_traits::ice_or< is_same< T, char >::value, + is_same< T, wchar_t_if_supported >::value, + is_same< T, char16_t_if_supported >::value, + is_same< T, char32_t_if_supported >::value, is_same< T, unsigned char >::value, is_same< T, signed char >::value >::value ) ); -#endif }; template @@ -1658,7 +1703,7 @@ namespace boost , BOOST_DEDUCED_TYPENAME detail::stream_char::type >::type char_type; - typedef detail::lcast_src_length lcast_src_length; + typedef detail::lcast_src_length lcast_src_length; std::size_t const src_len = lcast_src_length::value; char_type buf[src_len + 1]; lcast_src_length::check_coverage(); diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index f07926b..47381cd 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -100,6 +100,13 @@ void test_wallocator(); #endif void test_char_types_conversions(); void operators_overload_test(); +#ifndef BOOST_NO_CHAR16_T +void test_char16_conversions(); +#endif +#ifndef BOOST_NO_CHAR32_T +void test_char32_conversions(); +#endif + unit_test::test_suite *init_unit_test_suite(int, char *[]) { @@ -142,6 +149,12 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(&test_char_types_conversions)); suite->add(BOOST_TEST_CASE(&operators_overload_test)); +#ifndef BOOST_NO_CHAR16_T + suite->add(BOOST_TEST_CASE(&test_char16_conversions)); +#endif +#ifndef BOOST_NO_CHAR32_T + suite->add(BOOST_TEST_CASE(&test_char32_conversions)); +#endif return suite; } @@ -582,7 +595,7 @@ void test_conversion_from_integral_to_string(CharT) // Test values around zero: if(limits::is_signed) - for(t = -counter; t < static_cast(counter); ++t) + for(t = static_cast(-counter); t < static_cast(counter); ++t) BOOST_CHECK(lexical_cast(t) == to_str(t)); // Test values around 100, 1000, 10000, ... @@ -679,7 +692,7 @@ void test_conversion_from_string_to_integral(CharT) // Test values around zero: if(limits::is_signed) - for(t = -counter; t < static_cast(counter); ++t) + for(t = static_cast(-counter); t < static_cast(counter); ++t) BOOST_CHECK(lexical_cast(to_str(t)) == t); // Test values around 100, 1000, 10000, ... @@ -990,3 +1003,20 @@ void operators_overload_test() (void)boost::lexical_cast(foo); } + +#ifndef BOOST_NO_CHAR16_T +void test_char16_conversions() +{ + BOOST_CHECK(u"100" == lexical_cast(u"100")); + BOOST_CHECK(u"1" == lexical_cast(u'1')); +} +#endif + +#ifndef BOOST_NO_CHAR32_T +void test_char32_conversions() +{ + BOOST_CHECK(U"100" == lexical_cast(U"100")); + BOOST_CHECK(U"1" == lexical_cast(U'1')); +} +#endif + From 3a62368d0ef37a320e98b76bf77ce87ba5ca5cbb Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sun, 25 Sep 2011 16:44:39 +0000 Subject: [PATCH 099/138] Merge from trunk r74564 * char16_t and char32_t conversions now work on gcc for C locale * Optimizations for C locale * Performance section of documentation updated [SVN r74565] --- doc/lexical_cast.qbk | 780 +++++++++++++++------------------ include/boost/lexical_cast.hpp | 175 ++++---- lexical_cast_test.cpp | 10 + 3 files changed, 448 insertions(+), 517 deletions(-) diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index 9fb6cdf..b540267 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -243,457 +243,365 @@ Do not use this results to compare compilers, because tests were taken on differ [section clang-linux-2.8][table:id Performance Table (clang-linux-2.8) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 106 ][ 11 ][ 11 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 102 ][ 8 ][ 8 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 83 ][ 7 ][ 15 ]] -[[ string->int ][ !!! *8* !!! ][ 114 ][ 21 ][ 17 ]] -[[ string->short ][ !!! *10* !!! ][ 111 ][ 20 ][ 17 ]] -[[ string->long int ][ !!! *9* !!! ][ 113 ][ 20 ][ 16 ]] -[[ string->long long ][ !!! *9* !!! ][ 112 ][ 21 ][ 16 ]] -[[ string->unsigned int ][ !!! *9* !!! ][ 115 ][ 23 ][ 17 ]] -[[ string->unsigned short ][ !!! *7* !!! ][ 111 ][ 21 ][ 16 ]] -[[ string->unsigned long int ][ !!! *9* !!! ][ 106 ][ 20 ][ 17 ]] -[[ string->unsigned long long ][ !!! *9* !!! ][ 104 ][ 21 ][ 17 ]] -[[ string->bool ][ !!! *<1* !!! ][ 101 ][ 17 ][ 10 ]] -[[ string->float ][ !!! *16* !!! ][ 175 ][ 67 ][ 33 ]] -[[ string->double ][ !!! *18* !!! ][ 196 ][ 91 ][ 56 ]] -[[ string->long double ][ 126 ][ 198 ][ 92 ][ !!! *61* !!! ]] -[[ char->string ][ !!! *12* !!! ][ 101 ][ 16 ][ 12 ]] -[[ unsigned char->string ][ !!! *10* !!! ][ 103 ][ 18 ][ 17 ]] -[[ signed char->string ][ !!! *12* !!! ][ 101 ][ 18 ][ 12 ]] -[[ int->string ][ !!! *19* !!! ][ 124 ][ 25 ][ 19 ]] -[[ short->string ][ 23 ][ 124 ][ 26 ][ !!! *17* !!! ]] -[[ long int->string ][ 20 ][ 123 ][ 23 ][ !!! *17* !!! ]] -[[ long long->string ][ 19 ][ 124 ][ 23 ][ !!! *18* !!! ]] -[[ unsigned int->string ][ 18 ][ 122 ][ 28 ][ !!! *17* !!! ]] -[[ unsigned short->string ][ 36 ][ 160 ][ 31 ][ !!! *17* !!! ]] -[[ unsigned long int->string ][ 22 ][ 123 ][ 28 ][ !!! *18* !!! ]] -[[ unsigned long long->string ][ !!! *23* !!! ][ 137 ][ 32 ][ 23 ]] -[[ bool->string ][ !!! *11* !!! ][ 124 ][ 26 ][ 17 ]] -[[ float->string ][ 178 ][ 273 ][ 124 ][ !!! *57* !!! ]] -[[ double->string ][ 227 ][ 450 ][ 241 ][ !!! *77* !!! ]] -[[ long double->string ][ 249 ][ 331 ][ 185 ][ !!! *85* !!! ]] -[[ char*->char ][ !!! *<1* !!! ][ 109 ][ 9 ][ 11 ]] -[[ char*->signed char ][ !!! *<1* !!! ][ 105 ][ 15 ][ 8 ]] -[[ char*->unsigned char ][ !!! *<1* !!! ][ 111 ][ 11 ][ 20 ]] -[[ char*->int ][ !!! *7* !!! ][ 143 ][ 25 ][ 19 ]] -[[ char*->short ][ !!! *10* !!! ][ 131 ][ 24 ][ 18 ]] -[[ char*->long int ][ !!! *12* !!! ][ 134 ][ 24 ][ 18 ]] -[[ char*->long long ][ !!! *12* !!! ][ 132 ][ 26 ][ 17 ]] -[[ char*->unsigned int ][ !!! *10* !!! ][ 133 ][ 26 ][ 19 ]] -[[ char*->unsigned short ][ !!! *11* !!! ][ 127 ][ 24 ][ 20 ]] -[[ char*->unsigned long int ][ !!! *10* !!! ][ 143 ][ 26 ][ 19 ]] -[[ char*->unsigned long long ][ !!! *12* !!! ][ 137 ][ 26 ][ 19 ]] -[[ char*->bool ][ !!! *2* !!! ][ 138 ][ 27 ][ 13 ]] -[[ char*->float ][ !!! *19* !!! ][ 186 ][ 65 ][ 31 ]] -[[ char*->double ][ !!! *19* !!! ][ 195 ][ 96 ][ 57 ]] -[[ char*->long double ][ 134 ][ 200 ][ 92 ][ !!! *61* !!! ]] -[[ unsigned char*->char ][ !!! *<1* !!! ][ 87 ][ 8 ][ 10 ]] -[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 87 ][ 8 ][ 10 ]] -[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 89 ][ 8 ][ 16 ]] -[[ unsigned char*->int ][ !!! *10* !!! ][ 117 ][ 22 ][ 17 ]] -[[ unsigned char*->short ][ !!! *11* !!! ][ 117 ][ 21 ][ 17 ]] -[[ unsigned char*->long int ][ !!! *10* !!! ][ 116 ][ 22 ][ 17 ]] -[[ unsigned char*->long long ][ !!! *9* !!! ][ 116 ][ 22 ][ 17 ]] -[[ unsigned char*->unsigned int ][ !!! *10* !!! ][ 117 ][ 24 ][ 17 ]] -[[ unsigned char*->unsigned short ][ !!! *11* !!! ][ 119 ][ 22 ][ 17 ]] -[[ unsigned char*->unsigned long int ][ !!! *10* !!! ][ 111 ][ 21 ][ 17 ]] -[[ unsigned char*->unsigned long long ][ !!! *10* !!! ][ 109 ][ 21 ][ 17 ]] -[[ unsigned char*->bool ][ !!! *<1* !!! ][ 105 ][ 18 ][ 10 ]] -[[ unsigned char*->float ][ !!! *17* !!! ][ 174 ][ 66 ][ 33 ]] -[[ unsigned char*->double ][ !!! *19* !!! ][ 198 ][ 91 ][ 56 ]] -[[ unsigned char*->long double ][ 129 ][ 200 ][ 92 ][ !!! *58* !!! ]] -[[ unsigned char*->string ][ !!! *12* !!! ][ 122 ][ 20 ][ --- ]] -[[ signed char*->char ][ !!! *<1* !!! ][ 87 ][ 8 ][ 9 ]] -[[ signed char*->signed char ][ !!! *<1* !!! ][ 86 ][ 8 ][ 10 ]] -[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 93 ][ 8 ][ 16 ]] -[[ signed char*->int ][ !!! *10* !!! ][ 117 ][ 21 ][ 17 ]] -[[ signed char*->short ][ !!! *11* !!! ][ 117 ][ 22 ][ 17 ]] -[[ signed char*->long int ][ !!! *10* !!! ][ 115 ][ 21 ][ 17 ]] -[[ signed char*->long long ][ !!! *10* !!! ][ 115 ][ 24 ][ 17 ]] -[[ signed char*->unsigned int ][ !!! *10* !!! ][ 118 ][ 24 ][ 17 ]] -[[ signed char*->unsigned short ][ !!! *11* !!! ][ 139 ][ 27 ][ 20 ]] -[[ signed char*->unsigned long int ][ !!! *9* !!! ][ 144 ][ 27 ][ 19 ]] -[[ signed char*->unsigned long long ][ !!! *7* !!! ][ 127 ][ 25 ][ 22 ]] -[[ signed char*->bool ][ !!! *<1* !!! ][ 123 ][ 23 ][ 9 ]] -[[ signed char*->float ][ !!! *21* !!! ][ 207 ][ 80 ][ 41 ]] -[[ signed char*->double ][ !!! *23* !!! ][ 255 ][ 115 ][ 68 ]] -[[ signed char*->long double ][ 159 ][ 275 ][ 125 ][ !!! *72* !!! ]] -[[ signed char*->string ][ !!! *16* !!! ][ 155 ][ 27 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 150 ][ 32 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 304 ][ 162 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 298 ][ 168 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 311 ][ 154 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 308 ][ 154 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 97 ][ 9 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 94 ][ 11 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 106 ][ 8 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 111 ][ 8 ][ --- ]] -] -[endsect] -[section gcc-4.3][table:id Performance Table (gcc-4.3) -[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 92 ][ 7 ][ 8 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 92 ][ 7 ][ 8 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 92 ][ 7 ][ 13 ]] -[[ string->int ][ !!! *6* !!! ][ 115 ][ 21 ][ 14 ]] -[[ string->short ][ !!! *7* !!! ][ 141 ][ 26 ][ 24 ]] -[[ string->long int ][ !!! *7* !!! ][ 141 ][ 27 ][ 18 ]] -[[ string->long long ][ !!! *7* !!! ][ 153 ][ 28 ][ 17 ]] -[[ string->unsigned int ][ !!! *7* !!! ][ 156 ][ 26 ][ 18 ]] -[[ string->unsigned short ][ !!! *8* !!! ][ 146 ][ 25 ][ 18 ]] -[[ string->unsigned long int ][ !!! *9* !!! ][ 143 ][ 29 ][ 37 ]] -[[ string->unsigned long long ][ !!! *14* !!! ][ 135 ][ 20 ][ 15 ]] -[[ string->bool ][ !!! *<1* !!! ][ 117 ][ 20 ][ 8 ]] -[[ string->float ][ !!! *15* !!! ][ 177 ][ 63 ][ 31 ]] -[[ string->double ][ !!! *15* !!! ][ 198 ][ 89 ][ 54 ]] -[[ string->long double ][ 133 ][ 198 ][ 88 ][ !!! *55* !!! ]] -[[ char->string ][ !!! *10* !!! ][ 108 ][ 16 ][ 12 ]] -[[ unsigned char->string ][ !!! *10* !!! ][ 119 ][ 18 ][ 15 ]] -[[ signed char->string ][ !!! *10* !!! ][ 111 ][ 24 ][ 11 ]] -[[ int->string ][ !!! *14* !!! ][ 129 ][ 22 ][ 15 ]] -[[ short->string ][ !!! *14* !!! ][ 128 ][ 22 ][ 17 ]] -[[ long int->string ][ !!! *14* !!! ][ 127 ][ 21 ][ 17 ]] -[[ long long->string ][ !!! *14* !!! ][ 127 ][ 22 ][ 18 ]] -[[ unsigned int->string ][ !!! *15* !!! ][ 124 ][ 22 ][ 17 ]] -[[ unsigned short->string ][ 16 ][ 125 ][ 22 ][ !!! *15* !!! ]] -[[ unsigned long int->string ][ !!! *15* !!! ][ 125 ][ 22 ][ 17 ]] -[[ unsigned long long->string ][ !!! *18* !!! ][ 138 ][ 34 ][ 23 ]] -[[ bool->string ][ !!! *7* !!! ][ 120 ][ 22 ][ 12 ]] -[[ float->string ][ 136 ][ 229 ][ 110 ][ !!! *48* !!! ]] -[[ double->string ][ 184 ][ 270 ][ 136 ][ !!! *67* !!! ]] -[[ long double->string ][ 198 ][ 264 ][ 148 ][ !!! *69* !!! ]] -[[ char*->char ][ !!! *<1* !!! ][ 98 ][ 8 ][ 8 ]] -[[ char*->signed char ][ !!! *<1* !!! ][ 99 ][ 8 ][ 8 ]] -[[ char*->unsigned char ][ !!! *<1* !!! ][ 96 ][ 8 ][ 14 ]] -[[ char*->int ][ !!! *8* !!! ][ 120 ][ 21 ][ 15 ]] -[[ char*->short ][ !!! *8* !!! ][ 122 ][ 22 ][ 16 ]] -[[ char*->long int ][ !!! *8* !!! ][ 122 ][ 24 ][ 16 ]] -[[ char*->long long ][ !!! *8* !!! ][ 120 ][ 23 ][ 14 ]] -[[ char*->unsigned int ][ !!! *7* !!! ][ 123 ][ 23 ][ 15 ]] -[[ char*->unsigned short ][ !!! *8* !!! ][ 123 ][ 24 ][ 15 ]] -[[ char*->unsigned long int ][ !!! *8* !!! ][ 121 ][ 22 ][ 14 ]] -[[ char*->unsigned long long ][ !!! *7* !!! ][ 116 ][ 20 ][ 16 ]] -[[ char*->bool ][ !!! *<1* !!! ][ 107 ][ 18 ][ 10 ]] -[[ char*->float ][ !!! *14* !!! ][ 181 ][ 67 ][ 32 ]] -[[ char*->double ][ !!! *16* !!! ][ 197 ][ 88 ][ 53 ]] -[[ char*->long double ][ 127 ][ 208 ][ 93 ][ !!! *56* !!! ]] -[[ unsigned char*->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 8 ]] -[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 93 ][ 8 ][ 10 ]] -[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 15 ]] -[[ unsigned char*->int ][ !!! *7* !!! ][ 117 ][ 21 ][ 16 ]] -[[ unsigned char*->short ][ !!! *8* !!! ][ 119 ][ 21 ][ 16 ]] -[[ unsigned char*->long int ][ !!! *7* !!! ][ 117 ][ 22 ][ 16 ]] -[[ unsigned char*->long long ][ !!! *8* !!! ][ 119 ][ 23 ][ 16 ]] -[[ unsigned char*->unsigned int ][ !!! *10* !!! ][ 123 ][ 20 ][ 15 ]] -[[ unsigned char*->unsigned short ][ !!! *8* !!! ][ 122 ][ 24 ][ 15 ]] -[[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 120 ][ 21 ][ 14 ]] -[[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 118 ][ 23 ][ 16 ]] -[[ unsigned char*->bool ][ !!! *1* !!! ][ 108 ][ 18 ][ 8 ]] -[[ unsigned char*->float ][ !!! *13* !!! ][ 182 ][ 63 ][ 30 ]] -[[ unsigned char*->double ][ !!! *16* !!! ][ 204 ][ 87 ][ 53 ]] -[[ unsigned char*->long double ][ 126 ][ 206 ][ 90 ][ !!! *60* !!! ]] -[[ unsigned char*->string ][ !!! *9* !!! ][ 123 ][ 21 ][ --- ]] -[[ signed char*->char ][ !!! *<1* !!! ][ 95 ][ 8 ][ 10 ]] -[[ signed char*->signed char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 10 ]] -[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 15 ]] -[[ signed char*->int ][ !!! *8* !!! ][ 117 ][ 22 ][ 16 ]] -[[ signed char*->short ][ !!! *7* !!! ][ 117 ][ 22 ][ 16 ]] -[[ signed char*->long int ][ !!! *8* !!! ][ 118 ][ 25 ][ 15 ]] -[[ signed char*->long long ][ !!! *7* !!! ][ 117 ][ 24 ][ 16 ]] -[[ signed char*->unsigned int ][ !!! *7* !!! ][ 120 ][ 20 ][ 16 ]] -[[ signed char*->unsigned short ][ !!! *8* !!! ][ 124 ][ 24 ][ 15 ]] -[[ signed char*->unsigned long int ][ !!! *8* !!! ][ 115 ][ 21 ][ 16 ]] -[[ signed char*->unsigned long long ][ !!! *9* !!! ][ 120 ][ 21 ][ 16 ]] -[[ signed char*->bool ][ !!! *1* !!! ][ 112 ][ 19 ][ 8 ]] -[[ signed char*->float ][ !!! *14* !!! ][ 183 ][ 64 ][ 31 ]] -[[ signed char*->double ][ !!! *18* !!! ][ 208 ][ 87 ][ 51 ]] -[[ signed char*->long double ][ 126 ][ 217 ][ 94 ][ !!! *55* !!! ]] -[[ signed char*->string ][ !!! *12* !!! ][ 126 ][ 22 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 146 ][ 23 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 275 ][ 139 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 270 ][ 142 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 281 ][ 145 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 301 ][ 145 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 96 ][ 7 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 95 ][ 7 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 96 ][ 7 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 91 ][ 7 ][ --- ]] +[[ string->char ][ !!! *<1* !!! ][ 148 ][ 14 ][ 12 ]] +[[ string->signed char ][ !!! *<1* !!! ][ 97 ][ 8 ][ 7 ]] +[[ string->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ 13 ]] +[[ string->int ][ !!! *4* !!! ][ 102 ][ 19 ][ 15 ]] +[[ string->short ][ !!! *4* !!! ][ 105 ][ 20 ][ 15 ]] +[[ string->long int ][ !!! *4* !!! ][ 105 ][ 19 ][ 15 ]] +[[ string->long long ][ !!! *4* !!! ][ 115 ][ 19 ][ 14 ]] +[[ string->unsigned int ][ !!! *4* !!! ][ 102 ][ 18 ][ 14 ]] +[[ string->unsigned short ][ !!! *4* !!! ][ 101 ][ 19 ][ 15 ]] +[[ string->unsigned long int ][ !!! *3* !!! ][ 107 ][ 20 ][ 14 ]] +[[ string->unsigned long long ][ !!! *3* !!! ][ 103 ][ 20 ][ 14 ]] +[[ string->bool ][ !!! *<1* !!! ][ 97 ][ 16 ][ 8 ]] +[[ string->float ][ !!! *21* !!! ][ 170 ][ 61 ][ 32 ]] +[[ string->double ][ !!! *18* !!! ][ 206 ][ 93 ][ 58 ]] +[[ string->long double ][ 135 ][ 221 ][ 94 ][ !!! *57* !!! ]] +[[ char->string ][ !!! *7* !!! ][ 100 ][ 17 ][ 13 ]] +[[ unsigned char->string ][ !!! *7* !!! ][ 99 ][ 18 ][ 16 ]] +[[ signed char->string ][ !!! *7* !!! ][ 101 ][ 17 ][ 12 ]] +[[ int->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 15 ]] +[[ short->string ][ !!! *13* !!! ][ 112 ][ 24 ][ 18 ]] +[[ long int->string ][ !!! *13* !!! ][ 119 ][ 23 ][ 17 ]] +[[ long long->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 18 ]] +[[ unsigned int->string ][ !!! *14* !!! ][ 113 ][ 24 ][ 17 ]] +[[ unsigned short->string ][ !!! *13* !!! ][ 108 ][ 24 ][ 17 ]] +[[ unsigned long int->string ][ !!! *13* !!! ][ 109 ][ 24 ][ 16 ]] +[[ unsigned long long->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 17 ]] +[[ bool->string ][ !!! *7* !!! ][ 105 ][ 24 ][ 12 ]] +[[ float->string ][ 70 ][ 192 ][ 94 ][ !!! *49* !!! ]] +[[ double->string ][ 106 ][ 217 ][ 122 ][ !!! *76* !!! ]] +[[ long double->string ][ 120 ][ 219 ][ 123 ][ !!! *80* !!! ]] +[[ char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 8 ]] +[[ char*->signed char ][ !!! *2* !!! ][ 87 ][ 10 ][ 7 ]] +[[ char*->unsigned char ][ !!! *3* !!! ][ 90 ][ 10 ][ 13 ]] +[[ char*->int ][ !!! *6* !!! ][ 107 ][ 21 ][ 15 ]] +[[ char*->short ][ !!! *6* !!! ][ 110 ][ 19 ][ 14 ]] +[[ char*->long int ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] +[[ char*->long long ][ !!! *7* !!! ][ 104 ][ 20 ][ 15 ]] +[[ char*->unsigned int ][ !!! *6* !!! ][ 101 ][ 20 ][ 15 ]] +[[ char*->unsigned short ][ !!! *7* !!! ][ 100 ][ 20 ][ 14 ]] +[[ char*->unsigned long int ][ !!! *6* !!! ][ 105 ][ 22 ][ 15 ]] +[[ char*->unsigned long long ][ !!! *7* !!! ][ 106 ][ 21 ][ 14 ]] +[[ char*->bool ][ !!! *2* !!! ][ 99 ][ 18 ][ 7 ]] +[[ char*->float ][ !!! *22* !!! ][ 159 ][ 67 ][ 33 ]] +[[ char*->double ][ !!! *20* !!! ][ 205 ][ 94 ][ 58 ]] +[[ char*->long double ][ 140 ][ 214 ][ 95 ][ !!! *58* !!! ]] +[[ unsigned char*->char ][ !!! *2* !!! ][ 92 ][ 9 ][ 7 ]] +[[ unsigned char*->signed char ][ !!! *2* !!! ][ 89 ][ 10 ][ 7 ]] +[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 89 ][ 10 ][ 14 ]] +[[ unsigned char*->int ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]] +[[ unsigned char*->short ][ !!! *6* !!! ][ 106 ][ 21 ][ 14 ]] +[[ unsigned char*->long int ][ !!! *6* !!! ][ 105 ][ 19 ][ 14 ]] +[[ unsigned char*->long long ][ !!! *6* !!! ][ 106 ][ 20 ][ 15 ]] +[[ unsigned char*->unsigned int ][ !!! *7* !!! ][ 105 ][ 19 ][ 14 ]] +[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] +[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 106 ][ 19 ][ 14 ]] +[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 21 ][ 15 ]] +[[ unsigned char*->bool ][ !!! *2* !!! ][ 102 ][ 18 ][ 7 ]] +[[ unsigned char*->float ][ !!! *23* !!! ][ 160 ][ 66 ][ 32 ]] +[[ unsigned char*->double ][ !!! *20* !!! ][ 201 ][ 95 ][ 58 ]] +[[ unsigned char*->long double ][ 144 ][ 221 ][ 95 ][ !!! *60* !!! ]] +[[ unsigned char*->string ][ !!! *12* !!! ][ 104 ][ 23 ][ --- ]] +[[ signed char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 7 ]] +[[ signed char*->signed char ][ !!! *2* !!! ][ 89 ][ 9 ][ 7 ]] +[[ signed char*->unsigned char ][ !!! *2* !!! ][ 89 ][ 10 ][ 13 ]] +[[ signed char*->int ][ !!! *6* !!! ][ 106 ][ 19 ][ 15 ]] +[[ signed char*->short ][ !!! *6* !!! ][ 107 ][ 20 ][ 15 ]] +[[ signed char*->long int ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] +[[ signed char*->long long ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] +[[ signed char*->unsigned int ][ !!! *6* !!! ][ 101 ][ 19 ][ 15 ]] +[[ signed char*->unsigned short ][ !!! *6* !!! ][ 101 ][ 19 ][ 16 ]] +[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 105 ][ 22 ][ 15 ]] +[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 21 ][ 15 ]] +[[ signed char*->bool ][ !!! *2* !!! ][ 100 ][ 18 ][ 7 ]] +[[ signed char*->float ][ !!! *23* !!! ][ 161 ][ 62 ][ 32 ]] +[[ signed char*->double ][ !!! *20* !!! ][ 207 ][ 102 ][ 57 ]] +[[ signed char*->long double ][ 144 ][ 216 ][ 96 ][ !!! *63* !!! ]] +[[ signed char*->string ][ !!! *12* !!! ][ 104 ][ 23 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 110 ][ 22 ][ --- ]] +[[ float->double ][ !!! *<1* !!! ][ 223 ][ 113 ][ --- ]] +[[ double->double ][ !!! *<1* !!! ][ 227 ][ 111 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 231 ][ 122 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 229 ][ 121 ][ --- ]] +[[ char->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]] +[[ char->signed char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]] +[[ unsigned char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] +[[ signed char->char ][ !!! *<1* !!! ][ 91 ][ 9 ][ --- ]] ] [endsect] [section gcc-4.4][table:id Performance Table (gcc-4.4) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 81 ][ 8 ][ 8 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 110 ][ 7 ][ 9 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 18 ]] -[[ string->int ][ !!! *9* !!! ][ 125 ][ 25 ][ 15 ]] -[[ string->short ][ !!! *7* !!! ][ 113 ][ 25 ][ 15 ]] -[[ string->long int ][ !!! *8* !!! ][ 112 ][ 24 ][ 15 ]] -[[ string->long long ][ !!! *8* !!! ][ 109 ][ 22 ][ 15 ]] -[[ string->unsigned int ][ !!! *8* !!! ][ 108 ][ 26 ][ 20 ]] -[[ string->unsigned short ][ !!! *9* !!! ][ 125 ][ 22 ][ 18 ]] -[[ string->unsigned long int ][ !!! *11* !!! ][ 125 ][ 32 ][ 17 ]] -[[ string->unsigned long long ][ !!! *10* !!! ][ 119 ][ 23 ][ 19 ]] -[[ string->bool ][ !!! *<1* !!! ][ 132 ][ 24 ][ 11 ]] -[[ string->float ][ !!! *18* !!! ][ 178 ][ 75 ][ 37 ]] -[[ string->double ][ !!! *24* !!! ][ 236 ][ 100 ][ 64 ]] -[[ string->long double ][ 146 ][ 233 ][ 118 ][ !!! *75* !!! ]] -[[ char->string ][ !!! *8* !!! ][ 136 ][ 22 ][ 13 ]] -[[ unsigned char->string ][ !!! *11* !!! ][ 127 ][ 22 ][ 20 ]] -[[ signed char->string ][ !!! *11* !!! ][ 128 ][ 21 ][ 15 ]] -[[ int->string ][ 25 ][ 159 ][ 30 ][ !!! *20* !!! ]] -[[ short->string ][ 25 ][ 151 ][ 30 ][ !!! *20* !!! ]] -[[ long int->string ][ !!! *20* !!! ][ 150 ][ 30 ][ 20 ]] -[[ long long->string ][ !!! *19* !!! ][ 164 ][ 26 ][ 21 ]] -[[ unsigned int->string ][ 35 ][ 147 ][ 27 ][ !!! *20* !!! ]] -[[ unsigned short->string ][ 26 ][ 149 ][ 26 ][ !!! *20* !!! ]] -[[ unsigned long int->string ][ 19 ][ 142 ][ 38 ][ !!! *17* !!! ]] -[[ unsigned long long->string ][ !!! *20* !!! ][ 139 ][ 36 ][ 26 ]] -[[ bool->string ][ !!! *10* !!! ][ 144 ][ 28 ][ 13 ]] -[[ float->string ][ 166 ][ 268 ][ 127 ][ !!! *52* !!! ]] -[[ double->string ][ 192 ][ 285 ][ 170 ][ !!! *90* !!! ]] -[[ long double->string ][ 250 ][ 344 ][ 160 ][ !!! *85* !!! ]] -[[ char*->char ][ !!! *<1* !!! ][ 90 ][ 9 ][ 8 ]] -[[ char*->signed char ][ !!! *<1* !!! ][ 82 ][ 9 ][ 8 ]] -[[ char*->unsigned char ][ !!! *<1* !!! ][ 88 ][ 8 ][ 13 ]] -[[ char*->int ][ !!! *6* !!! ][ 113 ][ 26 ][ 14 ]] -[[ char*->short ][ !!! *6* !!! ][ 114 ][ 25 ][ 14 ]] -[[ char*->long int ][ !!! *6* !!! ][ 123 ][ 38 ][ 17 ]] -[[ char*->long long ][ !!! *7* !!! ][ 126 ][ 37 ][ 17 ]] -[[ char*->unsigned int ][ !!! *6* !!! ][ 134 ][ 26 ][ 18 ]] -[[ char*->unsigned short ][ !!! *8* !!! ][ 126 ][ 24 ][ 17 ]] -[[ char*->unsigned long int ][ !!! *8* !!! ][ 121 ][ 24 ][ 17 ]] -[[ char*->unsigned long long ][ !!! *5* !!! ][ 117 ][ 24 ][ 18 ]] -[[ char*->bool ][ !!! *<1* !!! ][ 116 ][ 24 ][ 9 ]] -[[ char*->float ][ !!! *16* !!! ][ 171 ][ 67 ][ 30 ]] -[[ char*->double ][ !!! *15* !!! ][ 204 ][ 109 ][ 64 ]] -[[ char*->long double ][ 152 ][ 250 ][ 110 ][ !!! *71* !!! ]] -[[ unsigned char*->char ][ !!! *<1* !!! ][ 109 ][ 11 ][ 11 ]] -[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 108 ][ 11 ][ 9 ]] -[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 106 ][ 11 ][ 17 ]] -[[ unsigned char*->int ][ !!! *7* !!! ][ 143 ][ 31 ][ 17 ]] -[[ unsigned char*->short ][ !!! *9* !!! ][ 143 ][ 32 ][ 19 ]] -[[ unsigned char*->long int ][ !!! *8* !!! ][ 153 ][ 30 ][ 18 ]] -[[ unsigned char*->long long ][ !!! *10* !!! ][ 146 ][ 27 ][ 18 ]] -[[ unsigned char*->unsigned int ][ !!! *9* !!! ][ 144 ][ 25 ][ 18 ]] -[[ unsigned char*->unsigned short ][ !!! *9* !!! ][ 138 ][ 26 ][ 17 ]] -[[ unsigned char*->unsigned long int ][ !!! *9* !!! ][ 143 ][ 25 ][ 18 ]] -[[ unsigned char*->unsigned long long ][ !!! *10* !!! ][ 132 ][ 26 ][ 18 ]] -[[ unsigned char*->bool ][ !!! *<1* !!! ][ 102 ][ 18 ][ 9 ]] -[[ unsigned char*->float ][ !!! *13* !!! ][ 171 ][ 65 ][ 31 ]] -[[ unsigned char*->double ][ !!! *14* !!! ][ 197 ][ 89 ][ 53 ]] -[[ unsigned char*->long double ][ 122 ][ 208 ][ 89 ][ !!! *58* !!! ]] -[[ unsigned char*->string ][ !!! *8* !!! ][ 115 ][ 20 ][ --- ]] -[[ signed char*->char ][ !!! *<1* !!! ][ 93 ][ 10 ][ 9 ]] -[[ signed char*->signed char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 8 ]] -[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 90 ][ 10 ][ 15 ]] -[[ signed char*->int ][ !!! *7* !!! ][ 112 ][ 26 ][ 16 ]] -[[ signed char*->short ][ !!! *7* !!! ][ 112 ][ 26 ][ 16 ]] -[[ signed char*->long int ][ !!! *6* !!! ][ 118 ][ 25 ][ 14 ]] -[[ signed char*->long long ][ !!! *13* !!! ][ 114 ][ 25 ][ 14 ]] -[[ signed char*->unsigned int ][ !!! *7* !!! ][ 114 ][ 23 ][ 16 ]] -[[ signed char*->unsigned short ][ !!! *7* !!! ][ 107 ][ 25 ][ 16 ]] -[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 106 ][ 23 ][ 14 ]] -[[ signed char*->unsigned long long ][ !!! *7* !!! ][ 103 ][ 22 ][ 16 ]] -[[ signed char*->bool ][ !!! *<1* !!! ][ 110 ][ 20 ][ 9 ]] -[[ signed char*->float ][ !!! *13* !!! ][ 175 ][ 66 ][ 32 ]] -[[ signed char*->double ][ !!! *14* !!! ][ 203 ][ 90 ][ 53 ]] -[[ signed char*->long double ][ 124 ][ 205 ][ 87 ][ !!! *55* !!! ]] -[[ signed char*->string ][ !!! *8* !!! ][ 120 ][ 20 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 116 ][ 28 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 264 ][ 135 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 260 ][ 140 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 275 ][ 135 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 274 ][ 135 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 77 ][ 7 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 79 ][ 7 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 78 ][ 8 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 83 ][ 7 ][ --- ]] +[[ string->char ][ !!! *<1* !!! ][ 90 ][ 7 ][ 7 ]] +[[ string->signed char ][ !!! *<1* !!! ][ 88 ][ 7 ][ 8 ]] +[[ string->unsigned char ][ !!! *<1* !!! ][ 88 ][ 8 ][ 14 ]] +[[ string->int ][ !!! *3* !!! ][ 103 ][ 18 ][ 15 ]] +[[ string->short ][ !!! *3* !!! ][ 105 ][ 20 ][ 15 ]] +[[ string->long int ][ !!! *3* !!! ][ 101 ][ 18 ][ 16 ]] +[[ string->long long ][ !!! *3* !!! ][ 101 ][ 18 ][ 15 ]] +[[ string->unsigned int ][ !!! *3* !!! ][ 98 ][ 23 ][ 14 ]] +[[ string->unsigned short ][ !!! *3* !!! ][ 100 ][ 17 ][ 14 ]] +[[ string->unsigned long int ][ !!! *3* !!! ][ 100 ][ 21 ][ 15 ]] +[[ string->unsigned long long ][ !!! *3* !!! ][ 99 ][ 19 ][ 15 ]] +[[ string->bool ][ !!! *<1* !!! ][ 95 ][ 16 ][ 8 ]] +[[ string->float ][ !!! *13* !!! ][ 160 ][ 61 ][ 33 ]] +[[ string->double ][ !!! *14* !!! ][ 206 ][ 93 ][ 59 ]] +[[ string->long double ][ 128 ][ 217 ][ 96 ][ !!! *61* !!! ]] +[[ char->string ][ !!! *7* !!! ][ 100 ][ 17 ][ 12 ]] +[[ unsigned char->string ][ !!! *7* !!! ][ 109 ][ 17 ][ 16 ]] +[[ signed char->string ][ !!! *7* !!! ][ 99 ][ 17 ][ 12 ]] +[[ int->string ][ !!! *13* !!! ][ 110 ][ 21 ][ 15 ]] +[[ short->string ][ !!! *14* !!! ][ 110 ][ 22 ][ 17 ]] +[[ long int->string ][ !!! *14* !!! ][ 109 ][ 21 ][ 16 ]] +[[ long long->string ][ !!! *13* !!! ][ 114 ][ 20 ][ 17 ]] +[[ unsigned int->string ][ !!! *13* !!! ][ 109 ][ 23 ][ 15 ]] +[[ unsigned short->string ][ !!! *14* !!! ][ 109 ][ 23 ][ 17 ]] +[[ unsigned long int->string ][ !!! *13* !!! ][ 112 ][ 23 ][ 16 ]] +[[ unsigned long long->string ][ !!! *14* !!! ][ 109 ][ 21 ][ 17 ]] +[[ bool->string ][ !!! *7* !!! ][ 108 ][ 23 ][ 11 ]] +[[ float->string ][ 63 ][ 185 ][ 92 ][ !!! *50* !!! ]] +[[ double->string ][ 106 ][ 216 ][ 116 ][ !!! *75* !!! ]] +[[ long double->string ][ 118 ][ 219 ][ 119 ][ !!! *80* !!! ]] +[[ char*->char ][ !!! *1* !!! ][ 93 ][ 9 ][ 9 ]] +[[ char*->signed char ][ !!! *1* !!! ][ 92 ][ 9 ][ 9 ]] +[[ char*->unsigned char ][ !!! *1* !!! ][ 92 ][ 9 ][ 14 ]] +[[ char*->int ][ !!! *4* !!! ][ 107 ][ 19 ][ 15 ]] +[[ char*->short ][ !!! *5* !!! ][ 109 ][ 19 ][ 15 ]] +[[ char*->long int ][ !!! *4* !!! ][ 113 ][ 19 ][ 15 ]] +[[ char*->long long ][ !!! *4* !!! ][ 108 ][ 20 ][ 15 ]] +[[ char*->unsigned int ][ !!! *4* !!! ][ 106 ][ 19 ][ 15 ]] +[[ char*->unsigned short ][ !!! *4* !!! ][ 106 ][ 18 ][ 15 ]] +[[ char*->unsigned long int ][ !!! *4* !!! ][ 103 ][ 22 ][ 15 ]] +[[ char*->unsigned long long ][ !!! *4* !!! ][ 105 ][ 20 ][ 15 ]] +[[ char*->bool ][ !!! *1* !!! ][ 104 ][ 18 ][ 8 ]] +[[ char*->float ][ !!! *15* !!! ][ 164 ][ 62 ][ 33 ]] +[[ char*->double ][ !!! *16* !!! ][ 203 ][ 97 ][ 58 ]] +[[ char*->long double ][ 132 ][ 223 ][ 98 ][ !!! *60* !!! ]] +[[ unsigned char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 8 ]] +[[ unsigned char*->signed char ][ !!! *2* !!! ][ 92 ][ 10 ][ 8 ]] +[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 91 ][ 9 ][ 14 ]] +[[ unsigned char*->int ][ !!! *6* !!! ][ 106 ][ 20 ][ 15 ]] +[[ unsigned char*->short ][ !!! *6* !!! ][ 106 ][ 21 ][ 15 ]] +[[ unsigned char*->long int ][ !!! *6* !!! ][ 111 ][ 19 ][ 15 ]] +[[ unsigned char*->long long ][ !!! *6* !!! ][ 107 ][ 20 ][ 15 ]] +[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 105 ][ 19 ][ 15 ]] +[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 103 ][ 18 ][ 15 ]] +[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 106 ][ 22 ][ 14 ]] +[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 105 ][ 20 ][ 14 ]] +[[ unsigned char*->bool ][ !!! *2* !!! ][ 106 ][ 18 ][ 8 ]] +[[ unsigned char*->float ][ !!! *15* !!! ][ 167 ][ 68 ][ 33 ]] +[[ unsigned char*->double ][ !!! *17* !!! ][ 203 ][ 99 ][ 58 ]] +[[ unsigned char*->long double ][ 129 ][ 216 ][ 97 ][ !!! *61* !!! ]] +[[ unsigned char*->string ][ !!! *13* !!! ][ 111 ][ 23 ][ --- ]] +[[ signed char*->char ][ !!! *2* !!! ][ 92 ][ 9 ][ 8 ]] +[[ signed char*->signed char ][ !!! *2* !!! ][ 91 ][ 9 ][ 8 ]] +[[ signed char*->unsigned char ][ !!! *2* !!! ][ 91 ][ 9 ][ 14 ]] +[[ signed char*->int ][ !!! *6* !!! ][ 107 ][ 19 ][ 15 ]] +[[ signed char*->short ][ !!! *6* !!! ][ 109 ][ 24 ][ 14 ]] +[[ signed char*->long int ][ !!! *6* !!! ][ 112 ][ 19 ][ 15 ]] +[[ signed char*->long long ][ !!! *5* !!! ][ 107 ][ 20 ][ 15 ]] +[[ signed char*->unsigned int ][ !!! *6* !!! ][ 108 ][ 20 ][ 15 ]] +[[ signed char*->unsigned short ][ !!! *6* !!! ][ 104 ][ 18 ][ 15 ]] +[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 22 ][ 15 ]] +[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 20 ][ 15 ]] +[[ signed char*->bool ][ !!! *2* !!! ][ 104 ][ 18 ][ 8 ]] +[[ signed char*->float ][ !!! *16* !!! ][ 165 ][ 63 ][ 33 ]] +[[ signed char*->double ][ !!! *16* !!! ][ 203 ][ 98 ][ 59 ]] +[[ signed char*->long double ][ 129 ][ 215 ][ 98 ][ !!! *61* !!! ]] +[[ signed char*->string ][ !!! *13* !!! ][ 109 ][ 21 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 109 ][ 21 ][ --- ]] +[[ float->double ][ !!! *<1* !!! ][ 221 ][ 102 ][ --- ]] +[[ double->double ][ !!! *<1* !!! ][ 223 ][ 103 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 231 ][ 115 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 231 ][ 115 ][ --- ]] +[[ char->unsigned char ][ !!! *<1* !!! ][ 92 ][ 8 ][ --- ]] +[[ char->signed char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]] +[[ unsigned char->char ][ !!! *<1* !!! ][ 88 ][ 7 ][ --- ]] +[[ signed char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] ] [endsect] [section gcc-4.5][table:id Performance Table (gcc-4.5) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 86 ][ 8 ][ 9 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 88 ][ 9 ][ 9 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 87 ][ 8 ][ 15 ]] -[[ string->int ][ !!! *6* !!! ][ 107 ][ 23 ][ 16 ]] -[[ string->short ][ !!! *7* !!! ][ 108 ][ 25 ][ 15 ]] -[[ string->long int ][ !!! *6* !!! ][ 110 ][ 26 ][ 15 ]] -[[ string->long long ][ !!! *7* !!! ][ 110 ][ 26 ][ 15 ]] -[[ string->unsigned int ][ !!! *6* !!! ][ 108 ][ 26 ][ 16 ]] -[[ string->unsigned short ][ !!! *7* !!! ][ 105 ][ 24 ][ 15 ]] -[[ string->unsigned long int ][ !!! *6* !!! ][ 108 ][ 23 ][ 15 ]] -[[ string->unsigned long long ][ !!! *10* !!! ][ 104 ][ 24 ][ 15 ]] -[[ string->bool ][ !!! *<1* !!! ][ 102 ][ 21 ][ 9 ]] -[[ string->float ][ !!! *13* !!! ][ 173 ][ 64 ][ 34 ]] -[[ string->double ][ !!! *15* !!! ][ 196 ][ 89 ][ 53 ]] -[[ string->long double ][ 126 ][ 211 ][ 90 ][ !!! *56* !!! ]] -[[ char->string ][ !!! *8* !!! ][ 107 ][ 20 ][ 10 ]] -[[ unsigned char->string ][ !!! *8* !!! ][ 107 ][ 17 ][ 15 ]] -[[ signed char->string ][ !!! *8* !!! ][ 108 ][ 19 ][ 10 ]] -[[ int->string ][ 16 ][ 129 ][ 25 ][ !!! *15* !!! ]] -[[ short->string ][ !!! *14* !!! ][ 128 ][ 25 ][ 17 ]] -[[ long int->string ][ 20 ][ 128 ][ 24 ][ !!! *15* !!! ]] -[[ long long->string ][ !!! *16* !!! ][ 128 ][ 25 ][ 16 ]] -[[ unsigned int->string ][ !!! *15* !!! ][ 125 ][ 25 ][ 15 ]] -[[ unsigned short->string ][ !!! *14* !!! ][ 125 ][ 24 ][ 15 ]] -[[ unsigned long int->string ][ 16 ][ 125 ][ 25 ][ !!! *15* !!! ]] -[[ unsigned long long->string ][ !!! *18* !!! ][ 140 ][ 32 ][ 22 ]] -[[ bool->string ][ !!! *8* !!! ][ 121 ][ 24 ][ 10 ]] -[[ float->string ][ 137 ][ 226 ][ 108 ][ !!! *48* !!! ]] -[[ double->string ][ 174 ][ 255 ][ 141 ][ !!! *71* !!! ]] -[[ long double->string ][ 208 ][ 268 ][ 144 ][ !!! *72* !!! ]] -[[ char*->char ][ !!! *<1* !!! ][ 93 ][ 8 ][ 9 ]] -[[ char*->signed char ][ !!! *<1* !!! ][ 94 ][ 9 ][ 9 ]] -[[ char*->unsigned char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 15 ]] -[[ char*->int ][ !!! *7* !!! ][ 115 ][ 26 ][ 16 ]] -[[ char*->short ][ !!! *8* !!! ][ 114 ][ 26 ][ 15 ]] -[[ char*->long int ][ !!! *7* !!! ][ 115 ][ 27 ][ 16 ]] -[[ char*->long long ][ !!! *7* !!! ][ 114 ][ 26 ][ 16 ]] -[[ char*->unsigned int ][ !!! *8* !!! ][ 115 ][ 25 ][ 16 ]] -[[ char*->unsigned short ][ !!! *7* !!! ][ 113 ][ 24 ][ 16 ]] -[[ char*->unsigned long int ][ !!! *8* !!! ][ 117 ][ 23 ][ 16 ]] -[[ char*->unsigned long long ][ !!! *8* !!! ][ 107 ][ 25 ][ 16 ]] -[[ char*->bool ][ !!! *<1* !!! ][ 110 ][ 21 ][ 9 ]] -[[ char*->float ][ !!! *17* !!! ][ 170 ][ 67 ][ 34 ]] -[[ char*->double ][ !!! *14* !!! ][ 197 ][ 91 ][ 52 ]] -[[ char*->long double ][ 127 ][ 206 ][ 89 ][ !!! *56* !!! ]] -[[ unsigned char*->char ][ !!! *<1* !!! ][ 83 ][ 8 ][ 9 ]] -[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 83 ][ 10 ][ 9 ]] -[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 83 ][ 8 ][ 15 ]] -[[ unsigned char*->int ][ !!! *7* !!! ][ 113 ][ 26 ][ 16 ]] -[[ unsigned char*->short ][ !!! *7* !!! ][ 112 ][ 24 ][ 16 ]] -[[ unsigned char*->long int ][ !!! *8* !!! ][ 114 ][ 26 ][ 16 ]] -[[ unsigned char*->long long ][ !!! *8* !!! ][ 113 ][ 26 ][ 16 ]] -[[ unsigned char*->unsigned int ][ !!! *8* !!! ][ 114 ][ 25 ][ 16 ]] -[[ unsigned char*->unsigned short ][ !!! *8* !!! ][ 109 ][ 24 ][ 16 ]] -[[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 111 ][ 23 ][ 16 ]] -[[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 106 ][ 25 ][ 16 ]] -[[ unsigned char*->bool ][ !!! *<1* !!! ][ 106 ][ 20 ][ 9 ]] -[[ unsigned char*->float ][ !!! *14* !!! ][ 169 ][ 65 ][ 34 ]] -[[ unsigned char*->double ][ !!! *16* !!! ][ 198 ][ 91 ][ 52 ]] -[[ unsigned char*->long double ][ 127 ][ 205 ][ 88 ][ !!! *56* !!! ]] -[[ unsigned char*->string ][ !!! *10* !!! ][ 123 ][ 21 ][ --- ]] -[[ signed char*->char ][ !!! *<1* !!! ][ 90 ][ 9 ][ 9 ]] -[[ signed char*->signed char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 9 ]] -[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 92 ][ 8 ][ 15 ]] -[[ signed char*->int ][ !!! *7* !!! ][ 116 ][ 26 ][ 16 ]] -[[ signed char*->short ][ !!! *8* !!! ][ 113 ][ 26 ][ 15 ]] -[[ signed char*->long int ][ !!! *8* !!! ][ 113 ][ 24 ][ 16 ]] -[[ signed char*->long long ][ !!! *8* !!! ][ 113 ][ 27 ][ 16 ]] -[[ signed char*->unsigned int ][ !!! *8* !!! ][ 113 ][ 25 ][ 16 ]] -[[ signed char*->unsigned short ][ !!! *7* !!! ][ 107 ][ 24 ][ 16 ]] -[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 111 ][ 23 ][ 17 ]] -[[ signed char*->unsigned long long ][ !!! *8* !!! ][ 105 ][ 25 ][ 16 ]] -[[ signed char*->bool ][ !!! *<1* !!! ][ 106 ][ 21 ][ 9 ]] -[[ signed char*->float ][ !!! *13* !!! ][ 169 ][ 63 ][ 34 ]] -[[ signed char*->double ][ !!! *16* !!! ][ 196 ][ 90 ][ 52 ]] -[[ signed char*->long double ][ 127 ][ 211 ][ 91 ][ !!! *60* !!! ]] -[[ signed char*->string ][ !!! *9* !!! ][ 123 ][ 21 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 120 ][ 29 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 258 ][ 147 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 261 ][ 140 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 266 ][ 138 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 266 ][ 137 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 91 ][ 8 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 90 ][ 9 ][ --- ]] +[[ string->char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 7 ]] +[[ string->signed char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 7 ]] +[[ string->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ 13 ]] +[[ string->int ][ !!! *3* !!! ][ 100 ][ 20 ][ 14 ]] +[[ string->short ][ !!! *3* !!! ][ 106 ][ 20 ][ 14 ]] +[[ string->long int ][ !!! *3* !!! ][ 100 ][ 18 ][ 14 ]] +[[ string->long long ][ !!! *9* !!! ][ 100 ][ 18 ][ 15 ]] +[[ string->unsigned int ][ !!! *3* !!! ][ 97 ][ 20 ][ 14 ]] +[[ string->unsigned short ][ !!! *3* !!! ][ 102 ][ 17 ][ 14 ]] +[[ string->unsigned long int ][ !!! *3* !!! ][ 97 ][ 21 ][ 14 ]] +[[ string->unsigned long long ][ !!! *3* !!! ][ 97 ][ 19 ][ 14 ]] +[[ string->bool ][ !!! *<1* !!! ][ 95 ][ 16 ][ 7 ]] +[[ string->float ][ !!! *15* !!! ][ 157 ][ 63 ][ 32 ]] +[[ string->double ][ !!! *17* !!! ][ 203 ][ 95 ][ 59 ]] +[[ string->long double ][ 129 ][ 216 ][ 93 ][ !!! *58* !!! ]] +[[ char->string ][ !!! *8* !!! ][ 100 ][ 17 ][ 10 ]] +[[ unsigned char->string ][ !!! *8* !!! ][ 96 ][ 18 ][ 16 ]] +[[ signed char->string ][ !!! *8* !!! ][ 96 ][ 18 ][ 10 ]] +[[ int->string ][ !!! *14* !!! ][ 105 ][ 22 ][ 15 ]] +[[ short->string ][ !!! *14* !!! ][ 107 ][ 23 ][ 17 ]] +[[ long int->string ][ !!! *14* !!! ][ 109 ][ 22 ][ 17 ]] +[[ long long->string ][ !!! *14* !!! ][ 105 ][ 22 ][ 18 ]] +[[ unsigned int->string ][ !!! *14* !!! ][ 105 ][ 25 ][ 15 ]] +[[ unsigned short->string ][ !!! *15* !!! ][ 105 ][ 23 ][ 17 ]] +[[ unsigned long int->string ][ !!! *14* !!! ][ 109 ][ 24 ][ 17 ]] +[[ unsigned long long->string ][ !!! *14* !!! ][ 102 ][ 23 ][ 17 ]] +[[ bool->string ][ !!! *8* !!! ][ 104 ][ 23 ][ 12 ]] +[[ float->string ][ 66 ][ 181 ][ 92 ][ !!! *49* !!! ]] +[[ double->string ][ 107 ][ 215 ][ 120 ][ !!! *75* !!! ]] +[[ long double->string ][ 117 ][ 221 ][ 125 ][ !!! *79* !!! ]] +[[ char*->char ][ !!! *1* !!! ][ 89 ][ 9 ][ 7 ]] +[[ char*->signed char ][ !!! *1* !!! ][ 90 ][ 9 ][ 7 ]] +[[ char*->unsigned char ][ !!! *2* !!! ][ 90 ][ 9 ][ 13 ]] +[[ char*->int ][ !!! *7* !!! ][ 103 ][ 20 ][ 15 ]] +[[ char*->short ][ !!! *6* !!! ][ 102 ][ 29 ][ 14 ]] +[[ char*->long int ][ !!! *7* !!! ][ 101 ][ 20 ][ 15 ]] +[[ char*->long long ][ !!! *6* !!! ][ 102 ][ 20 ][ 14 ]] +[[ char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 19 ][ 14 ]] +[[ char*->unsigned short ][ !!! *6* !!! ][ 101 ][ 18 ][ 14 ]] +[[ char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 22 ][ 14 ]] +[[ char*->unsigned long long ][ !!! *6* !!! ][ 101 ][ 21 ][ 14 ]] +[[ char*->bool ][ !!! *3* !!! ][ 98 ][ 18 ][ 7 ]] +[[ char*->float ][ !!! *18* !!! ][ 162 ][ 63 ][ 31 ]] +[[ char*->double ][ !!! *17* !!! ][ 203 ][ 96 ][ 58 ]] +[[ char*->long double ][ 135 ][ 214 ][ 98 ][ !!! *58* !!! ]] +[[ unsigned char*->char ][ !!! *2* !!! ][ 87 ][ 9 ][ 7 ]] +[[ unsigned char*->signed char ][ !!! *2* !!! ][ 87 ][ 9 ][ 7 ]] +[[ unsigned char*->unsigned char ][ !!! *3* !!! ][ 87 ][ 9 ][ 13 ]] +[[ unsigned char*->int ][ !!! *6* !!! ][ 105 ][ 20 ][ 14 ]] +[[ unsigned char*->short ][ !!! *6* !!! ][ 102 ][ 21 ][ 14 ]] +[[ unsigned char*->long int ][ !!! *6* !!! ][ 101 ][ 20 ][ 14 ]] +[[ unsigned char*->long long ][ !!! *6* !!! ][ 102 ][ 20 ][ 14 ]] +[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 19 ][ 14 ]] +[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 100 ][ 18 ][ 14 ]] +[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 101 ][ 24 ][ 14 ]] +[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 100 ][ 20 ][ 14 ]] +[[ unsigned char*->bool ][ !!! *3* !!! ][ 99 ][ 18 ][ 8 ]] +[[ unsigned char*->float ][ !!! *17* !!! ][ 164 ][ 64 ][ 32 ]] +[[ unsigned char*->double ][ !!! *18* !!! ][ 201 ][ 94 ][ 58 ]] +[[ unsigned char*->long double ][ 133 ][ 217 ][ 95 ][ !!! *60* !!! ]] +[[ unsigned char*->string ][ !!! *14* !!! ][ 103 ][ 23 ][ --- ]] +[[ signed char*->char ][ !!! *3* !!! ][ 88 ][ 10 ][ 8 ]] +[[ signed char*->signed char ][ !!! *2* !!! ][ 87 ][ 10 ][ 7 ]] +[[ signed char*->unsigned char ][ !!! *3* !!! ][ 87 ][ 9 ][ 13 ]] +[[ signed char*->int ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]] +[[ signed char*->short ][ !!! *6* !!! ][ 105 ][ 21 ][ 14 ]] +[[ signed char*->long int ][ !!! *6* !!! ][ 104 ][ 20 ][ 15 ]] +[[ signed char*->long long ][ !!! *6* !!! ][ 106 ][ 20 ][ 14 ]] +[[ signed char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 20 ][ 14 ]] +[[ signed char*->unsigned short ][ !!! *6* !!! ][ 100 ][ 18 ][ 14 ]] +[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 23 ][ 14 ]] +[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 103 ][ 20 ][ 14 ]] +[[ signed char*->bool ][ !!! *3* !!! ][ 99 ][ 18 ][ 7 ]] +[[ signed char*->float ][ !!! *18* !!! ][ 159 ][ 60 ][ 32 ]] +[[ signed char*->double ][ !!! *18* !!! ][ 203 ][ 95 ][ 57 ]] +[[ signed char*->long double ][ 129 ][ 213 ][ 97 ][ !!! *56* !!! ]] +[[ signed char*->string ][ !!! *14* !!! ][ 105 ][ 22 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 109 ][ 22 ][ --- ]] +[[ float->double ][ !!! *<1* !!! ][ 226 ][ 104 ][ --- ]] +[[ double->double ][ !!! *<1* !!! ][ 229 ][ 103 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 225 ][ 115 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 227 ][ 115 ][ --- ]] +[[ char->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]] +[[ char->signed char ][ !!! *<1* !!! ][ 84 ][ 8 ][ --- ]] +[[ unsigned char->char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]] [[ signed char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] ] [endsect] -[section intel-12-linux][table:id Performance Table (intel-12-linux) +[section gcc-4.6][table:id Performance Table (gcc-4.6) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *1* !!! ][ 87 ][ 9 ][ 8 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 90 ][ 9 ][ 8 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 99 ][ 9 ][ 20 ]] -[[ string->int ][ !!! *8* !!! ][ 112 ][ 24 ][ 16 ]] -[[ string->short ][ !!! *8* !!! ][ 110 ][ 26 ][ 16 ]] -[[ string->long int ][ !!! *7* !!! ][ 110 ][ 23 ][ 16 ]] -[[ string->long long ][ !!! *10* !!! ][ 114 ][ 31 ][ 16 ]] -[[ string->unsigned int ][ !!! *7* !!! ][ 122 ][ 25 ][ 16 ]] -[[ string->unsigned short ][ !!! *7* !!! ][ 120 ][ 27 ][ 16 ]] -[[ string->unsigned long int ][ !!! *7* !!! ][ 114 ][ 25 ][ 16 ]] -[[ string->unsigned long long ][ !!! *7* !!! ][ 128 ][ 23 ][ 25 ]] -[[ string->bool ][ !!! *1* !!! ][ 103 ][ 20 ][ 9 ]] -[[ string->float ][ !!! *15* !!! ][ 166 ][ 73 ][ 31 ]] -[[ string->double ][ !!! *19* !!! ][ 206 ][ 103 ][ 56 ]] -[[ string->long double ][ 142 ][ 205 ][ 106 ][ !!! *61* !!! ]] -[[ char->string ][ !!! *10* !!! ][ 111 ][ 19 ][ 12 ]] -[[ unsigned char->string ][ !!! *12* !!! ][ 109 ][ 19 ][ 16 ]] -[[ signed char->string ][ !!! *9* !!! ][ 110 ][ 18 ][ 12 ]] -[[ int->string ][ 19 ][ 126 ][ 23 ][ !!! *17* !!! ]] -[[ short->string ][ 20 ][ 127 ][ 23 ][ !!! *18* !!! ]] -[[ long int->string ][ 20 ][ 128 ][ 24 ][ !!! *18* !!! ]] -[[ long long->string ][ !!! *16* !!! ][ 129 ][ 23 ][ 22 ]] -[[ unsigned int->string ][ 20 ][ 126 ][ 23 ][ !!! *17* !!! ]] -[[ unsigned short->string ][ 20 ][ 126 ][ 23 ][ !!! *17* !!! ]] -[[ unsigned long int->string ][ 20 ][ 126 ][ 23 ][ !!! *17* !!! ]] -[[ unsigned long long->string ][ !!! *24* !!! ][ 134 ][ 35 ][ 24 ]] -[[ bool->string ][ !!! *9* !!! ][ 124 ][ 29 ][ 12 ]] -[[ float->string ][ 147 ][ 218 ][ 104 ][ !!! *48* !!! ]] -[[ double->string ][ 202 ][ 245 ][ 128 ][ !!! *68* !!! ]] -[[ long double->string ][ 199 ][ 236 ][ 128 ][ !!! *69* !!! ]] -[[ char*->char ][ !!! *1* !!! ][ 91 ][ 10 ][ 9 ]] -[[ char*->signed char ][ !!! *1* !!! ][ 98 ][ 10 ][ 9 ]] -[[ char*->unsigned char ][ !!! *1* !!! ][ 97 ][ 14 ][ 15 ]] -[[ char*->int ][ !!! *8* !!! ][ 114 ][ 24 ][ 16 ]] -[[ char*->short ][ !!! *8* !!! ][ 112 ][ 27 ][ 15 ]] -[[ char*->long int ][ !!! *8* !!! ][ 117 ][ 28 ][ 16 ]] -[[ char*->long long ][ !!! *8* !!! ][ 123 ][ 30 ][ 16 ]] -[[ char*->unsigned int ][ !!! *8* !!! ][ 120 ][ 26 ][ 16 ]] -[[ char*->unsigned short ][ !!! *8* !!! ][ 122 ][ 30 ][ 16 ]] -[[ char*->unsigned long int ][ !!! *10* !!! ][ 119 ][ 25 ][ 16 ]] -[[ char*->unsigned long long ][ !!! *8* !!! ][ 140 ][ 54 ][ 34 ]] -[[ char*->bool ][ !!! *1* !!! ][ 108 ][ 21 ][ 8 ]] -[[ char*->float ][ !!! *16* !!! ][ 177 ][ 76 ][ 33 ]] -[[ char*->double ][ !!! *18* !!! ][ 271 ][ 104 ][ 56 ]] -[[ char*->long double ][ 142 ][ 207 ][ 106 ][ !!! *61* !!! ]] -[[ unsigned char*->char ][ !!! *1* !!! ][ 91 ][ 10 ][ 9 ]] -[[ unsigned char*->signed char ][ !!! *1* !!! ][ 92 ][ 10 ][ 8 ]] -[[ unsigned char*->unsigned char ][ !!! *1* !!! ][ 92 ][ 10 ][ 15 ]] -[[ unsigned char*->int ][ !!! *8* !!! ][ 111 ][ 24 ][ 16 ]] -[[ unsigned char*->short ][ !!! *9* !!! ][ 113 ][ 27 ][ 16 ]] -[[ unsigned char*->long int ][ !!! *7* !!! ][ 113 ][ 28 ][ 16 ]] -[[ unsigned char*->long long ][ !!! *7* !!! ][ 120 ][ 29 ][ 15 ]] -[[ unsigned char*->unsigned int ][ !!! *7* !!! ][ 119 ][ 24 ][ 15 ]] -[[ unsigned char*->unsigned short ][ !!! *8* !!! ][ 116 ][ 28 ][ 15 ]] -[[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 118 ][ 25 ][ 16 ]] -[[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 116 ][ 25 ][ 16 ]] -[[ unsigned char*->bool ][ !!! *1* !!! ][ 102 ][ 20 ][ 9 ]] -[[ unsigned char*->float ][ !!! *16* !!! ][ 167 ][ 74 ][ 31 ]] -[[ unsigned char*->double ][ !!! *19* !!! ][ 231 ][ 109 ][ 55 ]] -[[ unsigned char*->long double ][ 141 ][ 214 ][ 109 ][ !!! *61* !!! ]] -[[ unsigned char*->string ][ !!! *12* !!! ][ 122 ][ 23 ][ --- ]] -[[ signed char*->char ][ !!! *1* !!! ][ 91 ][ 10 ][ 8 ]] -[[ signed char*->signed char ][ !!! *1* !!! ][ 92 ][ 10 ][ 9 ]] -[[ signed char*->unsigned char ][ !!! *1* !!! ][ 92 ][ 10 ][ 15 ]] -[[ signed char*->int ][ !!! *7* !!! ][ 117 ][ 34 ][ 16 ]] -[[ signed char*->short ][ !!! *8* !!! ][ 117 ][ 25 ][ 15 ]] -[[ signed char*->long int ][ !!! *7* !!! ][ 115 ][ 28 ][ 16 ]] -[[ signed char*->long long ][ !!! *8* !!! ][ 116 ][ 31 ][ 15 ]] -[[ signed char*->unsigned int ][ !!! *8* !!! ][ 123 ][ 27 ][ 16 ]] -[[ signed char*->unsigned short ][ !!! *8* !!! ][ 120 ][ 27 ][ 16 ]] -[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 119 ][ 26 ][ 16 ]] -[[ signed char*->unsigned long long ][ !!! *7* !!! ][ 118 ][ 26 ][ 17 ]] -[[ signed char*->bool ][ !!! *1* !!! ][ 108 ][ 26 ][ 9 ]] -[[ signed char*->float ][ !!! *16* !!! ][ 170 ][ 73 ][ 31 ]] -[[ signed char*->double ][ !!! *18* !!! ][ 210 ][ 112 ][ 55 ]] -[[ signed char*->long double ][ 137 ][ 210 ][ 107 ][ !!! *61* !!! ]] -[[ signed char*->string ][ !!! *14* !!! ][ 121 ][ 23 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 115 ][ 26 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 266 ][ 155 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 267 ][ 157 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 261 ][ 153 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 264 ][ 152 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 96 ][ 9 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 96 ][ 9 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 93 ][ 9 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 87 ][ 9 ][ --- ]] +[[ string->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 7 ]] +[[ string->signed char ][ !!! *<1* !!! ][ 96 ][ 9 ][ 7 ]] +[[ string->unsigned char ][ !!! *<1* !!! ][ 96 ][ 8 ][ 13 ]] +[[ string->int ][ !!! *3* !!! ][ 110 ][ 18 ][ 16 ]] +[[ string->short ][ !!! *3* !!! ][ 111 ][ 18 ][ 16 ]] +[[ string->long int ][ !!! *3* !!! ][ 109 ][ 18 ][ 15 ]] +[[ string->long long ][ !!! *3* !!! ][ 111 ][ 18 ][ 15 ]] +[[ string->unsigned int ][ !!! *3* !!! ][ 110 ][ 20 ][ 15 ]] +[[ string->unsigned short ][ !!! *3* !!! ][ 111 ][ 18 ][ 15 ]] +[[ string->unsigned long int ][ !!! *3* !!! ][ 109 ][ 18 ][ 15 ]] +[[ string->unsigned long long ][ !!! *3* !!! ][ 114 ][ 19 ][ 15 ]] +[[ string->bool ][ !!! *<1* !!! ][ 106 ][ 17 ][ 8 ]] +[[ string->float ][ !!! *13* !!! ][ 175 ][ 70 ][ 33 ]] +[[ string->double ][ !!! *14* !!! ][ 182 ][ 81 ][ 58 ]] +[[ string->long double ][ 118 ][ 190 ][ 87 ][ !!! *58* !!! ]] +[[ char->string ][ !!! *8* !!! ][ 118 ][ 21 ][ 12 ]] +[[ unsigned char->string ][ !!! *8* !!! ][ 109 ][ 18 ][ 16 ]] +[[ signed char->string ][ !!! *8* !!! ][ 108 ][ 18 ][ 12 ]] +[[ int->string ][ 20 ][ 121 ][ 21 ][ !!! *16* !!! ]] +[[ short->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 17 ]] +[[ long int->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 16 ]] +[[ long long->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 17 ]] +[[ unsigned int->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 16 ]] +[[ unsigned short->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 18 ]] +[[ unsigned long int->string ][ 16 ][ 118 ][ 22 ][ !!! *15* !!! ]] +[[ unsigned long long->string ][ !!! *15* !!! ][ 117 ][ 21 ][ 17 ]] +[[ bool->string ][ !!! *8* !!! ][ 117 ][ 23 ][ 10 ]] +[[ float->string ][ 77 ][ 218 ][ 105 ][ !!! *50* !!! ]] +[[ double->string ][ 108 ][ 247 ][ 129 ][ !!! *73* !!! ]] +[[ long double->string ][ 120 ][ 250 ][ 131 ][ !!! *79* !!! ]] +[[ char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 7 ]] +[[ char*->signed char ][ !!! *2* !!! ][ 98 ][ 9 ][ 8 ]] +[[ char*->unsigned char ][ !!! *2* !!! ][ 98 ][ 9 ][ 13 ]] +[[ char*->int ][ !!! *6* !!! ][ 115 ][ 22 ][ 15 ]] +[[ char*->short ][ !!! *6* !!! ][ 114 ][ 22 ][ 15 ]] +[[ char*->long int ][ !!! *6* !!! ][ 114 ][ 22 ][ 16 ]] +[[ char*->long long ][ !!! *6* !!! ][ 119 ][ 22 ][ 15 ]] +[[ char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 20 ][ 15 ]] +[[ char*->unsigned short ][ !!! *6* !!! ][ 116 ][ 20 ][ 15 ]] +[[ char*->unsigned long int ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]] +[[ char*->unsigned long long ][ !!! *6* !!! ][ 118 ][ 22 ][ 15 ]] +[[ char*->bool ][ !!! *3* !!! ][ 113 ][ 18 ][ 8 ]] +[[ char*->float ][ !!! *15* !!! ][ 180 ][ 78 ][ 32 ]] +[[ char*->double ][ !!! *16* !!! ][ 185 ][ 89 ][ 58 ]] +[[ char*->long double ][ 119 ][ 193 ][ 91 ][ !!! *60* !!! ]] +[[ unsigned char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 8 ]] +[[ unsigned char*->signed char ][ !!! *2* !!! ][ 99 ][ 10 ][ 8 ]] +[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 100 ][ 9 ][ 15 ]] +[[ unsigned char*->int ][ !!! *6* !!! ][ 118 ][ 22 ][ 15 ]] +[[ unsigned char*->short ][ !!! *6* !!! ][ 117 ][ 26 ][ 15 ]] +[[ unsigned char*->long int ][ !!! *6* !!! ][ 119 ][ 21 ][ 15 ]] +[[ unsigned char*->long long ][ !!! *6* !!! ][ 118 ][ 21 ][ 14 ]] +[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 115 ][ 22 ][ 14 ]] +[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 117 ][ 20 ][ 15 ]] +[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 115 ][ 21 ][ 15 ]] +[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]] +[[ unsigned char*->bool ][ !!! *3* !!! ][ 112 ][ 18 ][ 8 ]] +[[ unsigned char*->float ][ !!! *15* !!! ][ 181 ][ 78 ][ 33 ]] +[[ unsigned char*->double ][ !!! *16* !!! ][ 185 ][ 92 ][ 59 ]] +[[ unsigned char*->long double ][ 120 ][ 190 ][ 89 ][ !!! *58* !!! ]] +[[ unsigned char*->string ][ !!! *14* !!! ][ 121 ][ 22 ][ --- ]] +[[ signed char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 9 ]] +[[ signed char*->signed char ][ !!! *2* !!! ][ 98 ][ 9 ][ 8 ]] +[[ signed char*->unsigned char ][ !!! *2* !!! ][ 98 ][ 9 ][ 14 ]] +[[ signed char*->int ][ !!! *6* !!! ][ 119 ][ 22 ][ 16 ]] +[[ signed char*->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 15 ]] +[[ signed char*->long int ][ !!! *6* !!! ][ 119 ][ 22 ][ 15 ]] +[[ signed char*->long long ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]] +[[ signed char*->unsigned int ][ !!! *6* !!! ][ 117 ][ 23 ][ 15 ]] +[[ signed char*->unsigned short ][ !!! *6* !!! ][ 117 ][ 21 ][ 14 ]] +[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 119 ][ 24 ][ 15 ]] +[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 116 ][ 22 ][ 15 ]] +[[ signed char*->bool ][ !!! *3* !!! ][ 111 ][ 18 ][ 8 ]] +[[ signed char*->float ][ !!! *16* !!! ][ 180 ][ 78 ][ 33 ]] +[[ signed char*->double ][ !!! *16* !!! ][ 185 ][ 89 ][ 59 ]] +[[ signed char*->long double ][ 120 ][ 191 ][ 91 ][ !!! *59* !!! ]] +[[ signed char*->string ][ !!! *14* !!! ][ 122 ][ 23 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 120 ][ 22 ][ --- ]] +[[ float->double ][ !!! *<1* !!! ][ 242 ][ 115 ][ --- ]] +[[ double->double ][ !!! *<1* !!! ][ 243 ][ 115 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 265 ][ 141 ][ --- ]] +[[ int->int ][ !!! *<1* !!! ][ 266 ][ 140 ][ --- ]] +[[ char->unsigned char ][ !!! *<1* !!! ][ 95 ][ 8 ][ --- ]] +[[ char->signed char ][ !!! *<1* !!! ][ 95 ][ 8 ][ --- ]] +[[ unsigned char->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ --- ]] +[[ signed char->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ --- ]] ] [endsect] - - [/ END of section, generated by performance measuring program ] [endsect] diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index e536ac5..94f8c70 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -461,7 +461,7 @@ namespace boost namespace detail // lcast_put_unsigned { template - CharT* lcast_put_unsigned(T n, CharT* finish) + CharT* lcast_put_unsigned(const T n_param, CharT* finish) { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS BOOST_STATIC_ASSERT(!std::numeric_limits::is_signed); @@ -470,51 +470,58 @@ namespace boost typedef typename Traits::int_type int_type; CharT const czero = lcast_char_constants::zero; int_type const zero = Traits::to_int_type(czero); + BOOST_DEDUCED_TYPENAME boost::mpl::if_c< + (sizeof(int_type) > sizeof(T)) + , int_type + , T + >::type n = n_param; #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE std::locale loc; - typedef std::numpunct numpunct; - numpunct const& np = BOOST_USE_FACET(numpunct, loc); - std::string const& grouping = np.grouping(); - std::string::size_type const grouping_size = grouping.size(); + if (loc != std::locale::classic()) { + typedef std::numpunct numpunct; + numpunct const& np = BOOST_USE_FACET(numpunct, loc); + std::string const grouping = np.grouping(); + std::string::size_type const grouping_size = grouping.size(); - if ( grouping_size && grouping[0] > 0 ) - { + if ( grouping_size && grouping[0] > 0 ) + { #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS - // Check that ulimited group is unreachable: - BOOST_STATIC_ASSERT(std::numeric_limits::digits10 < CHAR_MAX); + // Check that ulimited group is unreachable: + BOOST_STATIC_ASSERT(std::numeric_limits::digits10 < CHAR_MAX); #endif - CharT thousands_sep = np.thousands_sep(); - std::string::size_type group = 0; // current group number - char last_grp_size = grouping[0]; - char left = last_grp_size; + CharT thousands_sep = np.thousands_sep(); + std::string::size_type group = 0; // current group number + char last_grp_size = grouping[0]; + char left = last_grp_size; - do - { - if(left == 0) + do { - ++group; - if(group < grouping_size) + if(left == 0) { - char const grp_size = grouping[group]; - last_grp_size = grp_size <= 0 ? CHAR_MAX : grp_size; + ++group; + if(group < grouping_size) + { + char const grp_size = grouping[group]; + last_grp_size = grp_size <= 0 ? CHAR_MAX : grp_size; + } + + left = last_grp_size; + --finish; + Traits::assign(*finish, thousands_sep); } - left = last_grp_size; + --left; + --finish; - Traits::assign(*finish, thousands_sep); - } - - --left; - - --finish; - int_type const digit = static_cast(n % 10U); - Traits::assign(*finish, Traits::to_char_type(zero + digit)); - n /= 10; - } while(n); - - } else + int_type const digit = static_cast(n % 10U); + Traits::assign(*finish, Traits::to_char_type(zero + digit)); + n /= 10; + } while(n); + return finish; + } + } #endif { do @@ -551,61 +558,63 @@ namespace boost #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE std::locale loc; - typedef std::numpunct numpunct; - numpunct const& np = BOOST_USE_FACET(numpunct, loc); - std::string const& grouping = np.grouping(); - std::string::size_type const grouping_size = grouping.size(); + if (loc != std::locale::classic()) { + typedef std::numpunct numpunct; + numpunct const& np = BOOST_USE_FACET(numpunct, loc); + std::string const& grouping = np.grouping(); + std::string::size_type const grouping_size = grouping.size(); - /* According to Programming languages - C++ - * we MUST check for correct grouping - */ - if (grouping_size && grouping[0] > 0) - { - unsigned char current_grouping = 0; - CharT const thousands_sep = np.thousands_sep(); - char remained = grouping[current_grouping] - 1; - bool shall_we_return = true; - - for(;end>=begin; --end) + /* According to Programming languages - C++ + * we MUST check for correct grouping + */ + if (grouping_size && grouping[0] > 0) { - if (remained) { - T const new_sub_value = multiplier * 10 * (*end - czero); + unsigned char current_grouping = 0; + CharT const thousands_sep = np.thousands_sep(); + char remained = grouping[current_grouping] - 1; + bool shall_we_return = true; - if (*end < czero || *end >= czero + 10 - /* detecting overflow */ - || new_sub_value/10 != multiplier * (*end - czero) - || static_cast((std::numeric_limits::max)()-new_sub_value) < value - ) - return false; + for(;end>=begin; --end) + { + if (remained) { + T const new_sub_value = multiplier * 10 * (*end - czero); - value += new_sub_value; - multiplier *= 10; - --remained; - } else { - if ( !Traits::eq(*end, thousands_sep) ) //|| begin == end ) return false; - { - /* - * According to Programming languages - C++ - * Digit grouping is checked. That is, the positions of discarded - * separators is examined for consistency with - * use_facet >(loc ).grouping() - * - * BUT what if there is no separators at all and grouping() - * is not empty? Well, we have no extraced separators, so we - * won`t check them for consistency. This will allow us to - * work with "C" locale from other locales - */ - shall_we_return = false; - break; + if (*end < czero || *end >= czero + 10 + /* detecting overflow */ + || new_sub_value/10 != multiplier * (*end - czero) + || static_cast((std::numeric_limits::max)()-new_sub_value) < value + ) + return false; + + value += new_sub_value; + multiplier *= 10; + --remained; } else { - if ( begin == end ) return false; - if (current_grouping < grouping_size-1 ) ++current_grouping; - remained = grouping[current_grouping]; + if ( !Traits::eq(*end, thousands_sep) ) //|| begin == end ) return false; + { + /* + * According to Programming languages - C++ + * Digit grouping is checked. That is, the positions of discarded + * separators is examined for consistency with + * use_facet >(loc ).grouping() + * + * BUT what if there is no separators at all and grouping() + * is not empty? Well, we have no extraced separators, so we + * won`t check them for consistency. This will allow us to + * work with "C" locale from other locales + */ + shall_we_return = false; + break; + } else { + if ( begin == end ) return false; + if (current_grouping < grouping_size-1 ) ++current_grouping; + remained = grouping[current_grouping]; + } } } - } - if (shall_we_return) return true; + if (shall_we_return) return true; + } } #endif { @@ -809,7 +818,11 @@ namespace boost std::locale loc; typedef std::numpunct numpunct; numpunct const& np = BOOST_USE_FACET(numpunct, loc); - std::string const& grouping = np.grouping(); + std::string const grouping( + (loc == std::locale::classic()) + ? std::string() + : np.grouping() + ); std::string::size_type const grouping_size = grouping.size(); CharT const thousands_sep = grouping_size ? np.thousands_sep() : 0; CharT const decimal_point = np.decimal_point(); diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 47381cd..6820612 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -756,6 +756,16 @@ void test_conversion_from_to_integral() test_conversion_from_integral_to_char(wzero); test_conversion_from_char_to_integral(wzero); #endif +#ifndef BOOST_NO_CHAR16_T + char16_t const u16zero = u'0'; + test_conversion_from_integral_to_char(u16zero); + test_conversion_from_char_to_integral(u16zero); +#endif +#ifndef BOOST_NO_CHAR32_T + char32_t const u32zero = u'0'; + test_conversion_from_integral_to_char(u32zero); + test_conversion_from_char_to_integral(u32zero); +#endif BOOST_CHECK(lexical_cast("-1") == static_cast(-1)); BOOST_CHECK(lexical_cast("-9") == static_cast(-9)); From 1eda87448e2e41fb931ec51a052e7ad7444052d5 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Tue, 8 Nov 2011 18:12:23 +0000 Subject: [PATCH 100/138] Fixes #6083 Merge from trunk [SVN r75411] --- include/boost/lexical_cast.hpp | 2 +- test/Jamfile.v2 | 1 + test/lexical_cast_empty_input_test.cpp | 58 ++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 test/lexical_cast_empty_input_test.cpp diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 94f8c70..0004461 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1147,7 +1147,7 @@ namespace boost bool const result = !(stream << input).fail(); start = stringbuffer.pbase(); finish = stringbuffer.pptr(); - return result; + return result && (start != finish); } template diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2dd3500..55aacc5 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -28,6 +28,7 @@ test-suite conversion [ run lexical_cast_wchars_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_float_types_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_inf_nan_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_empty_input_test.cpp ../../test/build//boost_unit_test_framework/static ] ; diff --git a/test/lexical_cast_empty_input_test.cpp b/test/lexical_cast_empty_input_test.cpp new file mode 100755 index 0000000..f655acd --- /dev/null +++ b/test/lexical_cast_empty_input_test.cpp @@ -0,0 +1,58 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2011. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include +#include + +using namespace boost; + +void test_empty_iterator_range() +{ + boost::iterator_range v; + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +} + +void test_empty_string() +{ + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_EQUAL(lexical_cast(std::string()), std::string()); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test_framework::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast. Empty input unit test"); + suite->add(BOOST_TEST_CASE(&test_empty_iterator_range)); + suite->add(BOOST_TEST_CASE(&test_empty_string)); + + return suite; +} From 0ff14c8595afadcaea864c7ee0a9cc7840fc58da Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 30 Nov 2011 01:35:25 +0000 Subject: [PATCH 101/138] Quickbook: Merge from trunk to quickbook-dev [SVN r75739] --- include/boost/lexical_cast.hpp | 2 +- test/Jamfile.v2 | 1 + test/lexical_cast_empty_input_test.cpp | 58 ++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 test/lexical_cast_empty_input_test.cpp diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 62f0f66..3d65297 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1181,7 +1181,7 @@ namespace boost bool const result = !(stream << input).fail(); start = stringbuffer.pbase(); finish = stringbuffer.pptr(); - return result; + return result && (start != finish); } template diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 7e5eacf..6eebe72 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -29,6 +29,7 @@ test-suite conversion [ run lexical_cast_float_types_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_inf_nan_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_containers_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_empty_input_test.cpp ../../test/build//boost_unit_test_framework/static ] ; diff --git a/test/lexical_cast_empty_input_test.cpp b/test/lexical_cast_empty_input_test.cpp new file mode 100755 index 0000000..42e7cec --- /dev/null +++ b/test/lexical_cast_empty_input_test.cpp @@ -0,0 +1,58 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2011. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include +#include + +using namespace boost; + +void test_empty_iterator_range() +{ + boost::iterator_range v; + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +} + +void test_empty_string() +{ + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_EQUAL(lexical_cast(std::string()), std::string()); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast. Empty input unit test"); + suite->add(BOOST_TEST_CASE(&test_empty_iterator_range)); + suite->add(BOOST_TEST_CASE(&test_empty_string)); + + return suite; +} From 82d366cfb413f2989eda1a84cd93bd00f7fd70d1 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 7 Dec 2011 09:40:30 +0000 Subject: [PATCH 102/138] Quickbook: Merge from trunk to quickbook-dev. [SVN r75846] --- include/boost/lexical_cast.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 3d65297..e7ab248 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -17,7 +17,8 @@ // enhanced with contributions from Terje Slettebo, // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, -// Alexander Nasonov, Antony Polukhin and other Boosters +// Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann +// and other Boosters // when: November 2000, March 2003, June 2005, June 2006, March 2011 #include @@ -47,8 +48,9 @@ #include #include #include -#include - +#ifndef BOOST_NO_CWCHAR +# include +#endif #ifndef BOOST_NO_STD_LOCALE # include @@ -682,8 +684,8 @@ namespace boost , const CharT opening_brace, const CharT closing_brace) { using namespace std; - const wchar_t minus = lcast_char_constants::minus; - const wchar_t plus = lcast_char_constants::plus; + const CharT minus = lcast_char_constants::minus; + const CharT plus = lcast_char_constants::plus; const int inifinity_size = 8; bool has_minus = false; From 7112ded1b967279a0e984602d68184ea29d2a5b2 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Mon, 19 Dec 2011 15:19:43 +0000 Subject: [PATCH 103/138] Merge from trunk r75937 * fixed a lot of wchar_t errors * Optimizations for boost::containers::basic_string * More tests [SVN r76062] --- doc/lexical_cast.qbk | 12 +++ include/boost/lexical_cast.hpp | 90 +++++++++++++++++-- lexical_cast_test.cpp | 2 +- test/Jamfile.v2 | 9 +- test/lexical_cast_abstract_test.cpp | 2 +- test/lexical_cast_containers_test.cpp | 38 ++++++++ test/lexical_cast_empty_input_test.cpp | 2 +- test/lexical_cast_float_types_test.cpp | 2 +- test/lexical_cast_inf_nan_test.cpp | 2 +- test/lexical_cast_loopback_test.cpp | 2 +- test/lexical_cast_noncopyable_test.cpp | 2 +- test/lexical_cast_typedefed_wchar_test.cpp | 25 ++++++ ...ical_cast_typedefed_wchar_test_runtime.cpp | 48 ++++++++++ test/lexical_cast_vc8_bug_test.cpp | 2 +- test/lexical_cast_wchars_test.cpp | 2 +- 15 files changed, 222 insertions(+), 18 deletions(-) create mode 100644 test/lexical_cast_containers_test.cpp create mode 100755 test/lexical_cast_typedefed_wchar_test.cpp create mode 100755 test/lexical_cast_typedefed_wchar_test_runtime.cpp diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index b540267..0532b56 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -159,9 +159,21 @@ Read a good C++ book, study `std::sentry` and [@boost:libs/io/doc/ios_state.html the rules of `scanf` for conversions. And in the C99 standard for unsigned input value minus sign is optional, so if a negative number is read, no errors will arise and the result will be the two's complement. +[pre +] + +* [*Question:] Why `boost::lexical_cast(L'A');` outputs 65 and `boost::lexical_cast(L"65");` does not throw? + * [*Answer:] If you are using an old version of Visual Studio or compile code with /Zc:wchar_t- flag, +`boost::lexical_cast` sees single `wchar_t` character as `unsigned short`. It is not a `boost::lexical_cast` mistake, but a +limitation of compiler options that you use. + [endsect] [section Changes] +* [*boost 1.49.0 :] + + * Added code to work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). + * [*boost 1.48.0 :] * Added code to work with Inf and NaN on any platform. diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 0004461..5fa6a96 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -17,7 +17,8 @@ // enhanced with contributions from Terje Slettebo, // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, -// Alexander Nasonov, Antony Polukhin and other Boosters +// Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann, +// Cheng Yang and other Boosters // when: November 2000, March 2003, June 2005, June 2006, March 2011 #include @@ -46,8 +47,10 @@ #include #include #include -#include - +#include +#ifndef BOOST_NO_CWCHAR +# include +#endif #ifndef BOOST_NO_STD_LOCALE # include @@ -145,6 +148,12 @@ namespace boost { typedef CharT type; }; + + template + struct stream_char< ::boost::container::basic_string > + { + typedef CharT type; + }; #endif #ifndef BOOST_LCAST_NO_WCHAR_T @@ -259,6 +268,24 @@ namespace boost typedef Traits type; }; + template + struct deduce_char_traits< CharT + , ::boost::container::basic_string + , Source + > + { + typedef Traits type; + }; + + template + struct deduce_char_traits< CharT + , Target + , ::boost::container::basic_string + > + { + typedef Traits type; + }; + template struct deduce_char_traits< CharT , std::basic_string @@ -267,6 +294,15 @@ namespace boost { typedef Traits type; }; + + template + struct deduce_char_traits< CharT + , ::boost::container::basic_string + , ::boost::container::basic_string + > + { + typedef Traits type; + }; #endif } @@ -648,8 +684,8 @@ namespace boost , const CharT opening_brace, const CharT closing_brace) { using namespace std; - const wchar_t minus = lcast_char_constants::minus; - const wchar_t plus = lcast_char_constants::plus; + const CharT minus = lcast_char_constants::minus; + const CharT plus = lcast_char_constants::plus; const int inifinity_size = 8; bool has_minus = false; @@ -1257,6 +1293,14 @@ namespace boost return true; } + template + bool operator<<(::boost::container::basic_string const& str) + { + start = const_cast(str.data()); + finish = start + str.length(); + return true; + } + bool operator<<(bool value) { CharT const czero = lcast_char_constants::zero; @@ -1310,6 +1354,7 @@ namespace boost /************************************ HELPER FUNCTIONS FOR OPERATORS >> ( ... ) ********************************/ private: + template bool shr_unsigned(Type& output) { @@ -1436,7 +1481,7 @@ namespace boost } /************************************ OPERATORS >> ( ... ) ********************************/ - public: + public: bool operator>>(unsigned short& output) { return shr_unsigned(output); } bool operator>>(unsigned int& output) { return shr_unsigned(output); } bool operator>>(unsigned long int& output) { return shr_unsigned(output); } @@ -1449,11 +1494,19 @@ namespace boost #elif defined(BOOST_HAS_MS_INT64) bool operator>>(unsigned __int64& output) { return shr_unsigned(output); } bool operator>>(__int64& output) { return shr_signed(output); } - #endif - bool operator>>(CharT& output) { return shr_xchar(output); } + bool operator>>(char& output) { return shr_xchar(output); } bool operator>>(unsigned char& output) { return shr_xchar(output); } bool operator>>(signed char& output) { return shr_xchar(output); } +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + bool operator>>(wchar_t& output) { return shr_xchar(output); } +#endif +#ifndef BOOST_NO_CHAR16_T + bool operator>>(char16_t& output) { return shr_xchar(output); } +#endif +#ifndef BOOST_NO_CHAR32_T + bool operator>>(char32_t& output) { return shr_xchar(output); } +#endif #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION bool operator>>(std::string& str) { str.assign(start, finish); return true; } # ifndef BOOST_LCAST_NO_WCHAR_T @@ -1462,6 +1515,9 @@ namespace boost #else template bool operator>>(std::basic_string& str) { str.assign(start, finish); return true; } + + template + bool operator>>(::boost::container::basic_string& str) { str.assign(start, finish); return true; } #endif /* * case "-0" || "0" || "+0" : output = false; return true; @@ -1598,6 +1654,12 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = true ); }; + template + struct is_stdstring< ::boost::container::basic_string > + { + BOOST_STATIC_CONSTANT(bool, value = true ); + }; + template struct is_char_or_wchar { @@ -1698,6 +1760,18 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = true ); }; + template + struct is_char_array_to_stdstring< ::boost::container::basic_string, CharT* > + { + BOOST_STATIC_CONSTANT(bool, value = true ); + }; + + template + struct is_char_array_to_stdstring< ::boost::container::basic_string, const CharT* > + { + BOOST_STATIC_CONSTANT(bool, value = true ); + }; + #if (defined _MSC_VER) # pragma warning( push ) # pragma warning( disable : 4701 ) // possible use of ... before initialization diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 6820612..faeaa93 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -110,7 +110,7 @@ void test_char32_conversions(); unit_test::test_suite *init_unit_test_suite(int, char *[]) { - unit_test_framework::test_suite *suite = + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast unit test"); suite->add(BOOST_TEST_CASE(test_conversion_to_char)); suite->add(BOOST_TEST_CASE(test_conversion_to_int)); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 55aacc5..8718301 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -14,7 +14,12 @@ # bring in rules for testing import testing ; +import feature ; +feature.feature nowchar : on : + composite optional propagated link-incompatible ; +feature.compose on : /Zc:wchar_t- ; + test-suite conversion : [ run implicit_cast.cpp ] [ compile-fail implicit_cast_fail.cpp ] @@ -28,7 +33,9 @@ test-suite conversion [ run lexical_cast_wchars_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_float_types_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_inf_nan_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_containers_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_empty_input_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ compile lexical_cast_typedefed_wchar_test.cpp : msvc:on ] + [ run lexical_cast_typedefed_wchar_test_runtime.cpp ../../test/build//boost_unit_test_framework/static : : : msvc:on ] ; - diff --git a/test/lexical_cast_abstract_test.cpp b/test/lexical_cast_abstract_test.cpp index 4b92e49..70cdeca 100644 --- a/test/lexical_cast_abstract_test.cpp +++ b/test/lexical_cast_abstract_test.cpp @@ -28,7 +28,7 @@ void test_abstract(); unit_test::test_suite *init_unit_test_suite(int, char *[]) { - unit_test_framework::test_suite *suite = + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast unit test"); suite->add(BOOST_TEST_CASE(&test_abstract)); diff --git a/test/lexical_cast_containers_test.cpp b/test/lexical_cast_containers_test.cpp new file mode 100644 index 0000000..5f98ac8 --- /dev/null +++ b/test/lexical_cast_containers_test.cpp @@ -0,0 +1,38 @@ +// Testing boost::lexical_cast with boost::container::string. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2011. +// +// 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). + +#include +#include +#include + +void testing_boost_containers_basic_string(); + +using namespace boost; + +boost::unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = + BOOST_TEST_SUITE("Testing boost::lexical_cast with boost::container::string"); + suite->add(BOOST_TEST_CASE(testing_boost_containers_basic_string)); + + return suite; +} + +void testing_boost_containers_basic_string() +{ + BOOST_CHECK("100" == lexical_cast("100")); + BOOST_CHECK(L"100" == lexical_cast(L"100")); + + BOOST_CHECK("100" == lexical_cast(100)); + boost::container::string str("1000"); + BOOST_CHECK(1000 == lexical_cast(str)); +} + + diff --git a/test/lexical_cast_empty_input_test.cpp b/test/lexical_cast_empty_input_test.cpp index f655acd..42e7cec 100755 --- a/test/lexical_cast_empty_input_test.cpp +++ b/test/lexical_cast_empty_input_test.cpp @@ -49,7 +49,7 @@ void test_empty_string() unit_test::test_suite *init_unit_test_suite(int, char *[]) { - unit_test_framework::test_suite *suite = + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast. Empty input unit test"); suite->add(BOOST_TEST_CASE(&test_empty_iterator_range)); suite->add(BOOST_TEST_CASE(&test_empty_string)); diff --git a/test/lexical_cast_float_types_test.cpp b/test/lexical_cast_float_types_test.cpp index 72279bb..808f456 100755 --- a/test/lexical_cast_float_types_test.cpp +++ b/test/lexical_cast_float_types_test.cpp @@ -31,7 +31,7 @@ using namespace boost; unit_test::test_suite *init_unit_test_suite(int, char *[]) { - unit_test_framework::test_suite *suite = + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast float types unit test"); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_float)); suite->add(BOOST_TEST_CASE(&test_conversion_from_to_double)); diff --git a/test/lexical_cast_inf_nan_test.cpp b/test/lexical_cast_inf_nan_test.cpp index 4617d5e..bb4331a 100755 --- a/test/lexical_cast_inf_nan_test.cpp +++ b/test/lexical_cast_inf_nan_test.cpp @@ -170,7 +170,7 @@ void test_inf_nan_long_double() unit_test::test_suite *init_unit_test_suite(int, char *[]) { - unit_test_framework::test_suite *suite = + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast inf anf nan parsing unit test"); suite->add(BOOST_TEST_CASE(&test_inf_nan_float)); suite->add(BOOST_TEST_CASE(&test_inf_nan_double)); diff --git a/test/lexical_cast_loopback_test.cpp b/test/lexical_cast_loopback_test.cpp index 5787996..25b18ec 100644 --- a/test/lexical_cast_loopback_test.cpp +++ b/test/lexical_cast_loopback_test.cpp @@ -30,7 +30,7 @@ void test_round_conversion_long_double(); unit_test::test_suite *init_unit_test_suite(int, char *[]) { - unit_test_framework::test_suite *suite = + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast unit test"); suite->add(BOOST_TEST_CASE(&test_round_conversion_float)); suite->add(BOOST_TEST_CASE(&test_round_conversion_double)); diff --git a/test/lexical_cast_noncopyable_test.cpp b/test/lexical_cast_noncopyable_test.cpp index 6284b14..1f120d9 100644 --- a/test/lexical_cast_noncopyable_test.cpp +++ b/test/lexical_cast_noncopyable_test.cpp @@ -28,7 +28,7 @@ void test_noncopyable(); unit_test::test_suite *init_unit_test_suite(int, char *[]) { - unit_test_framework::test_suite *suite = + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast unit test"); suite->add(BOOST_TEST_CASE(&test_noncopyable)); diff --git a/test/lexical_cast_typedefed_wchar_test.cpp b/test/lexical_cast_typedefed_wchar_test.cpp new file mode 100755 index 0000000..752c3e5 --- /dev/null +++ b/test/lexical_cast_typedefed_wchar_test.cpp @@ -0,0 +1,25 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2011. +// +// 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). + +#include + +#include +#include + +int main() +{ +#ifdef BOOST_MSVC + BOOST_STATIC_ASSERT((boost::is_same::value)); +#endif + + return ::boost::lexical_cast(L"1000") == 1000; +} + + diff --git a/test/lexical_cast_typedefed_wchar_test_runtime.cpp b/test/lexical_cast_typedefed_wchar_test_runtime.cpp new file mode 100755 index 0000000..d01700a --- /dev/null +++ b/test/lexical_cast_typedefed_wchar_test_runtime.cpp @@ -0,0 +1,48 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2011. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include + +#include +using namespace boost; + +void test_typedefed_wchar_t_runtime() +{ +#ifndef BOOST_LCAST_NO_WCHAR_T +#ifdef BOOST_MSVC + BOOST_STATIC_ASSERT((boost::is_same::value)); + + + BOOST_CHECK_EQUAL(boost::lexical_cast(L'A'), 65); + BOOST_CHECK_EQUAL(boost::lexical_cast(L'B'), 66); + + BOOST_CHECK_EQUAL(boost::lexical_cast(L"65"), 65); + BOOST_CHECK_EQUAL(boost::lexical_cast(L"66"), 66); +#endif +#endif + BOOST_CHECK(1); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast typedefed wchar_t runtime test"); + suite->add(BOOST_TEST_CASE(&test_typedefed_wchar_t_runtime)); + + return suite; +} diff --git a/test/lexical_cast_vc8_bug_test.cpp b/test/lexical_cast_vc8_bug_test.cpp index 151e4f8..9e5ef0b 100644 --- a/test/lexical_cast_vc8_bug_test.cpp +++ b/test/lexical_cast_vc8_bug_test.cpp @@ -60,7 +60,7 @@ void test_vc8_bug() unit_test::test_suite *init_unit_test_suite(int, char *[]) { - unit_test_framework::test_suite *suite = + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast vc8 bug unit test"); suite->add(BOOST_TEST_CASE(test_vc8_bug)); return suite; diff --git a/test/lexical_cast_wchars_test.cpp b/test/lexical_cast_wchars_test.cpp index 14ac461..acd78b1 100755 --- a/test/lexical_cast_wchars_test.cpp +++ b/test/lexical_cast_wchars_test.cpp @@ -48,7 +48,7 @@ void test_char_types_conversions() unit_test::test_suite *init_unit_test_suite(int, char *[]) { - unit_test_framework::test_suite *suite = + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast char<->wchar_t unit test"); suite->add(BOOST_TEST_CASE(&test_char_types_conversions)); From 82abf7b54faa09276be5fbb0307ca6a65a1c8ec4 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Fri, 30 Dec 2011 15:18:00 +0000 Subject: [PATCH 104/138] Merge from trunk r76232 [SVN r76233] --- doc/lexical_cast.qbk | 2 +- include/boost/lexical_cast.hpp | 31 ++++++- test/lexical_cast_empty_input_test.cpp | 115 ++++++++++++++++++++++--- 3 files changed, 132 insertions(+), 16 deletions(-) diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index 0532b56..bf6b562 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -172,7 +172,7 @@ limitation of compiler options that you use. [section Changes] * [*boost 1.49.0 :] - * Added code to work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). + * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). * [*boost 1.48.0 :] diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 5fa6a96..b9bc984 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -18,7 +18,7 @@ // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, // Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann, -// Cheng Yang and other Boosters +// Cheng Yang, Matthew Bradbury and other Boosters // when: November 2000, March 2003, June 2005, June 2006, March 2011 #include @@ -586,7 +586,7 @@ namespace boost --end; value = 0; - if ( *end < czero || *end >= czero + 10 || begin > end) + if (begin > end || *end < czero || *end >= czero + 10) return false; value = *end - czero; --end; @@ -684,6 +684,7 @@ namespace boost , const CharT opening_brace, const CharT closing_brace) { using namespace std; + if (begin == end) return false; const CharT minus = lcast_char_constants::minus; const CharT plus = lcast_char_constants::plus; const int inifinity_size = 8; @@ -743,6 +744,26 @@ namespace boost , L'(', L')'); } #endif +#ifndef BOOST_NO_CHAR16_T + template + bool parse_inf_nan(const char16_t* begin, const char16_t* end, T& value) + { + return parse_inf_nan_impl(begin, end, value + , u"NAN", u"nan" + , u"INFINITY", u"infinity" + , u'(', u')'); + } +#endif +#ifndef BOOST_NO_CHAR32_T + template + bool parse_inf_nan(const char32_t* begin, const char32_t* end, T& value) + { + return parse_inf_nan_impl(begin, end, value + , U"NAN", U"nan" + , U"INFINITY", U"infinity" + , U'(', U')'); + } +#endif template bool parse_inf_nan(const CharT* begin, const CharT* end, T& value) @@ -863,7 +884,7 @@ namespace boost CharT const thousands_sep = grouping_size ? np.thousands_sep() : 0; CharT const decimal_point = np.decimal_point(); bool found_grouping = false; - unsigned int last_grouping_pos = grouping_size - 1; + std::string::size_type last_grouping_pos = grouping_size - 1; #else CharT const decimal_point = lcast_char_constants::c_decimal_separator; #endif @@ -1183,7 +1204,7 @@ namespace boost bool const result = !(stream << input).fail(); start = stringbuffer.pbase(); finish = stringbuffer.pptr(); - return result && (start != finish); + return result; } template @@ -1358,6 +1379,7 @@ namespace boost template bool shr_unsigned(Type& output) { + if (start == finish) return false; CharT const minus = lcast_char_constants::minus; CharT const plus = lcast_char_constants::plus; bool has_minus = false; @@ -1392,6 +1414,7 @@ namespace boost template bool shr_signed(Type& output) { + if (start == finish) return false; CharT const minus = lcast_char_constants::minus; CharT const plus = lcast_char_constants::plus; typedef BOOST_DEDUCED_TYPENAME make_unsigned::type utype; diff --git a/test/lexical_cast_empty_input_test.cpp b/test/lexical_cast_empty_input_test.cpp index 42e7cec..5a5881b 100755 --- a/test/lexical_cast_empty_input_test.cpp +++ b/test/lexical_cast_empty_input_test.cpp @@ -22,29 +22,120 @@ using namespace boost; -void test_empty_iterator_range() +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) +#define BOOST_LCAST_NO_WCHAR_T +#endif + +template +void do_test_on_empty_input(T& v) { - boost::iterator_range v; BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +#if defined(BOOST_HAS_LONG_LONG) + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +#elif defined(BOOST_HAS_MS_INT64) + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast<__int64>(v), bad_lexical_cast); +#endif +} + +void test_empty_iterator_range() +{ + + boost::iterator_range v; + do_test_on_empty_input(v); + BOOST_CHECK_EQUAL(lexical_cast(v), std::string()); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + + boost::iterator_range cv; + do_test_on_empty_input(cv); + BOOST_CHECK_EQUAL(lexical_cast(cv), std::string()); + BOOST_CHECK_THROW(lexical_cast(cv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(cv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(cv), bad_lexical_cast); + + const boost::iterator_range ccv; + do_test_on_empty_input(ccv); + BOOST_CHECK_EQUAL(lexical_cast(ccv), std::string()); + BOOST_CHECK_THROW(lexical_cast(ccv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(ccv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(ccv), bad_lexical_cast); } void test_empty_string() { - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_EQUAL(lexical_cast(std::string()), std::string()); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + std::string v; + do_test_on_empty_input(v); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + +#ifndef BOOST_LCAST_NO_WCHAR_T + std::wstring vw; + do_test_on_empty_input(vw); + BOOST_CHECK_THROW(lexical_cast(vw), bad_lexical_cast); +#endif + +// Currently, no compiler and STL library fully support char16_t and char32_t +//#ifndef BOOST_NO_CHAR16_T +// std::basic_string v16w; +// do_test_on_empty_input(v16w); +// BOOST_CHECK_THROW(lexical_cast(v16w), bad_lexical_cast); +//#endif +//#ifndef BOOST_NO_CHAR32_T +// std::basic_string v32w; +// do_test_on_empty_input(v32w); +// BOOST_CHECK_THROW(lexical_cast(v32w), bad_lexical_cast); +//#endif +} + +struct Escape +{ + Escape(const std::string& s) + : str_(s) + {} + + std::string str_; +}; + +inline std::ostream& operator<< (std::ostream& o, const Escape& rhs) +{ + return o << rhs.str_; +} + +void test_empty_user_class() +{ + Escape v(""); + do_test_on_empty_input(v); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +} + +namespace std { +inline std::ostream & operator<<(std::ostream & out, const std::vector & v) +{ + std::ostream_iterator it(out); + std::copy(v.begin(), v.end(), it); + assert(out); + return out; +} +} + +void test_empty_vector() +{ + std::vector v; + do_test_on_empty_input(v); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); } unit_test::test_suite *init_unit_test_suite(int, char *[]) @@ -53,6 +144,8 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) BOOST_TEST_SUITE("lexical_cast. Empty input unit test"); suite->add(BOOST_TEST_CASE(&test_empty_iterator_range)); suite->add(BOOST_TEST_CASE(&test_empty_string)); + suite->add(BOOST_TEST_CASE(&test_empty_user_class)); + suite->add(BOOST_TEST_CASE(&test_empty_vector)); return suite; } From 5638b5dbec31eeed2121b7f3264b9464c058eb00 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 1 Jan 2012 13:35:27 +0000 Subject: [PATCH 105/138] Quickbook: Merge from trunk to quickbook-dev. [SVN r76255] --- doc/lexical_cast.qbk | 12 ++ include/boost/lexical_cast.hpp | 48 ++++++-- test/Jamfile.v2 | 8 +- test/lexical_cast_empty_input_test.cpp | 115 ++++++++++++++++-- test/lexical_cast_typedefed_wchar_test.cpp | 25 ++++ ...ical_cast_typedefed_wchar_test_runtime.cpp | 48 ++++++++ 6 files changed, 236 insertions(+), 20 deletions(-) create mode 100755 test/lexical_cast_typedefed_wchar_test.cpp create mode 100755 test/lexical_cast_typedefed_wchar_test_runtime.cpp diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index b540267..bf6b562 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -159,9 +159,21 @@ Read a good C++ book, study `std::sentry` and [@boost:libs/io/doc/ios_state.html the rules of `scanf` for conversions. And in the C99 standard for unsigned input value minus sign is optional, so if a negative number is read, no errors will arise and the result will be the two's complement. +[pre +] + +* [*Question:] Why `boost::lexical_cast(L'A');` outputs 65 and `boost::lexical_cast(L"65");` does not throw? + * [*Answer:] If you are using an old version of Visual Studio or compile code with /Zc:wchar_t- flag, +`boost::lexical_cast` sees single `wchar_t` character as `unsigned short`. It is not a `boost::lexical_cast` mistake, but a +limitation of compiler options that you use. + [endsect] [section Changes] +* [*boost 1.49.0 :] + + * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). + * [*boost 1.48.0 :] * Added code to work with Inf and NaN on any platform. diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index e7ab248..b9bc984 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -17,8 +17,8 @@ // enhanced with contributions from Terje Slettebo, // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, -// Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann -// and other Boosters +// Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann, +// Cheng Yang, Matthew Bradbury and other Boosters // when: November 2000, March 2003, June 2005, June 2006, March 2011 #include @@ -586,7 +586,7 @@ namespace boost --end; value = 0; - if ( *end < czero || *end >= czero + 10 || begin > end) + if (begin > end || *end < czero || *end >= czero + 10) return false; value = *end - czero; --end; @@ -684,6 +684,7 @@ namespace boost , const CharT opening_brace, const CharT closing_brace) { using namespace std; + if (begin == end) return false; const CharT minus = lcast_char_constants::minus; const CharT plus = lcast_char_constants::plus; const int inifinity_size = 8; @@ -743,6 +744,26 @@ namespace boost , L'(', L')'); } #endif +#ifndef BOOST_NO_CHAR16_T + template + bool parse_inf_nan(const char16_t* begin, const char16_t* end, T& value) + { + return parse_inf_nan_impl(begin, end, value + , u"NAN", u"nan" + , u"INFINITY", u"infinity" + , u'(', u')'); + } +#endif +#ifndef BOOST_NO_CHAR32_T + template + bool parse_inf_nan(const char32_t* begin, const char32_t* end, T& value) + { + return parse_inf_nan_impl(begin, end, value + , U"NAN", U"nan" + , U"INFINITY", U"infinity" + , U'(', U')'); + } +#endif template bool parse_inf_nan(const CharT* begin, const CharT* end, T& value) @@ -863,7 +884,7 @@ namespace boost CharT const thousands_sep = grouping_size ? np.thousands_sep() : 0; CharT const decimal_point = np.decimal_point(); bool found_grouping = false; - unsigned int last_grouping_pos = grouping_size - 1; + std::string::size_type last_grouping_pos = grouping_size - 1; #else CharT const decimal_point = lcast_char_constants::c_decimal_separator; #endif @@ -1183,7 +1204,7 @@ namespace boost bool const result = !(stream << input).fail(); start = stringbuffer.pbase(); finish = stringbuffer.pptr(); - return result && (start != finish); + return result; } template @@ -1354,9 +1375,11 @@ namespace boost /************************************ HELPER FUNCTIONS FOR OPERATORS >> ( ... ) ********************************/ private: + template bool shr_unsigned(Type& output) { + if (start == finish) return false; CharT const minus = lcast_char_constants::minus; CharT const plus = lcast_char_constants::plus; bool has_minus = false; @@ -1391,6 +1414,7 @@ namespace boost template bool shr_signed(Type& output) { + if (start == finish) return false; CharT const minus = lcast_char_constants::minus; CharT const plus = lcast_char_constants::plus; typedef BOOST_DEDUCED_TYPENAME make_unsigned::type utype; @@ -1480,7 +1504,7 @@ namespace boost } /************************************ OPERATORS >> ( ... ) ********************************/ - public: + public: bool operator>>(unsigned short& output) { return shr_unsigned(output); } bool operator>>(unsigned int& output) { return shr_unsigned(output); } bool operator>>(unsigned long int& output) { return shr_unsigned(output); } @@ -1493,11 +1517,19 @@ namespace boost #elif defined(BOOST_HAS_MS_INT64) bool operator>>(unsigned __int64& output) { return shr_unsigned(output); } bool operator>>(__int64& output) { return shr_signed(output); } - #endif - bool operator>>(CharT& output) { return shr_xchar(output); } + bool operator>>(char& output) { return shr_xchar(output); } bool operator>>(unsigned char& output) { return shr_xchar(output); } bool operator>>(signed char& output) { return shr_xchar(output); } +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) + bool operator>>(wchar_t& output) { return shr_xchar(output); } +#endif +#ifndef BOOST_NO_CHAR16_T + bool operator>>(char16_t& output) { return shr_xchar(output); } +#endif +#ifndef BOOST_NO_CHAR32_T + bool operator>>(char32_t& output) { return shr_xchar(output); } +#endif #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION bool operator>>(std::string& str) { str.assign(start, finish); return true; } # ifndef BOOST_LCAST_NO_WCHAR_T diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6eebe72..8718301 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -14,7 +14,12 @@ # bring in rules for testing import testing ; +import feature ; +feature.feature nowchar : on : + composite optional propagated link-incompatible ; +feature.compose on : /Zc:wchar_t- ; + test-suite conversion : [ run implicit_cast.cpp ] [ compile-fail implicit_cast_fail.cpp ] @@ -30,6 +35,7 @@ test-suite conversion [ run lexical_cast_inf_nan_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_containers_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_empty_input_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ compile lexical_cast_typedefed_wchar_test.cpp : msvc:on ] + [ run lexical_cast_typedefed_wchar_test_runtime.cpp ../../test/build//boost_unit_test_framework/static : : : msvc:on ] ; - diff --git a/test/lexical_cast_empty_input_test.cpp b/test/lexical_cast_empty_input_test.cpp index 42e7cec..5a5881b 100755 --- a/test/lexical_cast_empty_input_test.cpp +++ b/test/lexical_cast_empty_input_test.cpp @@ -22,29 +22,120 @@ using namespace boost; -void test_empty_iterator_range() +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) +#define BOOST_LCAST_NO_WCHAR_T +#endif + +template +void do_test_on_empty_input(T& v) { - boost::iterator_range v; BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +#if defined(BOOST_HAS_LONG_LONG) + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +#elif defined(BOOST_HAS_MS_INT64) + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast<__int64>(v), bad_lexical_cast); +#endif +} + +void test_empty_iterator_range() +{ + + boost::iterator_range v; + do_test_on_empty_input(v); + BOOST_CHECK_EQUAL(lexical_cast(v), std::string()); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + + boost::iterator_range cv; + do_test_on_empty_input(cv); + BOOST_CHECK_EQUAL(lexical_cast(cv), std::string()); + BOOST_CHECK_THROW(lexical_cast(cv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(cv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(cv), bad_lexical_cast); + + const boost::iterator_range ccv; + do_test_on_empty_input(ccv); + BOOST_CHECK_EQUAL(lexical_cast(ccv), std::string()); + BOOST_CHECK_THROW(lexical_cast(ccv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(ccv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(ccv), bad_lexical_cast); } void test_empty_string() { - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_EQUAL(lexical_cast(std::string()), std::string()); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(std::string()), bad_lexical_cast); + std::string v; + do_test_on_empty_input(v); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + +#ifndef BOOST_LCAST_NO_WCHAR_T + std::wstring vw; + do_test_on_empty_input(vw); + BOOST_CHECK_THROW(lexical_cast(vw), bad_lexical_cast); +#endif + +// Currently, no compiler and STL library fully support char16_t and char32_t +//#ifndef BOOST_NO_CHAR16_T +// std::basic_string v16w; +// do_test_on_empty_input(v16w); +// BOOST_CHECK_THROW(lexical_cast(v16w), bad_lexical_cast); +//#endif +//#ifndef BOOST_NO_CHAR32_T +// std::basic_string v32w; +// do_test_on_empty_input(v32w); +// BOOST_CHECK_THROW(lexical_cast(v32w), bad_lexical_cast); +//#endif +} + +struct Escape +{ + Escape(const std::string& s) + : str_(s) + {} + + std::string str_; +}; + +inline std::ostream& operator<< (std::ostream& o, const Escape& rhs) +{ + return o << rhs.str_; +} + +void test_empty_user_class() +{ + Escape v(""); + do_test_on_empty_input(v); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +} + +namespace std { +inline std::ostream & operator<<(std::ostream & out, const std::vector & v) +{ + std::ostream_iterator it(out); + std::copy(v.begin(), v.end(), it); + assert(out); + return out; +} +} + +void test_empty_vector() +{ + std::vector v; + do_test_on_empty_input(v); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); } unit_test::test_suite *init_unit_test_suite(int, char *[]) @@ -53,6 +144,8 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) BOOST_TEST_SUITE("lexical_cast. Empty input unit test"); suite->add(BOOST_TEST_CASE(&test_empty_iterator_range)); suite->add(BOOST_TEST_CASE(&test_empty_string)); + suite->add(BOOST_TEST_CASE(&test_empty_user_class)); + suite->add(BOOST_TEST_CASE(&test_empty_vector)); return suite; } diff --git a/test/lexical_cast_typedefed_wchar_test.cpp b/test/lexical_cast_typedefed_wchar_test.cpp new file mode 100755 index 0000000..752c3e5 --- /dev/null +++ b/test/lexical_cast_typedefed_wchar_test.cpp @@ -0,0 +1,25 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2011. +// +// 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). + +#include + +#include +#include + +int main() +{ +#ifdef BOOST_MSVC + BOOST_STATIC_ASSERT((boost::is_same::value)); +#endif + + return ::boost::lexical_cast(L"1000") == 1000; +} + + diff --git a/test/lexical_cast_typedefed_wchar_test_runtime.cpp b/test/lexical_cast_typedefed_wchar_test_runtime.cpp new file mode 100755 index 0000000..d01700a --- /dev/null +++ b/test/lexical_cast_typedefed_wchar_test_runtime.cpp @@ -0,0 +1,48 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2011. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include + +#include +using namespace boost; + +void test_typedefed_wchar_t_runtime() +{ +#ifndef BOOST_LCAST_NO_WCHAR_T +#ifdef BOOST_MSVC + BOOST_STATIC_ASSERT((boost::is_same::value)); + + + BOOST_CHECK_EQUAL(boost::lexical_cast(L'A'), 65); + BOOST_CHECK_EQUAL(boost::lexical_cast(L'B'), 66); + + BOOST_CHECK_EQUAL(boost::lexical_cast(L"65"), 65); + BOOST_CHECK_EQUAL(boost::lexical_cast(L"66"), 66); +#endif +#endif + BOOST_CHECK(1); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast typedefed wchar_t runtime test"); + suite->add(BOOST_TEST_CASE(&test_typedefed_wchar_t_runtime)); + + return suite; +} From a2e4606e6cd3b0909c28894a62db6ae4631fde09 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sun, 8 Jan 2012 09:05:35 +0000 Subject: [PATCH 106/138] Merge from trunk r76354 (Fixes overflow detection, pointers casts) [SVN r76355] --- include/boost/lexical_cast.hpp | 48 +++++++++++---- lexical_cast_test.cpp | 11 ++++ test/Jamfile.v2 | 1 + test/lexical_cast_pointers_test.cpp | 96 +++++++++++++++++++++++++++++ 4 files changed, 145 insertions(+), 11 deletions(-) create mode 100755 test/lexical_cast_pointers_test.cpp diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index b9bc984..0927e39 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -18,8 +18,8 @@ // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, // Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann, -// Cheng Yang, Matthew Bradbury and other Boosters -// when: November 2000, March 2003, June 2005, June 2006, March 2011 +// Cheng Yang, Matthew Bradbury, David W. Birdsall and other Boosters +// when: November 2000, March 2003, June 2005, June 2006, March 2011 - 2012 #include #include @@ -591,6 +591,7 @@ namespace boost value = *end - czero; --end; T multiplier = 1; + bool multiplier_overflowed = false; #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE std::locale loc; @@ -613,12 +614,17 @@ namespace boost for(;end>=begin; --end) { if (remained) { - T const new_sub_value = multiplier * 10 * (*end - czero); + T const multiplier_10 = multiplier * 10; + if (multiplier_10 / 10 != multiplier) multiplier_overflowed = true; + + T const dig_value = *end - czero; + T const new_sub_value = multiplier_10 * dig_value; if (*end < czero || *end >= czero + 10 /* detecting overflow */ - || new_sub_value/10 != multiplier * (*end - czero) + || (dig_value && new_sub_value / dig_value != multiplier_10) || static_cast((std::numeric_limits::max)()-new_sub_value) < value + || (multiplier_overflowed && dig_value) ) return false; @@ -656,12 +662,17 @@ namespace boost { while ( begin <= end ) { - T const new_sub_value = multiplier * 10 * (*end - czero); + T const multiplier_10 = multiplier * 10; + if (multiplier_10 / 10 != multiplier) multiplier_overflowed = true; + + T const dig_value = *end - czero; + T const new_sub_value = multiplier_10 * dig_value; if (*end < czero || *end >= czero + 10 /* detecting overflow */ - || new_sub_value/10 != multiplier * (*end - czero) + || (dig_value && new_sub_value / dig_value != multiplier_10) || static_cast((std::numeric_limits::max)()-new_sub_value) < value + || (multiplier_overflowed && dig_value) ) return false; @@ -1822,6 +1833,24 @@ namespace boost deduce_char_traits::type traits; typedef BOOST_DEDUCED_TYPENAME remove_pointer::type removed_ptr_t; + + // is_char_types_match variable value can be computed via + // sizeof(char_type) == sizeof(removed_ptr_t). But when + // removed_ptr_t is an incomplete type or void*, compilers + // produce warnings or errors. + const bool is_char_types_match = + (::boost::type_traits::ice_or< + ::boost::type_traits::ice_and< + ::boost::type_traits::ice_eq::value, + ::boost::type_traits::ice_or< + ::boost::is_same::value, + ::boost::is_same::value, + ::boost::is_same::value + >::value + >::value, + is_same::value + >::value); + const bool requires_stringbuf = !( ::boost::type_traits::ice_or< @@ -1830,10 +1859,7 @@ namespace boost ::boost::type_traits::ice_and< is_pointer::value, is_char_or_wchar::value, - ::boost::type_traits::ice_eq< - sizeof(char_type), - sizeof(removed_ptr_t) - >::value + is_char_types_match >::value >::value ); @@ -2111,7 +2137,7 @@ namespace boost // Copyright Kevlin Henney, 2000-2005. // Copyright Alexander Nasonov, 2006-2010. -// Copyright Antony Polukhin, 2011. +// Copyright Antony Polukhin, 2011-2012. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index faeaa93..4e9ec90 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -796,6 +796,17 @@ void test_conversion_from_to_integral() BOOST_CHECK_THROW(lexical_cast("+-9"), bad_lexical_cast); // test_conversion_from_to_integral_for_locale + // Overflow test case from David W. Birdsall + std::string must_owerflow_str = "160000000000000000000"; + std::string must_owerflow_negative_str = "-160000000000000000000"; + for (int i = 0; i < 15; ++i) { + BOOST_CHECK_THROW(lexical_cast(must_owerflow_str), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(must_owerflow_negative_str), bad_lexical_cast); + + must_owerflow_str += '0'; + must_owerflow_negative_str += '0'; + } + typedef std::numpunct numpunct; restore_oldloc guard; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8718301..c311420 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -35,6 +35,7 @@ test-suite conversion [ run lexical_cast_inf_nan_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_containers_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_empty_input_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_pointers_test.cpp ../../test/build//boost_unit_test_framework/static ] [ compile lexical_cast_typedefed_wchar_test.cpp : msvc:on ] [ run lexical_cast_typedefed_wchar_test_runtime.cpp ../../test/build//boost_unit_test_framework/static : : : msvc:on ] ; diff --git a/test/lexical_cast_pointers_test.cpp b/test/lexical_cast_pointers_test.cpp new file mode 100755 index 0000000..d24a895 --- /dev/null +++ b/test/lexical_cast_pointers_test.cpp @@ -0,0 +1,96 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2012. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include + +using namespace boost; + +#if defined(BOOST_NO_STRINGSTREAM) + typedef std::strstream ss_t; +#else + typedef std::stringstream ss_t; +#endif + +void test_void_pointers_conversions() +{ + void *p_to_null = NULL; + const void *cp_to_data = "Some data"; + char nonconst_data[5]; + void *p_to_data = nonconst_data; + ss_t ss; + + ss << p_to_null; + BOOST_CHECK_EQUAL(boost::lexical_cast(p_to_null), ss.str()); + ss.str(std::string()); + + ss << cp_to_data; + BOOST_CHECK_EQUAL(boost::lexical_cast(cp_to_data), ss.str()); + ss.str(std::string()); + + ss << p_to_data; + BOOST_CHECK_EQUAL(boost::lexical_cast(p_to_data), ss.str()); + ss.str(std::string()); +} + +struct incomplete_type; + +void test_incomplete_type_pointers_conversions() +{ + incomplete_type *p_to_null = NULL; + const incomplete_type *cp_to_data = NULL; + char nonconst_data[5]; + incomplete_type *p_to_data = reinterpret_cast(nonconst_data); + ss_t ss; + + ss << p_to_null; + BOOST_CHECK_EQUAL(boost::lexical_cast(p_to_null), ss.str()); + ss.str(std::string()); + + ss << cp_to_data; + BOOST_CHECK_EQUAL(boost::lexical_cast(cp_to_data), ss.str()); + ss.str(std::string()); + + ss << p_to_data; + BOOST_CHECK_EQUAL(boost::lexical_cast(p_to_data), ss.str()); + ss.str(std::string()); +} + +struct ble; +typedef struct ble *meh; +std::ostream& operator <<(std::ostream &o, meh) { + o << "yay"; + return o; +} + +void test_inomplete_type_with_overloaded_ostream_op() { + meh heh = NULL; + ss_t ss; + ss << heh; + BOOST_CHECK_EQUAL(boost::lexical_cast(heh), ss.str()); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast pinters test"); + suite->add(BOOST_TEST_CASE(&test_void_pointers_conversions)); + suite->add(BOOST_TEST_CASE(&test_incomplete_type_pointers_conversions)); + suite->add(BOOST_TEST_CASE(&test_inomplete_type_with_overloaded_ostream_op)); + return suite; +} From 51a6aacb57cb8ae1b3c3d99a6f6c3af992d7558a Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sun, 8 Jan 2012 09:25:04 +0000 Subject: [PATCH 107/138] Merge from trunk r76357 (tiny documentation update) [SVN r76358] --- doc/lexical_cast.qbk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index bf6b562..4715803 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -172,7 +172,8 @@ limitation of compiler options that you use. [section Changes] * [*boost 1.49.0 :] - * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). + * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). + * Better performance and less memory usage for `boost::container::basic_string` conversions. * [*boost 1.48.0 :] From 105c7133262ef90dc01236d7110b51c18d677d36 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 21 Jan 2012 21:43:17 +0000 Subject: [PATCH 108/138] Quickbook: Merge to quickbook-dev [SVN r76630] --- doc/lexical_cast.qbk | 3 +- include/boost/lexical_cast.hpp | 79 +++++++++++++++++++----- lexical_cast_test.cpp | 11 ++++ test/Jamfile.v2 | 1 + test/lexical_cast_pointers_test.cpp | 96 +++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+), 17 deletions(-) create mode 100755 test/lexical_cast_pointers_test.cpp diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index bf6b562..4715803 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -172,7 +172,8 @@ limitation of compiler options that you use. [section Changes] * [*boost 1.49.0 :] - * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). + * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). + * Better performance and less memory usage for `boost::container::basic_string` conversions. * [*boost 1.48.0 :] diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index b9bc984..cd7d512 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -18,8 +18,34 @@ // with additional fixes and suggestions from Gennaro Prota, // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, // Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann, -// Cheng Yang, Matthew Bradbury and other Boosters -// when: November 2000, March 2003, June 2005, June 2006, March 2011 +// Cheng Yang, Matthew Bradbury, David W. Birdsall and other Boosters +// when: November 2000, March 2003, June 2005, June 2006, March 2011 - 2012 + +#include +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) +#define BOOST_LCAST_NO_WCHAR_T +#endif + +#if (defined(__MINGW32__) || defined(__MINGW64__)) && (__GNUC__ == 4) \ + && ((__GNUC_MINOR__ == 4) || (__GNUC_MINOR__ == 5)) && defined(__STRICT_ANSI__) \ + && !defined(BOOST_LCAST_NO_WCHAR_T) + +// workaround for a mingw bug +// http://sourceforge.net/tracker/index.php?func=detail&aid=2373234&group_id=2435&atid=102435 +#include <_mingw.h> +#if (__GNUC_MINOR__ == 4) +extern "C" { +_CRTIMP int __cdecl swprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...); +_CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...); +} +#endif +#if (__GNUC_MINOR__ == 5) +extern "C" { +_CRTIMP int __cdecl swprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...); +_CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , va_list); +} +#endif +#endif #include #include @@ -30,7 +56,6 @@ #include #include #include -#include #include #include #include @@ -67,10 +92,6 @@ #include #endif -#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) -#define BOOST_LCAST_NO_WCHAR_T -#endif - #ifdef BOOST_NO_TYPEID #define BOOST_LCAST_THROW_BAD_CAST(S, T) throw_exception(bad_lexical_cast()) #else @@ -591,6 +612,7 @@ namespace boost value = *end - czero; --end; T multiplier = 1; + bool multiplier_overflowed = false; #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE std::locale loc; @@ -613,12 +635,17 @@ namespace boost for(;end>=begin; --end) { if (remained) { - T const new_sub_value = multiplier * 10 * (*end - czero); + T const multiplier_10 = multiplier * 10; + if (multiplier_10 / 10 != multiplier) multiplier_overflowed = true; + + T const dig_value = *end - czero; + T const new_sub_value = multiplier_10 * dig_value; if (*end < czero || *end >= czero + 10 /* detecting overflow */ - || new_sub_value/10 != multiplier * (*end - czero) + || (dig_value && new_sub_value / dig_value != multiplier_10) || static_cast((std::numeric_limits::max)()-new_sub_value) < value + || (multiplier_overflowed && dig_value) ) return false; @@ -656,12 +683,17 @@ namespace boost { while ( begin <= end ) { - T const new_sub_value = multiplier * 10 * (*end - czero); + T const multiplier_10 = multiplier * 10; + if (multiplier_10 / 10 != multiplier) multiplier_overflowed = true; + + T const dig_value = *end - czero; + T const new_sub_value = multiplier_10 * dig_value; if (*end < czero || *end >= czero + 10 /* detecting overflow */ - || new_sub_value/10 != multiplier * (*end - czero) + || (dig_value && new_sub_value / dig_value != multiplier_10) || static_cast((std::numeric_limits::max)()-new_sub_value) < value + || (multiplier_overflowed && dig_value) ) return false; @@ -1822,6 +1854,24 @@ namespace boost deduce_char_traits::type traits; typedef BOOST_DEDUCED_TYPENAME remove_pointer::type removed_ptr_t; + + // is_char_types_match variable value can be computed via + // sizeof(char_type) == sizeof(removed_ptr_t). But when + // removed_ptr_t is an incomplete type or void*, compilers + // produce warnings or errors. + const bool is_char_types_match = + (::boost::type_traits::ice_or< + ::boost::type_traits::ice_and< + ::boost::type_traits::ice_eq::value, + ::boost::type_traits::ice_or< + ::boost::is_same::value, + ::boost::is_same::value, + ::boost::is_same::value + >::value + >::value, + is_same::value + >::value); + const bool requires_stringbuf = !( ::boost::type_traits::ice_or< @@ -1830,10 +1880,7 @@ namespace boost ::boost::type_traits::ice_and< is_pointer::value, is_char_or_wchar::value, - ::boost::type_traits::ice_eq< - sizeof(char_type), - sizeof(removed_ptr_t) - >::value + is_char_types_match >::value >::value ); @@ -2111,7 +2158,7 @@ namespace boost // Copyright Kevlin Henney, 2000-2005. // Copyright Alexander Nasonov, 2006-2010. -// Copyright Antony Polukhin, 2011. +// Copyright Antony Polukhin, 2011-2012. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index faeaa93..4e9ec90 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -796,6 +796,17 @@ void test_conversion_from_to_integral() BOOST_CHECK_THROW(lexical_cast("+-9"), bad_lexical_cast); // test_conversion_from_to_integral_for_locale + // Overflow test case from David W. Birdsall + std::string must_owerflow_str = "160000000000000000000"; + std::string must_owerflow_negative_str = "-160000000000000000000"; + for (int i = 0; i < 15; ++i) { + BOOST_CHECK_THROW(lexical_cast(must_owerflow_str), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(must_owerflow_negative_str), bad_lexical_cast); + + must_owerflow_str += '0'; + must_owerflow_negative_str += '0'; + } + typedef std::numpunct numpunct; restore_oldloc guard; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8718301..c311420 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -35,6 +35,7 @@ test-suite conversion [ run lexical_cast_inf_nan_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_containers_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_empty_input_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_pointers_test.cpp ../../test/build//boost_unit_test_framework/static ] [ compile lexical_cast_typedefed_wchar_test.cpp : msvc:on ] [ run lexical_cast_typedefed_wchar_test_runtime.cpp ../../test/build//boost_unit_test_framework/static : : : msvc:on ] ; diff --git a/test/lexical_cast_pointers_test.cpp b/test/lexical_cast_pointers_test.cpp new file mode 100755 index 0000000..d24a895 --- /dev/null +++ b/test/lexical_cast_pointers_test.cpp @@ -0,0 +1,96 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2012. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include + +using namespace boost; + +#if defined(BOOST_NO_STRINGSTREAM) + typedef std::strstream ss_t; +#else + typedef std::stringstream ss_t; +#endif + +void test_void_pointers_conversions() +{ + void *p_to_null = NULL; + const void *cp_to_data = "Some data"; + char nonconst_data[5]; + void *p_to_data = nonconst_data; + ss_t ss; + + ss << p_to_null; + BOOST_CHECK_EQUAL(boost::lexical_cast(p_to_null), ss.str()); + ss.str(std::string()); + + ss << cp_to_data; + BOOST_CHECK_EQUAL(boost::lexical_cast(cp_to_data), ss.str()); + ss.str(std::string()); + + ss << p_to_data; + BOOST_CHECK_EQUAL(boost::lexical_cast(p_to_data), ss.str()); + ss.str(std::string()); +} + +struct incomplete_type; + +void test_incomplete_type_pointers_conversions() +{ + incomplete_type *p_to_null = NULL; + const incomplete_type *cp_to_data = NULL; + char nonconst_data[5]; + incomplete_type *p_to_data = reinterpret_cast(nonconst_data); + ss_t ss; + + ss << p_to_null; + BOOST_CHECK_EQUAL(boost::lexical_cast(p_to_null), ss.str()); + ss.str(std::string()); + + ss << cp_to_data; + BOOST_CHECK_EQUAL(boost::lexical_cast(cp_to_data), ss.str()); + ss.str(std::string()); + + ss << p_to_data; + BOOST_CHECK_EQUAL(boost::lexical_cast(p_to_data), ss.str()); + ss.str(std::string()); +} + +struct ble; +typedef struct ble *meh; +std::ostream& operator <<(std::ostream &o, meh) { + o << "yay"; + return o; +} + +void test_inomplete_type_with_overloaded_ostream_op() { + meh heh = NULL; + ss_t ss; + ss << heh; + BOOST_CHECK_EQUAL(boost::lexical_cast(heh), ss.str()); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast pinters test"); + suite->add(BOOST_TEST_CASE(&test_void_pointers_conversions)); + suite->add(BOOST_TEST_CASE(&test_incomplete_type_pointers_conversions)); + suite->add(BOOST_TEST_CASE(&test_inomplete_type_with_overloaded_ostream_op)); + return suite; +} From e51cf081b355f248db435dd132a4f80160b5c284 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sat, 4 Feb 2012 18:04:45 +0000 Subject: [PATCH 109/138] Merge from trunk (fixed #6251, fixed #6453, disabled some optimizations for sunCC #6462) [SVN r76887] --- include/boost/lexical_cast.hpp | 68 +++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 0927e39..5a3d4f0 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -21,6 +21,32 @@ // Cheng Yang, Matthew Bradbury, David W. Birdsall and other Boosters // when: November 2000, March 2003, June 2005, June 2006, March 2011 - 2012 +#include +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) +#define BOOST_LCAST_NO_WCHAR_T +#endif + +#if (defined(__MINGW32__) || defined(__MINGW64__)) && (__GNUC__ == 4) \ + && ((__GNUC_MINOR__ == 4) || (__GNUC_MINOR__ == 5)) && defined(__STRICT_ANSI__) \ + && !defined(BOOST_LCAST_NO_WCHAR_T) + +// workaround for a mingw bug +// http://sourceforge.net/tracker/index.php?func=detail&aid=2373234&group_id=2435&atid=102435 +#include <_mingw.h> +#if (__GNUC_MINOR__ == 4) +extern "C" { +_CRTIMP int __cdecl swprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...); +_CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...); +} +#endif +#if (__GNUC_MINOR__ == 5) +extern "C" { +_CRTIMP int __cdecl swprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...); +_CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , va_list); +} +#endif +#endif + #include #include #include @@ -30,7 +56,6 @@ #include #include #include -#include #include #include #include @@ -47,7 +72,9 @@ #include #include #include +#if !defined(__SUNPRO_CC) #include +#endif // !defined(__SUNPRO_CC) #ifndef BOOST_NO_CWCHAR # include #endif @@ -67,10 +94,6 @@ #include #endif -#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) -#define BOOST_LCAST_NO_WCHAR_T -#endif - #ifdef BOOST_NO_TYPEID #define BOOST_LCAST_THROW_BAD_CAST(S, T) throw_exception(bad_lexical_cast()) #else @@ -149,11 +172,13 @@ namespace boost typedef CharT type; }; +#if !defined(__SUNPRO_CC) template struct stream_char< ::boost::container::basic_string > { typedef CharT type; }; +#endif // !defined(__SUNPRO_CC) #endif #ifndef BOOST_LCAST_NO_WCHAR_T @@ -268,6 +293,7 @@ namespace boost typedef Traits type; }; +#if !defined(__SUNPRO_CC) template struct deduce_char_traits< CharT , ::boost::container::basic_string @@ -303,6 +329,25 @@ namespace boost { typedef Traits type; }; + + template + struct deduce_char_traits< CharT + , ::boost::container::basic_string + , std::basic_string + > + { + typedef Traits type; + }; + + template + struct deduce_char_traits< CharT + , std::basic_string + , ::boost::container::basic_string + > + { + typedef Traits type; + }; +#endif // !defined(__SUNPRO_CC) #endif } @@ -1325,6 +1370,7 @@ namespace boost return true; } +#if !defined(__SUNPRO_CC) template bool operator<<(::boost::container::basic_string const& str) { @@ -1332,7 +1378,7 @@ namespace boost finish = start + str.length(); return true; } - +#endif // !defined(__SUNPRO_CC) bool operator<<(bool value) { CharT const czero = lcast_char_constants::zero; @@ -1549,9 +1595,10 @@ namespace boost #else template bool operator>>(std::basic_string& str) { str.assign(start, finish); return true; } - +#if !defined(__SUNPRO_CC) template bool operator>>(::boost::container::basic_string& str) { str.assign(start, finish); return true; } +#endif // !defined(__SUNPRO_CC) #endif /* * case "-0" || "0" || "+0" : output = false; return true; @@ -1687,13 +1734,13 @@ namespace boost { BOOST_STATIC_CONSTANT(bool, value = true ); }; - +#if !defined(__SUNPRO_CC) template struct is_stdstring< ::boost::container::basic_string > { BOOST_STATIC_CONSTANT(bool, value = true ); }; - +#endif // !defined(__SUNPRO_CC) template struct is_char_or_wchar { @@ -1793,7 +1840,7 @@ namespace boost { BOOST_STATIC_CONSTANT(bool, value = true ); }; - +#if !defined(__SUNPRO_CC) template struct is_char_array_to_stdstring< ::boost::container::basic_string, CharT* > { @@ -1805,6 +1852,7 @@ namespace boost { BOOST_STATIC_CONSTANT(bool, value = true ); }; +#endif // !defined(__SUNPRO_CC) #if (defined _MSC_VER) # pragma warning( push ) From a065884c59fd9390590ec15bd063b9f5d1eb0e94 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sat, 10 Mar 2012 07:31:36 +0000 Subject: [PATCH 110/138] Merge from trunk * Much more tests * Now numeric_cast (and lexical_cast) can be compiled with disabled exceptions * Supress warning described in #6645 (implicit conversion shortens 64-bit value into a 32-bit value) * Fixed compilation of lexical_cast with BOOST_NO_STD_LOCALE defined * Documentation updates * Case insensitive "NaN" and "Inf" parsing * Performance tests commit [SVN r77288] --- doc/lexical_cast.qbk | 15 +- include/boost/lexical_cast.hpp | 275 +++++++++--------- perf/Jamfile.v2 | 29 ++ perf/performance_test.cpp | 309 +++++++++++++++++++++ test/Jamfile.v2 | 11 +- test/lexical_cast_containers_test.cpp | 22 ++ test/lexical_cast_empty_input_test.cpp | 14 + test/lexical_cast_inf_nan_test.cpp | 21 ++ test/lexical_cast_no_exceptions_test.cpp | 95 +++++++ test/lexical_cast_no_locale_test.cpp | 166 +++++++++++ test/lexical_cast_typedefed_wchar_test.cpp | 15 + 11 files changed, 839 insertions(+), 133 deletions(-) create mode 100644 perf/Jamfile.v2 create mode 100644 perf/performance_test.cpp create mode 100755 test/lexical_cast_no_exceptions_test.cpp create mode 100755 test/lexical_cast_no_locale_test.cpp diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index 4715803..4ad8336 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -3,7 +3,7 @@ [version 1.0] [copyright 2000-2005 Kevlin Henney] [copyright 2006-2010 Alexander Nasonov] - [copyright 2011 Antony Polukhin] + [copyright 2011-2012 Antony Polukhin] [category String and text processing] [category Miscellaneous] [license @@ -167,9 +167,22 @@ if a negative number is read, no errors will arise and the result will be the tw `boost::lexical_cast` sees single `wchar_t` character as `unsigned short`. It is not a `boost::lexical_cast` mistake, but a limitation of compiler options that you use. +[pre +] + +* [*Question:] Why `boost::lexical_cast("-1.#IND");` throws `boost::bad_lexical_cast`? + * [*Answer:] `"-1.#IND"` is a compiler extension, that violates standard. You shall input `"-nan"`, `"nan"`, `"inf"` +, `"-inf"` (case insensitive) strings to get NaN and Inf values. `boost::lexical_cast` outputs `"-nan"`, `"nan"`, +`"inf"`, `"-inf"` strings, when has NaN or Inf input values. + [endsect] [section Changes] +* [*boost 1.50.0 :] + + * `boost::bad_lexical_cast` exception is now globaly visible and can be catched even if code is compiled with -fvisibility=hidden. + * Now it is possible to compile library with disabled exceptions. + * [*boost 1.49.0 :] * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 5a3d4f0..b73c741 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -104,7 +104,7 @@ _CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * __restric namespace boost { // exception used to indicate runtime lexical_cast failure - class bad_lexical_cast : + class BOOST_SYMBOL_VISIBLE bad_lexical_cast : // workaround MSVC bug with std::bad_cast when _HAS_EXCEPTIONS == 0 #if defined(BOOST_MSVC) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS public std::exception @@ -732,6 +732,15 @@ namespace boost namespace detail { + template + bool lc_iequal(const CharT* val, const CharT* lcase, const CharT* ucase, unsigned int len) { + for( unsigned int i=0; i < len; ++i ) { + if ( val[i] != lcase[i] && val[i] != ucase[i] ) return false; + } + + return true; + } + /* Returns true and sets the correct value if found NaN or Inf. */ template inline bool parse_inf_nan_impl(const CharT* begin, const CharT* end, T& value @@ -755,7 +764,7 @@ namespace boost else if( *begin == plus ) ++begin; if( end-begin < 3 ) return false; - if( !memcmp(begin, lc_nan, 3*sizeof(CharT)) || !memcmp(begin, lc_NAN, 3*sizeof(CharT)) ) + if( lc_iequal(begin, lc_nan, lc_NAN, 3) ) { begin += 3; if (end != begin) /* It is 'nan(...)' or some bad input*/ @@ -772,13 +781,13 @@ namespace boost if (( /* 'INF' or 'inf' */ end-begin==3 && - (!memcmp(begin, lc_infinity, 3*sizeof(CharT)) || !memcmp(begin, lc_INFINITY, 3*sizeof(CharT))) + lc_iequal(begin, lc_infinity, lc_INFINITY, 3) ) || ( /* 'INFINITY' or 'infinity' */ end-begin==inifinity_size && - (!memcmp(begin, lc_infinity, inifinity_size)|| !memcmp(begin, lc_INFINITY, inifinity_size)) + lc_iequal(begin, lc_infinity, lc_INFINITY, inifinity_size) ) ) { @@ -790,6 +799,41 @@ namespace boost return false; } + template + bool put_inf_nan_impl(CharT* begin, CharT*& end, const T& value + , const CharT* lc_nan + , const CharT* lc_infinity) + { + using namespace std; + const CharT minus = lcast_char_constants::minus; + if ( (boost::math::isnan)(value) ) + { + if ( (boost::math::signbit)(value) ) + { + *begin = minus; + ++ begin; + } + + memcpy(begin, lc_nan, 3 * sizeof(CharT)); + end = begin + 3; + return true; + } else if ( (boost::math::isinf)(value) ) + { + if ( (boost::math::signbit)(value) ) + { + *begin = minus; + ++ begin; + } + + memcpy(begin, lc_infinity, 3 * sizeof(CharT)); + end = begin + 3; + return true; + } + + return false; + } + + #ifndef BOOST_LCAST_NO_WCHAR_T template bool parse_inf_nan(const wchar_t* begin, const wchar_t* end, T& value) @@ -799,6 +843,13 @@ namespace boost , L"INFINITY", L"infinity" , L'(', L')'); } + + template + bool put_inf_nan(wchar_t* begin, wchar_t*& end, const T& value) + { + return put_inf_nan_impl(begin, end, value, L"nan", L"infinity"); + } + #endif #ifndef BOOST_NO_CHAR16_T template @@ -809,6 +860,12 @@ namespace boost , u"INFINITY", u"infinity" , u'(', u')'); } + + template + bool put_inf_nan(char16_t* begin, char16_t*& end, const T& value) + { + return put_inf_nan_impl(begin, end, value, u"nan", u"infinity"); + } #endif #ifndef BOOST_NO_CHAR32_T template @@ -819,6 +876,12 @@ namespace boost , U"INFINITY", U"infinity" , U'(', U')'); } + + template + bool put_inf_nan(char32_t* begin, char32_t*& end, const T& value) + { + return put_inf_nan_impl(begin, end, value, U"nan", U"infinity"); + } #endif template @@ -829,73 +892,12 @@ namespace boost , "INFINITY", "infinity" , '(', ')'); } -#ifndef BOOST_LCAST_NO_WCHAR_T - template - bool put_inf_nan(wchar_t* begin, wchar_t*& end, const T& value) - { - using namespace std; - if ( (boost::math::isnan)(value) ) - { - if ( (boost::math::signbit)(value) ) - { - memcpy(begin,L"-nan", sizeof(L"-nan")); - end = begin + 4; - } else - { - memcpy(begin,L"nan", sizeof(L"nan")); - end = begin + 3; - } - return true; - } else if ( (boost::math::isinf)(value) ) - { - if ( (boost::math::signbit)(value) ) - { - memcpy(begin,L"-inf", sizeof(L"-inf")); - end = begin + 4; - } else - { - memcpy(begin,L"inf", sizeof(L"inf")); - end = begin + 3; - } - return true; - } - return false; - } -#endif template bool put_inf_nan(CharT* begin, CharT*& end, const T& value) { - using namespace std; - if ( (boost::math::isnan)(value) ) - { - if ( (boost::math::signbit)(value) ) - { - memcpy(begin,"-nan", sizeof("-nan")); - end = begin + 4; - } else - { - memcpy(begin,"nan", sizeof("nan")); - end = begin + 3; - } - return true; - } else if ( (boost::math::isinf)(value) ) - { - if ( (boost::math::signbit)(value) ) - { - memcpy(begin,"-inf", sizeof("-inf")); - end = begin + 4; - } else - { - memcpy(begin,"inf", sizeof("inf")); - end = begin + 3; - } - return true; - } - - return false; + return put_inf_nan_impl(begin, end, value, "nan", "infinity"); } - } @@ -951,7 +953,7 @@ namespace boost CharT const capital_e = lcast_char_constants::capital_e; CharT const lowercase_e = lcast_char_constants::lowercase_e; - value = 0.0; + value = static_cast(0); if (parse_inf_nan(begin, end, value)) return true; @@ -1165,7 +1167,7 @@ namespace boost namespace detail { - struct do_not_construct_stringbuffer_t{}; + struct do_not_construct_out_stream_t{}; } namespace detail // optimized stream wrapper @@ -1177,25 +1179,27 @@ namespace boost > class lexical_stream_limited_src { - typedef stl_buf_unlocker, CharT > local_streambuffer_t; #if defined(BOOST_NO_STRINGSTREAM) - typedef stl_buf_unlocker local_stringbuffer_t; + typedef std::ostrstream out_stream_t; + typedef stl_buf_unlocker unlocked_but_t; #elif defined(BOOST_NO_STD_LOCALE) - typedef stl_buf_unlocker local_stringbuffer_t; + typedef std::ostringstream out_stream_t; + typedef stl_buf_unlocker unlocked_but_t; #else - typedef stl_buf_unlocker, CharT > local_stringbuffer_t; + typedef std::basic_ostringstream out_stream_t; + typedef stl_buf_unlocker, CharT> unlocked_but_t; #endif typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< RequiresStringbuffer, - local_stringbuffer_t, - do_not_construct_stringbuffer_t - >::type deduced_stringbuffer_t; + out_stream_t, + do_not_construct_out_stream_t + >::type deduced_out_stream_t; // A string representation of Source is written to [start, finish). CharT* start; CharT* finish; - deduced_stringbuffer_t stringbuffer; + deduced_out_stream_t out_stream; public: lexical_stream_limited_src(CharT* sta, CharT* fin) @@ -1256,10 +1260,16 @@ namespace boost template bool shl_input_streamable(InputStreamable& input) { - std::basic_ostream stream(&stringbuffer); - bool const result = !(stream << input).fail(); - start = stringbuffer.pbase(); - finish = stringbuffer.pptr(); +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_LOCALE) + // If you have compilation error at this point, than your STL library + // unsupports such conversions. Try updating it. + BOOST_STATIC_ASSERT((boost::is_same::value)); +#endif + bool const result = !(out_stream << input).fail(); + const unlocked_but_t* const p + = static_cast(out_stream.rdbuf()) ; + start = p->pbase(); + finish = p->pptr(); return result; } @@ -1524,9 +1534,22 @@ namespace boost if(is_pointer::value) return false; - local_streambuffer_t bb; - bb.setg(start, start, finish); - std::basic_istream stream(&bb); +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_LOCALE) + // If you have compilation error at this point, than your STL library + // unsupports such conversions. Try updating it. + BOOST_STATIC_ASSERT((boost::is_same::value)); +#endif + +#if defined(BOOST_NO_STRINGSTREAM) + std::istrstream stream(start, finish - start); +#elif defined(BOOST_NO_STD_LOCALE) + std::istringstream stream; +#else + std::basic_istringstream stream; +#endif + static_cast(stream.rdbuf()) + ->setg(start, start, finish); + stream.unsetf(std::ios::skipws); lcast_set_precision(stream, static_cast(0)); #if (defined _MSC_VER) @@ -1935,52 +1958,52 @@ namespace boost } }; - class precision_loss_error : public boost::numeric::bad_numeric_cast + template + struct detect_precision_loss { - public: - virtual const char * what() const throw() - { return "bad numeric conversion: precision loss error"; } - }; + typedef boost::numeric::Trunc Rounder; + typedef Source source_type ; - template - struct throw_on_precision_loss - { - typedef boost::numeric::Trunc Rounder; - typedef S source_type ; - - typedef typename mpl::if_< is_arithmetic,S,S const&>::type argument_type ; + typedef BOOST_DEDUCED_TYPENAME mpl::if_< + is_arithmetic, Source, Source const& + >::type argument_type ; static source_type nearbyint ( argument_type s ) { - source_type orig_div_round = s / Rounder::nearbyint(s); + const source_type orig_div_round = s / Rounder::nearbyint(s); + const source_type eps = std::numeric_limits::epsilon(); + + if ((orig_div_round > 1 ? orig_div_round - 1 : 1 - orig_div_round) > eps) + BOOST_LCAST_THROW_BAD_CAST(Source, Target); - if ( (orig_div_round > 1 ? orig_div_round - 1 : 1 - orig_div_round) > std::numeric_limits::epsilon() ) - BOOST_THROW_EXCEPTION( precision_loss_error() ); return s ; } typedef typename Rounder::round_style round_style; } ; + template + struct nothrow_overflow_handler + { + void operator() ( boost::numeric::range_check_result r ) + { + if (r != boost::numeric::cInRange) + BOOST_LCAST_THROW_BAD_CAST(Source, Target); + } + } ; + template struct lexical_cast_dynamic_num_not_ignoring_minus { static inline Target lexical_cast_impl(const Source &arg) { - try{ - typedef boost::numeric::converter< - Target, - Source, - boost::numeric::conversion_traits, - boost::numeric::def_overflow_handler, - throw_on_precision_loss - > Converter ; - - return Converter::convert(arg); - } catch( ::boost::numeric::bad_numeric_cast const& ) { - BOOST_LCAST_THROW_BAD_CAST(Source, Target); - } - BOOST_UNREACHABLE_RETURN(static_cast(0)); + return boost::numeric::converter< + Target, + Source, + boost::numeric::conversion_traits, + nothrow_overflow_handler, + detect_precision_loss + >::convert(arg); } }; @@ -1989,25 +2012,17 @@ namespace boost { static inline Target lexical_cast_impl(const Source &arg) { - try{ - typedef boost::numeric::converter< - Target, - Source, - boost::numeric::conversion_traits, - boost::numeric::def_overflow_handler, - throw_on_precision_loss - > Converter ; + typedef boost::numeric::converter< + Target, + Source, + boost::numeric::conversion_traits, + nothrow_overflow_handler, + detect_precision_loss + > converter_t; - bool has_minus = ( arg < 0); - if ( has_minus ) { - return static_cast(-Converter::convert(-arg)); - } else { - return Converter::convert(arg); - } - } catch( ::boost::numeric::bad_numeric_cast const& ) { - BOOST_LCAST_THROW_BAD_CAST(Source, Target); - } - BOOST_UNREACHABLE_RETURN(static_cast(0)); + return ( + arg < 0 ? -converter_t::convert(-arg) : converter_t::convert(arg) + ); } }; diff --git a/perf/Jamfile.v2 b/perf/Jamfile.v2 new file mode 100644 index 0000000..78176be --- /dev/null +++ b/perf/Jamfile.v2 @@ -0,0 +1,29 @@ +#============================================================================== +# Copyright (c) 2012 Antony Polukhin +# +# 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) +#============================================================================== + +# performance tests +import testing ; +import path ; + +path-constant TEST_DIR : . ; + +project performance/test + : source-location ./ + : requirements +# /boost/chrono//boost_chrono +# /boost/system//boost_system + static + freebsd:"-lrt" + linux:"-lrt" + gcc:-fvisibility=hidden + intel-linux:-fvisibility=hidden + sun:-xldscope=hidden + : default-build release + ; + +run performance_test.cpp : $(TEST_DIR) ; + diff --git a/perf/performance_test.cpp b/perf/performance_test.cpp new file mode 100644 index 0000000..ff1eb1d --- /dev/null +++ b/perf/performance_test.cpp @@ -0,0 +1,309 @@ +// (C) Copyright Antony Polukhin 2012. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/config for most recent version. + +// +// Testing lexical_cast<> performance +// + +#define BOOST_ERROR_CODE_HEADER_ONLY +#define BOOST_CHRONO_HEADER_ONLY + +#include +#include +#include +#include + +// File to output data +std::fstream fout; + +template +static inline void test_lexical(const InT& in_val) { + OutT out_val = boost::lexical_cast(in_val); + (void)out_val; +} + +template +static inline void test_ss_constr(const InT& in_val) { + OutT out_val; + std::stringstream ss; + ss << in_val; + if (ss.fail()) throw std::logic_error("descr"); + ss >> out_val; + if (ss.fail()) throw std::logic_error("descr"); +} + +template +static inline void test_ss_noconstr(StringStreamT& ss, const InT& in_val) { + OutT out_val; + ss << in_val; // ss is an instance of std::stringstream + if (ss.fail()) throw std::logic_error("descr"); + ss >> out_val; + if (ss.fail()) throw std::logic_error("descr"); + /* reseting std::stringstream to use it again */ + ss.str(std::string()); + ss.clear(); +} + +struct structure_sprintf { + template + static inline void test(BufferT* buffer, const InT& in_val, const char* const conv) { + sprintf(buffer, conv, in_val); + OutT out_val(buffer); + } + + template + static inline void test(BufferT* buffer, const std::string& in_val, const char* const conv) { + sprintf(buffer, conv, in_val.c_str()); + OutT out_val(buffer); + } +}; + +struct structure_sscanf { + template + static inline void test(BufferT* /*buffer*/, const InT& in_val, const char* const conv) { + OutT out_val; + sscanf(reinterpret_cast(in_val), conv, &out_val); + } + + template + static inline void test(BufferT* /*buffer*/, const std::string& in_val, const char* const conv) { + OutT out_val; + sscanf(in_val.c_str(), conv, &out_val); + } +}; + +struct structure_fake { + template + static inline void test(BufferT* /*buffer*/, const InT& /*in_val*/, const char* const /*conv*/) {} +}; + +static const int fake_test_value = 9999; + +template +static inline void min_fancy_output(T v1, T v2, T v3, T v4) { + const char beg_mark[] = "!!! *"; + const char end_mark[] = "* !!!"; + const char no_mark[] = ""; + + unsigned int res = 4; + if (v1 < v2 && v1 < v3 && v1 < v4) res = 1; + if (v2 < v1 && v2 < v3 && v2 < v4) res = 2; + if (v3 < v1 && v3 < v2 && v3 < v4) res = 3; + + fout << "[ " + << (res == 1 ? beg_mark : no_mark) + ; + + if (v1) fout << v1; + else fout << "<1"; + + fout << (res == 1 ? end_mark : no_mark) + << " ][ " + << (res == 2 ? beg_mark : no_mark) + ; + + if (v2) fout << v2; + else fout << "<1"; + + fout << (res == 2 ? end_mark : no_mark) + << " ][ " + << (res == 3 ? beg_mark : no_mark) + ; + + if (v3) fout << v3; + else fout << "<1"; + + fout << (res == 3 ? end_mark : no_mark) + << " ][ " + << (res == 4 ? beg_mark : no_mark) + ; + + if (!v4) fout << "<1"; + else if (v4 == fake_test_value) fout << "---"; + else fout << v4; + + fout + << (res == 4 ? end_mark : no_mark) + << " ]"; +} + +template +static inline void perf_test_impl(const FromT& in_val, const char* const conv) { + + typedef boost::chrono::steady_clock test_clock; + test_clock::time_point start; + typedef boost::chrono::milliseconds duration_t; + duration_t lexical_cast_time, ss_constr_time, ss_noconstr_time, printf_time; + + start = test_clock::now(); + for (unsigned int i = 0; i < IetartionsCountV; ++i) { + test_lexical(in_val); + test_lexical(in_val); + test_lexical(in_val); + test_lexical(in_val); + } + lexical_cast_time = boost::chrono::duration_cast(test_clock::now() - start); + + + start = test_clock::now(); + for (unsigned int i = 0; i < IetartionsCountV; ++i) { + test_ss_constr(in_val); + test_ss_constr(in_val); + test_ss_constr(in_val); + test_ss_constr(in_val); + } + ss_constr_time = boost::chrono::duration_cast(test_clock::now() - start); + + std::stringstream ss; + start = test_clock::now(); + for (unsigned int i = 0; i < IetartionsCountV; ++i) { + test_ss_noconstr(ss, in_val); + test_ss_noconstr(ss, in_val); + test_ss_noconstr(ss, in_val); + test_ss_noconstr(ss, in_val); + } + ss_noconstr_time = boost::chrono::duration_cast(test_clock::now() - start); + + + char buffer[128]; + start = test_clock::now(); + for (unsigned int i = 0; i < IetartionsCountV; ++i) { + SprintfT::template test(buffer, in_val, conv); + SprintfT::template test(buffer, in_val, conv); + SprintfT::template test(buffer, in_val, conv); + SprintfT::template test(buffer, in_val, conv); + } + printf_time = boost::chrono::duration_cast(test_clock::now() - start); + + min_fancy_output( + lexical_cast_time.count(), + ss_constr_time.count(), + ss_noconstr_time.count(), + boost::is_same::value ? fake_test_value : printf_time.count() + ); +} + +template +static inline void perf_test(const std::string& test_name, const FromT& in_val, const char* const conv) { + const unsigned int ITERATIONSCOUNT = 100000; + fout << " [[ " << test_name << " ]"; + + perf_test_impl(in_val, conv); + + fout << "]\n"; +} + + +template +void string_like_test_set(const std::string& from) { + typedef structure_sscanf ssc_t; + ConverterT conv; + + perf_test(from + "->char", conv("c"), "%c"); + perf_test(from + "->signed char", conv("c"), "%hhd"); + perf_test(from + "->unsigned char", conv("c"), "%hhu"); + + perf_test(from + "->int", conv("100"), "%d"); + perf_test(from + "->short", conv("100"), "%hd"); + perf_test(from + "->long int", conv("100"), "%ld"); + perf_test(from + "->long long", conv("100"), "%lld"); + + perf_test(from + "->unsigned int", conv("100"), "%u"); + perf_test(from + "->unsigned short", conv("100"), "%hu"); + perf_test(from + "->unsigned long int", conv("100"), "%lu"); + perf_test(from + "->unsigned long long", conv("100"), "%llu"); + + // perf_test(from + "->bool", conv("1"), "%"); + + perf_test(from + "->float", conv("1.123"), "%f"); + perf_test(from + "->double", conv("1.123"), "%lf"); + perf_test(from + "->long double", conv("1.123"), "%Lf"); + + + perf_test(from + "->string", conv("string"), "%Lf"); + perf_test(from + "->container::string" + , conv("string"), "%Lf"); + +} + +struct to_string_conv { + std::string operator()(const char* const c) const { + return c; + } +}; + +struct to_char_conv { + const char* operator()(const char* const c) const { + return c; + } +}; + +struct to_uchar_conv { + const unsigned char* operator()(const char* const c) const { + return reinterpret_cast(c); + } +}; + + +struct to_schar_conv { + const signed char* operator()(const char* const c) const { + return reinterpret_cast(c); + } +}; + +int main(int argc, char** argv) { + BOOST_ASSERT(argc >= 2); + std::string output_path(argv[1]); + output_path += "/results.txt"; + fout.open(output_path.c_str(), std::fstream::in | std::fstream::out | std::fstream::app); + BOOST_ASSERT(fout); + + fout << "[section " << BOOST_COMPILER << "]\n" + << "[table:id Performance Table ( "<< BOOST_COMPILER << ")\n" + << "[[From->To] [lexical_cast] [std::stringstream with construction] " + << "[std::stringstream without construction][scanf/printf]]\n"; + + + // From std::string to ... + string_like_test_set("string"); + + // From ... to std::string + perf_test("string->char", 'c', "%c"); + perf_test("string->signed char", static_cast('c'), "%hhd"); + perf_test("string->unsigned char", static_cast('c'), "%hhu"); + + perf_test("int->string", 100, "%d"); + perf_test("short->string", static_cast(100), "%hd"); + perf_test("long int->string", 100l, "%ld"); + perf_test("long long->string", 100ll, "%lld"); + + perf_test("unsigned int->string", static_cast(100u), "%u"); + perf_test("unsigned short->string", 100u, "%hu"); + perf_test("unsigned long int->string", 100ul, "%lu"); + perf_test("unsigned long long->string", static_cast(100), "%llu"); + + // perf_test("bool->string", std::string("1"), "%"); + + perf_test("float->string", 1.123f, "%f"); + perf_test("double->string", 1.123, "%lf"); + perf_test("long double->string", 1.123L, "%Lf"); + + + string_like_test_set("char*"); + string_like_test_set("unsigned char*"); + string_like_test_set("signed char*"); + + perf_test("int->int", 100, ""); + perf_test("float->double", 100.0f, ""); + perf_test("char->signed char", 'c', ""); + + fout << "]\n" + << "[endsect]\n\n"; + return 0; +} + + diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c311420..019c9e7 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -38,5 +38,12 @@ test-suite conversion [ run lexical_cast_pointers_test.cpp ../../test/build//boost_unit_test_framework/static ] [ compile lexical_cast_typedefed_wchar_test.cpp : msvc:on ] [ run lexical_cast_typedefed_wchar_test_runtime.cpp ../../test/build//boost_unit_test_framework/static : : : msvc:on ] - ; - + [ run lexical_cast_no_locale_test.cpp ../../test/build//boost_unit_test_framework/static : : : BOOST_NO_STD_LOCALE BOOST_LEXICAL_CAST_ASSUME_C_LOCALE ] + [ run lexical_cast_no_exceptions_test.cpp ../../test/build//boost_unit_test_framework/static : : : BOOST_NO_EXCEPTIONS + gcc-4.3:-fno-exceptions + gcc-4.4:-fno-exceptions + gcc-4.5:-fno-exceptions + gcc-4.6:-fno-exceptions + ] + ; + diff --git a/test/lexical_cast_containers_test.cpp b/test/lexical_cast_containers_test.cpp index 5f98ac8..0c6315b 100644 --- a/test/lexical_cast_containers_test.cpp +++ b/test/lexical_cast_containers_test.cpp @@ -13,6 +13,7 @@ #include void testing_boost_containers_basic_string(); +void testing_boost_containers_string_std_string(); using namespace boost; @@ -21,6 +22,7 @@ boost::unit_test::test_suite *init_unit_test_suite(int, char *[]) unit_test::test_suite *suite = BOOST_TEST_SUITE("Testing boost::lexical_cast with boost::container::string"); suite->add(BOOST_TEST_CASE(testing_boost_containers_basic_string)); + suite->add(BOOST_TEST_CASE(testing_boost_containers_string_std_string)); return suite; } @@ -35,4 +37,24 @@ void testing_boost_containers_basic_string() BOOST_CHECK(1000 == lexical_cast(str)); } +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) +#define BOOST_LCAST_NO_WCHAR_T +#endif +void testing_boost_containers_string_std_string() +{ + std::string std_str("std_str"); + boost::container::string boost_str("boost_str"); + BOOST_CHECK(boost::lexical_cast(boost_str) == "boost_str"); + BOOST_CHECK(boost::lexical_cast(std_str) == "std_str"); + +#ifndef BOOST_LCAST_NO_WCHAR_T + std::wstring std_wstr(L"std_wstr"); + boost::container::wstring boost_wstr(L"boost_wstr"); + + BOOST_CHECK(boost::lexical_cast(boost_wstr) == L"boost_wstr"); + BOOST_CHECK(boost::lexical_cast(std_wstr) == L"std_wstr"); + +#endif + +} diff --git a/test/lexical_cast_empty_input_test.cpp b/test/lexical_cast_empty_input_test.cpp index 5a5881b..df05981 100755 --- a/test/lexical_cast_empty_input_test.cpp +++ b/test/lexical_cast_empty_input_test.cpp @@ -138,6 +138,19 @@ void test_empty_vector() BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); } + +struct my_string { + friend std::ostream &operator<<(std::ostream& sout, my_string const&/* st*/) { + return sout << ""; + } +}; + +void test_empty_zero_terminated_string() +{ + my_string st; + BOOST_CHECK_EQUAL(boost::lexical_cast(st), std::string());; +} + unit_test::test_suite *init_unit_test_suite(int, char *[]) { unit_test::test_suite *suite = @@ -146,6 +159,7 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(&test_empty_string)); suite->add(BOOST_TEST_CASE(&test_empty_user_class)); suite->add(BOOST_TEST_CASE(&test_empty_vector)); + suite->add(BOOST_TEST_CASE(&test_empty_zero_terminated_string)); return suite; } diff --git a/test/lexical_cast_inf_nan_test.cpp b/test/lexical_cast_inf_nan_test.cpp index bb4331a..af1caa0 100755 --- a/test/lexical_cast_inf_nan_test.cpp +++ b/test/lexical_cast_inf_nan_test.cpp @@ -85,6 +85,12 @@ void test_inf_nan_templated() BOOST_CHECK( is_pos_inf( lexical_cast("+infinity") ) ); BOOST_CHECK( is_pos_inf( lexical_cast("+INFINITY") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast("iNfiNity") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast("INfinity") ) ); + + BOOST_CHECK( is_neg_inf( lexical_cast("-inFINITY") ) ); + BOOST_CHECK( is_neg_inf( lexical_cast("-INFINITY") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast("nan") ) ); BOOST_CHECK( is_pos_nan( lexical_cast("NAN") ) ); @@ -94,6 +100,15 @@ void test_inf_nan_templated() BOOST_CHECK( is_pos_nan( lexical_cast("+nan") ) ); BOOST_CHECK( is_pos_nan( lexical_cast("+NAN") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast("nAn") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast("NaN") ) ); + + BOOST_CHECK( is_neg_nan( lexical_cast("-nAn") ) ); + BOOST_CHECK( is_neg_nan( lexical_cast("-NaN") ) ); + + BOOST_CHECK( is_pos_nan( lexical_cast("+Nan") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast("+nAN") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast("nan()") ) ); BOOST_CHECK( is_pos_nan( lexical_cast("NAN(some string)") ) ); BOOST_CHECK_THROW( lexical_cast("NAN(some string"), bad_lexical_cast ); @@ -127,6 +142,12 @@ void test_inf_nan_templated() BOOST_CHECK( is_pos_inf( lexical_cast(L"+infinity") ) ); BOOST_CHECK( is_pos_inf( lexical_cast(L"+INFINITY") ) ); + BOOST_CHECK( is_neg_inf( lexical_cast(L"-infINIty") ) ); + BOOST_CHECK( is_neg_inf( lexical_cast(L"-INFiniTY") ) ); + + BOOST_CHECK( is_pos_inf( lexical_cast(L"+inFINIty") ) ); + BOOST_CHECK( is_pos_inf( lexical_cast(L"+INfinITY") ) ); + BOOST_CHECK( is_pos_nan( lexical_cast(L"nan") ) ); BOOST_CHECK( is_pos_nan( lexical_cast(L"NAN") ) ); diff --git a/test/lexical_cast_no_exceptions_test.cpp b/test/lexical_cast_no_exceptions_test.cpp new file mode 100755 index 0000000..8431c3a --- /dev/null +++ b/test/lexical_cast_no_exceptions_test.cpp @@ -0,0 +1,95 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2012. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include +#include + +#ifndef BOOST_NO_EXCEPTIONS +#error "This test must be compiled with -DBOOST_NO_EXCEPTIONS" +#endif + +bool g_was_exception = false; + +namespace boost { + +void throw_exception(std::exception const & ) { + g_was_exception = true; +} + +} + +using namespace boost; + + +struct Escape +{ + Escape(){} + Escape(const std::string& s) + : str_(s) + {} + + std::string str_; +}; + +inline std::ostream& operator<< (std::ostream& o, const Escape& rhs) +{ + return o << rhs.str_; +} + +inline std::istream& operator>> (std::istream& i, Escape& rhs) +{ + return i >> rhs.str_; +} + +void test_exceptions_off() +{ + Escape v(""); + + g_was_exception = false; + lexical_cast(v); + BOOST_CHECK(g_was_exception); + + g_was_exception = false; + lexical_cast(v); + BOOST_CHECK(g_was_exception); + + v = lexical_cast(100); + BOOST_CHECK_EQUAL(lexical_cast(v), 100); + BOOST_CHECK_EQUAL(lexical_cast(v), 100u); + + v = lexical_cast(0.0); + BOOST_CHECK_EQUAL(lexical_cast(v), 0.0); + + BOOST_CHECK_EQUAL(lexical_cast(100), 100); + BOOST_CHECK_EQUAL(lexical_cast(0.0), 0.0); + + g_was_exception = false; + lexical_cast(700000); + BOOST_CHECK(g_was_exception); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast. Testing with BOOST_NO_EXCEPTIONS"); + suite->add(BOOST_TEST_CASE(&test_exceptions_off)); + + return suite; +} + diff --git a/test/lexical_cast_no_locale_test.cpp b/test/lexical_cast_no_locale_test.cpp new file mode 100755 index 0000000..f3defb3 --- /dev/null +++ b/test/lexical_cast_no_locale_test.cpp @@ -0,0 +1,166 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2012. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include +#include + +using namespace boost; + +// Testing compilation and some basic usage with BOOST_NO_STD_LOCALE +// Tests are mainly copyied from lexical_cast_empty_input_test.cpp (something +// new added to test_empty_3) + +#ifndef BOOST_NO_STD_LOCALE +#error "This test must be compiled with -DBOOST_NO_STD_LOCALE" +#endif + + +template +void do_test_on_empty_input(T& v) +{ + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +#if defined(BOOST_HAS_LONG_LONG) + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +#elif defined(BOOST_HAS_MS_INT64) + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast<__int64>(v), bad_lexical_cast); +#endif +} + +void test_empty_1() +{ + boost::iterator_range v; + do_test_on_empty_input(v); + BOOST_CHECK_EQUAL(lexical_cast(v), std::string()); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + + boost::iterator_range cv; + do_test_on_empty_input(cv); + BOOST_CHECK_EQUAL(lexical_cast(cv), std::string()); + BOOST_CHECK_THROW(lexical_cast(cv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(cv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(cv), bad_lexical_cast); + + const boost::iterator_range ccv; + do_test_on_empty_input(ccv); + BOOST_CHECK_EQUAL(lexical_cast(ccv), std::string()); + BOOST_CHECK_THROW(lexical_cast(ccv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(ccv), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(ccv), bad_lexical_cast); +} + +void test_empty_2() +{ + std::string v; + do_test_on_empty_input(v); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +} + +struct Escape +{ + Escape(){} + Escape(const std::string& s) + : str_(s) + {} + + std::string str_; +}; + +inline std::ostream& operator<< (std::ostream& o, const Escape& rhs) +{ + return o << rhs.str_; +} + +inline std::istream& operator>> (std::istream& i, Escape& rhs) +{ + return i >> rhs.str_; +} + +void test_empty_3() +{ + Escape v(""); + do_test_on_empty_input(v); + + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + + v = lexical_cast(100); + BOOST_CHECK_EQUAL(lexical_cast(v), 100); + BOOST_CHECK_EQUAL(lexical_cast(v), 100u); + + v = lexical_cast(0.0); + BOOST_CHECK_EQUAL(lexical_cast(v), 0.0); +} + +namespace std { +inline std::ostream & operator<<(std::ostream & out, const std::vector & v) +{ + std::ostream_iterator it(out); + std::copy(v.begin(), v.end(), it); + assert(out); + return out; +} +} + +void test_empty_4() +{ + std::vector v; + do_test_on_empty_input(v); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); +} + + +struct my_string { + friend std::ostream &operator<<(std::ostream& sout, my_string const&/* st*/) { + return sout << ""; + } +}; + +void test_empty_5() +{ + my_string st; + BOOST_CHECK_EQUAL(boost::lexical_cast(st), std::string());; +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast. Testing with BOOST_NO_STD_LOCALE"); + suite->add(BOOST_TEST_CASE(&test_empty_1)); + suite->add(BOOST_TEST_CASE(&test_empty_2)); + suite->add(BOOST_TEST_CASE(&test_empty_3)); + suite->add(BOOST_TEST_CASE(&test_empty_4)); + suite->add(BOOST_TEST_CASE(&test_empty_5)); + + return suite; +} + diff --git a/test/lexical_cast_typedefed_wchar_test.cpp b/test/lexical_cast_typedefed_wchar_test.cpp index 752c3e5..2dc0098 100755 --- a/test/lexical_cast_typedefed_wchar_test.cpp +++ b/test/lexical_cast_typedefed_wchar_test.cpp @@ -13,12 +13,27 @@ #include #include +#include +#include + +void parseDate() +{ + std::locale locale; + boost::date_time::format_date_parser parser(L"", locale); + boost::date_time::special_values_parser svp; + + boost::gregorian::date date = parser.parse_date(L"", L"", svp); + (void)date; +} + + int main() { #ifdef BOOST_MSVC BOOST_STATIC_ASSERT((boost::is_same::value)); #endif + parseDate(); return ::boost::lexical_cast(L"1000") == 1000; } From 93ee01ab691d75bde4f16740158186bab5b38640 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 29 Mar 2012 16:48:31 +0000 Subject: [PATCH 111/138] Merge from trunk r77627 (merged lexical_cast optimizations for iterator_range<>, fixed performance regression, docs updated) [SVN r77628] --- doc/lexical_cast.qbk | 802 ++++++++++++---------- include/boost/lexical_cast.hpp | 108 ++- perf/performance_test.cpp | 15 + test/Jamfile.v2 | 1 + test/lexical_cast_iterator_range_test.cpp | 189 +++++ 5 files changed, 753 insertions(+), 362 deletions(-) create mode 100644 test/lexical_cast_iterator_range_test.cpp diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index 4ad8336..ffab311 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -115,6 +115,55 @@ Exception used to indicate runtime lexical_cast failure. [endsect] +[section Tuning classes for fast lexical conversions] +Because of `boost::lexical_cast` optimizations for `boost::iterator_range`, it is possibile to make very fast lexical conversions for non zero terminated strings, substrings and user-defined classes. + +Consider the following example: +`` + class example_class { + char non_zero_terminated_data[10]; + std::size_t data_length; + + public: + example_class(); + void fill_data(); + + const char* data() const { + return non_zero_terminated_data; + } + + std::size_t size() const { + return data_length; + } + }; + + inline std::ostream& operator << (std::ostream& ostr, const example_class& rhs) { + return ostr << boost::make_iterator_range(rhs.data(), rhs.data() + rhs.size()); + } +`` + +This is a good generic solution for most use cases. +But we can make it even faster for some performance critical applications. During conversion, we loose speed at: + +* `std::ostream` construction (it makes some heap allocations) +* `operator <<` (it copyies one by one all the symbols to an instance of `std::ostream`) +* `std::ostream` destruction (it makes some heap deallocations) + +We can avoid all of this, by specifieng an overload for `boost::lexical_cast`: +`` +namespace boost { + template + OutT lexical_cast(const example_class& rhs) { + return boost::lexical_cast( + boost::make_iterator_range(rhs.data(), rhs.data() + rhs.size()) + ); + } +} +`` +Now `boost::lexical_cast(example_class_instance)` conversions won't copy data and construct heavy STL stream objects. See [link boost_lexical_cast.performance Performance] section for info on `boost::iterator_range` conversion performance. +[endsect] + + [section Frequently Asked Questions] * [*Question:] Why does `lexical_cast("127")` throw `bad_lexical_cast`? @@ -175,6 +224,9 @@ limitation of compiler options that you use. , `"-inf"` (case insensitive) strings to get NaN and Inf values. `boost::lexical_cast` outputs `"-nan"`, `"nan"`, `"inf"`, `"-inf"` strings, when has NaN or Inf input values. +* [*Question:] What is the fastest way to convert a non zero terminated string or a substring using `boost::lexical_cast`? + * [*Answer:] Use `boost::iterator_range` for conversion. For example, if you whant to convert to `int` two characters from a string `str`, you shall write `lexacal_cast(make_iterator_range(str.c_str(), str.c_str() + 2));`. + [endsect] [section Changes] @@ -182,7 +234,8 @@ limitation of compiler options that you use. * `boost::bad_lexical_cast` exception is now globaly visible and can be catched even if code is compiled with -fvisibility=hidden. * Now it is possible to compile library with disabled exceptions. - + * Better performance, less memory usage and bugfixes for `boost::iterator_range` conversions. + * [*boost 1.49.0 :] * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). @@ -267,364 +320,415 @@ Do not use this results to compare compilers, because tests were taken on differ [/ BEGIN of section, generated by performance measuring program ] -[section clang-linux-2.8][table:id Performance Table (clang-linux-2.8) +[section Clang version 2.9 (tags/RELEASE_29/final)] +[table:id Performance Table ( Clang version 2.9 (tags/RELEASE_29/final)) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 148 ][ 14 ][ 12 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 97 ][ 8 ][ 7 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ 13 ]] -[[ string->int ][ !!! *4* !!! ][ 102 ][ 19 ][ 15 ]] -[[ string->short ][ !!! *4* !!! ][ 105 ][ 20 ][ 15 ]] -[[ string->long int ][ !!! *4* !!! ][ 105 ][ 19 ][ 15 ]] -[[ string->long long ][ !!! *4* !!! ][ 115 ][ 19 ][ 14 ]] -[[ string->unsigned int ][ !!! *4* !!! ][ 102 ][ 18 ][ 14 ]] -[[ string->unsigned short ][ !!! *4* !!! ][ 101 ][ 19 ][ 15 ]] -[[ string->unsigned long int ][ !!! *3* !!! ][ 107 ][ 20 ][ 14 ]] -[[ string->unsigned long long ][ !!! *3* !!! ][ 103 ][ 20 ][ 14 ]] -[[ string->bool ][ !!! *<1* !!! ][ 97 ][ 16 ][ 8 ]] -[[ string->float ][ !!! *21* !!! ][ 170 ][ 61 ][ 32 ]] -[[ string->double ][ !!! *18* !!! ][ 206 ][ 93 ][ 58 ]] -[[ string->long double ][ 135 ][ 221 ][ 94 ][ !!! *57* !!! ]] -[[ char->string ][ !!! *7* !!! ][ 100 ][ 17 ][ 13 ]] -[[ unsigned char->string ][ !!! *7* !!! ][ 99 ][ 18 ][ 16 ]] -[[ signed char->string ][ !!! *7* !!! ][ 101 ][ 17 ][ 12 ]] -[[ int->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 15 ]] -[[ short->string ][ !!! *13* !!! ][ 112 ][ 24 ][ 18 ]] -[[ long int->string ][ !!! *13* !!! ][ 119 ][ 23 ][ 17 ]] -[[ long long->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 18 ]] -[[ unsigned int->string ][ !!! *14* !!! ][ 113 ][ 24 ][ 17 ]] -[[ unsigned short->string ][ !!! *13* !!! ][ 108 ][ 24 ][ 17 ]] -[[ unsigned long int->string ][ !!! *13* !!! ][ 109 ][ 24 ][ 16 ]] -[[ unsigned long long->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 17 ]] -[[ bool->string ][ !!! *7* !!! ][ 105 ][ 24 ][ 12 ]] -[[ float->string ][ 70 ][ 192 ][ 94 ][ !!! *49* !!! ]] -[[ double->string ][ 106 ][ 217 ][ 122 ][ !!! *76* !!! ]] -[[ long double->string ][ 120 ][ 219 ][ 123 ][ !!! *80* !!! ]] -[[ char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 8 ]] -[[ char*->signed char ][ !!! *2* !!! ][ 87 ][ 10 ][ 7 ]] -[[ char*->unsigned char ][ !!! *3* !!! ][ 90 ][ 10 ][ 13 ]] -[[ char*->int ][ !!! *6* !!! ][ 107 ][ 21 ][ 15 ]] -[[ char*->short ][ !!! *6* !!! ][ 110 ][ 19 ][ 14 ]] -[[ char*->long int ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] -[[ char*->long long ][ !!! *7* !!! ][ 104 ][ 20 ][ 15 ]] -[[ char*->unsigned int ][ !!! *6* !!! ][ 101 ][ 20 ][ 15 ]] -[[ char*->unsigned short ][ !!! *7* !!! ][ 100 ][ 20 ][ 14 ]] -[[ char*->unsigned long int ][ !!! *6* !!! ][ 105 ][ 22 ][ 15 ]] -[[ char*->unsigned long long ][ !!! *7* !!! ][ 106 ][ 21 ][ 14 ]] -[[ char*->bool ][ !!! *2* !!! ][ 99 ][ 18 ][ 7 ]] -[[ char*->float ][ !!! *22* !!! ][ 159 ][ 67 ][ 33 ]] -[[ char*->double ][ !!! *20* !!! ][ 205 ][ 94 ][ 58 ]] -[[ char*->long double ][ 140 ][ 214 ][ 95 ][ !!! *58* !!! ]] -[[ unsigned char*->char ][ !!! *2* !!! ][ 92 ][ 9 ][ 7 ]] -[[ unsigned char*->signed char ][ !!! *2* !!! ][ 89 ][ 10 ][ 7 ]] -[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 89 ][ 10 ][ 14 ]] -[[ unsigned char*->int ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]] -[[ unsigned char*->short ][ !!! *6* !!! ][ 106 ][ 21 ][ 14 ]] -[[ unsigned char*->long int ][ !!! *6* !!! ][ 105 ][ 19 ][ 14 ]] -[[ unsigned char*->long long ][ !!! *6* !!! ][ 106 ][ 20 ][ 15 ]] -[[ unsigned char*->unsigned int ][ !!! *7* !!! ][ 105 ][ 19 ][ 14 ]] -[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] -[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 106 ][ 19 ][ 14 ]] -[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 21 ][ 15 ]] -[[ unsigned char*->bool ][ !!! *2* !!! ][ 102 ][ 18 ][ 7 ]] -[[ unsigned char*->float ][ !!! *23* !!! ][ 160 ][ 66 ][ 32 ]] -[[ unsigned char*->double ][ !!! *20* !!! ][ 201 ][ 95 ][ 58 ]] -[[ unsigned char*->long double ][ 144 ][ 221 ][ 95 ][ !!! *60* !!! ]] -[[ unsigned char*->string ][ !!! *12* !!! ][ 104 ][ 23 ][ --- ]] -[[ signed char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 7 ]] -[[ signed char*->signed char ][ !!! *2* !!! ][ 89 ][ 9 ][ 7 ]] -[[ signed char*->unsigned char ][ !!! *2* !!! ][ 89 ][ 10 ][ 13 ]] -[[ signed char*->int ][ !!! *6* !!! ][ 106 ][ 19 ][ 15 ]] -[[ signed char*->short ][ !!! *6* !!! ][ 107 ][ 20 ][ 15 ]] -[[ signed char*->long int ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] -[[ signed char*->long long ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] -[[ signed char*->unsigned int ][ !!! *6* !!! ][ 101 ][ 19 ][ 15 ]] -[[ signed char*->unsigned short ][ !!! *6* !!! ][ 101 ][ 19 ][ 16 ]] -[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 105 ][ 22 ][ 15 ]] -[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 21 ][ 15 ]] -[[ signed char*->bool ][ !!! *2* !!! ][ 100 ][ 18 ][ 7 ]] -[[ signed char*->float ][ !!! *23* !!! ][ 161 ][ 62 ][ 32 ]] -[[ signed char*->double ][ !!! *20* !!! ][ 207 ][ 102 ][ 57 ]] -[[ signed char*->long double ][ 144 ][ 216 ][ 96 ][ !!! *63* !!! ]] -[[ signed char*->string ][ !!! *12* !!! ][ 104 ][ 23 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 110 ][ 22 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 223 ][ 113 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 227 ][ 111 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 231 ][ 122 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 229 ][ 121 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 91 ][ 9 ][ --- ]] + [[ string->char ][ !!! *<1* !!! ][ 319 ][ 17 ][ 16 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 192 ][ 16 ][ 9 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 142 ][ 9 ][ 9 ]] + [[ string->int ][ !!! *7* !!! ][ 109 ][ 21 ][ 16 ]] + [[ string->short ][ !!! *6* !!! ][ 113 ][ 21 ][ 15 ]] + [[ string->long int ][ !!! *7* !!! ][ 110 ][ 22 ][ 15 ]] + [[ string->long long ][ !!! *7* !!! ][ 112 ][ 23 ][ 17 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 107 ][ 19 ][ 14 ]] + [[ string->unsigned short ][ !!! *6* !!! ][ 106 ][ 18 ][ 16 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 108 ][ 20 ][ 15 ]] + [[ string->unsigned long long ][ !!! *7* !!! ][ 109 ][ 22 ][ 15 ]] + [[ string->float ][ !!! *14* !!! ][ 204 ][ 81 ][ 43 ]] + [[ string->double ][ !!! *24* !!! ][ 244 ][ 74 ][ 45 ]] + [[ string->long double ][ 121 ][ 170 ][ 62 ][ !!! *38* !!! ]] + [[ string->string ][ !!! *1* !!! ][ 124 ][ 25 ][ --- ]] + [[ string->container::string ][ !!! *3* !!! ][ 121 ][ 28 ][ --- ]] + [[ string->char ][ 6 ][ 115 ][ 26 ][ !!! *6* !!! ]] + [[ string->signed char ][ !!! *6* !!! ][ 115 ][ 23 ][ 21 ]] + [[ string->unsigned char ][ !!! *6* !!! ][ 113 ][ 25 ][ 22 ]] + [[ int->string ][ !!! *12* !!! ][ 128 ][ 29 ][ 19 ]] + [[ short->string ][ !!! *12* !!! ][ 128 ][ 29 ][ 21 ]] + [[ long int->string ][ !!! *12* !!! ][ 132 ][ 29 ][ 21 ]] + [[ long long->string ][ !!! *12* !!! ][ 127 ][ 29 ][ 22 ]] + [[ unsigned int->string ][ !!! *12* !!! ][ 137 ][ 33 ][ 19 ]] + [[ unsigned short->string ][ !!! *12* !!! ][ 137 ][ 31 ][ 20 ]] + [[ unsigned long int->string ][ !!! *12* !!! ][ 136 ][ 30 ][ 21 ]] + [[ unsigned long long->string ][ !!! *12* !!! ][ 128 ][ 27 ][ 23 ]] + [[ float->string ][ 51 ][ 187 ][ 82 ][ !!! *44* !!! ]] + [[ double->string ][ 56 ][ 190 ][ 83 ][ !!! *42* !!! ]] + [[ long double->string ][ 69 ][ 208 ][ 90 ][ !!! *54* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 138 ][ 18 ][ 8 ]] + [[ char*->signed char ][ !!! *8* !!! ][ 126 ][ 10 ][ 9 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 9 ][ 9 ]] + [[ char*->int ][ !!! *8* !!! ][ 113 ][ 22 ][ 15 ]] + [[ char*->short ][ !!! *7* !!! ][ 113 ][ 22 ][ 17 ]] + [[ char*->long int ][ !!! *8* !!! ][ 111 ][ 23 ][ 15 ]] + [[ char*->long long ][ !!! *9* !!! ][ 112 ][ 24 ][ 18 ]] + [[ char*->unsigned int ][ !!! *8* !!! ][ 113 ][ 20 ][ 15 ]] + [[ char*->unsigned short ][ !!! *8* !!! ][ 113 ][ 20 ][ 15 ]] + [[ char*->unsigned long int ][ !!! *8* !!! ][ 112 ][ 21 ][ 16 ]] + [[ char*->unsigned long long ][ !!! *9* !!! ][ 110 ][ 23 ][ 14 ]] + [[ char*->float ][ !!! *14* !!! ][ 149 ][ 54 ][ 32 ]] + [[ char*->double ][ !!! *15* !!! ][ 166 ][ 59 ][ 33 ]] + [[ char*->long double ][ 122 ][ 171 ][ 63 ][ !!! *38* !!! ]] + [[ char*->string ][ !!! *7* !!! ][ 126 ][ 26 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 124 ][ 27 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 8 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 102 ][ 10 ][ 9 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 9 ]] + [[ unsigned char*->int ][ !!! *7* !!! ][ 115 ][ 24 ][ 15 ]] + [[ unsigned char*->short ][ !!! *7* !!! ][ 115 ][ 25 ][ 17 ]] + [[ unsigned char*->long int ][ !!! *8* !!! ][ 115 ][ 22 ][ 16 ]] + [[ unsigned char*->long long ][ !!! *8* !!! ][ 116 ][ 23 ][ 16 ]] + [[ unsigned char*->unsigned int ][ !!! *8* !!! ][ 113 ][ 20 ][ 14 ]] + [[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 114 ][ 21 ][ 15 ]] + [[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 21 ][ 14 ]] + [[ unsigned char*->unsigned long long ][ !!! *9* !!! ][ 112 ][ 23 ][ 16 ]] + [[ unsigned char*->float ][ !!! *14* !!! ][ 149 ][ 52 ][ 32 ]] + [[ unsigned char*->double ][ !!! *15* !!! ][ 165 ][ 59 ][ 33 ]] + [[ unsigned char*->long double ][ 122 ][ 172 ][ 63 ][ !!! *37* !!! ]] + [[ unsigned char*->string ][ !!! *8* !!! ][ 125 ][ 26 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *4* !!! ][ 119 ][ 26 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 8 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 95 ][ 10 ][ 9 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 9 ][ 9 ]] + [[ signed char*->int ][ !!! *8* !!! ][ 111 ][ 21 ][ 15 ]] + [[ signed char*->short ][ !!! *7* !!! ][ 114 ][ 22 ][ 16 ]] + [[ signed char*->long int ][ !!! *8* !!! ][ 113 ][ 22 ][ 17 ]] + [[ signed char*->long long ][ !!! *8* !!! ][ 116 ][ 24 ][ 17 ]] + [[ signed char*->unsigned int ][ !!! *8* !!! ][ 109 ][ 20 ][ 15 ]] + [[ signed char*->unsigned short ][ !!! *8* !!! ][ 111 ][ 20 ][ 14 ]] + [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 109 ][ 22 ][ 15 ]] + [[ signed char*->unsigned long long ][ !!! *8* !!! ][ 111 ][ 23 ][ 15 ]] + [[ signed char*->float ][ !!! *14* !!! ][ 150 ][ 53 ][ 32 ]] + [[ signed char*->double ][ !!! *15* !!! ][ 168 ][ 59 ][ 30 ]] + [[ signed char*->long double ][ 123 ][ 174 ][ 62 ][ !!! *37* !!! ]] + [[ signed char*->string ][ !!! *8* !!! ][ 127 ][ 28 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 124 ][ 27 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 8 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 107 ][ 13 ][ 9 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 121 ][ 26 ][ 13 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 165 ][ 33 ][ 23 ]] + [[ iterator_range->short ][ !!! *8* !!! ][ 175 ][ 34 ][ 29 ]] + [[ iterator_range->long int ][ !!! *14* !!! ][ 160 ][ 33 ][ 23 ]] + [[ iterator_range->long long ][ !!! *10* !!! ][ 199 ][ 35 ][ 28 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 131 ][ 24 ][ 16 ]] + [[ iterator_range->unsigned short ][ !!! *7* !!! ][ 110 ][ 22 ][ 16 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 111 ][ 22 ][ 14 ]] + [[ iterator_range->unsigned long long ][ !!! *8* !!! ][ 115 ][ 24 ][ 15 ]] + [[ iterator_range->float ][ !!! *13* !!! ][ 134 ][ 40 ][ 33 ]] + [[ iterator_range->double ][ !!! *15* !!! ][ 140 ][ 59 ][ 41 ]] + [[ iterator_range->long double ][ 131 ][ 146 ][ 53 ][ !!! *38* !!! ]] + [[ iterator_range->string ][ !!! *9* !!! ][ 121 ][ 31 ][ --- ]] + [[ iterator_range->container::string ][ !!! *4* !!! ][ 115 ][ 25 ][ --- ]] + [[ int->int ][ !!! *<1* !!! ][ 113 ][ 25 ][ --- ]] + [[ float->double ][ !!! *<1* !!! ][ 234 ][ 117 ][ --- ]] + [[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ --- ]] ] [endsect] -[section gcc-4.4][table:id Performance Table (gcc-4.4) + +[section GNU C++ version 4.6.1] +[table:id Performance Table ( GNU C++ version 4.6.1) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 90 ][ 7 ][ 7 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 88 ][ 7 ][ 8 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 88 ][ 8 ][ 14 ]] -[[ string->int ][ !!! *3* !!! ][ 103 ][ 18 ][ 15 ]] -[[ string->short ][ !!! *3* !!! ][ 105 ][ 20 ][ 15 ]] -[[ string->long int ][ !!! *3* !!! ][ 101 ][ 18 ][ 16 ]] -[[ string->long long ][ !!! *3* !!! ][ 101 ][ 18 ][ 15 ]] -[[ string->unsigned int ][ !!! *3* !!! ][ 98 ][ 23 ][ 14 ]] -[[ string->unsigned short ][ !!! *3* !!! ][ 100 ][ 17 ][ 14 ]] -[[ string->unsigned long int ][ !!! *3* !!! ][ 100 ][ 21 ][ 15 ]] -[[ string->unsigned long long ][ !!! *3* !!! ][ 99 ][ 19 ][ 15 ]] -[[ string->bool ][ !!! *<1* !!! ][ 95 ][ 16 ][ 8 ]] -[[ string->float ][ !!! *13* !!! ][ 160 ][ 61 ][ 33 ]] -[[ string->double ][ !!! *14* !!! ][ 206 ][ 93 ][ 59 ]] -[[ string->long double ][ 128 ][ 217 ][ 96 ][ !!! *61* !!! ]] -[[ char->string ][ !!! *7* !!! ][ 100 ][ 17 ][ 12 ]] -[[ unsigned char->string ][ !!! *7* !!! ][ 109 ][ 17 ][ 16 ]] -[[ signed char->string ][ !!! *7* !!! ][ 99 ][ 17 ][ 12 ]] -[[ int->string ][ !!! *13* !!! ][ 110 ][ 21 ][ 15 ]] -[[ short->string ][ !!! *14* !!! ][ 110 ][ 22 ][ 17 ]] -[[ long int->string ][ !!! *14* !!! ][ 109 ][ 21 ][ 16 ]] -[[ long long->string ][ !!! *13* !!! ][ 114 ][ 20 ][ 17 ]] -[[ unsigned int->string ][ !!! *13* !!! ][ 109 ][ 23 ][ 15 ]] -[[ unsigned short->string ][ !!! *14* !!! ][ 109 ][ 23 ][ 17 ]] -[[ unsigned long int->string ][ !!! *13* !!! ][ 112 ][ 23 ][ 16 ]] -[[ unsigned long long->string ][ !!! *14* !!! ][ 109 ][ 21 ][ 17 ]] -[[ bool->string ][ !!! *7* !!! ][ 108 ][ 23 ][ 11 ]] -[[ float->string ][ 63 ][ 185 ][ 92 ][ !!! *50* !!! ]] -[[ double->string ][ 106 ][ 216 ][ 116 ][ !!! *75* !!! ]] -[[ long double->string ][ 118 ][ 219 ][ 119 ][ !!! *80* !!! ]] -[[ char*->char ][ !!! *1* !!! ][ 93 ][ 9 ][ 9 ]] -[[ char*->signed char ][ !!! *1* !!! ][ 92 ][ 9 ][ 9 ]] -[[ char*->unsigned char ][ !!! *1* !!! ][ 92 ][ 9 ][ 14 ]] -[[ char*->int ][ !!! *4* !!! ][ 107 ][ 19 ][ 15 ]] -[[ char*->short ][ !!! *5* !!! ][ 109 ][ 19 ][ 15 ]] -[[ char*->long int ][ !!! *4* !!! ][ 113 ][ 19 ][ 15 ]] -[[ char*->long long ][ !!! *4* !!! ][ 108 ][ 20 ][ 15 ]] -[[ char*->unsigned int ][ !!! *4* !!! ][ 106 ][ 19 ][ 15 ]] -[[ char*->unsigned short ][ !!! *4* !!! ][ 106 ][ 18 ][ 15 ]] -[[ char*->unsigned long int ][ !!! *4* !!! ][ 103 ][ 22 ][ 15 ]] -[[ char*->unsigned long long ][ !!! *4* !!! ][ 105 ][ 20 ][ 15 ]] -[[ char*->bool ][ !!! *1* !!! ][ 104 ][ 18 ][ 8 ]] -[[ char*->float ][ !!! *15* !!! ][ 164 ][ 62 ][ 33 ]] -[[ char*->double ][ !!! *16* !!! ][ 203 ][ 97 ][ 58 ]] -[[ char*->long double ][ 132 ][ 223 ][ 98 ][ !!! *60* !!! ]] -[[ unsigned char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 8 ]] -[[ unsigned char*->signed char ][ !!! *2* !!! ][ 92 ][ 10 ][ 8 ]] -[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 91 ][ 9 ][ 14 ]] -[[ unsigned char*->int ][ !!! *6* !!! ][ 106 ][ 20 ][ 15 ]] -[[ unsigned char*->short ][ !!! *6* !!! ][ 106 ][ 21 ][ 15 ]] -[[ unsigned char*->long int ][ !!! *6* !!! ][ 111 ][ 19 ][ 15 ]] -[[ unsigned char*->long long ][ !!! *6* !!! ][ 107 ][ 20 ][ 15 ]] -[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 105 ][ 19 ][ 15 ]] -[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 103 ][ 18 ][ 15 ]] -[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 106 ][ 22 ][ 14 ]] -[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 105 ][ 20 ][ 14 ]] -[[ unsigned char*->bool ][ !!! *2* !!! ][ 106 ][ 18 ][ 8 ]] -[[ unsigned char*->float ][ !!! *15* !!! ][ 167 ][ 68 ][ 33 ]] -[[ unsigned char*->double ][ !!! *17* !!! ][ 203 ][ 99 ][ 58 ]] -[[ unsigned char*->long double ][ 129 ][ 216 ][ 97 ][ !!! *61* !!! ]] -[[ unsigned char*->string ][ !!! *13* !!! ][ 111 ][ 23 ][ --- ]] -[[ signed char*->char ][ !!! *2* !!! ][ 92 ][ 9 ][ 8 ]] -[[ signed char*->signed char ][ !!! *2* !!! ][ 91 ][ 9 ][ 8 ]] -[[ signed char*->unsigned char ][ !!! *2* !!! ][ 91 ][ 9 ][ 14 ]] -[[ signed char*->int ][ !!! *6* !!! ][ 107 ][ 19 ][ 15 ]] -[[ signed char*->short ][ !!! *6* !!! ][ 109 ][ 24 ][ 14 ]] -[[ signed char*->long int ][ !!! *6* !!! ][ 112 ][ 19 ][ 15 ]] -[[ signed char*->long long ][ !!! *5* !!! ][ 107 ][ 20 ][ 15 ]] -[[ signed char*->unsigned int ][ !!! *6* !!! ][ 108 ][ 20 ][ 15 ]] -[[ signed char*->unsigned short ][ !!! *6* !!! ][ 104 ][ 18 ][ 15 ]] -[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 22 ][ 15 ]] -[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 20 ][ 15 ]] -[[ signed char*->bool ][ !!! *2* !!! ][ 104 ][ 18 ][ 8 ]] -[[ signed char*->float ][ !!! *16* !!! ][ 165 ][ 63 ][ 33 ]] -[[ signed char*->double ][ !!! *16* !!! ][ 203 ][ 98 ][ 59 ]] -[[ signed char*->long double ][ 129 ][ 215 ][ 98 ][ !!! *61* !!! ]] -[[ signed char*->string ][ !!! *13* !!! ][ 109 ][ 21 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 109 ][ 21 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 221 ][ 102 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 223 ][ 103 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 231 ][ 115 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 231 ][ 115 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 92 ][ 8 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 88 ][ 7 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] + [[ string->char ][ !!! *<1* !!! ][ 140 ][ 17 ][ 13 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 129 ][ 8 ][ 10 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 10 ]] + [[ string->int ][ !!! *6* !!! ][ 110 ][ 20 ][ 14 ]] + [[ string->short ][ !!! *5* !!! ][ 106 ][ 20 ][ 14 ]] + [[ string->long int ][ !!! *7* !!! ][ 107 ][ 22 ][ 14 ]] + [[ string->long long ][ !!! *7* !!! ][ 112 ][ 21 ][ 14 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 110 ][ 20 ][ 14 ]] + [[ string->unsigned short ][ !!! *5* !!! ][ 107 ][ 18 ][ 14 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 108 ][ 23 ][ 14 ]] + [[ string->unsigned long long ][ !!! *7* !!! ][ 108 ][ 21 ][ 14 ]] + [[ string->float ][ !!! *12* !!! ][ 154 ][ 57 ][ 32 ]] + [[ string->double ][ !!! *11* !!! ][ 151 ][ 61 ][ 33 ]] + [[ string->long double ][ 109 ][ 187 ][ 79 ][ !!! *55* !!! ]] + [[ string->string ][ !!! *2* !!! ][ 122 ][ 27 ][ --- ]] + [[ string->container::string ][ !!! *3* !!! ][ 123 ][ 22 ][ --- ]] + [[ string->char ][ !!! *7* !!! ][ 109 ][ 27 ][ 17 ]] + [[ string->signed char ][ !!! *7* !!! ][ 110 ][ 25 ][ 22 ]] + [[ string->unsigned char ][ !!! *7* !!! ][ 112 ][ 27 ][ 24 ]] + [[ int->string ][ !!! *12* !!! ][ 187 ][ 48 ][ 37 ]] + [[ short->string ][ !!! *18* !!! ][ 133 ][ 33 ][ 20 ]] + [[ long int->string ][ !!! *12* !!! ][ 129 ][ 32 ][ 21 ]] + [[ long long->string ][ !!! *12* !!! ][ 127 ][ 35 ][ 23 ]] + [[ unsigned int->string ][ !!! *15* !!! ][ 133 ][ 31 ][ 21 ]] + [[ unsigned short->string ][ !!! *12* !!! ][ 133 ][ 31 ][ 21 ]] + [[ unsigned long int->string ][ !!! *12* !!! ][ 132 ][ 31 ][ 21 ]] + [[ unsigned long long->string ][ !!! *12* !!! ][ 127 ][ 29 ][ 24 ]] + [[ float->string ][ 53 ][ 215 ][ 103 ][ !!! *40* !!! ]] + [[ double->string ][ 58 ][ 215 ][ 103 ][ !!! *41* !!! ]] + [[ long double->string ][ 67 ][ 227 ][ 112 ][ !!! *45* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 132 ][ 12 ][ 8 ]] + [[ char*->signed char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 9 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 96 ][ 10 ][ 9 ]] + [[ char*->int ][ !!! *6* !!! ][ 109 ][ 22 ][ 14 ]] + [[ char*->short ][ !!! *5* !!! ][ 109 ][ 26 ][ 14 ]] + [[ char*->long int ][ !!! *7* !!! ][ 111 ][ 23 ][ 14 ]] + [[ char*->long long ][ !!! *8* !!! ][ 112 ][ 25 ][ 16 ]] + [[ char*->unsigned int ][ !!! *6* !!! ][ 113 ][ 19 ][ 14 ]] + [[ char*->unsigned short ][ !!! *6* !!! ][ 111 ][ 20 ][ 14 ]] + [[ char*->unsigned long int ][ !!! *7* !!! ][ 109 ][ 21 ][ 14 ]] + [[ char*->unsigned long long ][ !!! *7* !!! ][ 111 ][ 22 ][ 14 ]] + [[ char*->float ][ !!! *12* !!! ][ 156 ][ 62 ][ 32 ]] + [[ char*->double ][ !!! *13* !!! ][ 156 ][ 65 ][ 33 ]] + [[ char*->long double ][ 108 ][ 156 ][ 59 ][ !!! *36* !!! ]] + [[ char*->string ][ !!! *7* !!! ][ 123 ][ 29 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 116 ][ 24 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 96 ][ 12 ][ 8 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ 9 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 93 ][ 10 ][ 9 ]] + [[ unsigned char*->int ][ !!! *6* !!! ][ 110 ][ 22 ][ 14 ]] + [[ unsigned char*->short ][ !!! *6* !!! ][ 111 ][ 22 ][ 15 ]] + [[ unsigned char*->long int ][ !!! *8* !!! ][ 110 ][ 23 ][ 14 ]] + [[ unsigned char*->long long ][ !!! *7* !!! ][ 111 ][ 25 ][ 14 ]] + [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 111 ][ 21 ][ 16 ]] + [[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 110 ][ 21 ][ 15 ]] + [[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 21 ][ 14 ]] + [[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 108 ][ 23 ][ 15 ]] + [[ unsigned char*->float ][ !!! *12* !!! ][ 154 ][ 62 ][ 33 ]] + [[ unsigned char*->double ][ !!! *14* !!! ][ 157 ][ 65 ][ 32 ]] + [[ unsigned char*->long double ][ 107 ][ 154 ][ 56 ][ !!! *36* !!! ]] + [[ unsigned char*->string ][ !!! *9* !!! ][ 122 ][ 28 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *4* !!! ][ 118 ][ 26 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 94 ][ 10 ][ 8 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 94 ][ 12 ][ 9 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 95 ][ 12 ][ 9 ]] + [[ signed char*->int ][ !!! *7* !!! ][ 109 ][ 22 ][ 14 ]] + [[ signed char*->short ][ !!! *5* !!! ][ 108 ][ 22 ][ 14 ]] + [[ signed char*->long int ][ !!! *7* !!! ][ 110 ][ 23 ][ 14 ]] + [[ signed char*->long long ][ !!! *7* !!! ][ 110 ][ 25 ][ 15 ]] + [[ signed char*->unsigned int ][ !!! *6* !!! ][ 109 ][ 20 ][ 15 ]] + [[ signed char*->unsigned short ][ !!! *6* !!! ][ 107 ][ 21 ][ 14 ]] + [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 111 ][ 21 ][ 14 ]] + [[ signed char*->unsigned long long ][ !!! *7* !!! ][ 109 ][ 23 ][ 14 ]] + [[ signed char*->float ][ !!! *12* !!! ][ 156 ][ 61 ][ 31 ]] + [[ signed char*->double ][ !!! *13* !!! ][ 156 ][ 68 ][ 33 ]] + [[ signed char*->long double ][ 109 ][ 159 ][ 56 ][ !!! *36* !!! ]] + [[ signed char*->string ][ !!! *9* !!! ][ 123 ][ 28 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 125 ][ 25 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 100 ][ 13 ][ 8 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 98 ][ 14 ][ 9 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 99 ][ 12 ][ 10 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 108 ][ 21 ][ 16 ]] + [[ iterator_range->short ][ !!! *5* !!! ][ 110 ][ 22 ][ 17 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 107 ][ 22 ][ 15 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 110 ][ 27 ][ 15 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 107 ][ 24 ][ 15 ]] + [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 106 ][ 21 ][ 15 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 110 ][ 21 ][ 16 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 109 ][ 23 ][ 16 ]] + [[ iterator_range->float ][ !!! *11* !!! ][ 137 ][ 46 ][ 33 ]] + [[ iterator_range->double ][ !!! *11* !!! ][ 131 ][ 50 ][ 33 ]] + [[ iterator_range->long double ][ 107 ][ 136 ][ 44 ][ !!! *39* !!! ]] + [[ iterator_range->string ][ !!! *8* !!! ][ 117 ][ 32 ][ --- ]] + [[ iterator_range->container::string ][ !!! *3* !!! ][ 111 ][ 23 ][ --- ]] + [[ int->int ][ !!! *<1* !!! ][ 110 ][ 33 ][ --- ]] + [[ float->double ][ !!! *<1* !!! ][ 241 ][ 152 ][ --- ]] + [[ char->signed char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]] ] [endsect] -[section gcc-4.5][table:id Performance Table (gcc-4.5) + +[section GNU C++ version 4.5.4] +[table:id Performance Table ( GNU C++ version 4.5.4) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 7 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 7 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ 13 ]] -[[ string->int ][ !!! *3* !!! ][ 100 ][ 20 ][ 14 ]] -[[ string->short ][ !!! *3* !!! ][ 106 ][ 20 ][ 14 ]] -[[ string->long int ][ !!! *3* !!! ][ 100 ][ 18 ][ 14 ]] -[[ string->long long ][ !!! *9* !!! ][ 100 ][ 18 ][ 15 ]] -[[ string->unsigned int ][ !!! *3* !!! ][ 97 ][ 20 ][ 14 ]] -[[ string->unsigned short ][ !!! *3* !!! ][ 102 ][ 17 ][ 14 ]] -[[ string->unsigned long int ][ !!! *3* !!! ][ 97 ][ 21 ][ 14 ]] -[[ string->unsigned long long ][ !!! *3* !!! ][ 97 ][ 19 ][ 14 ]] -[[ string->bool ][ !!! *<1* !!! ][ 95 ][ 16 ][ 7 ]] -[[ string->float ][ !!! *15* !!! ][ 157 ][ 63 ][ 32 ]] -[[ string->double ][ !!! *17* !!! ][ 203 ][ 95 ][ 59 ]] -[[ string->long double ][ 129 ][ 216 ][ 93 ][ !!! *58* !!! ]] -[[ char->string ][ !!! *8* !!! ][ 100 ][ 17 ][ 10 ]] -[[ unsigned char->string ][ !!! *8* !!! ][ 96 ][ 18 ][ 16 ]] -[[ signed char->string ][ !!! *8* !!! ][ 96 ][ 18 ][ 10 ]] -[[ int->string ][ !!! *14* !!! ][ 105 ][ 22 ][ 15 ]] -[[ short->string ][ !!! *14* !!! ][ 107 ][ 23 ][ 17 ]] -[[ long int->string ][ !!! *14* !!! ][ 109 ][ 22 ][ 17 ]] -[[ long long->string ][ !!! *14* !!! ][ 105 ][ 22 ][ 18 ]] -[[ unsigned int->string ][ !!! *14* !!! ][ 105 ][ 25 ][ 15 ]] -[[ unsigned short->string ][ !!! *15* !!! ][ 105 ][ 23 ][ 17 ]] -[[ unsigned long int->string ][ !!! *14* !!! ][ 109 ][ 24 ][ 17 ]] -[[ unsigned long long->string ][ !!! *14* !!! ][ 102 ][ 23 ][ 17 ]] -[[ bool->string ][ !!! *8* !!! ][ 104 ][ 23 ][ 12 ]] -[[ float->string ][ 66 ][ 181 ][ 92 ][ !!! *49* !!! ]] -[[ double->string ][ 107 ][ 215 ][ 120 ][ !!! *75* !!! ]] -[[ long double->string ][ 117 ][ 221 ][ 125 ][ !!! *79* !!! ]] -[[ char*->char ][ !!! *1* !!! ][ 89 ][ 9 ][ 7 ]] -[[ char*->signed char ][ !!! *1* !!! ][ 90 ][ 9 ][ 7 ]] -[[ char*->unsigned char ][ !!! *2* !!! ][ 90 ][ 9 ][ 13 ]] -[[ char*->int ][ !!! *7* !!! ][ 103 ][ 20 ][ 15 ]] -[[ char*->short ][ !!! *6* !!! ][ 102 ][ 29 ][ 14 ]] -[[ char*->long int ][ !!! *7* !!! ][ 101 ][ 20 ][ 15 ]] -[[ char*->long long ][ !!! *6* !!! ][ 102 ][ 20 ][ 14 ]] -[[ char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 19 ][ 14 ]] -[[ char*->unsigned short ][ !!! *6* !!! ][ 101 ][ 18 ][ 14 ]] -[[ char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 22 ][ 14 ]] -[[ char*->unsigned long long ][ !!! *6* !!! ][ 101 ][ 21 ][ 14 ]] -[[ char*->bool ][ !!! *3* !!! ][ 98 ][ 18 ][ 7 ]] -[[ char*->float ][ !!! *18* !!! ][ 162 ][ 63 ][ 31 ]] -[[ char*->double ][ !!! *17* !!! ][ 203 ][ 96 ][ 58 ]] -[[ char*->long double ][ 135 ][ 214 ][ 98 ][ !!! *58* !!! ]] -[[ unsigned char*->char ][ !!! *2* !!! ][ 87 ][ 9 ][ 7 ]] -[[ unsigned char*->signed char ][ !!! *2* !!! ][ 87 ][ 9 ][ 7 ]] -[[ unsigned char*->unsigned char ][ !!! *3* !!! ][ 87 ][ 9 ][ 13 ]] -[[ unsigned char*->int ][ !!! *6* !!! ][ 105 ][ 20 ][ 14 ]] -[[ unsigned char*->short ][ !!! *6* !!! ][ 102 ][ 21 ][ 14 ]] -[[ unsigned char*->long int ][ !!! *6* !!! ][ 101 ][ 20 ][ 14 ]] -[[ unsigned char*->long long ][ !!! *6* !!! ][ 102 ][ 20 ][ 14 ]] -[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 19 ][ 14 ]] -[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 100 ][ 18 ][ 14 ]] -[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 101 ][ 24 ][ 14 ]] -[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 100 ][ 20 ][ 14 ]] -[[ unsigned char*->bool ][ !!! *3* !!! ][ 99 ][ 18 ][ 8 ]] -[[ unsigned char*->float ][ !!! *17* !!! ][ 164 ][ 64 ][ 32 ]] -[[ unsigned char*->double ][ !!! *18* !!! ][ 201 ][ 94 ][ 58 ]] -[[ unsigned char*->long double ][ 133 ][ 217 ][ 95 ][ !!! *60* !!! ]] -[[ unsigned char*->string ][ !!! *14* !!! ][ 103 ][ 23 ][ --- ]] -[[ signed char*->char ][ !!! *3* !!! ][ 88 ][ 10 ][ 8 ]] -[[ signed char*->signed char ][ !!! *2* !!! ][ 87 ][ 10 ][ 7 ]] -[[ signed char*->unsigned char ][ !!! *3* !!! ][ 87 ][ 9 ][ 13 ]] -[[ signed char*->int ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]] -[[ signed char*->short ][ !!! *6* !!! ][ 105 ][ 21 ][ 14 ]] -[[ signed char*->long int ][ !!! *6* !!! ][ 104 ][ 20 ][ 15 ]] -[[ signed char*->long long ][ !!! *6* !!! ][ 106 ][ 20 ][ 14 ]] -[[ signed char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 20 ][ 14 ]] -[[ signed char*->unsigned short ][ !!! *6* !!! ][ 100 ][ 18 ][ 14 ]] -[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 23 ][ 14 ]] -[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 103 ][ 20 ][ 14 ]] -[[ signed char*->bool ][ !!! *3* !!! ][ 99 ][ 18 ][ 7 ]] -[[ signed char*->float ][ !!! *18* !!! ][ 159 ][ 60 ][ 32 ]] -[[ signed char*->double ][ !!! *18* !!! ][ 203 ][ 95 ][ 57 ]] -[[ signed char*->long double ][ 129 ][ 213 ][ 97 ][ !!! *56* !!! ]] -[[ signed char*->string ][ !!! *14* !!! ][ 105 ][ 22 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 109 ][ 22 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 226 ][ 104 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 229 ][ 103 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 225 ][ 115 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 227 ][ 115 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 84 ][ 8 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] + [[ string->char ][ !!! *<1* !!! ][ 147 ][ 12 ][ 8 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 138 ][ 13 ][ 10 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 86 ][ 12 ][ 9 ]] + [[ string->int ][ !!! *7* !!! ][ 103 ][ 20 ][ 15 ]] + [[ string->short ][ !!! *5* !!! ][ 103 ][ 20 ][ 15 ]] + [[ string->long int ][ !!! *7* !!! ][ 103 ][ 22 ][ 15 ]] + [[ string->long long ][ !!! *7* !!! ][ 104 ][ 22 ][ 16 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 108 ][ 19 ][ 15 ]] + [[ string->unsigned short ][ !!! *5* !!! ][ 104 ][ 19 ][ 15 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 103 ][ 20 ][ 16 ]] + [[ string->unsigned long long ][ !!! *7* !!! ][ 101 ][ 22 ][ 14 ]] + [[ string->float ][ !!! *13* !!! ][ 148 ][ 58 ][ 35 ]] + [[ string->double ][ !!! *13* !!! ][ 147 ][ 60 ][ 34 ]] + [[ string->long double ][ 103 ][ 149 ][ 56 ][ !!! *38* !!! ]] + [[ string->string ][ !!! *2* !!! ][ 127 ][ 27 ][ --- ]] + [[ string->container::string ][ !!! *3* !!! ][ 101 ][ 24 ][ --- ]] + [[ string->char ][ !!! *7* !!! ][ 108 ][ 35 ][ 17 ]] + [[ string->signed char ][ !!! *7* !!! ][ 112 ][ 26 ][ 23 ]] + [[ string->unsigned char ][ !!! *7* !!! ][ 113 ][ 25 ][ 25 ]] + [[ int->string ][ !!! *11* !!! ][ 183 ][ 47 ][ 40 ]] + [[ short->string ][ !!! *14* !!! ][ 153 ][ 35 ][ 23 ]] + [[ long int->string ][ !!! *12* !!! ][ 135 ][ 32 ][ 22 ]] + [[ long long->string ][ !!! *11* !!! ][ 131 ][ 30 ][ 24 ]] + [[ unsigned int->string ][ !!! *12* !!! ][ 137 ][ 31 ][ 22 ]] + [[ unsigned short->string ][ !!! *11* !!! ][ 137 ][ 33 ][ 22 ]] + [[ unsigned long int->string ][ !!! *11* !!! ][ 136 ][ 36 ][ 23 ]] + [[ unsigned long long->string ][ !!! *11* !!! ][ 127 ][ 29 ][ 23 ]] + [[ float->string ][ 56 ][ 218 ][ 107 ][ !!! *44* !!! ]] + [[ double->string ][ 63 ][ 223 ][ 106 ][ !!! *44* !!! ]] + [[ long double->string ][ 69 ][ 229 ][ 118 ][ !!! *49* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 91 ][ 12 ][ 9 ]] + [[ char*->signed char ][ !!! *<1* !!! ][ 100 ][ 11 ][ 11 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 97 ][ 12 ][ 10 ]] + [[ char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]] + [[ char*->short ][ !!! *6* !!! ][ 116 ][ 23 ][ 16 ]] + [[ char*->long int ][ !!! *8* !!! ][ 113 ][ 23 ][ 16 ]] + [[ char*->long long ][ !!! *8* !!! ][ 122 ][ 28 ][ 16 ]] + [[ char*->unsigned int ][ !!! *6* !!! ][ 117 ][ 21 ][ 15 ]] + [[ char*->unsigned short ][ !!! *6* !!! ][ 113 ][ 21 ][ 16 ]] + [[ char*->unsigned long int ][ !!! *7* !!! ][ 118 ][ 22 ][ 16 ]] + [[ char*->unsigned long long ][ !!! *8* !!! ][ 113 ][ 22 ][ 17 ]] + [[ char*->float ][ !!! *11* !!! ][ 164 ][ 67 ][ 34 ]] + [[ char*->double ][ !!! *13* !!! ][ 163 ][ 66 ][ 35 ]] + [[ char*->long double ][ 110 ][ 164 ][ 63 ][ !!! *39* !!! ]] + [[ char*->string ][ !!! *8* !!! ][ 130 ][ 30 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 113 ][ 24 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 10 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 97 ][ 12 ][ 10 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 97 ][ 11 ][ 10 ]] + [[ unsigned char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]] + [[ unsigned char*->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 20 ]] + [[ unsigned char*->long int ][ !!! *8* !!! ][ 112 ][ 23 ][ 15 ]] + [[ unsigned char*->long long ][ !!! *8* !!! ][ 115 ][ 29 ][ 17 ]] + [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 21 ][ 14 ]] + [[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 112 ][ 22 ][ 15 ]] + [[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 115 ][ 23 ][ 14 ]] + [[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 112 ][ 24 ][ 15 ]] + [[ unsigned char*->float ][ !!! *12* !!! ][ 161 ][ 66 ][ 34 ]] + [[ unsigned char*->double ][ !!! *13* !!! ][ 162 ][ 66 ][ 36 ]] + [[ unsigned char*->long double ][ 112 ][ 161 ][ 63 ][ !!! *39* !!! ]] + [[ unsigned char*->string ][ !!! *9* !!! ][ 127 ][ 29 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *4* !!! ][ 111 ][ 25 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 104 ][ 11 ][ 8 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 11 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 11 ]] + [[ signed char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]] + [[ signed char*->short ][ !!! *7* !!! ][ 113 ][ 23 ][ 15 ]] + [[ signed char*->long int ][ !!! *8* !!! ][ 112 ][ 22 ][ 14 ]] + [[ signed char*->long long ][ !!! *8* !!! ][ 115 ][ 25 ][ 16 ]] + [[ signed char*->unsigned int ][ !!! *8* !!! ][ 114 ][ 21 ][ 18 ]] + [[ signed char*->unsigned short ][ !!! *6* !!! ][ 112 ][ 22 ][ 15 ]] + [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 116 ][ 22 ][ 15 ]] + [[ signed char*->unsigned long long ][ !!! *8* !!! ][ 113 ][ 23 ][ 16 ]] + [[ signed char*->float ][ !!! *13* !!! ][ 161 ][ 65 ][ 34 ]] + [[ signed char*->double ][ !!! *12* !!! ][ 172 ][ 67 ][ 34 ]] + [[ signed char*->long double ][ 110 ][ 164 ][ 63 ][ !!! *38* !!! ]] + [[ signed char*->string ][ !!! *9* !!! ][ 131 ][ 30 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 112 ][ 24 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 12 ][ 8 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 101 ][ 13 ][ 9 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 10 ]] + [[ iterator_range->int ][ !!! *7* !!! ][ 113 ][ 26 ][ 14 ]] + [[ iterator_range->short ][ !!! *5* !!! ][ 115 ][ 21 ][ 16 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 115 ][ 22 ][ 15 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 116 ][ 25 ][ 16 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 115 ][ 24 ][ 23 ]] + [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 113 ][ 22 ][ 16 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 117 ][ 20 ][ 16 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 114 ][ 21 ][ 16 ]] + [[ iterator_range->float ][ !!! *11* !!! ][ 145 ][ 51 ][ 34 ]] + [[ iterator_range->double ][ !!! *11* !!! ][ 139 ][ 53 ][ 35 ]] + [[ iterator_range->long double ][ 109 ][ 147 ][ 44 ][ !!! *38* !!! ]] + [[ iterator_range->string ][ !!! *9* !!! ][ 123 ][ 36 ][ --- ]] + [[ iterator_range->container::string ][ !!! *3* !!! ][ 113 ][ 20 ][ --- ]] + [[ int->int ][ !!! *<1* !!! ][ 117 ][ 23 ][ --- ]] + [[ float->double ][ !!! *<1* !!! ][ 262 ][ 150 ][ --- ]] + [[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ --- ]] ] [endsect] -[section gcc-4.6][table:id Performance Table (gcc-4.6) + +[section GNU C++ version 4.4.6] +[table:id Performance Table ( GNU C++ version 4.4.6) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 7 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 96 ][ 9 ][ 7 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 96 ][ 8 ][ 13 ]] -[[ string->int ][ !!! *3* !!! ][ 110 ][ 18 ][ 16 ]] -[[ string->short ][ !!! *3* !!! ][ 111 ][ 18 ][ 16 ]] -[[ string->long int ][ !!! *3* !!! ][ 109 ][ 18 ][ 15 ]] -[[ string->long long ][ !!! *3* !!! ][ 111 ][ 18 ][ 15 ]] -[[ string->unsigned int ][ !!! *3* !!! ][ 110 ][ 20 ][ 15 ]] -[[ string->unsigned short ][ !!! *3* !!! ][ 111 ][ 18 ][ 15 ]] -[[ string->unsigned long int ][ !!! *3* !!! ][ 109 ][ 18 ][ 15 ]] -[[ string->unsigned long long ][ !!! *3* !!! ][ 114 ][ 19 ][ 15 ]] -[[ string->bool ][ !!! *<1* !!! ][ 106 ][ 17 ][ 8 ]] -[[ string->float ][ !!! *13* !!! ][ 175 ][ 70 ][ 33 ]] -[[ string->double ][ !!! *14* !!! ][ 182 ][ 81 ][ 58 ]] -[[ string->long double ][ 118 ][ 190 ][ 87 ][ !!! *58* !!! ]] -[[ char->string ][ !!! *8* !!! ][ 118 ][ 21 ][ 12 ]] -[[ unsigned char->string ][ !!! *8* !!! ][ 109 ][ 18 ][ 16 ]] -[[ signed char->string ][ !!! *8* !!! ][ 108 ][ 18 ][ 12 ]] -[[ int->string ][ 20 ][ 121 ][ 21 ][ !!! *16* !!! ]] -[[ short->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 17 ]] -[[ long int->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 16 ]] -[[ long long->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 17 ]] -[[ unsigned int->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 16 ]] -[[ unsigned short->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 18 ]] -[[ unsigned long int->string ][ 16 ][ 118 ][ 22 ][ !!! *15* !!! ]] -[[ unsigned long long->string ][ !!! *15* !!! ][ 117 ][ 21 ][ 17 ]] -[[ bool->string ][ !!! *8* !!! ][ 117 ][ 23 ][ 10 ]] -[[ float->string ][ 77 ][ 218 ][ 105 ][ !!! *50* !!! ]] -[[ double->string ][ 108 ][ 247 ][ 129 ][ !!! *73* !!! ]] -[[ long double->string ][ 120 ][ 250 ][ 131 ][ !!! *79* !!! ]] -[[ char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 7 ]] -[[ char*->signed char ][ !!! *2* !!! ][ 98 ][ 9 ][ 8 ]] -[[ char*->unsigned char ][ !!! *2* !!! ][ 98 ][ 9 ][ 13 ]] -[[ char*->int ][ !!! *6* !!! ][ 115 ][ 22 ][ 15 ]] -[[ char*->short ][ !!! *6* !!! ][ 114 ][ 22 ][ 15 ]] -[[ char*->long int ][ !!! *6* !!! ][ 114 ][ 22 ][ 16 ]] -[[ char*->long long ][ !!! *6* !!! ][ 119 ][ 22 ][ 15 ]] -[[ char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 20 ][ 15 ]] -[[ char*->unsigned short ][ !!! *6* !!! ][ 116 ][ 20 ][ 15 ]] -[[ char*->unsigned long int ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]] -[[ char*->unsigned long long ][ !!! *6* !!! ][ 118 ][ 22 ][ 15 ]] -[[ char*->bool ][ !!! *3* !!! ][ 113 ][ 18 ][ 8 ]] -[[ char*->float ][ !!! *15* !!! ][ 180 ][ 78 ][ 32 ]] -[[ char*->double ][ !!! *16* !!! ][ 185 ][ 89 ][ 58 ]] -[[ char*->long double ][ 119 ][ 193 ][ 91 ][ !!! *60* !!! ]] -[[ unsigned char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 8 ]] -[[ unsigned char*->signed char ][ !!! *2* !!! ][ 99 ][ 10 ][ 8 ]] -[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 100 ][ 9 ][ 15 ]] -[[ unsigned char*->int ][ !!! *6* !!! ][ 118 ][ 22 ][ 15 ]] -[[ unsigned char*->short ][ !!! *6* !!! ][ 117 ][ 26 ][ 15 ]] -[[ unsigned char*->long int ][ !!! *6* !!! ][ 119 ][ 21 ][ 15 ]] -[[ unsigned char*->long long ][ !!! *6* !!! ][ 118 ][ 21 ][ 14 ]] -[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 115 ][ 22 ][ 14 ]] -[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 117 ][ 20 ][ 15 ]] -[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 115 ][ 21 ][ 15 ]] -[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]] -[[ unsigned char*->bool ][ !!! *3* !!! ][ 112 ][ 18 ][ 8 ]] -[[ unsigned char*->float ][ !!! *15* !!! ][ 181 ][ 78 ][ 33 ]] -[[ unsigned char*->double ][ !!! *16* !!! ][ 185 ][ 92 ][ 59 ]] -[[ unsigned char*->long double ][ 120 ][ 190 ][ 89 ][ !!! *58* !!! ]] -[[ unsigned char*->string ][ !!! *14* !!! ][ 121 ][ 22 ][ --- ]] -[[ signed char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 9 ]] -[[ signed char*->signed char ][ !!! *2* !!! ][ 98 ][ 9 ][ 8 ]] -[[ signed char*->unsigned char ][ !!! *2* !!! ][ 98 ][ 9 ][ 14 ]] -[[ signed char*->int ][ !!! *6* !!! ][ 119 ][ 22 ][ 16 ]] -[[ signed char*->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 15 ]] -[[ signed char*->long int ][ !!! *6* !!! ][ 119 ][ 22 ][ 15 ]] -[[ signed char*->long long ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]] -[[ signed char*->unsigned int ][ !!! *6* !!! ][ 117 ][ 23 ][ 15 ]] -[[ signed char*->unsigned short ][ !!! *6* !!! ][ 117 ][ 21 ][ 14 ]] -[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 119 ][ 24 ][ 15 ]] -[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 116 ][ 22 ][ 15 ]] -[[ signed char*->bool ][ !!! *3* !!! ][ 111 ][ 18 ][ 8 ]] -[[ signed char*->float ][ !!! *16* !!! ][ 180 ][ 78 ][ 33 ]] -[[ signed char*->double ][ !!! *16* !!! ][ 185 ][ 89 ][ 59 ]] -[[ signed char*->long double ][ 120 ][ 191 ][ 91 ][ !!! *59* !!! ]] -[[ signed char*->string ][ !!! *14* !!! ][ 122 ][ 23 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 120 ][ 22 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 242 ][ 115 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 243 ][ 115 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 265 ][ 141 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 266 ][ 140 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 95 ][ 8 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 95 ][ 8 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ --- ]] + [[ string->char ][ !!! *<1* !!! ][ 162 ][ 17 ][ 8 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 103 ][ 9 ][ 9 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 91 ][ 9 ][ 9 ]] + [[ string->int ][ !!! *6* !!! ][ 104 ][ 21 ][ 14 ]] + [[ string->short ][ !!! *5* !!! ][ 107 ][ 22 ][ 14 ]] + [[ string->long int ][ !!! *7* !!! ][ 106 ][ 23 ][ 15 ]] + [[ string->long long ][ !!! *7* !!! ][ 104 ][ 21 ][ 16 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 100 ][ 20 ][ 16 ]] + [[ string->unsigned short ][ !!! *5* !!! ][ 102 ][ 20 ][ 16 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 106 ][ 25 ][ 16 ]] + [[ string->unsigned long long ][ !!! *7* !!! ][ 109 ][ 25 ][ 14 ]] + [[ string->float ][ !!! *13* !!! ][ 142 ][ 48 ][ 32 ]] + [[ string->double ][ !!! *13* !!! ][ 162 ][ 62 ][ 33 ]] + [[ string->long double ][ 119 ][ 164 ][ 62 ][ !!! *37* !!! ]] + [[ string->string ][ !!! *2* !!! ][ 122 ][ 27 ][ --- ]] + [[ string->container::string ][ !!! *2* !!! ][ 107 ][ 23 ][ --- ]] + [[ string->char ][ !!! *6* !!! ][ 110 ][ 24 ][ 15 ]] + [[ string->signed char ][ !!! *6* !!! ][ 107 ][ 24 ][ 21 ]] + [[ string->unsigned char ][ !!! *6* !!! ][ 106 ][ 27 ][ 21 ]] + [[ int->string ][ !!! *12* !!! ][ 122 ][ 31 ][ 21 ]] + [[ short->string ][ !!! *12* !!! ][ 136 ][ 29 ][ 20 ]] + [[ long int->string ][ !!! *12* !!! ][ 127 ][ 32 ][ 19 ]] + [[ long long->string ][ !!! *12* !!! ][ 121 ][ 32 ][ 21 ]] + [[ unsigned int->string ][ !!! *12* !!! ][ 133 ][ 32 ][ 19 ]] + [[ unsigned short->string ][ !!! *12* !!! ][ 126 ][ 33 ][ 20 ]] + [[ unsigned long int->string ][ !!! *11* !!! ][ 126 ][ 34 ][ 19 ]] + [[ unsigned long long->string ][ !!! *12* !!! ][ 125 ][ 28 ][ 21 ]] + [[ float->string ][ 47 ][ 183 ][ 86 ][ !!! *43* !!! ]] + [[ double->string ][ 57 ][ 184 ][ 90 ][ !!! *42* !!! ]] + [[ long double->string ][ 64 ][ 199 ][ 87 ][ !!! *46* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 95 ][ 10 ][ 8 ]] + [[ char*->signed char ][ !!! *<1* !!! ][ 90 ][ 12 ][ 9 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 93 ][ 12 ][ 9 ]] + [[ char*->int ][ !!! *6* !!! ][ 108 ][ 24 ][ 14 ]] + [[ char*->short ][ !!! *6* !!! ][ 106 ][ 23 ][ 14 ]] + [[ char*->long int ][ !!! *7* !!! ][ 107 ][ 24 ][ 17 ]] + [[ char*->long long ][ !!! *7* !!! ][ 109 ][ 25 ][ 17 ]] + [[ char*->unsigned int ][ !!! *6* !!! ][ 104 ][ 23 ][ 17 ]] + [[ char*->unsigned short ][ !!! *6* !!! ][ 102 ][ 22 ][ 17 ]] + [[ char*->unsigned long int ][ !!! *7* !!! ][ 107 ][ 23 ][ 17 ]] + [[ char*->unsigned long long ][ !!! *7* !!! ][ 115 ][ 26 ][ 14 ]] + [[ char*->float ][ !!! *12* !!! ][ 150 ][ 56 ][ 30 ]] + [[ char*->double ][ !!! *12* !!! ][ 165 ][ 66 ][ 32 ]] + [[ char*->long double ][ 116 ][ 173 ][ 66 ][ !!! *37* !!! ]] + [[ char*->string ][ !!! *7* !!! ][ 120 ][ 28 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 108 ][ 26 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 90 ][ 12 ][ 8 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 91 ][ 11 ][ 9 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 91 ][ 12 ][ 9 ]] + [[ unsigned char*->int ][ !!! *6* !!! ][ 106 ][ 24 ][ 14 ]] + [[ unsigned char*->short ][ !!! *6* !!! ][ 108 ][ 24 ][ 14 ]] + [[ unsigned char*->long int ][ !!! *7* !!! ][ 116 ][ 23 ][ 14 ]] + [[ unsigned char*->long long ][ !!! *7* !!! ][ 108 ][ 28 ][ 14 ]] + [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 107 ][ 22 ][ 14 ]] + [[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 105 ][ 21 ][ 16 ]] + [[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 106 ][ 25 ][ 16 ]] + [[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 105 ][ 24 ][ 17 ]] + [[ unsigned char*->float ][ !!! *14* !!! ][ 150 ][ 57 ][ 33 ]] + [[ unsigned char*->double ][ !!! *14* !!! ][ 171 ][ 72 ][ 34 ]] + [[ unsigned char*->long double ][ 118 ][ 171 ][ 73 ][ !!! *38* !!! ]] + [[ unsigned char*->string ][ !!! *8* !!! ][ 120 ][ 29 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *3* !!! ][ 114 ][ 26 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 92 ][ 12 ][ 8 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 92 ][ 12 ][ 9 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 91 ][ 14 ][ 9 ]] + [[ signed char*->int ][ !!! *6* !!! ][ 109 ][ 22 ][ 15 ]] + [[ signed char*->short ][ !!! *6* !!! ][ 106 ][ 24 ][ 17 ]] + [[ signed char*->long int ][ !!! *7* !!! ][ 107 ][ 24 ][ 16 ]] + [[ signed char*->long long ][ !!! *7* !!! ][ 106 ][ 24 ][ 14 ]] + [[ signed char*->unsigned int ][ !!! *6* !!! ][ 106 ][ 22 ][ 14 ]] + [[ signed char*->unsigned short ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]] + [[ signed char*->unsigned long int ][ !!! *7* !!! ][ 105 ][ 22 ][ 16 ]] + [[ signed char*->unsigned long long ][ !!! *7* !!! ][ 108 ][ 24 ][ 15 ]] + [[ signed char*->float ][ !!! *14* !!! ][ 147 ][ 54 ][ 32 ]] + [[ signed char*->double ][ !!! *14* !!! ][ 170 ][ 68 ][ 37 ]] + [[ signed char*->long double ][ 133 ][ 167 ][ 66 ][ !!! *37* !!! ]] + [[ signed char*->string ][ !!! *8* !!! ][ 119 ][ 30 ][ --- ]] + [[ signed char*->container::string ][ !!! *3* !!! ][ 108 ][ 24 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 98 ][ 13 ][ 8 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 98 ][ 15 ][ 9 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 97 ][ 15 ][ 9 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 107 ][ 27 ][ 14 ]] + [[ iterator_range->short ][ !!! *5* !!! ][ 109 ][ 23 ][ 14 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 109 ][ 22 ][ 14 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 107 ][ 24 ][ 14 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 120 ][ 23 ][ 14 ]] + [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 104 ][ 21 ][ 17 ]] + [[ iterator_range->unsigned long int ][ !!! *8* !!! ][ 108 ][ 25 ][ 16 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 106 ][ 25 ][ 15 ]] + [[ iterator_range->float ][ !!! *13* !!! ][ 132 ][ 41 ][ 32 ]] + [[ iterator_range->double ][ !!! *12* !!! ][ 136 ][ 45 ][ 32 ]] + [[ iterator_range->long double ][ 113 ][ 138 ][ 50 ][ !!! *36* !!! ]] + [[ iterator_range->string ][ !!! *7* !!! ][ 114 ][ 33 ][ --- ]] + [[ iterator_range->container::string ][ !!! *2* !!! ][ 105 ][ 24 ][ --- ]] + [[ int->int ][ !!! *<1* !!! ][ 112 ][ 31 ][ --- ]] + [[ float->double ][ !!! *<1* !!! ][ 233 ][ 199 ][ --- ]] + [[ char->signed char ][ !!! *<1* !!! ][ 129 ][ 10 ][ --- ]] ] [endsect] diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index b73c741..fb1808f 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -72,6 +72,7 @@ _CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * __restric #include #include #include +#include #if !defined(__SUNPRO_CC) #include #endif // !defined(__SUNPRO_CC) @@ -166,6 +167,18 @@ namespace boost }; #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + template struct stream_char< std::basic_string > { @@ -1225,7 +1238,7 @@ namespace boost bool shl_char(T ch) { BOOST_STATIC_ASSERT_MSG(( sizeof(T) <= sizeof(CharT)) , - "boost::lexical_cast does not support conversions from whar_t to char types." + "boost::lexical_cast does not support conversions from wchar_t to char types." "Use boost::locale instead" ); #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE std::locale loc; @@ -1397,6 +1410,52 @@ namespace boost return true; } + bool operator<<(const iterator_range& rng) + { + start = rng.begin(); + finish = rng.end(); + return true; + } + + bool operator<<(const iterator_range& rng) + { + start = const_cast(rng.begin()); + finish = const_cast(rng.end()); + return true; + } + + bool operator<<(const iterator_range& rng) + { + return (*this) << iterator_range( + const_cast(reinterpret_cast(rng.begin())), + const_cast(reinterpret_cast(rng.end())) + ); + } + + bool operator<<(const iterator_range& rng) + { + return (*this) << iterator_range( + const_cast(reinterpret_cast(rng.begin())), + const_cast(reinterpret_cast(rng.end())) + ); + } + + bool operator<<(const iterator_range& rng) + { + return (*this) << iterator_range( + reinterpret_cast(rng.begin()), + reinterpret_cast(rng.end()) + ); + } + + bool operator<<(const iterator_range& rng) + { + return (*this) << iterator_range( + reinterpret_cast(rng.begin()), + reinterpret_cast(rng.end()) + ); + } + bool operator<<(char ch) { return shl_char(ch); } bool operator<<(unsigned char ch) { return ((*this) << static_cast(ch)); } bool operator<<(signed char ch) { return ((*this) << static_cast(ch)); } @@ -1572,7 +1631,7 @@ namespace boost inline bool shr_xchar(T& output) { BOOST_STATIC_ASSERT_MSG(( sizeof(CharT) == sizeof(T) ), - "boost::lexical_cast does not support conversions from whar_t to char types." + "boost::lexical_cast does not support conversions from wchar_t to char types." "Use boost::locale instead" ); bool const ok = (finish - start == 1); if(ok) { @@ -1801,6 +1860,24 @@ namespace boost ); }; + template + struct is_char_iterator_range + { + BOOST_STATIC_CONSTANT(bool, value = false ); + }; + + template + struct is_char_iterator_range > + { + BOOST_STATIC_CONSTANT(bool, value = (is_char_or_wchar::value) ); + }; + + template + struct is_char_iterator_range > + { + BOOST_STATIC_CONSTANT(bool, value = (is_char_or_wchar::value) ); + }; + template struct is_arithmetic_and_not_xchars { @@ -1889,10 +1966,10 @@ namespace boost static inline Target lexical_cast_impl(const Source& arg) { typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay::type src; - + typedef BOOST_DEDUCED_TYPENAME detail::stream_char::type target_char_t; + typedef BOOST_DEDUCED_TYPENAME detail::stream_char::type src_char_type; typedef BOOST_DEDUCED_TYPENAME detail::widest_char< - BOOST_DEDUCED_TYPENAME detail::stream_char::type - , BOOST_DEDUCED_TYPENAME detail::stream_char::type + target_char_t, src_char_type >::type char_type; typedef detail::lcast_src_length lcast_src_length; @@ -1903,7 +1980,8 @@ namespace boost typedef BOOST_DEDUCED_TYPENAME deduce_char_traits::type traits; - typedef BOOST_DEDUCED_TYPENAME remove_pointer::type removed_ptr_t; + typedef BOOST_DEDUCED_TYPENAME remove_pointer::type removed_ptr_t_1; + typedef BOOST_DEDUCED_TYPENAME remove_cv::type removed_ptr_t; // is_char_types_match variable value can be computed via // sizeof(char_type) == sizeof(removed_ptr_t). But when @@ -1914,12 +1992,12 @@ namespace boost ::boost::type_traits::ice_and< ::boost::type_traits::ice_eq::value, ::boost::type_traits::ice_or< - ::boost::is_same::value, - ::boost::is_same::value, - ::boost::is_same::value + ::boost::is_same::value, + ::boost::is_same::value, + ::boost::is_same::value >::value >::value, - is_same::value + is_same::value >::value); const bool requires_stringbuf = @@ -1928,14 +2006,18 @@ namespace boost is_stdstring::value, is_arithmetic::value, ::boost::type_traits::ice_and< - is_pointer::value, - is_char_or_wchar::value, + is_char_iterator_range::value, + is_char_types_match + >::value, + ::boost::type_traits::ice_and< + is_pointer::value, + is_char_or_wchar::value, is_char_types_match >::value >::value ); - detail::lexical_stream_limited_src + detail::lexical_stream_limited_src interpreter(buf, buf + src_len); Target result; diff --git a/perf/performance_test.cpp b/perf/performance_test.cpp index ff1eb1d..8640bc4 100644 --- a/perf/performance_test.cpp +++ b/perf/performance_test.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include // File to output data @@ -74,6 +75,12 @@ struct structure_sscanf { OutT out_val; sscanf(in_val.c_str(), conv, &out_val); } + + template + static inline void test(BufferT* /*buffer*/, const boost::iterator_range& in_val, const char* const conv) { + OutT out_val; + sscanf(in_val.begin(), conv, &out_val); + } }; struct structure_fake { @@ -255,6 +262,12 @@ struct to_schar_conv { } }; +struct to_iterator_range { + boost::iterator_range operator()(const char* const c) const { + return boost::make_iterator_range(c, c + std::strlen(c)); + } +}; + int main(int argc, char** argv) { BOOST_ASSERT(argc >= 2); std::string output_path(argv[1]); @@ -296,11 +309,13 @@ int main(int argc, char** argv) { string_like_test_set("char*"); string_like_test_set("unsigned char*"); string_like_test_set("signed char*"); + string_like_test_set("iterator_range"); perf_test("int->int", 100, ""); perf_test("float->double", 100.0f, ""); perf_test("char->signed char", 'c', ""); + fout << "]\n" << "[endsect]\n\n"; return 0; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 019c9e7..131fa3e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -45,5 +45,6 @@ test-suite conversion gcc-4.5:-fno-exceptions gcc-4.6:-fno-exceptions ] + [ run lexical_cast_iterator_range_test.cpp ../../test/build//boost_unit_test_framework/static ] ; diff --git a/test/lexical_cast_iterator_range_test.cpp b/test/lexical_cast_iterator_range_test.cpp new file mode 100644 index 0000000..7afb1ae --- /dev/null +++ b/test/lexical_cast_iterator_range_test.cpp @@ -0,0 +1,189 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2012. +// +// 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). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include + +#include +#include + +using namespace boost; + +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) +#define BOOST_LCAST_NO_WCHAR_T +#endif + +struct class_with_user_defined_sream_operators { + int i; + + operator int() const { + return i; + } +}; + +template +inline std::basic_istream& operator >> (std::basic_istream& istr, class_with_user_defined_sream_operators& rhs) +{ + return istr >> rhs.i; +} + + +template +void do_test_iterator_range(const RngT& rng) +{ + BOOST_CHECK_EQUAL(lexical_cast(rng), 1); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1.0f); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1.0); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1.0L); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1); + +#if defined(BOOST_HAS_LONG_LONG) + BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1); +#elif defined(BOOST_HAS_MS_INT64) + BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + BOOST_CHECK_EQUAL(lexical_cast<__int64>(rng), 1); +#endif + +#ifndef BOOST_LCAST_NO_WCHAR_T + BOOST_CHECK(lexical_cast(rng) == L"1"); +#endif +} + +void test_char_iterator_ranges() +{ + typedef char test_char_type; + + // Zero terminated + test_char_type data1[] = "1"; + iterator_range rng1(data1, data1 + 1); + do_test_iterator_range(rng1); + BOOST_CHECK_EQUAL(lexical_cast(rng1), "1"); + + const test_char_type cdata1[] = "1"; + iterator_range crng1(cdata1, cdata1 + 1); + do_test_iterator_range(crng1); + BOOST_CHECK_EQUAL(lexical_cast(crng1), "1"); + + // Non zero terminated + test_char_type data2[] = "11"; + iterator_range rng2(data2, data2 + 1); + do_test_iterator_range(rng2); + BOOST_CHECK_EQUAL(lexical_cast(rng2), "1"); + + const test_char_type cdata2[] = "11"; + iterator_range crng2(cdata2, cdata2 + 1); + do_test_iterator_range(crng2); + BOOST_CHECK_EQUAL(lexical_cast(crng2), "1"); +} + +void test_unsigned_char_iterator_ranges() +{ + typedef unsigned char test_char_type; + + // Zero terminated + test_char_type data1[] = "1"; + iterator_range rng1(data1, data1 + 1); + do_test_iterator_range(rng1); + BOOST_CHECK_EQUAL(lexical_cast(rng1), "1"); + + const test_char_type cdata1[] = "1"; + iterator_range crng1(cdata1, cdata1 + 1); + do_test_iterator_range(crng1); + BOOST_CHECK_EQUAL(lexical_cast(crng1), "1"); + + // Non zero terminated + test_char_type data2[] = "11"; + iterator_range rng2(data2, data2 + 1); + do_test_iterator_range(rng2); + BOOST_CHECK_EQUAL(lexical_cast(rng2), "1"); + + const test_char_type cdata2[] = "11"; + iterator_range crng2(cdata2, cdata2 + 1); + do_test_iterator_range(crng2); + BOOST_CHECK_EQUAL(lexical_cast(crng2), "1"); +} + +void test_signed_char_iterator_ranges() +{ + typedef signed char test_char_type; + + // Zero terminated + test_char_type data1[] = "1"; + iterator_range rng1(data1, data1 + 1); + do_test_iterator_range(rng1); + BOOST_CHECK_EQUAL(lexical_cast(rng1), "1"); + + const test_char_type cdata1[] = "1"; + iterator_range crng1(cdata1, cdata1 + 1); + do_test_iterator_range(crng1); + BOOST_CHECK_EQUAL(lexical_cast(crng1), "1"); + + // Non zero terminated + test_char_type data2[] = "11"; + iterator_range rng2(data2, data2 + 1); + do_test_iterator_range(rng2); + BOOST_CHECK_EQUAL(lexical_cast(rng2), "1"); + + const test_char_type cdata2[] = "11"; + iterator_range crng2(cdata2, cdata2 + 1); + do_test_iterator_range(crng2); + BOOST_CHECK_EQUAL(lexical_cast(crng2), "1"); +} + +void test_wide_char_iterator_ranges() +{ +#ifndef BOOST_LCAST_NO_WCHAR_T + typedef wchar_t test_char_type; + + // Zero terminated + test_char_type data1[] = L"1"; + iterator_range rng1(data1, data1 + 1); + do_test_iterator_range(rng1); + + const test_char_type cdata1[] = L"1"; + iterator_range crng1(cdata1, cdata1 + 1); + do_test_iterator_range(crng1); + + // Non zero terminated + test_char_type data2[] = L"11"; + iterator_range rng2(data2, data2 + 1); + do_test_iterator_range(rng2); + + const test_char_type cdata2[] = L"11"; + iterator_range crng2(cdata2, cdata2 + 1); + do_test_iterator_range(crng2); +#endif + + BOOST_CHECK(true); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast. Testing conversions using iterator_range<>"); + suite->add(BOOST_TEST_CASE(&test_char_iterator_ranges)); + suite->add(BOOST_TEST_CASE(&test_unsigned_char_iterator_ranges)); + suite->add(BOOST_TEST_CASE(&test_signed_char_iterator_ranges)); + suite->add(BOOST_TEST_CASE(&test_wide_char_iterator_ranges)); + + return suite; +} From 1e58331bafdc716eb68f10eb78c4f3ec62a4a415 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sat, 7 Apr 2012 07:52:23 +0000 Subject: [PATCH 112/138] Merge lexical_cast from trunk: * fixed #6717 (now lexical_cast won`t try to support non confirming swprintf) * fixed #6670 (now using BOOST_NO_UNICODE_LITERALS macro to detect unicode literals support) * rewritten Jamfile [SVN r77804] --- include/boost/lexical_cast.hpp | 203 +++++++++++------------ lexical_cast_test.cpp | 16 +- test/Jamfile.v2 | 60 +++---- test/lexical_cast_no_exceptions_test.cpp | 2 +- 4 files changed, 140 insertions(+), 141 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index fb1808f..61501d6 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -26,27 +26,6 @@ #define BOOST_LCAST_NO_WCHAR_T #endif -#if (defined(__MINGW32__) || defined(__MINGW64__)) && (__GNUC__ == 4) \ - && ((__GNUC_MINOR__ == 4) || (__GNUC_MINOR__ == 5)) && defined(__STRICT_ANSI__) \ - && !defined(BOOST_LCAST_NO_WCHAR_T) - -// workaround for a mingw bug -// http://sourceforge.net/tracker/index.php?func=detail&aid=2373234&group_id=2435&atid=102435 -#include <_mingw.h> -#if (__GNUC_MINOR__ == 4) -extern "C" { -_CRTIMP int __cdecl swprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...); -_CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...); -} -#endif -#if (__GNUC_MINOR__ == 5) -extern "C" { -_CRTIMP int __cdecl swprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...); -_CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , va_list); -} -#endif -#endif - #include #include #include @@ -501,7 +480,7 @@ namespace boost }; #endif -#ifndef BOOST_NO_CHAR16_T +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) template<> struct lcast_char_constants { @@ -514,7 +493,7 @@ namespace boost }; #endif -#ifndef BOOST_NO_CHAR32_T +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) template<> struct lcast_char_constants { @@ -864,7 +843,7 @@ namespace boost } #endif -#ifndef BOOST_NO_CHAR16_T +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) template bool parse_inf_nan(const char16_t* begin, const char16_t* end, T& value) { @@ -880,7 +859,7 @@ namespace boost return put_inf_nan_impl(begin, end, value, u"nan", u"infinity"); } #endif -#ifndef BOOST_NO_CHAR32_T +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) template bool parse_inf_nan(const char32_t* begin, const char32_t* end, T& value) { @@ -1275,7 +1254,7 @@ namespace boost { #if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_LOCALE) // If you have compilation error at this point, than your STL library - // unsupports such conversions. Try updating it. + // does not support such conversions. Try updating it. BOOST_STATIC_ASSERT((boost::is_same::value)); #endif bool const result = !(out_stream << input).fail(); @@ -1299,34 +1278,42 @@ namespace boost return true; } + template + bool shl_real_type(const T& val, SomeCharT* begin, SomeCharT*& end) + { + if (put_inf_nan(begin, end, val)) return true; + lcast_set_precision(out_stream, &val); + return shl_input_streamable(val); + } + #if (defined _MSC_VER) # pragma warning( push ) // C4996: This function or variable may be unsafe. Consider using sprintf_s instead # pragma warning( disable : 4996 ) #endif - - template - bool shl_float(float val,T* out) + static bool shl_real_type(float val, char* begin, char*& end) { using namespace std; - if (put_inf_nan(start,finish,val)) return true; - finish = start + sprintf(out,"%.*g", static_cast(boost::detail::lcast_get_precision()), val ); - return finish > start; + if (put_inf_nan(begin, end, val)) return true; + end = begin; + end += sprintf(begin,"%.*g", static_cast(boost::detail::lcast_get_precision()), val); + return end > begin; } - template - bool shl_double(double val,T* out) + static bool shl_real_type(double val, char* begin, char*& end) { using namespace std; - if (put_inf_nan(start,finish,val)) return true; - finish = start + sprintf(out,"%.*lg", static_cast(boost::detail::lcast_get_precision()), val ); - return finish > start; + if (put_inf_nan(begin, end, val)) return true; + end = begin; + end += sprintf(begin,"%.*lg", static_cast(boost::detail::lcast_get_precision()), val); + return end > begin; } + #ifndef __MINGW32__ - template - bool shl_long_double(long double val,T* out) + static bool shl_real_type(long double val, char* begin, char*& end) { using namespace std; - if (put_inf_nan(start,finish,val)) return true; - finish = start + sprintf(out,"%.*Lg", static_cast(boost::detail::lcast_get_precision()), val ); - return finish > start; + if (put_inf_nan(begin, end, val)) return true; + end = begin; + end += sprintf(begin,"%.*Lg", static_cast(boost::detail::lcast_get_precision()), val ); + return end > begin; } #endif @@ -1335,54 +1322,32 @@ namespace boost #endif -#ifndef BOOST_LCAST_NO_WCHAR_T - bool shl_float(float val,wchar_t* out) +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_SWPRINTF) && !defined(__MINGW32__) + static bool shl_real_type(float val, wchar_t* begin, wchar_t*& end) { using namespace std; - if (put_inf_nan(start,finish,val)) return true; - finish = start + swprintf(out, -#if !defined(__MINGW32__) && !defined(UNDER_CE) - finish-start, -#endif + if (put_inf_nan(begin, end, val)) return true; + end = begin + swprintf(begin, end-begin, L"%.*g", static_cast(boost::detail::lcast_get_precision()), val ); - - return finish > start; + return end > begin; } - - bool shl_double(double val,wchar_t* out) + static bool shl_real_type(double val, wchar_t* begin, wchar_t*& end) { using namespace std; - if (put_inf_nan(start,finish,val)) return true; - /* __MINGW32__ is defined for both mingw.org and for mingw-w64. - * For mingw-w64, __MINGW64__ is defined, too, when targetting - * 64 bits. - * - * swprintf realization in MinGW and under WinCE does not conform - * to the ISO C - * Standard. - */ - finish = start + swprintf(out, -#if !defined(__MINGW32__) && !defined(UNDER_CE) - finish-start, -#endif + if (put_inf_nan(begin, end, val)) return true; + end = begin + swprintf(begin, end-begin, L"%.*lg", static_cast(boost::detail::lcast_get_precision()), val ); - return finish > start; + return end > begin; } -#ifndef __MINGW32__ - bool shl_long_double(long double val,wchar_t* out) + static bool shl_real_type(long double val, wchar_t* begin, wchar_t*& end) { using namespace std; - if (put_inf_nan(start,finish,val)) return true; - finish = start + swprintf(out, -#if !defined(UNDER_CE) - finish-start, -#endif + if (put_inf_nan(begin, end, val)) return true; + end = begin + swprintf(begin, end-begin, L"%.*Lg", static_cast(boost::detail::lcast_get_precision()), val ); - return finish > start; + return end > begin; } #endif -#endif - /************************************ OPERATORS << ( ... ) ********************************/ public: template @@ -1486,13 +1451,13 @@ namespace boost bool operator<<(unsigned __int64 n) { start = lcast_put_unsigned(n, finish); return true; } bool operator<<( __int64 n) { return shl_signed(n); } #endif - bool operator<<(float val) { return shl_float(val,start); } - bool operator<<(double val) { return shl_double(val,start); } + bool operator<<(float val) { return shl_real_type(val, start, finish); } + bool operator<<(double val) { return shl_real_type(val, start, finish); } bool operator<<(long double val) { #ifndef __MINGW32__ - return shl_long_double(val,start); + return shl_real_type(val, start, finish); #else - return shl_double(val,start); + return shl_real_type(static_cast(val), start, finish); #endif } @@ -1663,10 +1628,10 @@ namespace boost #if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) bool operator>>(wchar_t& output) { return shr_xchar(output); } #endif -#ifndef BOOST_NO_CHAR16_T +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) bool operator>>(char16_t& output) { return shr_xchar(output); } #endif -#ifndef BOOST_NO_CHAR32_T +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) bool operator>>(char32_t& output) { return shr_xchar(output); } #endif #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION @@ -1884,8 +1849,8 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = ( ::boost::type_traits::ice_and< - is_arithmetic::value, - is_arithmetic::value, + ::boost::is_arithmetic::value, + ::boost::is_arithmetic::value, ::boost::type_traits::ice_not< detail::is_char_or_wchar::value >::value, @@ -1923,6 +1888,28 @@ namespace boost ); }; + + // this metafunction evaluates to true, if we have optimized comnversion + // from Float type to Char array. + // Must be in sync with lexical_stream_limited_src::shl_real_type(...) + template + struct is_this_float_conversion_optimized + { + typedef ::boost::type_traits::ice_and< + ::boost::is_float::value, +#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_SWPRINTF) && !defined(__MINGW32__) + ::boost::type_traits::ice_or< + ::boost::type_traits::ice_eq::value, + ::boost::is_same::value + >::value +#else + ::boost::type_traits::ice_eq::value +#endif + > result_type; + + BOOST_STATIC_CONSTANT(bool, value = (result_type::value) ); + }; + template struct is_char_array_to_stdstring { @@ -1972,6 +1959,17 @@ namespace boost target_char_t, src_char_type >::type char_type; +#if !defined(BOOST_NO_CHAR16_T) && defined(BOOST_NO_UNICODE_LITERALS) + BOOST_STATIC_ASSERT_MSG(( !::boost::is_same::value + && !::boost::is_same::value), + "Your compiler does not have full support for char16_t" ); +#endif +#if !defined(BOOST_NO_CHAR32_T) && defined(BOOST_NO_UNICODE_LITERALS) + BOOST_STATIC_ASSERT_MSG(( !::boost::is_same::value + && !::boost::is_same::value), + "Your compiler does not have full support for char32_t" ); +#endif + typedef detail::lcast_src_length lcast_src_length; std::size_t const src_len = lcast_src_length::value; char_type buf[src_len + 1]; @@ -1997,21 +1995,22 @@ namespace boost ::boost::is_same::value >::value >::value, - is_same::value + ::boost::is_same::value >::value); const bool requires_stringbuf = !( ::boost::type_traits::ice_or< - is_stdstring::value, - is_arithmetic::value, + ::boost::detail::is_stdstring::value, + ::boost::is_integral::value, + ::boost::detail::is_this_float_conversion_optimized::value, ::boost::type_traits::ice_and< - is_char_iterator_range::value, + ::boost::detail::is_char_iterator_range::value, is_char_types_match >::value, ::boost::type_traits::ice_and< - is_pointer::value, - is_char_or_wchar::value, + ::boost::is_pointer::value, + ::boost::detail::is_char_or_wchar::value, is_char_types_match >::value >::value @@ -2047,7 +2046,7 @@ namespace boost typedef Source source_type ; typedef BOOST_DEDUCED_TYPENAME mpl::if_< - is_arithmetic, Source, Source const& + ::boost::is_arithmetic, Source, Source const& >::type argument_type ; static source_type nearbyint ( argument_type s ) @@ -2138,10 +2137,10 @@ namespace boost ::boost::is_float::value >::value, ::boost::type_traits::ice_not< - is_same::value + ::boost::is_same::value >::value, ::boost::type_traits::ice_not< - is_same::value + ::boost::is_same::value >::value, ::boost::is_unsigned::value >::value, @@ -2157,27 +2156,27 @@ namespace boost template inline Target lexical_cast(const Source &arg) { - typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay::type src; + typedef BOOST_DEDUCED_TYPENAME ::boost::detail::array_to_pointer_decay::type src; typedef BOOST_DEDUCED_TYPENAME ::boost::type_traits::ice_or< - detail::is_xchar_to_xchar::value, - detail::is_char_array_to_stdstring::value, + ::boost::detail::is_xchar_to_xchar::value, + ::boost::detail::is_char_array_to_stdstring::value, ::boost::type_traits::ice_and< - is_same::value, - detail::is_stdstring::value + ::boost::is_same::value, + ::boost::detail::is_stdstring::value >::value > do_copy_type; typedef BOOST_DEDUCED_TYPENAME - detail::is_arithmetic_and_not_xchars do_copy_with_dynamic_check_type; + ::boost::detail::is_arithmetic_and_not_xchars do_copy_with_dynamic_check_type; typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< do_copy_type::value, detail::lexical_cast_copy, BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< do_copy_with_dynamic_check_type::value, - detail::lexical_cast_dynamic_num, - detail::lexical_cast_do_cast + ::boost::detail::lexical_cast_dynamic_num, + ::boost::detail::lexical_cast_do_cast >::type >::type caster_type; diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 4e9ec90..4e70bdd 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -100,10 +100,10 @@ void test_wallocator(); #endif void test_char_types_conversions(); void operators_overload_test(); -#ifndef BOOST_NO_CHAR16_T +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) void test_char16_conversions(); #endif -#ifndef BOOST_NO_CHAR32_T +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) void test_char32_conversions(); #endif @@ -149,10 +149,10 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(&test_char_types_conversions)); suite->add(BOOST_TEST_CASE(&operators_overload_test)); -#ifndef BOOST_NO_CHAR16_T +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) suite->add(BOOST_TEST_CASE(&test_char16_conversions)); #endif -#ifndef BOOST_NO_CHAR32_T +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) suite->add(BOOST_TEST_CASE(&test_char32_conversions)); #endif @@ -756,12 +756,12 @@ void test_conversion_from_to_integral() test_conversion_from_integral_to_char(wzero); test_conversion_from_char_to_integral(wzero); #endif -#ifndef BOOST_NO_CHAR16_T +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) char16_t const u16zero = u'0'; test_conversion_from_integral_to_char(u16zero); test_conversion_from_char_to_integral(u16zero); #endif -#ifndef BOOST_NO_CHAR32_T +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) char32_t const u32zero = u'0'; test_conversion_from_integral_to_char(u32zero); test_conversion_from_char_to_integral(u32zero); @@ -1025,7 +1025,7 @@ void operators_overload_test() } -#ifndef BOOST_NO_CHAR16_T +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) void test_char16_conversions() { BOOST_CHECK(u"100" == lexical_cast(u"100")); @@ -1033,7 +1033,7 @@ void test_char16_conversions() } #endif -#ifndef BOOST_NO_CHAR32_T +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) void test_char32_conversions() { BOOST_CHECK(U"100" == lexical_cast(U"100")); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 131fa3e..2673009 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -1,50 +1,50 @@ -# Signals library - # Copyright (C) 2001-2003 Douglas Gregor +# Copyright (C) 2011-2012 Antony Polukhin +# +# 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) +# -# Permission to copy, use, sell and distribute this software is granted -# provided this copyright notice appears in all copies. Permission to modify -# the code and to distribute modified code is granted provided this copyright -# notice appears in all copies, and a notice that the code was modified is -# included with the copyright notice. This software is provided "as is" -# without express or implied warranty, and with no claim as to its suitability -# for any purpose. - -# For more information, see http://www.boost.org/ - -# bring in rules for testing import testing ; import feature ; +project + : requirements + /boost/test//boost_unit_test_framework + static + ; + +# Thanks to Steven Watanabe for helping with feature feature.feature nowchar : on : composite optional propagated link-incompatible ; -feature.compose on : /Zc:wchar_t- ; +feature.compose on : /Zc:wchar_t- ; test-suite conversion : [ run implicit_cast.cpp ] [ compile-fail implicit_cast_fail.cpp ] [ run ../cast_test.cpp ] [ run ../numeric_cast_test.cpp ] - [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_loopback_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_abstract_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_noncopyable_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_vc8_bug_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_wchars_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_float_types_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_inf_nan_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_containers_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_empty_input_test.cpp ../../test/build//boost_unit_test_framework/static ] - [ run lexical_cast_pointers_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run ../lexical_cast_test.cpp ] + [ run lexical_cast_loopback_test.cpp ] + [ run lexical_cast_abstract_test.cpp ] + [ run lexical_cast_noncopyable_test.cpp ] + [ run lexical_cast_vc8_bug_test.cpp ] + [ run lexical_cast_wchars_test.cpp ] + [ run lexical_cast_float_types_test.cpp ] + [ run lexical_cast_inf_nan_test.cpp ] + [ run lexical_cast_containers_test.cpp ] + [ run lexical_cast_empty_input_test.cpp ] + [ run lexical_cast_pointers_test.cpp ] [ compile lexical_cast_typedefed_wchar_test.cpp : msvc:on ] - [ run lexical_cast_typedefed_wchar_test_runtime.cpp ../../test/build//boost_unit_test_framework/static : : : msvc:on ] - [ run lexical_cast_no_locale_test.cpp ../../test/build//boost_unit_test_framework/static : : : BOOST_NO_STD_LOCALE BOOST_LEXICAL_CAST_ASSUME_C_LOCALE ] - [ run lexical_cast_no_exceptions_test.cpp ../../test/build//boost_unit_test_framework/static : : : BOOST_NO_EXCEPTIONS + [ run lexical_cast_typedefed_wchar_test_runtime.cpp : : : msvc:on msvc,stlport:no ] + [ run lexical_cast_no_locale_test.cpp : : : BOOST_NO_STD_LOCALE BOOST_LEXICAL_CAST_ASSUME_C_LOCALE ] + [ run lexical_cast_no_exceptions_test.cpp : : : BOOST_NO_EXCEPTIONS gcc-4.3:-fno-exceptions gcc-4.4:-fno-exceptions gcc-4.5:-fno-exceptions gcc-4.6:-fno-exceptions + gcc-4.7:-fno-exceptions ] - [ run lexical_cast_iterator_range_test.cpp ../../test/build//boost_unit_test_framework/static ] - ; + [ run lexical_cast_iterator_range_test.cpp ] + ; diff --git a/test/lexical_cast_no_exceptions_test.cpp b/test/lexical_cast_no_exceptions_test.cpp index 8431c3a..dbec8ea 100755 --- a/test/lexical_cast_no_exceptions_test.cpp +++ b/test/lexical_cast_no_exceptions_test.cpp @@ -29,7 +29,7 @@ bool g_was_exception = false; namespace boost { void throw_exception(std::exception const & ) { - g_was_exception = true; + g_was_exception = true; } } From eb4ad73cafed624fcb68e12b4bf11c1d195fbe62 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Wed, 18 Apr 2012 04:09:49 +0000 Subject: [PATCH 113/138] Merge lexical_cast library from trunk: * multiple optimizations and bugfixes for boost::iterator_range (refs #6786, refs #6430, refs #6663) * documentation update * new Unicode characters support updated * much more tests, removed incorrect tests [SVN r78059] --- doc/lexical_cast.qbk | 25 +- include/boost/lexical_cast.hpp | 523 +++++++++++----------- lexical_cast_test.cpp | 1 - test/Jamfile.v2 | 1 + test/lexical_cast_containers_test.cpp | 23 + test/lexical_cast_iterator_range_test.cpp | 188 ++++---- test/lexical_cast_wchars_test.cpp | 62 ++- 7 files changed, 459 insertions(+), 364 deletions(-) diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index ffab311..c786fbc 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -97,7 +97,21 @@ The requirements on the argument and result types are: * Target is CopyConstructible [20.1.3]. * Target is DefaultConstructible, meaning that it is possible to default-initialize an object of that type [8.5, 20.1.4]. -The character type of the underlying stream is assumed to be char unless either the Source or the Target requires wide-character streaming, in which case the underlying stream uses `wchar_t`. Source types that require wide-character streaming are `wchar_t`, `wchar_t *`, and `std::wstring`. Target types that require wide-character streaming are `wchar_t` and `std::wstring`. +The character type of the underlying stream is assumed to be `char` unless either the `Source` or the `Target` requires wide-character streaming, in which case the underlying stream uses `wchar_t`, `char16_t` or `char32_t`. Wide-character streaming is currently detected for: + +* Single character: `wchar_t`, `char16_t`, `char32_t` +* Arrays of characters: `wchar_t *`, `char16_t *`, `char32_t *`, `const wchar_t *`, `const char16_t *`, `const char32_t *` +* Strings: `std::basic_string`, `boost::containers::basic_string` +* `boost::iterator_range`, where `WideCharPtr` is a pointer to wide-character or pointer to const wide-character + +[important Many compilers and runtime libraries fail to make conversions using new Unicode characters. Make shure that the following code compiles and outputs nonzero values, before using new types: +`` + std::cout + << booat::lexical_cast(1.0).size() + << " " + << booat::lexical_cast(1.0).size(); +`` +] Where a higher degree of control is required over conversions, `std::stringstream` and `std::wstringstream` offer a more appropriate path. Where non-stream-based conversions are required, `lexical_cast` is the wrong tool for the job and is not special-cased for such scenarios. [endsect] @@ -115,6 +129,7 @@ Exception used to indicate runtime lexical_cast failure. [endsect] +[/ Commenting out bad advise (this will break the ability to get correct function pointers via &lexical_cast) [section Tuning classes for fast lexical conversions] Because of `boost::lexical_cast` optimizations for `boost::iterator_range`, it is possibile to make very fast lexical conversions for non zero terminated strings, substrings and user-defined classes. @@ -145,9 +160,9 @@ Consider the following example: This is a good generic solution for most use cases. But we can make it even faster for some performance critical applications. During conversion, we loose speed at: -* `std::ostream` construction (it makes some heap allocations) -* `operator <<` (it copyies one by one all the symbols to an instance of `std::ostream`) -* `std::ostream` destruction (it makes some heap deallocations) + * `std::ostream` construction (it makes some heap allocations) + * `operator <<` (it copyies one by one all the symbols to an instance of `std::ostream`) + * `std::ostream` destruction (it makes some heap deallocations) We can avoid all of this, by specifieng an overload for `boost::lexical_cast`: `` @@ -162,7 +177,7 @@ namespace boost { `` Now `boost::lexical_cast(example_class_instance)` conversions won't copy data and construct heavy STL stream objects. See [link boost_lexical_cast.performance Performance] section for info on `boost::iterator_range` conversion performance. [endsect] - +] [section Frequently Asked Questions] diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 61501d6..2e5c140 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -28,36 +28,20 @@ #include #include -#include #include #include #include #include #include -#include #include #include #include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include +#include #include #include #include -#include -#if !defined(__SUNPRO_CC) -#include -#endif // !defined(__SUNPRO_CC) -#ifndef BOOST_NO_CWCHAR -# include -#endif + #ifndef BOOST_NO_STD_LOCALE # include @@ -137,118 +121,9 @@ namespace boost const std::type_info *target; }; - namespace detail // selectors for choosing stream character type + namespace detail // widest_char { - template - struct stream_char - { - typedef char type; - }; - -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template - struct stream_char > - { - typedef BOOST_DEDUCED_TYPENAME stream_char::type type; - }; - - template - struct stream_char > - { - typedef BOOST_DEDUCED_TYPENAME stream_char::type type; - }; - - template - struct stream_char< std::basic_string > - { - typedef CharT type; - }; - -#if !defined(__SUNPRO_CC) - template - struct stream_char< ::boost::container::basic_string > - { - typedef CharT type; - }; -#endif // !defined(__SUNPRO_CC) -#endif - -#ifndef BOOST_LCAST_NO_WCHAR_T -#ifndef BOOST_NO_INTRINSIC_WCHAR_T - template<> - struct stream_char - { - typedef wchar_t type; - }; -#endif - - template<> - struct stream_char - { - typedef wchar_t type; - }; - - template<> - struct stream_char - { - typedef wchar_t type; - }; - -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - template<> - struct stream_char - { - typedef wchar_t type; - }; -#endif -#endif - - -#ifndef BOOST_NO_CHAR16_T - - template<> - struct stream_char - { - typedef char16_t type; - }; - - template<> - struct stream_char - { - typedef char16_t type; - }; - - template<> - struct stream_char - { - typedef char16_t type; - }; - -#endif - -#ifndef BOOST_NO_CHAR32_T - - template<> - struct stream_char - { - typedef char32_t type; - }; - - template<> - struct stream_char - { - typedef char32_t type; - }; - - template<> - struct stream_char - { - typedef char32_t type; - }; - -#endif - - template + template struct widest_char { typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c< @@ -257,10 +132,162 @@ namespace boost , SourceChar >::type type; }; } +} // namespace boost + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if !defined(__SUNPRO_CC) +#include +#endif // !defined(__SUNPRO_CC) +#ifndef BOOST_NO_CWCHAR +# include +#endif + +namespace boost { + namespace detail // widest_char<...> (continuation) + { + struct not_a_character_type{}; + + template + struct widest_char + { + typedef CharT type; + }; + + template + struct widest_char< CharT, not_a_character_type > + { + typedef CharT type; + }; + + template <> + struct widest_char< not_a_character_type, not_a_character_type > + { + typedef char type; + }; + } + + namespace detail // is_char_or_wchar<...> and stream_char<...> templates + { + // returns true, if T is one of the character types + template + struct is_char_or_wchar + { + typedef ::boost::type_traits::ice_or< + ::boost::is_same< T, char >::value, + #ifndef BOOST_LCAST_NO_WCHAR_T + ::boost::is_same< T, wchar_t >::value, + #endif + #ifndef BOOST_NO_CHAR16_T + ::boost::is_same< T, char16_t >::value, + #endif + #ifndef BOOST_NO_CHAR32_T + ::boost::is_same< T, char32_t >::value, + #endif + ::boost::is_same< T, unsigned char >::value, + ::boost::is_same< T, signed char >::value + > result_type; + + BOOST_STATIC_CONSTANT(bool, value = (result_type::value) ); + }; + + // selectors for choosing stream character type + // returns one of char, wchar_t, char16_t, char32_t or not_a_character_type types + template + struct stream_char + { + typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c< + is_char_or_wchar::value, + Type, + boost::detail::not_a_character_type + >::type type; + }; + + template <> + struct stream_char + { + typedef char type; + }; + + template <> + struct stream_char + { + typedef char type; + }; + + template + struct stream_char + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + + template + struct stream_char + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + + template + struct stream_char< std::basic_string > + { + typedef CharT type; + }; + +#if !defined(__SUNPRO_CC) + template + struct stream_char< ::boost::container::basic_string > + { + typedef CharT type; + }; +#endif // !defined(__SUNPRO_CC) + +#if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T) + template<> + struct stream_char + { + typedef boost::detail::not_a_character_type type; + }; + + template<> + struct stream_char + { + typedef wchar_t type; + }; + + template<> + struct stream_char + { + typedef wchar_t type; + }; +#endif + } namespace detail // deduce_char_traits template { -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template struct deduce_char_traits { @@ -325,7 +352,7 @@ namespace boost template struct deduce_char_traits< CharT , ::boost::container::basic_string - , std::basic_string + , ::std::basic_string > { typedef Traits type; @@ -333,14 +360,13 @@ namespace boost template struct deduce_char_traits< CharT - , std::basic_string + , ::std::basic_string , ::boost::container::basic_string > { typedef Traits type; }; #endif // !defined(__SUNPRO_CC) -#endif } namespace detail // lcast_src_length @@ -383,7 +409,7 @@ namespace boost BOOST_STATIC_ASSERT(sizeof(Source) * CHAR_BIT <= 256); #endif }; -// TODO: FIX for char16_t, char32_t, we can ignore CharT + #define BOOST_LCAST_DEF(T) \ template<> struct lcast_src_length \ : lcast_src_length_integral \ @@ -1217,7 +1243,7 @@ namespace boost bool shl_char(T ch) { BOOST_STATIC_ASSERT_MSG(( sizeof(T) <= sizeof(CharT)) , - "boost::lexical_cast does not support conversions from wchar_t to char types." + "boost::lexical_cast does not support conversions from wide character to char types." "Use boost::locale instead" ); #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE std::locale loc; @@ -1243,7 +1269,7 @@ namespace boost bool shl_char_array(T const* str) { BOOST_STATIC_ASSERT_MSG(( sizeof(T) <= sizeof(CharT)), - "boost::lexical_cast does not support conversions from wchar_t to char types." + "boost::lexical_cast does not support conversions from wide characters to char types." "Use boost::locale instead" ); return shl_input_streamable(str); } @@ -1430,6 +1456,16 @@ namespace boost #ifndef BOOST_NO_INTRINSIC_WCHAR_T bool operator<<(wchar_t ch) { return shl_char(ch); } #endif +#endif +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) + bool operator<<(char16_t ch) { return shl_char(ch); } + bool operator<<(char16_t * str) { return shl_char_array(str); } + bool operator<<(char16_t const * str) { return shl_char_array(str); } +#endif +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) + bool operator<<(char32_t ch) { return shl_char(ch); } + bool operator<<(char32_t * str) { return shl_char_array(str); } + bool operator<<(char32_t const * str) { return shl_char_array(str); } #endif bool operator<<(unsigned char const* ch) { return ((*this) << reinterpret_cast(ch)); } bool operator<<(unsigned char * ch) { return ((*this) << reinterpret_cast(ch)); } @@ -1634,19 +1670,13 @@ namespace boost #if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) bool operator>>(char32_t& output) { return shr_xchar(output); } #endif -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - bool operator>>(std::string& str) { str.assign(start, finish); return true; } -# ifndef BOOST_LCAST_NO_WCHAR_T - bool operator>>(std::wstring& str) { str.assign(start, finish); return true; } -# endif -#else template bool operator>>(std::basic_string& str) { str.assign(start, finish); return true; } #if !defined(__SUNPRO_CC) template bool operator>>(::boost::container::basic_string& str) { str.assign(start, finish); return true; } #endif // !defined(__SUNPRO_CC) -#endif + /* * case "-0" || "0" || "+0" : output = false; return true; * case "1" || "+1": output = true; return true; @@ -1752,10 +1782,6 @@ namespace boost }; } -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - - // call-by-const reference version - namespace detail { template @@ -1788,60 +1814,6 @@ namespace boost BOOST_STATIC_CONSTANT(bool, value = true ); }; #endif // !defined(__SUNPRO_CC) - template - struct is_char_or_wchar - { - private: -#ifndef BOOST_LCAST_NO_WCHAR_T - typedef wchar_t wchar_t_if_supported; -#else - typedef char wchar_t_if_supported; -#endif - -#ifndef BOOST_NO_CHAR16_T - typedef char16_t char16_t_if_supported; -#else - typedef char char16_t_if_supported; -#endif - -#ifndef BOOST_NO_CHAR32_T - typedef char32_t char32_t_if_supported; -#else - typedef char char32_t_if_supported; -#endif - public: - - BOOST_STATIC_CONSTANT(bool, value = - ( - ::boost::type_traits::ice_or< - is_same< T, char >::value, - is_same< T, wchar_t_if_supported >::value, - is_same< T, char16_t_if_supported >::value, - is_same< T, char32_t_if_supported >::value, - is_same< T, unsigned char >::value, - is_same< T, signed char >::value - >::value - ) - ); - }; - - template - struct is_char_iterator_range - { - BOOST_STATIC_CONSTANT(bool, value = false ); - }; - - template - struct is_char_iterator_range > - { - BOOST_STATIC_CONSTANT(bool, value = (is_char_or_wchar::value) ); - }; - - template - struct is_char_iterator_range > - { - BOOST_STATIC_CONSTANT(bool, value = (is_char_or_wchar::value) ); - }; template struct is_arithmetic_and_not_xchars @@ -1970,51 +1942,34 @@ namespace boost "Your compiler does not have full support for char32_t" ); #endif - typedef detail::lcast_src_length lcast_src_length; + typedef detail::lcast_src_length lcast_src_length; std::size_t const src_len = lcast_src_length::value; char_type buf[src_len + 1]; lcast_src_length::check_coverage(); - typedef BOOST_DEDUCED_TYPENAME - deduce_char_traits::type traits; + typedef BOOST_DEDUCED_TYPENAME ::boost::detail::deduce_char_traits< + char_type, Target, Source + >::type traits; - typedef BOOST_DEDUCED_TYPENAME remove_pointer::type removed_ptr_t_1; - typedef BOOST_DEDUCED_TYPENAME remove_cv::type removed_ptr_t; + typedef ::boost::type_traits::ice_and< + ::boost::detail::is_char_or_wchar::value, // source is lexical type + ::boost::detail::is_char_or_wchar::value, // target is a lexical type + ::boost::is_same::value, // source is not a wide character based type + ::boost::type_traits::ice_ne::value // target type is based on wide character + > is_string_widening_required_t; - // is_char_types_match variable value can be computed via - // sizeof(char_type) == sizeof(removed_ptr_t). But when - // removed_ptr_t is an incomplete type or void*, compilers - // produce warnings or errors. - const bool is_char_types_match = - (::boost::type_traits::ice_or< - ::boost::type_traits::ice_and< - ::boost::type_traits::ice_eq::value, - ::boost::type_traits::ice_or< - ::boost::is_same::value, - ::boost::is_same::value, - ::boost::is_same::value - >::value - >::value, - ::boost::is_same::value - >::value); + typedef ::boost::type_traits::ice_or< + ::boost::is_integral::value, + ::boost::detail::is_this_float_conversion_optimized::value, + ::boost::detail::is_char_or_wchar::value + > is_source_input_optimized_t; - const bool requires_stringbuf = - !( - ::boost::type_traits::ice_or< - ::boost::detail::is_stdstring::value, - ::boost::is_integral::value, - ::boost::detail::is_this_float_conversion_optimized::value, - ::boost::type_traits::ice_and< - ::boost::detail::is_char_iterator_range::value, - is_char_types_match - >::value, - ::boost::type_traits::ice_and< - ::boost::is_pointer::value, - ::boost::detail::is_char_or_wchar::value, - is_char_types_match - >::value - >::value - ); + // If we have an optimized conversion for + // Source, we do not need to construct stringbuf. + const bool requires_stringbuf = ::boost::type_traits::ice_or< + is_string_widening_required_t::value, + ::boost::type_traits::ice_not< is_source_input_optimized_t::value >::value + >::value; detail::lexical_stream_limited_src interpreter(buf, buf + src_len); @@ -2030,7 +1985,7 @@ namespace boost # pragma warning( pop ) #endif - template + template struct lexical_cast_copy { static inline Source lexical_cast_impl(const Source &arg) @@ -2039,7 +1994,7 @@ namespace boost } }; - template + template struct detect_precision_loss { typedef boost::numeric::Trunc Rounder; @@ -2063,7 +2018,7 @@ namespace boost typedef typename Rounder::round_style round_style; } ; - template + template struct nothrow_overflow_handler { void operator() ( boost::numeric::range_check_result r ) @@ -2073,7 +2028,7 @@ namespace boost } } ; - template + template struct lexical_cast_dynamic_num_not_ignoring_minus { static inline Target lexical_cast_impl(const Source &arg) @@ -2088,7 +2043,7 @@ namespace boost } }; - template + template struct lexical_cast_dynamic_num_ignoring_minus { static inline Target lexical_cast_impl(const Source &arg) @@ -2125,7 +2080,7 @@ namespace boost * optional, so if a negative number is read, no errors will arise * and the result will be the two's complement. */ - template + template struct lexical_cast_dynamic_num { static inline Target lexical_cast_impl(const Source &arg) @@ -2153,40 +2108,80 @@ namespace boost }; } - template + template inline Target lexical_cast(const Source &arg) { typedef BOOST_DEDUCED_TYPENAME ::boost::detail::array_to_pointer_decay::type src; typedef BOOST_DEDUCED_TYPENAME ::boost::type_traits::ice_or< - ::boost::detail::is_xchar_to_xchar::value, - ::boost::detail::is_char_array_to_stdstring::value, + ::boost::detail::is_xchar_to_xchar::value, + ::boost::detail::is_char_array_to_stdstring::value, ::boost::type_traits::ice_and< - ::boost::is_same::value, - ::boost::detail::is_stdstring::value + ::boost::is_same::value, + ::boost::detail::is_stdstring::value >::value - > do_copy_type; + > shall_we_copy_t; typedef BOOST_DEDUCED_TYPENAME - ::boost::detail::is_arithmetic_and_not_xchars do_copy_with_dynamic_check_type; + ::boost::detail::is_arithmetic_and_not_xchars shall_we_copy_with_dynamic_check_t; typedef BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< - do_copy_type::value, - detail::lexical_cast_copy, + shall_we_copy_t::value, + ::boost::detail::lexical_cast_copy, BOOST_DEDUCED_TYPENAME ::boost::mpl::if_c< - do_copy_with_dynamic_check_type::value, - ::boost::detail::lexical_cast_dynamic_num, - ::boost::detail::lexical_cast_do_cast + shall_we_copy_with_dynamic_check_t::value, + ::boost::detail::lexical_cast_dynamic_num, + ::boost::detail::lexical_cast_do_cast >::type >::type caster_type; return caster_type::lexical_cast_impl(arg); } - #else +} // namespace boost - namespace detail // stream wrapper for handling lexical conversions +#else // #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + +namespace boost { + namespace detail { + + // selectors for choosing stream character type + template + struct stream_char + { + typedef char type; + }; + +#ifndef BOOST_LCAST_NO_WCHAR_T +#ifndef BOOST_NO_INTRINSIC_WCHAR_T + template<> + struct stream_char + { + typedef wchar_t type; + }; +#endif + + template<> + struct stream_char + { + typedef wchar_t type; + }; + + template<> + struct stream_char + { + typedef wchar_t type; + }; + + template<> + struct stream_char + { + typedef wchar_t type; + }; +#endif + + // stream wrapper for handling lexical conversions template class lexical_stream { @@ -2276,8 +2271,9 @@ namespace boost return result; } - #endif -} +} // namespace boost + +#endif // Copyright Kevlin Henney, 2000-2005. // Copyright Alexander Nasonov, 2006-2010. @@ -2287,5 +2283,8 @@ namespace boost // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#undef BOOST_LCAST_THROW_BAD_CAST #undef BOOST_LCAST_NO_WCHAR_T -#endif + +#endif // BOOST_LEXICAL_CAST_INCLUDED + diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 4e70bdd..844ee71 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -427,7 +427,6 @@ void test_conversion_to_wstring() BOOST_CHECK(str == lexical_cast(str)); BOOST_CHECK(L"123" == lexical_cast(123)); BOOST_CHECK(L"1.23" == lexical_cast(1.23)); - BOOST_CHECK(L"1.111111111" == lexical_cast(1.111111111)); BOOST_CHECK(L"1" == lexical_cast(true)); BOOST_CHECK(L"0" == lexical_cast(false)); #if !defined(BOOST_NO_INTRINSIC_WCHAR_T) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2673009..6edd59b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -12,6 +12,7 @@ project : requirements /boost/test//boost_unit_test_framework static + gcc-4.8:BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES ; # Thanks to Steven Watanabe for helping with feature diff --git a/test/lexical_cast_containers_test.cpp b/test/lexical_cast_containers_test.cpp index 0c6315b..e6c544a 100644 --- a/test/lexical_cast_containers_test.cpp +++ b/test/lexical_cast_containers_test.cpp @@ -14,6 +14,8 @@ void testing_boost_containers_basic_string(); void testing_boost_containers_string_std_string(); +void testing_boost_containers_string_widening(); + using namespace boost; @@ -23,6 +25,7 @@ boost::unit_test::test_suite *init_unit_test_suite(int, char *[]) BOOST_TEST_SUITE("Testing boost::lexical_cast with boost::container::string"); suite->add(BOOST_TEST_CASE(testing_boost_containers_basic_string)); suite->add(BOOST_TEST_CASE(testing_boost_containers_string_std_string)); + suite->add(BOOST_TEST_CASE(testing_boost_containers_string_widening)); return suite; } @@ -58,3 +61,23 @@ void testing_boost_containers_string_std_string() #endif } + +void testing_boost_containers_string_widening() +{ + const char char_array[] = "Test string"; + +#ifndef BOOST_LCAST_NO_WCHAR_T + const wchar_t wchar_array[] = L"Test string"; + BOOST_CHECK(boost::lexical_cast(char_array) == wchar_array); +#endif + +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES) + const char16_t char16_array[] = u"Test string"; + BOOST_CHECK(boost::lexical_cast >(char_array) == char16_array); +#endif + +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES) + const char32_t char32_array[] = U"Test string"; + BOOST_CHECK(boost::lexical_cast >(char_array) == char32_array); +#endif +} diff --git a/test/lexical_cast_iterator_range_test.cpp b/test/lexical_cast_iterator_range_test.cpp index 7afb1ae..d54de7a 100644 --- a/test/lexical_cast_iterator_range_test.cpp +++ b/test/lexical_cast_iterator_range_test.cpp @@ -43,7 +43,7 @@ inline std::basic_istream& operator >> (std::basic_istream& istr, template -void do_test_iterator_range(const RngT& rng) +void do_test_iterator_range_impl(const RngT& rng) { BOOST_CHECK_EQUAL(lexical_cast(rng), 1); BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); @@ -51,11 +51,13 @@ void do_test_iterator_range(const RngT& rng) BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); BOOST_CHECK_EQUAL(lexical_cast(rng), 1); BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + +#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES BOOST_CHECK_EQUAL(lexical_cast(rng), 1.0f); BOOST_CHECK_EQUAL(lexical_cast(rng), 1.0); BOOST_CHECK_EQUAL(lexical_cast(rng), 1.0L); BOOST_CHECK_EQUAL(lexical_cast(rng), 1); - +#endif #if defined(BOOST_HAS_LONG_LONG) BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); BOOST_CHECK_EQUAL(lexical_cast(rng), 1); @@ -63,115 +65,139 @@ void do_test_iterator_range(const RngT& rng) BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); BOOST_CHECK_EQUAL(lexical_cast<__int64>(rng), 1); #endif +} + +template +void test_it_range_using_any_chars(CharT* one, CharT* eleven) +{ + typedef CharT test_char_type; + + // Zero terminated + iterator_range rng1(one, one + 1); + do_test_iterator_range_impl(rng1); + + iterator_range crng1(one, one + 1); + do_test_iterator_range_impl(crng1); + + // Non zero terminated + iterator_range rng2(eleven, eleven + 1); + do_test_iterator_range_impl(rng2); + + iterator_range crng2(eleven, eleven + 1); + do_test_iterator_range_impl(crng2); +} + +template +void test_it_range_using_char(CharT* one, CharT* eleven) +{ + typedef CharT test_char_type; + + iterator_range rng1(one, one + 1); + BOOST_CHECK_EQUAL(lexical_cast(rng1), "1"); + + iterator_range crng1(one, one + 1); + BOOST_CHECK_EQUAL(lexical_cast(crng1), "1"); + + iterator_range rng2(eleven, eleven + 1); + BOOST_CHECK_EQUAL(lexical_cast(rng2), "1"); + + iterator_range crng2(eleven, eleven + 1); + BOOST_CHECK_EQUAL(lexical_cast(crng2), "1"); + + BOOST_CHECK_EQUAL(lexical_cast(rng1), 1.0f); + BOOST_CHECK_EQUAL(lexical_cast(rng1), 1.0); + BOOST_CHECK_EQUAL(lexical_cast(rng1), 1.0L); + BOOST_CHECK_EQUAL(lexical_cast(rng1), 1); + + BOOST_CHECK_EQUAL(lexical_cast(crng2), 1.0f); + BOOST_CHECK_EQUAL(lexical_cast(crng2), 1.0); + BOOST_CHECK_EQUAL(lexical_cast(crng2), 1.0L); + BOOST_CHECK_EQUAL(lexical_cast(crng2), 1); #ifndef BOOST_LCAST_NO_WCHAR_T - BOOST_CHECK(lexical_cast(rng) == L"1"); + BOOST_CHECK(lexical_cast(rng1) == L"1"); + BOOST_CHECK(lexical_cast(crng1) == L"1"); + BOOST_CHECK(lexical_cast(rng2) == L"1"); + BOOST_CHECK(lexical_cast(crng2) == L"1"); +#endif + +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES) + typedef std::basic_string my_char16_string; + BOOST_CHECK(lexical_cast(rng1) == u"1"); + BOOST_CHECK(lexical_cast(crng1) == u"1"); + BOOST_CHECK(lexical_cast(rng2) == u"1"); + BOOST_CHECK(lexical_cast(crng2) == u"1"); +#endif + +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES) + typedef std::basic_string my_char32_string; + BOOST_CHECK(lexical_cast(rng1) == U"1"); + BOOST_CHECK(lexical_cast(crng1) == U"1"); + BOOST_CHECK(lexical_cast(rng2) == U"1"); + BOOST_CHECK(lexical_cast(crng2) == U"1"); #endif } void test_char_iterator_ranges() { typedef char test_char_type; - - // Zero terminated test_char_type data1[] = "1"; - iterator_range rng1(data1, data1 + 1); - do_test_iterator_range(rng1); - BOOST_CHECK_EQUAL(lexical_cast(rng1), "1"); - - const test_char_type cdata1[] = "1"; - iterator_range crng1(cdata1, cdata1 + 1); - do_test_iterator_range(crng1); - BOOST_CHECK_EQUAL(lexical_cast(crng1), "1"); - - // Non zero terminated test_char_type data2[] = "11"; - iterator_range rng2(data2, data2 + 1); - do_test_iterator_range(rng2); - BOOST_CHECK_EQUAL(lexical_cast(rng2), "1"); - - const test_char_type cdata2[] = "11"; - iterator_range crng2(cdata2, cdata2 + 1); - do_test_iterator_range(crng2); - BOOST_CHECK_EQUAL(lexical_cast(crng2), "1"); + test_it_range_using_any_chars(data1, data2); + test_it_range_using_char(data1, data2); } + + void test_unsigned_char_iterator_ranges() { typedef unsigned char test_char_type; - - // Zero terminated test_char_type data1[] = "1"; - iterator_range rng1(data1, data1 + 1); - do_test_iterator_range(rng1); - BOOST_CHECK_EQUAL(lexical_cast(rng1), "1"); - - const test_char_type cdata1[] = "1"; - iterator_range crng1(cdata1, cdata1 + 1); - do_test_iterator_range(crng1); - BOOST_CHECK_EQUAL(lexical_cast(crng1), "1"); - - // Non zero terminated test_char_type data2[] = "11"; - iterator_range rng2(data2, data2 + 1); - do_test_iterator_range(rng2); - BOOST_CHECK_EQUAL(lexical_cast(rng2), "1"); - - const test_char_type cdata2[] = "11"; - iterator_range crng2(cdata2, cdata2 + 1); - do_test_iterator_range(crng2); - BOOST_CHECK_EQUAL(lexical_cast(crng2), "1"); + test_it_range_using_any_chars(data1, data2); + test_it_range_using_char(data1, data2); } void test_signed_char_iterator_ranges() { typedef signed char test_char_type; - - // Zero terminated test_char_type data1[] = "1"; - iterator_range rng1(data1, data1 + 1); - do_test_iterator_range(rng1); - BOOST_CHECK_EQUAL(lexical_cast(rng1), "1"); - - const test_char_type cdata1[] = "1"; - iterator_range crng1(cdata1, cdata1 + 1); - do_test_iterator_range(crng1); - BOOST_CHECK_EQUAL(lexical_cast(crng1), "1"); - - // Non zero terminated test_char_type data2[] = "11"; - iterator_range rng2(data2, data2 + 1); - do_test_iterator_range(rng2); - BOOST_CHECK_EQUAL(lexical_cast(rng2), "1"); - - const test_char_type cdata2[] = "11"; - iterator_range crng2(cdata2, cdata2 + 1); - do_test_iterator_range(crng2); - BOOST_CHECK_EQUAL(lexical_cast(crng2), "1"); + test_it_range_using_any_chars(data1, data2); + test_it_range_using_char(data1, data2); } -void test_wide_char_iterator_ranges() +void test_wchar_iterator_ranges() { #ifndef BOOST_LCAST_NO_WCHAR_T typedef wchar_t test_char_type; - - // Zero terminated test_char_type data1[] = L"1"; - iterator_range rng1(data1, data1 + 1); - do_test_iterator_range(rng1); - - const test_char_type cdata1[] = L"1"; - iterator_range crng1(cdata1, cdata1 + 1); - do_test_iterator_range(crng1); - - // Non zero terminated test_char_type data2[] = L"11"; - iterator_range rng2(data2, data2 + 1); - do_test_iterator_range(rng2); + test_it_range_using_any_chars(data1, data2); +#endif - const test_char_type cdata2[] = L"11"; - iterator_range crng2(cdata2, cdata2 + 1); - do_test_iterator_range(crng2); + BOOST_CHECK(true); +} + +void test_char16_iterator_ranges() +{ +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) + typedef char16_t test_char_type; + test_char_type data1[] = u"1"; + test_char_type data2[] = u"11"; + test_it_range_using_any_chars(data1, data2); +#endif + + BOOST_CHECK(true); +} + +void test_char32_iterator_ranges() +{ +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) + typedef char32_t test_char_type; + test_char_type data1[] = U"1"; + test_char_type data2[] = U"11"; + test_it_range_using_any_chars(data1, data2); #endif BOOST_CHECK(true); @@ -183,7 +209,9 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) suite->add(BOOST_TEST_CASE(&test_char_iterator_ranges)); suite->add(BOOST_TEST_CASE(&test_unsigned_char_iterator_ranges)); suite->add(BOOST_TEST_CASE(&test_signed_char_iterator_ranges)); - suite->add(BOOST_TEST_CASE(&test_wide_char_iterator_ranges)); + suite->add(BOOST_TEST_CASE(&test_wchar_iterator_ranges)); + suite->add(BOOST_TEST_CASE(&test_char16_iterator_ranges)); + suite->add(BOOST_TEST_CASE(&test_char32_iterator_ranges)); return suite; } diff --git a/test/lexical_cast_wchars_test.cpp b/test/lexical_cast_wchars_test.cpp index acd78b1..f78de1d 100755 --- a/test/lexical_cast_wchars_test.cpp +++ b/test/lexical_cast_wchars_test.cpp @@ -2,7 +2,7 @@ // // See http://www.boost.org for most recent version, including documentation. // -// Copyright Antony Polukhin, 2011. +// Copyright Antony Polukhin, 2011-2012. // // Distributed under the Boost // Software License, Version 1.0. (See accompanying file @@ -17,40 +17,70 @@ #endif #include - -#include #include -#include using namespace boost; -void test_char_types_conversions() +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) +#define BOOST_LCAST_NO_WCHAR_T +#endif + +template +void test_impl(const CharT* wc_arr) { -#ifndef BOOST_LCAST_NO_WCHAR_T + typedef CharT wide_char; + typedef std::basic_string wide_string; const char c_arr[] = "Test array of chars"; const unsigned char uc_arr[] = "Test array of chars"; const signed char sc_arr[] = "Test array of chars"; - const wchar_t wc_arr[] =L"Test array of chars"; // Following tests depend on realization of std::locale // and pass for popular compilers and STL realizations - BOOST_CHECK(boost::lexical_cast(c_arr[0]) == wc_arr[0]); - BOOST_CHECK(boost::lexical_cast(c_arr) == std::wstring(wc_arr)); + BOOST_CHECK(boost::lexical_cast(c_arr[0]) == wc_arr[0]); + BOOST_CHECK(boost::lexical_cast(c_arr) == wide_string(wc_arr)); - BOOST_CHECK(boost::lexical_cast(sc_arr) == std::wstring(wc_arr) ); - BOOST_CHECK(boost::lexical_cast(uc_arr) == std::wstring(wc_arr) ); + BOOST_CHECK(boost::lexical_cast(sc_arr) == wide_string(wc_arr) ); + BOOST_CHECK(boost::lexical_cast(uc_arr) == wide_string(wc_arr) ); - BOOST_CHECK_EQUAL(boost::lexical_cast(uc_arr[0]), wc_arr[0]); - BOOST_CHECK_EQUAL(boost::lexical_cast(sc_arr[0]), wc_arr[0]); + BOOST_CHECK_EQUAL(boost::lexical_cast(uc_arr[0]), wc_arr[0]); + BOOST_CHECK_EQUAL(boost::lexical_cast(sc_arr[0]), wc_arr[0]); +} + + +void test_char_types_conversions_wchar_t() +{ +#ifndef BOOST_LCAST_NO_WCHAR_T + test_impl(L"Test array of chars"); #endif - BOOST_CHECK(1); + + BOOST_CHECK(true); +} + +void test_char_types_conversions_char16_t() +{ +#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES) + test_impl(u"Test array of chars"); +#endif + + BOOST_CHECK(true); +} + +void test_char_types_conversions_char32_t() +{ +#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES) + test_impl(U"Test array of chars"); +#endif + + BOOST_CHECK(true); } unit_test::test_suite *init_unit_test_suite(int, char *[]) { unit_test::test_suite *suite = - BOOST_TEST_SUITE("lexical_cast char<->wchar_t unit test"); - suite->add(BOOST_TEST_CASE(&test_char_types_conversions)); + BOOST_TEST_SUITE("lexical_cast char => wide characters unit test (widening test)"); + suite->add(BOOST_TEST_CASE(&test_char_types_conversions_wchar_t)); + suite->add(BOOST_TEST_CASE(&test_char_types_conversions_char16_t)); + suite->add(BOOST_TEST_CASE(&test_char_types_conversions_char32_t)); return suite; } From b1b53059847d8c5eb891e65387c4b0c044fdc58f Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 26 Apr 2012 17:59:17 +0000 Subject: [PATCH 114/138] Merge from trunk: * fixed #6812 (now converting "." to float type throws bad_lexical_cast) [SVN r78211] --- include/boost/lexical_cast.hpp | 3 ++- test/lexical_cast_float_types_test.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 2e5c140..fb76d29 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1062,9 +1062,10 @@ namespace boost { ) return false; #endif - if(*begin == decimal_point){ + if(*begin == decimal_point) { ++ begin; found_decimal = true; + if (!found_number_before_exp && begin==end) return false; continue; }else { if (!found_number_before_exp) return false; diff --git a/test/lexical_cast_float_types_test.cpp b/test/lexical_cast_float_types_test.cpp index 808f456..60db0e1 100755 --- a/test/lexical_cast_float_types_test.cpp +++ b/test/lexical_cast_float_types_test.cpp @@ -261,6 +261,7 @@ void test_converion_to_float_types() BOOST_CHECK_THROW(lexical_cast(".e"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(".11111111111111111111111111111111111111111111111111111111111111111111ee"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(".11111111111111111111111111111111111111111111111111111111111111111111e-"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("."), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("-B"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("0xB"), bad_lexical_cast); @@ -276,6 +277,7 @@ void test_converion_to_float_types() BOOST_CHECK_THROW(lexical_cast("-"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast('\0'), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast('-'), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast('.'), bad_lexical_cast); } template From ca9c8d30bd31cd937ef57a77eb9c131b026a8c1c Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sun, 13 May 2012 08:15:51 +0000 Subject: [PATCH 115/138] =?UTF-8?q?Merge=20from=20trunk:=20*=20Fixes=20ISO?= =?UTF-8?q?=20C++=20does=20not=20support=20the=20=E2=80=98%lg=E2=80=99=20g?= =?UTF-8?q?nu=5Fprintf=20format=20(refs=20#6852)=20*=20explicit-failures-m?= =?UTF-8?q?arkup=20merge=20from=20trunk=20*=20supress=20warnings=20in=20im?= =?UTF-8?q?plicit=5Fcast.cpp=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [SVN r78450] --- include/boost/lexical_cast.hpp | 12 ++++++++---- test/implicit_cast.cpp | 6 ++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index fb76d29..c2580ec 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1322,7 +1322,8 @@ namespace boost { { using namespace std; if (put_inf_nan(begin, end, val)) return true; end = begin; - end += sprintf(begin,"%.*g", static_cast(boost::detail::lcast_get_precision()), val); + const double val_as_double = val; + end += sprintf(begin,"%.*g", static_cast(boost::detail::lcast_get_precision()), val_as_double); return end > begin; } @@ -1330,7 +1331,7 @@ namespace boost { { using namespace std; if (put_inf_nan(begin, end, val)) return true; end = begin; - end += sprintf(begin,"%.*lg", static_cast(boost::detail::lcast_get_precision()), val); + end += sprintf(begin,"%.*g", static_cast(boost::detail::lcast_get_precision()), val); return end > begin; } @@ -1353,8 +1354,11 @@ namespace boost { static bool shl_real_type(float val, wchar_t* begin, wchar_t*& end) { using namespace std; if (put_inf_nan(begin, end, val)) return true; + const double val_as_double = val; end = begin + swprintf(begin, end-begin, - L"%.*g", static_cast(boost::detail::lcast_get_precision()), val ); + L"%.*g", + static_cast(boost::detail::lcast_get_precision()), + val_as_double ); return end > begin; } @@ -1362,7 +1366,7 @@ namespace boost { { using namespace std; if (put_inf_nan(begin, end, val)) return true; end = begin + swprintf(begin, end-begin, - L"%.*lg", static_cast(boost::detail::lcast_get_precision()), val ); + L"%.*g", static_cast(boost::detail::lcast_get_precision()), val ); return end > begin; } diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp index e18e17a..8c3bc52 100644 --- a/test/implicit_cast.cpp +++ b/test/implicit_cast.cpp @@ -28,5 +28,11 @@ int main() type f = check_return(boost::implicit_cast("hello")); type z = check_return(boost::implicit_cast(foo("hello"))); + + // warning supression: + (void)x; + (void)f; + (void)z; + return boost::report_errors(); } From 79d6468aebf86e9ae9edb83c98912227f24fc340 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 24 May 2012 04:22:04 +0000 Subject: [PATCH 116/138] Merge lexical_cast from trunk : * force SunCC compiler to use fallback version of lexical_cast (with fallbak version SunCC can pass at least some tests) * removed trailing whitespaces [SVN r78565] --- doc/Jamfile.v2 | 6 +- doc/lexical_cast.qbk | 62 +++++++++---------- include/boost/lexical_cast.hpp | 60 ++++++++---------- perf/Jamfile.v2 | 10 +-- test/Jamfile.v2 | 10 +-- test/lexical_cast_containers_test.cpp | 2 +- test/lexical_cast_float_types_test.cpp | 2 +- test/lexical_cast_iterator_range_test.cpp | 12 ++-- test/lexical_cast_no_exceptions_test.cpp | 14 ++--- test/lexical_cast_no_locale_test.cpp | 10 +-- ...ical_cast_typedefed_wchar_test_runtime.cpp | 2 +- 11 files changed, 90 insertions(+), 100 deletions(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index b629c6a..0b47ee3 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -6,9 +6,9 @@ using quickbook ; import boostbook : boostbook ; xml lexical_cast : lexical_cast.qbk ; -boostbook standalone - : - lexical_cast +boostbook standalone + : + lexical_cast : boost.root=../../../.. pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index c786fbc..b856594 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -34,7 +34,7 @@ The standard C++ library offers `stringstream` for the kind of in-core formattin The `lexical_cast` function template offers a convenient and consistent form for supporting common conversions to and from arbitrary types when they are represented as text. The simplification it offers is in expression-level convenience for such conversions. For more involved conversions, such as where precision or formatting need tighter control than is offered by the default behavior of `lexical_cast`, the conventional `std::stringstream` approach is recommended. Where the conversions are numeric to numeric, __numericcast__ may offer more reasonable behavior than `lexical_cast`. -For a good discussion of the options and issues involved in string-based formatting, including comparison of `stringstream`, `lexical_cast`, and others, see Herb Sutter's article, [@http://www.gotw.ca/publications/mill19.htm The String Formatters of Manor Farm]. Also, take a look at the [link boost_lexical_cast.performance Performance] section. +For a good discussion of the options and issues involved in string-based formatting, including comparison of `stringstream`, `lexical_cast`, and others, see Herb Sutter's article, [@http://www.gotw.ca/publications/mill19.htm The String Formatters of Manor Farm]. Also, take a look at the [link boost_lexical_cast.performance Performance] section. [endsect] [section Examples] @@ -105,8 +105,8 @@ The character type of the underlying stream is assumed to be `char` unless eithe * `boost::iterator_range`, where `WideCharPtr` is a pointer to wide-character or pointer to const wide-character [important Many compilers and runtime libraries fail to make conversions using new Unicode characters. Make shure that the following code compiles and outputs nonzero values, before using new types: -`` - std::cout +`` + std::cout << booat::lexical_cast(1.0).size() << " " << booat::lexical_cast(1.0).size(); @@ -151,13 +151,13 @@ Consider the following example: return data_length; } }; - + inline std::ostream& operator << (std::ostream& ostr, const example_class& rhs) { return ostr << boost::make_iterator_range(rhs.data(), rhs.data() + rhs.size()); } `` -This is a good generic solution for most use cases. +This is a good generic solution for most use cases. But we can make it even faster for some performance critical applications. During conversion, we loose speed at: * `std::ostream` construction (it makes some heap allocations) @@ -182,35 +182,35 @@ Now `boost::lexical_cast(example_class_instance)` conversions won't c [section Frequently Asked Questions] * [*Question:] Why does `lexical_cast("127")` throw `bad_lexical_cast`? - * [*Answer:] The type `int8_t` is a `typedef` to `char` or `signed char`. Lexical conversion to these types is simply reading a byte from source but since the source has more than one byte, the exception is thrown. -Please use other integer types such as `int` or `short int`. If bounds checking is important, you can also -call __numericcast__: + * [*Answer:] The type `int8_t` is a `typedef` to `char` or `signed char`. Lexical conversion to these types is simply reading a byte from source but since the source has more than one byte, the exception is thrown. +Please use other integer types such as `int` or `short int`. If bounds checking is important, you can also +call __numericcast__: `numeric_cast(lexical_cast("127"));` [pre ] * [*Question:] Why does `lexical_cast("127")` throw `bad_lexical_cast`? - * [*Answer:] Lexical conversion to any char type is simply reading a byte from source. But since the source has more than one byte, the exception is thrown. -Please use other integer types such as `int` or `short int`. If bounds checking is important, you can also -call __numericcast__: + * [*Answer:] Lexical conversion to any char type is simply reading a byte from source. But since the source has more than one byte, the exception is thrown. +Please use other integer types such as `int` or `short int`. If bounds checking is important, you can also +call __numericcast__: `numeric_cast(lexical_cast("127"));` [pre ] * [*Question:] What does `lexical_cast` of an `int8_t` or `uint8_t` not do what I expect? - * [*Answer:] As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid + * [*Answer:] As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid this, cast to an integer type first: `lexical_cast(static_cast(n));` [pre ] -* [*Question:] The implementation always resets the `ios_base::skipws` flag of an underlying stream object. +* [*Question:] The implementation always resets the `ios_base::skipws` flag of an underlying stream object. It breaks my `operator>>` that works only in presence of this flag. Can you remove code that resets the flag? - * [*Answer:] May be in a future version. There is no requirement in -__proposallong__ to reset the flag but -remember that __proposalshort__ is not yet accepted by the committee. By the way, it's a great opportunity to + * [*Answer:] May be in a future version. There is no requirement in +__proposallong__ to reset the flag but +remember that __proposalshort__ is not yet accepted by the committee. By the way, it's a great opportunity to make your `operator>>` conform to the standard. Read a good C++ book, study `std::sentry` and [@boost:libs/io/doc/ios_state.html `ios_state_saver`]. @@ -218,17 +218,17 @@ Read a good C++ book, study `std::sentry` and [@boost:libs/io/doc/ios_state.html ] * [*Question:] Why `std::cout << boost::lexical_cast("-1");` does not throw, but outputs 4294967295? - * [*Answer:] `boost::lexical_cast` has the behavior of `std::stringstream`, which uses `num_get` functions of -`std::locale` to convert numbers. If we look at the Programming languages — C++, we'll see, that `num_get` uses -the rules of `scanf` for conversions. And in the C99 standard for unsigned input value minus sign is optional, so + * [*Answer:] `boost::lexical_cast` has the behavior of `std::stringstream`, which uses `num_get` functions of +`std::locale` to convert numbers. If we look at the Programming languages — C++, we'll see, that `num_get` uses +the rules of `scanf` for conversions. And in the C99 standard for unsigned input value minus sign is optional, so if a negative number is read, no errors will arise and the result will be the two's complement. [pre ] * [*Question:] Why `boost::lexical_cast(L'A');` outputs 65 and `boost::lexical_cast(L"65");` does not throw? - * [*Answer:] If you are using an old version of Visual Studio or compile code with /Zc:wchar_t- flag, -`boost::lexical_cast` sees single `wchar_t` character as `unsigned short`. It is not a `boost::lexical_cast` mistake, but a + * [*Answer:] If you are using an old version of Visual Studio or compile code with /Zc:wchar_t- flag, +`boost::lexical_cast` sees single `wchar_t` character as `unsigned short`. It is not a `boost::lexical_cast` mistake, but a limitation of compiler options that you use. [pre @@ -236,7 +236,7 @@ limitation of compiler options that you use. * [*Question:] Why `boost::lexical_cast("-1.#IND");` throws `boost::bad_lexical_cast`? * [*Answer:] `"-1.#IND"` is a compiler extension, that violates standard. You shall input `"-nan"`, `"nan"`, `"inf"` -, `"-inf"` (case insensitive) strings to get NaN and Inf values. `boost::lexical_cast` outputs `"-nan"`, `"nan"`, +, `"-inf"` (case insensitive) strings to get NaN and Inf values. `boost::lexical_cast` outputs `"-nan"`, `"nan"`, `"inf"`, `"-inf"` strings, when has NaN or Inf input values. * [*Question:] What is the fastest way to convert a non zero terminated string or a substring using `boost::lexical_cast`? @@ -246,21 +246,21 @@ limitation of compiler options that you use. [section Changes] * [*boost 1.50.0 :] - + * `boost::bad_lexical_cast` exception is now globaly visible and can be catched even if code is compiled with -fvisibility=hidden. * Now it is possible to compile library with disabled exceptions. * Better performance, less memory usage and bugfixes for `boost::iterator_range` conversions. * [*boost 1.49.0 :] - - * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). + + * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). * Better performance and less memory usage for `boost::container::basic_string` conversions. - + * [*boost 1.48.0 :] - - * Added code to work with Inf and NaN on any platform. + + * Added code to work with Inf and NaN on any platform. * Better performance and less memory usage for conversions to float type (and to double type, if `sizeof(double) < sizeof(long double)`). - + * [*boost 1.47.0 :] * Optimizations for "C" and other locales without number grouping. @@ -283,7 +283,7 @@ limitation of compiler options that you use. * The previous version of lexical_cast used the default stream precision for reading and writing floating-point numbers. For numerics that have a corresponding specialization of `std::numeric_limits`, the current version now chooses a precision to match. * The previous version of lexical_cast did not support conversion to or from any wide-character-based types. For compilers with full language and library support for wide characters, `lexical_cast` now supports conversions from `wchar_t`, `wchar_t *`, and `std::wstring` and to `wchar_t` and `std::wstring`. * The previous version of `lexical_cast` assumed that the conventional stream extractor operators were sufficient for reading values. However, string I/O is asymmetric, with the result that spaces play the role of I/O separators rather than string content. The current version fixes this error for `std::string` and, where supported, `std::wstring`: `lexical_cast("Hello, World")` succeeds instead of failing with a `bad_lexical_cast` exception. - * The previous version of `lexical_cast` allowed unsafe and meaningless conversions to pointers. The current version now throws a `bad_lexical_cast` for conversions to pointers: `lexical_cast("Goodbye, World")` now throws an exception instead of causing undefined behavior. + * The previous version of `lexical_cast` allowed unsafe and meaningless conversions to pointers. The current version now throws a `bad_lexical_cast` for conversions to pointers: `lexical_cast("Goodbye, World")` now throws an exception instead of causing undefined behavior. [endsect] @@ -328,7 +328,7 @@ All the tests measure execution speed in milliseconds for 10000 iterations of th ``] ] ] -Fastest results are highlitened with "!!! *x* !!!". +Fastest results are highlitened with "!!! *x* !!!". Do not use this results to compare compilers, because tests were taken on different hardware. [endsect] diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index c2580ec..3e2e53f 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -69,12 +69,12 @@ namespace boost { // exception used to indicate runtime lexical_cast failure class BOOST_SYMBOL_VISIBLE bad_lexical_cast : - // workaround MSVC bug with std::bad_cast when _HAS_EXCEPTIONS == 0 -#if defined(BOOST_MSVC) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS - public std::exception -#else - public std::bad_cast -#endif + // workaround MSVC bug with std::bad_cast when _HAS_EXCEPTIONS == 0 +#if defined(BOOST_MSVC) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS + public std::exception +#else + public std::bad_cast +#endif #if defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, < 0x560 ) // under bcc32 5.5.1 bad_cast doesn't derive from exception @@ -134,7 +134,7 @@ namespace boost } } // namespace boost -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__SUNPRO_CC) #include #include @@ -147,9 +147,7 @@ namespace boost #include #include #include -#if !defined(__SUNPRO_CC) #include -#endif // !defined(__SUNPRO_CC) #ifndef BOOST_NO_CWCHAR # include #endif @@ -170,13 +168,13 @@ namespace boost { { typedef CharT type; }; - + template <> struct widest_char< not_a_character_type, not_a_character_type > { typedef char type; }; - } + } namespace detail // is_char_or_wchar<...> and stream_char<...> templates { @@ -243,7 +241,7 @@ namespace boost { { typedef BOOST_DEDUCED_TYPENAME stream_char::type type; }; - + template struct stream_char > { @@ -256,13 +254,11 @@ namespace boost { typedef CharT type; }; -#if !defined(__SUNPRO_CC) template struct stream_char< ::boost::container::basic_string > { typedef CharT type; }; -#endif // !defined(__SUNPRO_CC) #if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T) template<> @@ -312,7 +308,6 @@ namespace boost { typedef Traits type; }; -#if !defined(__SUNPRO_CC) template struct deduce_char_traits< CharT , ::boost::container::basic_string @@ -366,7 +361,6 @@ namespace boost { { typedef Traits type; }; -#endif // !defined(__SUNPRO_CC) } namespace detail // lcast_src_length @@ -436,7 +430,7 @@ namespace boost { // -1.23456789e-123456 // ^ sign // ^ leading digit - // ^ decimal point + // ^ decimal point // ^^^^^^^^ lcast_precision::value // ^ "e" // ^ exponent sign @@ -1389,7 +1383,6 @@ namespace boost { return true; } -#if !defined(__SUNPRO_CC) template bool operator<<(::boost::container::basic_string const& str) { @@ -1397,7 +1390,7 @@ namespace boost { finish = start + str.length(); return true; } -#endif // !defined(__SUNPRO_CC) + bool operator<<(bool value) { CharT const czero = lcast_char_constants::zero; @@ -1410,14 +1403,14 @@ namespace boost { { start = rng.begin(); finish = rng.end(); - return true; + return true; } - + bool operator<<(const iterator_range& rng) { start = const_cast(rng.begin()); finish = const_cast(rng.end()); - return true; + return true; } bool operator<<(const iterator_range& rng) @@ -1677,10 +1670,9 @@ namespace boost { #endif template bool operator>>(std::basic_string& str) { str.assign(start, finish); return true; } -#if !defined(__SUNPRO_CC) + template bool operator>>(::boost::container::basic_string& str) { str.assign(start, finish); return true; } -#endif // !defined(__SUNPRO_CC) /* * case "-0" || "0" || "+0" : output = false; return true; @@ -1812,13 +1804,12 @@ namespace boost { { BOOST_STATIC_CONSTANT(bool, value = true ); }; -#if !defined(__SUNPRO_CC) + template struct is_stdstring< ::boost::container::basic_string > { BOOST_STATIC_CONSTANT(bool, value = true ); }; -#endif // !defined(__SUNPRO_CC) template struct is_arithmetic_and_not_xchars @@ -1866,11 +1857,11 @@ namespace boost { }; - // this metafunction evaluates to true, if we have optimized comnversion - // from Float type to Char array. + // this metafunction evaluates to true, if we have optimized comnversion + // from Float type to Char array. // Must be in sync with lexical_stream_limited_src::shl_real_type(...) template - struct is_this_float_conversion_optimized + struct is_this_float_conversion_optimized { typedef ::boost::type_traits::ice_and< ::boost::is_float::value, @@ -1904,7 +1895,7 @@ namespace boost { { BOOST_STATIC_CONSTANT(bool, value = true ); }; -#if !defined(__SUNPRO_CC) + template struct is_char_array_to_stdstring< ::boost::container::basic_string, CharT* > { @@ -1916,7 +1907,6 @@ namespace boost { { BOOST_STATIC_CONSTANT(bool, value = true ); }; -#endif // !defined(__SUNPRO_CC) #if (defined _MSC_VER) # pragma warning( push ) @@ -2262,10 +2252,10 @@ namespace boost { template Target lexical_cast(Source arg) { - typedef typename detail::widest_char< - BOOST_DEDUCED_TYPENAME detail::stream_char::type - , BOOST_DEDUCED_TYPENAME detail::stream_char::type - >::type char_type; + typedef typename detail::widest_char< + BOOST_DEDUCED_TYPENAME detail::stream_char::type + , BOOST_DEDUCED_TYPENAME detail::stream_char::type + >::type char_type; typedef std::char_traits traits; detail::lexical_stream interpreter; diff --git a/perf/Jamfile.v2 b/perf/Jamfile.v2 index 78176be..6f03fe1 100644 --- a/perf/Jamfile.v2 +++ b/perf/Jamfile.v2 @@ -13,17 +13,17 @@ path-constant TEST_DIR : . ; project performance/test : source-location ./ - : requirements -# /boost/chrono//boost_chrono + : requirements +# /boost/chrono//boost_chrono # /boost/system//boost_system static - freebsd:"-lrt" + freebsd:"-lrt" linux:"-lrt" gcc:-fvisibility=hidden intel-linux:-fvisibility=hidden sun:-xldscope=hidden : default-build release ; - + run performance_test.cpp : $(TEST_DIR) ; - + diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6edd59b..f8ee0d3 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -11,20 +11,20 @@ import feature ; project : requirements /boost/test//boost_unit_test_framework - static + static gcc-4.8:BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES ; -# Thanks to Steven Watanabe for helping with feature +# Thanks to Steven Watanabe for helping with feature feature.feature nowchar : on : composite optional propagated link-incompatible ; feature.compose on : /Zc:wchar_t- ; - + test-suite conversion : [ run implicit_cast.cpp ] [ compile-fail implicit_cast_fail.cpp ] [ run ../cast_test.cpp ] - [ run ../numeric_cast_test.cpp ] + [ run ../numeric_cast_test.cpp ] [ run ../lexical_cast_test.cpp ] [ run lexical_cast_loopback_test.cpp ] [ run lexical_cast_abstract_test.cpp ] @@ -39,7 +39,7 @@ test-suite conversion [ compile lexical_cast_typedefed_wchar_test.cpp : msvc:on ] [ run lexical_cast_typedefed_wchar_test_runtime.cpp : : : msvc:on msvc,stlport:no ] [ run lexical_cast_no_locale_test.cpp : : : BOOST_NO_STD_LOCALE BOOST_LEXICAL_CAST_ASSUME_C_LOCALE ] - [ run lexical_cast_no_exceptions_test.cpp : : : BOOST_NO_EXCEPTIONS + [ run lexical_cast_no_exceptions_test.cpp : : : BOOST_NO_EXCEPTIONS gcc-4.3:-fno-exceptions gcc-4.4:-fno-exceptions gcc-4.5:-fno-exceptions diff --git a/test/lexical_cast_containers_test.cpp b/test/lexical_cast_containers_test.cpp index e6c544a..bb13f31 100644 --- a/test/lexical_cast_containers_test.cpp +++ b/test/lexical_cast_containers_test.cpp @@ -31,7 +31,7 @@ boost::unit_test::test_suite *init_unit_test_suite(int, char *[]) } void testing_boost_containers_basic_string() -{ +{ BOOST_CHECK("100" == lexical_cast("100")); BOOST_CHECK(L"100" == lexical_cast(L"100")); diff --git a/test/lexical_cast_float_types_test.cpp b/test/lexical_cast_float_types_test.cpp index 60db0e1..827b6ec 100755 --- a/test/lexical_cast_float_types_test.cpp +++ b/test/lexical_cast_float_types_test.cpp @@ -237,7 +237,7 @@ void test_converion_to_float_types() CHECK_CLOSE_ABS_DIFF(-10101.0E-011, test_t); CHECK_CLOSE_ABS_DIFF(-10101093, test_t); CHECK_CLOSE_ABS_DIFF(10101093, test_t); - + CHECK_CLOSE_ABS_DIFF(-.34, test_t); CHECK_CLOSE_ABS_DIFF(.34, test_t); CHECK_CLOSE_ABS_DIFF(.34e10, test_t); diff --git a/test/lexical_cast_iterator_range_test.cpp b/test/lexical_cast_iterator_range_test.cpp index d54de7a..50b86ff 100644 --- a/test/lexical_cast_iterator_range_test.cpp +++ b/test/lexical_cast_iterator_range_test.cpp @@ -138,7 +138,7 @@ void test_it_range_using_char(CharT* one, CharT* eleven) #endif } -void test_char_iterator_ranges() +void test_char_iterator_ranges() { typedef char test_char_type; test_char_type data1[] = "1"; @@ -149,7 +149,7 @@ void test_char_iterator_ranges() -void test_unsigned_char_iterator_ranges() +void test_unsigned_char_iterator_ranges() { typedef unsigned char test_char_type; test_char_type data1[] = "1"; @@ -158,7 +158,7 @@ void test_unsigned_char_iterator_ranges() test_it_range_using_char(data1, data2); } -void test_signed_char_iterator_ranges() +void test_signed_char_iterator_ranges() { typedef signed char test_char_type; test_char_type data1[] = "1"; @@ -167,7 +167,7 @@ void test_signed_char_iterator_ranges() test_it_range_using_char(data1, data2); } -void test_wchar_iterator_ranges() +void test_wchar_iterator_ranges() { #ifndef BOOST_LCAST_NO_WCHAR_T typedef wchar_t test_char_type; @@ -179,7 +179,7 @@ void test_wchar_iterator_ranges() BOOST_CHECK(true); } -void test_char16_iterator_ranges() +void test_char16_iterator_ranges() { #if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) typedef char16_t test_char_type; @@ -191,7 +191,7 @@ void test_char16_iterator_ranges() BOOST_CHECK(true); } -void test_char32_iterator_ranges() +void test_char32_iterator_ranges() { #if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) typedef char32_t test_char_type; diff --git a/test/lexical_cast_no_exceptions_test.cpp b/test/lexical_cast_no_exceptions_test.cpp index dbec8ea..c470eda 100755 --- a/test/lexical_cast_no_exceptions_test.cpp +++ b/test/lexical_cast_no_exceptions_test.cpp @@ -22,7 +22,7 @@ #ifndef BOOST_NO_EXCEPTIONS #error "This test must be compiled with -DBOOST_NO_EXCEPTIONS" -#endif +#endif bool g_was_exception = false; @@ -60,25 +60,25 @@ inline std::istream& operator>> (std::istream& i, Escape& rhs) void test_exceptions_off() { Escape v(""); - - g_was_exception = false; + + g_was_exception = false; lexical_cast(v); BOOST_CHECK(g_was_exception); - + g_was_exception = false; lexical_cast(v); BOOST_CHECK(g_was_exception); - + v = lexical_cast(100); BOOST_CHECK_EQUAL(lexical_cast(v), 100); BOOST_CHECK_EQUAL(lexical_cast(v), 100u); - + v = lexical_cast(0.0); BOOST_CHECK_EQUAL(lexical_cast(v), 0.0); BOOST_CHECK_EQUAL(lexical_cast(100), 100); BOOST_CHECK_EQUAL(lexical_cast(0.0), 0.0); - + g_was_exception = false; lexical_cast(700000); BOOST_CHECK(g_was_exception); diff --git a/test/lexical_cast_no_locale_test.cpp b/test/lexical_cast_no_locale_test.cpp index f3defb3..2a5120b 100755 --- a/test/lexical_cast_no_locale_test.cpp +++ b/test/lexical_cast_no_locale_test.cpp @@ -23,12 +23,12 @@ using namespace boost; // Testing compilation and some basic usage with BOOST_NO_STD_LOCALE -// Tests are mainly copyied from lexical_cast_empty_input_test.cpp (something +// Tests are mainly copyied from lexical_cast_empty_input_test.cpp (something // new added to test_empty_3) #ifndef BOOST_NO_STD_LOCALE #error "This test must be compiled with -DBOOST_NO_STD_LOCALE" -#endif +#endif template @@ -106,15 +106,15 @@ void test_empty_3() { Escape v(""); do_test_on_empty_input(v); - + BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(v), bad_lexical_cast); - + v = lexical_cast(100); BOOST_CHECK_EQUAL(lexical_cast(v), 100); BOOST_CHECK_EQUAL(lexical_cast(v), 100u); - + v = lexical_cast(0.0); BOOST_CHECK_EQUAL(lexical_cast(v), 0.0); } diff --git a/test/lexical_cast_typedefed_wchar_test_runtime.cpp b/test/lexical_cast_typedefed_wchar_test_runtime.cpp index d01700a..adb024e 100755 --- a/test/lexical_cast_typedefed_wchar_test_runtime.cpp +++ b/test/lexical_cast_typedefed_wchar_test_runtime.cpp @@ -30,7 +30,7 @@ void test_typedefed_wchar_t_runtime() BOOST_CHECK_EQUAL(boost::lexical_cast(L'A'), 65); BOOST_CHECK_EQUAL(boost::lexical_cast(L'B'), 66); - + BOOST_CHECK_EQUAL(boost::lexical_cast(L"65"), 65); BOOST_CHECK_EQUAL(boost::lexical_cast(L"66"), 66); #endif From 3271717a5d3668b04019b2e0d583e4ac22afe32b Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Thu, 28 Jun 2012 12:37:29 +0000 Subject: [PATCH 117/138] Release 1.50.0 [SVN r79156] --- include/boost/implicit_cast.hpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 include/boost/implicit_cast.hpp diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 From 675d0bb4516025323a5ff5dd67aa12368abf22e5 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sun, 8 Jul 2012 18:06:32 +0000 Subject: [PATCH 118/138] Merge from trunk (now lexical_cast has optimized conversions to and from array<>, fixes #7065) [SVN r79364] --- doc/lexical_cast.qbk | 920 ++++++++++++---------- include/boost/lexical_cast.hpp | 231 +++++- lexical_cast_test.cpp | 477 +---------- perf/performance_test.cpp | 47 +- test/Jamfile.v2 | 2 + test/implicit_cast.cpp | 2 +- test/implicit_cast_fail.cpp | 2 + test/lexical_cast_arrays_test.cpp | 367 +++++++++ test/lexical_cast_integral_types_test.cpp | 539 +++++++++++++ 9 files changed, 1670 insertions(+), 917 deletions(-) create mode 100644 test/lexical_cast_arrays_test.cpp create mode 100644 test/lexical_cast_integral_types_test.cpp diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index b856594..59309d2 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -70,6 +70,15 @@ The following example uses numeric data in a string expression: log_message("Error " + boost::lexical_cast(yoko) + ": " + strerror(yoko)); } `` +Following example converts some number and puts it to file: +`` + int i; + FILE* file; + ... + typedef boost::array buf_t; // You can use std::array if your compiler supports it + buf_t buffer = boost::lexical_cast(i); // No dynamic memory allocation + puts(buffer.begin(), file); +`` [endsect] [section Synopsis] @@ -103,6 +112,7 @@ The character type of the underlying stream is assumed to be `char` unless eithe * Arrays of characters: `wchar_t *`, `char16_t *`, `char32_t *`, `const wchar_t *`, `const char16_t *`, `const char32_t *` * Strings: `std::basic_string`, `boost::containers::basic_string` * `boost::iterator_range`, where `WideCharPtr` is a pointer to wide-character or pointer to const wide-character +* `boost::array` and `std::array`, `boost::array` and `std::array` [important Many compilers and runtime libraries fail to make conversions using new Unicode characters. Make shure that the following code compiles and outputs nonzero values, before using new types: `` @@ -239,12 +249,20 @@ limitation of compiler options that you use. , `"-inf"` (case insensitive) strings to get NaN and Inf values. `boost::lexical_cast` outputs `"-nan"`, `"nan"`, `"inf"`, `"-inf"` strings, when has NaN or Inf input values. +[pre +] + * [*Question:] What is the fastest way to convert a non zero terminated string or a substring using `boost::lexical_cast`? * [*Answer:] Use `boost::iterator_range` for conversion. For example, if you whant to convert to `int` two characters from a string `str`, you shall write `lexacal_cast(make_iterator_range(str.c_str(), str.c_str() + 2));`. [endsect] [section Changes] + +* [*boost 1.51.0 :] + + * Better performance, less memory usage for `boost::array` and `std::array` conversions. + * [*boost 1.50.0 :] * `boost::bad_lexical_cast` exception is now globaly visible and can be catched even if code is compiled with -fvisibility=hidden. @@ -335,417 +353,507 @@ Do not use this results to compare compilers, because tests were taken on differ [/ BEGIN of section, generated by performance measuring program ] -[section Clang version 2.9 (tags/RELEASE_29/final)] -[table:id Performance Table ( Clang version 2.9 (tags/RELEASE_29/final)) + +[section Clang version 3.0 (tags/RELEASE_30/final)] +[table:id Performance Table ( Clang version 3.0 (tags/RELEASE_30/final)) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] - [[ string->char ][ !!! *<1* !!! ][ 319 ][ 17 ][ 16 ]] - [[ string->signed char ][ !!! *<1* !!! ][ 192 ][ 16 ][ 9 ]] - [[ string->unsigned char ][ !!! *<1* !!! ][ 142 ][ 9 ][ 9 ]] - [[ string->int ][ !!! *7* !!! ][ 109 ][ 21 ][ 16 ]] - [[ string->short ][ !!! *6* !!! ][ 113 ][ 21 ][ 15 ]] - [[ string->long int ][ !!! *7* !!! ][ 110 ][ 22 ][ 15 ]] - [[ string->long long ][ !!! *7* !!! ][ 112 ][ 23 ][ 17 ]] - [[ string->unsigned int ][ !!! *6* !!! ][ 107 ][ 19 ][ 14 ]] - [[ string->unsigned short ][ !!! *6* !!! ][ 106 ][ 18 ][ 16 ]] - [[ string->unsigned long int ][ !!! *7* !!! ][ 108 ][ 20 ][ 15 ]] - [[ string->unsigned long long ][ !!! *7* !!! ][ 109 ][ 22 ][ 15 ]] - [[ string->float ][ !!! *14* !!! ][ 204 ][ 81 ][ 43 ]] - [[ string->double ][ !!! *24* !!! ][ 244 ][ 74 ][ 45 ]] - [[ string->long double ][ 121 ][ 170 ][ 62 ][ !!! *38* !!! ]] - [[ string->string ][ !!! *1* !!! ][ 124 ][ 25 ][ --- ]] - [[ string->container::string ][ !!! *3* !!! ][ 121 ][ 28 ][ --- ]] - [[ string->char ][ 6 ][ 115 ][ 26 ][ !!! *6* !!! ]] - [[ string->signed char ][ !!! *6* !!! ][ 115 ][ 23 ][ 21 ]] - [[ string->unsigned char ][ !!! *6* !!! ][ 113 ][ 25 ][ 22 ]] - [[ int->string ][ !!! *12* !!! ][ 128 ][ 29 ][ 19 ]] - [[ short->string ][ !!! *12* !!! ][ 128 ][ 29 ][ 21 ]] - [[ long int->string ][ !!! *12* !!! ][ 132 ][ 29 ][ 21 ]] - [[ long long->string ][ !!! *12* !!! ][ 127 ][ 29 ][ 22 ]] - [[ unsigned int->string ][ !!! *12* !!! ][ 137 ][ 33 ][ 19 ]] - [[ unsigned short->string ][ !!! *12* !!! ][ 137 ][ 31 ][ 20 ]] - [[ unsigned long int->string ][ !!! *12* !!! ][ 136 ][ 30 ][ 21 ]] - [[ unsigned long long->string ][ !!! *12* !!! ][ 128 ][ 27 ][ 23 ]] - [[ float->string ][ 51 ][ 187 ][ 82 ][ !!! *44* !!! ]] - [[ double->string ][ 56 ][ 190 ][ 83 ][ !!! *42* !!! ]] - [[ long double->string ][ 69 ][ 208 ][ 90 ][ !!! *54* !!! ]] - [[ char*->char ][ !!! *<1* !!! ][ 138 ][ 18 ][ 8 ]] - [[ char*->signed char ][ !!! *8* !!! ][ 126 ][ 10 ][ 9 ]] - [[ char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 9 ][ 9 ]] - [[ char*->int ][ !!! *8* !!! ][ 113 ][ 22 ][ 15 ]] - [[ char*->short ][ !!! *7* !!! ][ 113 ][ 22 ][ 17 ]] - [[ char*->long int ][ !!! *8* !!! ][ 111 ][ 23 ][ 15 ]] - [[ char*->long long ][ !!! *9* !!! ][ 112 ][ 24 ][ 18 ]] - [[ char*->unsigned int ][ !!! *8* !!! ][ 113 ][ 20 ][ 15 ]] - [[ char*->unsigned short ][ !!! *8* !!! ][ 113 ][ 20 ][ 15 ]] - [[ char*->unsigned long int ][ !!! *8* !!! ][ 112 ][ 21 ][ 16 ]] - [[ char*->unsigned long long ][ !!! *9* !!! ][ 110 ][ 23 ][ 14 ]] - [[ char*->float ][ !!! *14* !!! ][ 149 ][ 54 ][ 32 ]] - [[ char*->double ][ !!! *15* !!! ][ 166 ][ 59 ][ 33 ]] - [[ char*->long double ][ 122 ][ 171 ][ 63 ][ !!! *38* !!! ]] - [[ char*->string ][ !!! *7* !!! ][ 126 ][ 26 ][ --- ]] - [[ char*->container::string ][ !!! *2* !!! ][ 124 ][ 27 ][ --- ]] - [[ unsigned char*->char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 8 ]] - [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 102 ][ 10 ][ 9 ]] - [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 9 ]] - [[ unsigned char*->int ][ !!! *7* !!! ][ 115 ][ 24 ][ 15 ]] - [[ unsigned char*->short ][ !!! *7* !!! ][ 115 ][ 25 ][ 17 ]] - [[ unsigned char*->long int ][ !!! *8* !!! ][ 115 ][ 22 ][ 16 ]] - [[ unsigned char*->long long ][ !!! *8* !!! ][ 116 ][ 23 ][ 16 ]] - [[ unsigned char*->unsigned int ][ !!! *8* !!! ][ 113 ][ 20 ][ 14 ]] - [[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 114 ][ 21 ][ 15 ]] - [[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 21 ][ 14 ]] - [[ unsigned char*->unsigned long long ][ !!! *9* !!! ][ 112 ][ 23 ][ 16 ]] - [[ unsigned char*->float ][ !!! *14* !!! ][ 149 ][ 52 ][ 32 ]] - [[ unsigned char*->double ][ !!! *15* !!! ][ 165 ][ 59 ][ 33 ]] - [[ unsigned char*->long double ][ 122 ][ 172 ][ 63 ][ !!! *37* !!! ]] - [[ unsigned char*->string ][ !!! *8* !!! ][ 125 ][ 26 ][ --- ]] - [[ unsigned char*->container::string ][ !!! *4* !!! ][ 119 ][ 26 ][ --- ]] - [[ signed char*->char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 8 ]] - [[ signed char*->signed char ][ !!! *<1* !!! ][ 95 ][ 10 ][ 9 ]] - [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 9 ][ 9 ]] - [[ signed char*->int ][ !!! *8* !!! ][ 111 ][ 21 ][ 15 ]] - [[ signed char*->short ][ !!! *7* !!! ][ 114 ][ 22 ][ 16 ]] - [[ signed char*->long int ][ !!! *8* !!! ][ 113 ][ 22 ][ 17 ]] - [[ signed char*->long long ][ !!! *8* !!! ][ 116 ][ 24 ][ 17 ]] - [[ signed char*->unsigned int ][ !!! *8* !!! ][ 109 ][ 20 ][ 15 ]] - [[ signed char*->unsigned short ][ !!! *8* !!! ][ 111 ][ 20 ][ 14 ]] - [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 109 ][ 22 ][ 15 ]] - [[ signed char*->unsigned long long ][ !!! *8* !!! ][ 111 ][ 23 ][ 15 ]] - [[ signed char*->float ][ !!! *14* !!! ][ 150 ][ 53 ][ 32 ]] - [[ signed char*->double ][ !!! *15* !!! ][ 168 ][ 59 ][ 30 ]] - [[ signed char*->long double ][ 123 ][ 174 ][ 62 ][ !!! *37* !!! ]] + [[ string->char ][ !!! *<1* !!! ][ 169 ][ 9 ][ 10 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 108 ][ 8 ][ 10 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 103 ][ 9 ][ 10 ]] + [[ string->int ][ !!! *6* !!! ][ 117 ][ 24 ][ 24 ]] + [[ string->short ][ !!! *7* !!! ][ 115 ][ 20 ][ 24 ]] + [[ string->long int ][ !!! *7* !!! ][ 115 ][ 19 ][ 22 ]] + [[ string->long long ][ !!! *8* !!! ][ 116 ][ 21 ][ 23 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 121 ][ 18 ][ 23 ]] + [[ string->unsigned short ][ !!! *6* !!! ][ 116 ][ 19 ][ 22 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 117 ][ 23 ][ 21 ]] + [[ string->unsigned long long ][ !!! *8* !!! ][ 118 ][ 19 ][ 34 ]] + [[ string->float ][ !!! *13* !!! ][ 201 ][ 55 ][ 41 ]] + [[ string->double ][ !!! *14* !!! ][ 151 ][ 54 ][ 41 ]] + [[ string->long double ][ 195 ][ 231 ][ 67 ][ !!! *42* !!! ]] + [[ string->array ][ !!! *<1* !!! ][ 121 ][ 18 ][ 12 ]] + [[ string->string ][ !!! *1* !!! ][ 124 ][ 27 ][ --- ]] + [[ string->container::string ][ !!! *3* !!! ][ 114 ][ 25 ][ --- ]] + [[ string->char ][ 7 ][ 111 ][ 25 ][ !!! *7* !!! ]] + [[ string->signed char ][ !!! *6* !!! ][ 112 ][ 30 ][ 26 ]] + [[ string->unsigned char ][ !!! *6* !!! ][ 113 ][ 25 ][ 24 ]] + [[ int->string ][ !!! *12* !!! ][ 126 ][ 36 ][ 21 ]] + [[ short->string ][ !!! *11* !!! ][ 135 ][ 30 ][ 21 ]] + [[ long int->string ][ !!! *11* !!! ][ 128 ][ 28 ][ 21 ]] + [[ long long->string ][ !!! *12* !!! ][ 126 ][ 32 ][ 24 ]] + [[ unsigned int->string ][ !!! *11* !!! ][ 131 ][ 36 ][ 22 ]] + [[ unsigned short->string ][ !!! *11* !!! ][ 130 ][ 28 ][ 22 ]] + [[ unsigned long int->string ][ !!! *11* !!! ][ 130 ][ 36 ][ 22 ]] + [[ unsigned long long->string ][ !!! *11* !!! ][ 127 ][ 43 ][ 25 ]] + [[ float->string ][ 53 ][ 190 ][ 83 ][ !!! *41* !!! ]] + [[ double->string ][ 59 ][ 197 ][ 82 ][ !!! *44* !!! ]] + [[ long double->string ][ 118 ][ 229 ][ 101 ][ !!! *44* !!! ]] + [[ char*->char ][ !!! *1* !!! ][ 105 ][ 9 ][ 9 ]] + [[ char*->signed char ][ !!! *1* !!! ][ 107 ][ 10 ][ 10 ]] + [[ char*->unsigned char ][ !!! *1* !!! ][ 106 ][ 9 ][ 11 ]] + [[ char*->int ][ !!! *7* !!! ][ 149 ][ 25 ][ 24 ]] + [[ char*->short ][ !!! *7* !!! ][ 118 ][ 20 ][ 22 ]] + [[ char*->long int ][ !!! *9* !!! ][ 117 ][ 20 ][ 28 ]] + [[ char*->long long ][ !!! *9* !!! ][ 128 ][ 23 ][ 29 ]] + [[ char*->unsigned int ][ !!! *7* !!! ][ 120 ][ 19 ][ 23 ]] + [[ char*->unsigned short ][ !!! *7* !!! ][ 125 ][ 20 ][ 22 ]] + [[ char*->unsigned long int ][ !!! *8* !!! ][ 125 ][ 21 ][ 24 ]] + [[ char*->unsigned long long ][ !!! *8* !!! ][ 130 ][ 19 ][ 22 ]] + [[ char*->float ][ !!! *14* !!! ][ 162 ][ 56 ][ 41 ]] + [[ char*->double ][ !!! *16* !!! ][ 151 ][ 54 ][ 39 ]] + [[ char*->long double ][ 111 ][ 176 ][ 58 ][ !!! *42* !!! ]] + [[ char*->array ][ !!! *1* !!! ][ 116 ][ 20 ][ 17 ]] + [[ char*->string ][ !!! *8* !!! ][ 125 ][ 27 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 115 ][ 26 ][ --- ]] + [[ unsigned char*->char ][ !!! *1* !!! ][ 101 ][ 9 ][ 9 ]] + [[ unsigned char*->signed char ][ !!! *1* !!! ][ 104 ][ 9 ][ 11 ]] + [[ unsigned char*->unsigned char ][ !!! *1* !!! ][ 103 ][ 9 ][ 13 ]] + [[ unsigned char*->int ][ !!! *8* !!! ][ 116 ][ 20 ][ 24 ]] + [[ unsigned char*->short ][ !!! *7* !!! ][ 121 ][ 20 ][ 26 ]] + [[ unsigned char*->long int ][ !!! *8* !!! ][ 118 ][ 20 ][ 22 ]] + [[ unsigned char*->long long ][ !!! *8* !!! ][ 122 ][ 20 ][ 23 ]] + [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 119 ][ 22 ][ 23 ]] + [[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 122 ][ 20 ][ 22 ]] + [[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 125 ][ 21 ][ 22 ]] + [[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 122 ][ 19 ][ 25 ]] + [[ unsigned char*->float ][ !!! *14* !!! ][ 162 ][ 62 ][ 37 ]] + [[ unsigned char*->double ][ !!! *15* !!! ][ 151 ][ 58 ][ 39 ]] + [[ unsigned char*->long double ][ 116 ][ 156 ][ 58 ][ !!! *42* !!! ]] + [[ unsigned char*->array ][ !!! *1* !!! ][ 122 ][ 19 ][ 15 ]] + [[ unsigned char*->string ][ !!! *8* !!! ][ 124 ][ 27 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *4* !!! ][ 119 ][ 25 ][ --- ]] + [[ signed char*->char ][ !!! *1* !!! ][ 107 ][ 9 ][ 9 ]] + [[ signed char*->signed char ][ !!! *1* !!! ][ 108 ][ 10 ][ 11 ]] + [[ signed char*->unsigned char ][ !!! *1* !!! ][ 106 ][ 9 ][ 11 ]] + [[ signed char*->int ][ !!! *7* !!! ][ 122 ][ 21 ][ 22 ]] + [[ signed char*->short ][ !!! *7* !!! ][ 126 ][ 20 ][ 22 ]] + [[ signed char*->long int ][ !!! *8* !!! ][ 119 ][ 20 ][ 23 ]] + [[ signed char*->long long ][ !!! *8* !!! ][ 119 ][ 21 ][ 26 ]] + [[ signed char*->unsigned int ][ !!! *6* !!! ][ 124 ][ 18 ][ 22 ]] + [[ signed char*->unsigned short ][ !!! *7* !!! ][ 124 ][ 21 ][ 23 ]] + [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 121 ][ 24 ][ 23 ]] + [[ signed char*->unsigned long long ][ !!! *8* !!! ][ 122 ][ 20 ][ 22 ]] + [[ signed char*->float ][ !!! *14* !!! ][ 167 ][ 56 ][ 37 ]] + [[ signed char*->double ][ !!! *14* !!! ][ 162 ][ 53 ][ 40 ]] + [[ signed char*->long double ][ 110 ][ 152 ][ 56 ][ !!! *42* !!! ]] + [[ signed char*->array ][ !!! *1* !!! ][ 117 ][ 19 ][ 12 ]] + [[ signed char*->string ][ !!! *8* !!! ][ 132 ][ 27 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 116 ][ 26 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 112 ][ 14 ][ 9 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 107 ][ 13 ][ 10 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 145 ][ 15 ][ 10 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 119 ][ 22 ][ 23 ]] + [[ iterator_range->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 23 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 115 ][ 25 ][ 22 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 117 ][ 21 ][ 23 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 118 ][ 22 ][ 22 ]] + [[ iterator_range->unsigned short ][ !!! *6* !!! ][ 117 ][ 24 ][ 22 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 124 ][ 25 ][ 22 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 119 ][ 22 ][ 22 ]] + [[ iterator_range->float ][ !!! *13* !!! ][ 159 ][ 42 ][ 41 ]] + [[ iterator_range->double ][ !!! *14* !!! ][ 152 ][ 40 ][ 40 ]] + [[ iterator_range->long double ][ 113 ][ 155 ][ 58 ][ !!! *54* !!! ]] + [[ iterator_range->array ][ !!! *<1* !!! ][ 127 ][ 23 ][ 13 ]] + [[ iterator_range->string ][ !!! *7* !!! ][ 132 ][ 30 ][ --- ]] + [[ iterator_range->container::string ][ !!! *3* !!! ][ 122 ][ 24 ][ --- ]] + [[ array->char ][ !!! *<1* !!! ][ 110 ][ 9 ][ 10 ]] + [[ array->signed char ][ !!! *<1* !!! ][ 119 ][ 9 ][ 13 ]] + [[ array->unsigned char ][ !!! *<1* !!! ][ 106 ][ 13 ][ 11 ]] + [[ array->int ][ !!! *6* !!! ][ 131 ][ 21 ][ 22 ]] + [[ array->short ][ !!! *7* !!! ][ 119 ][ 22 ][ 28 ]] + [[ array->long int ][ !!! *8* !!! ][ 133 ][ 21 ][ 26 ]] + [[ array->long long ][ !!! *8* !!! ][ 115 ][ 22 ][ 23 ]] + [[ array->unsigned int ][ !!! *6* !!! ][ 118 ][ 18 ][ 22 ]] + [[ array->unsigned short ][ !!! *7* !!! ][ 119 ][ 19 ][ 22 ]] + [[ array->unsigned long int ][ !!! *7* !!! ][ 118 ][ 23 ][ 21 ]] + [[ array->unsigned long long ][ !!! *7* !!! ][ 117 ][ 20 ][ 22 ]] + [[ array->float ][ !!! *15* !!! ][ 156 ][ 53 ][ 36 ]] + [[ array->double ][ !!! *15* !!! ][ 148 ][ 55 ][ 39 ]] + [[ array->long double ][ 110 ][ 150 ][ 56 ][ !!! *41* !!! ]] + [[ array->array ][ !!! *<1* !!! ][ 117 ][ 19 ][ 12 ]] + [[ array->string ][ !!! *7* !!! ][ 124 ][ 26 ][ --- ]] + [[ array->container::string ][ !!! *4* !!! ][ 115 ][ 26 ][ --- ]] + [[ int->int ][ !!! *<1* !!! ][ 117 ][ 24 ][ --- ]] + [[ float->double ][ !!! *<1* !!! ][ 245 ][ 125 ][ --- ]] + [[ char->signed char ][ !!! *<1* !!! ][ 100 ][ 9 ][ --- ]] +] +[endsect] + +[section GNU C++ version 4.6.3] +[table:id Performance Table ( GNU C++ version 4.6.3) +[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] + [[ string->char ][ !!! *<1* !!! ][ 142 ][ 10 ][ 18 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 111 ][ 8 ][ 10 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 101 ][ 8 ][ 10 ]] + [[ string->int ][ !!! *7* !!! ][ 110 ][ 20 ][ 24 ]] + [[ string->short ][ !!! *6* !!! ][ 109 ][ 20 ][ 25 ]] + [[ string->long int ][ !!! *7* !!! ][ 113 ][ 19 ][ 24 ]] + [[ string->long long ][ !!! *7* !!! ][ 116 ][ 24 ][ 23 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 110 ][ 19 ][ 23 ]] + [[ string->unsigned short ][ !!! *5* !!! ][ 116 ][ 18 ][ 23 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 111 ][ 22 ][ 23 ]] + [[ string->unsigned long long ][ !!! *7* !!! ][ 108 ][ 20 ][ 22 ]] + [[ string->float ][ !!! *11* !!! ][ 161 ][ 54 ][ 38 ]] + [[ string->double ][ !!! *11* !!! ][ 146 ][ 56 ][ 41 ]] + [[ string->long double ][ 113 ][ 151 ][ 59 ][ !!! *43* !!! ]] + [[ string->array ][ !!! *<1* !!! ][ 107 ][ 18 ][ 14 ]] + [[ string->string ][ !!! *2* !!! ][ 127 ][ 24 ][ --- ]] + [[ string->container::string ][ !!! *3* !!! ][ 142 ][ 26 ][ --- ]] + [[ string->char ][ !!! *7* !!! ][ 110 ][ 23 ][ 17 ]] + [[ string->signed char ][ !!! *7* !!! ][ 114 ][ 23 ][ 24 ]] + [[ string->unsigned char ][ !!! *7* !!! ][ 110 ][ 25 ][ 24 ]] + [[ int->string ][ !!! *12* !!! ][ 127 ][ 31 ][ 22 ]] + [[ short->string ][ !!! *13* !!! ][ 129 ][ 31 ][ 22 ]] + [[ long int->string ][ !!! *12* !!! ][ 125 ][ 30 ][ 22 ]] + [[ long long->string ][ !!! *13* !!! ][ 127 ][ 34 ][ 24 ]] + [[ unsigned int->string ][ !!! *13* !!! ][ 127 ][ 27 ][ 21 ]] + [[ unsigned short->string ][ !!! *12* !!! ][ 127 ][ 28 ][ 22 ]] + [[ unsigned long int->string ][ !!! *12* !!! ][ 131 ][ 27 ][ 22 ]] + [[ unsigned long long->string ][ !!! *12* !!! ][ 125 ][ 28 ][ 24 ]] + [[ float->string ][ 51 ][ 200 ][ 81 ][ !!! *40* !!! ]] + [[ double->string ][ 56 ][ 194 ][ 82 ][ !!! *48* !!! ]] + [[ long double->string ][ 65 ][ 220 ][ 82 ][ !!! *41* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 104 ][ 10 ][ 9 ]] + [[ char*->signed char ][ !!! *<1* !!! ][ 101 ][ 10 ][ 11 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 12 ]] + [[ char*->int ][ !!! *6* !!! ][ 112 ][ 23 ][ 24 ]] + [[ char*->short ][ !!! *6* !!! ][ 115 ][ 21 ][ 23 ]] + [[ char*->long int ][ !!! *8* !!! ][ 111 ][ 21 ][ 24 ]] + [[ char*->long long ][ !!! *9* !!! ][ 112 ][ 21 ][ 30 ]] + [[ char*->unsigned int ][ !!! *7* !!! ][ 112 ][ 22 ][ 24 ]] + [[ char*->unsigned short ][ !!! *6* !!! ][ 119 ][ 19 ][ 23 ]] + [[ char*->unsigned long int ][ !!! *7* !!! ][ 115 ][ 22 ][ 23 ]] + [[ char*->unsigned long long ][ !!! *7* !!! ][ 115 ][ 20 ][ 23 ]] + [[ char*->float ][ !!! *12* !!! ][ 153 ][ 54 ][ 39 ]] + [[ char*->double ][ !!! *12* !!! ][ 153 ][ 61 ][ 41 ]] + [[ char*->long double ][ 108 ][ 160 ][ 61 ][ !!! *49* !!! ]] + [[ char*->array ][ !!! *<1* !!! ][ 107 ][ 20 ][ 14 ]] + [[ char*->string ][ !!! *7* !!! ][ 123 ][ 26 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 121 ][ 24 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 97 ][ 10 ][ 9 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 12 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 99 ][ 11 ][ 12 ]] + [[ unsigned char*->int ][ !!! *6* !!! ][ 112 ][ 22 ][ 24 ]] + [[ unsigned char*->short ][ !!! *10* !!! ][ 111 ][ 24 ][ 24 ]] + [[ unsigned char*->long int ][ !!! *8* !!! ][ 110 ][ 23 ][ 24 ]] + [[ unsigned char*->long long ][ !!! *9* !!! ][ 115 ][ 21 ][ 25 ]] + [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 111 ][ 24 ][ 23 ]] + [[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 118 ][ 19 ][ 23 ]] + [[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 112 ][ 21 ][ 23 ]] + [[ unsigned char*->unsigned long long ][ !!! *13* !!! ][ 109 ][ 20 ][ 23 ]] + [[ unsigned char*->float ][ !!! *12* !!! ][ 154 ][ 56 ][ 39 ]] + [[ unsigned char*->double ][ !!! *17* !!! ][ 150 ][ 58 ][ 41 ]] + [[ unsigned char*->long double ][ 108 ][ 149 ][ 68 ][ !!! *43* !!! ]] + [[ unsigned char*->array ][ !!! *1* !!! ][ 107 ][ 19 ][ 15 ]] + [[ unsigned char*->string ][ !!! *8* !!! ][ 124 ][ 26 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *4* !!! ][ 121 ][ 24 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 9 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 10 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 12 ]] + [[ signed char*->int ][ !!! *6* !!! ][ 113 ][ 28 ][ 24 ]] + [[ signed char*->short ][ !!! *6* !!! ][ 110 ][ 21 ][ 25 ]] + [[ signed char*->long int ][ !!! *8* !!! ][ 110 ][ 21 ][ 24 ]] + [[ signed char*->long long ][ !!! *9* !!! ][ 116 ][ 21 ][ 24 ]] + [[ signed char*->unsigned int ][ !!! *7* !!! ][ 114 ][ 21 ][ 23 ]] + [[ signed char*->unsigned short ][ !!! *6* !!! ][ 116 ][ 20 ][ 23 ]] + [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 113 ][ 27 ][ 23 ]] + [[ signed char*->unsigned long long ][ !!! *8* !!! ][ 110 ][ 20 ][ 23 ]] + [[ signed char*->float ][ !!! *12* !!! ][ 155 ][ 53 ][ 44 ]] + [[ signed char*->double ][ !!! *13* !!! ][ 150 ][ 60 ][ 42 ]] + [[ signed char*->long double ][ 108 ][ 151 ][ 62 ][ !!! *44* !!! ]] + [[ signed char*->array ][ !!! *1* !!! ][ 107 ][ 19 ][ 15 ]] + [[ signed char*->string ][ !!! *8* !!! ][ 124 ][ 26 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 121 ][ 24 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 14 ][ 10 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 102 ][ 15 ][ 12 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 102 ][ 14 ][ 12 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 115 ][ 23 ][ 24 ]] + [[ iterator_range->short ][ !!! *5* !!! ][ 110 ][ 22 ][ 24 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 109 ][ 22 ][ 29 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 111 ][ 24 ][ 28 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 114 ][ 22 ][ 23 ]] + [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 115 ][ 20 ][ 22 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 123 ][ 26 ][ 23 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 110 ][ 23 ][ 24 ]] + [[ iterator_range->float ][ !!! *11* !!! ][ 153 ][ 38 ][ 38 ]] + [[ iterator_range->double ][ !!! *11* !!! ][ 140 ][ 43 ][ 40 ]] + [[ iterator_range->long double ][ 108 ][ 147 ][ !!! *41* !!! ][ 46 ]] + [[ iterator_range->array ][ !!! *<1* !!! ][ 109 ][ 22 ][ 15 ]] + [[ iterator_range->string ][ !!! *8* !!! ][ 122 ][ 29 ][ --- ]] + [[ iterator_range->container::string ][ !!! *3* !!! ][ 117 ][ 23 ][ --- ]] + [[ array->char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 9 ]] + [[ array->signed char ][ !!! *<1* !!! ][ 99 ][ 9 ][ 12 ]] + [[ array->unsigned char ][ !!! *<1* !!! ][ 102 ][ 9 ][ 12 ]] + [[ array->int ][ !!! *6* !!! ][ 119 ][ 23 ][ 23 ]] + [[ array->short ][ !!! *6* !!! ][ 111 ][ 21 ][ 26 ]] + [[ array->long int ][ !!! *7* !!! ][ 115 ][ 20 ][ 28 ]] + [[ array->long long ][ !!! *9* !!! ][ 110 ][ 21 ][ 26 ]] + [[ array->unsigned int ][ !!! *6* !!! ][ 115 ][ 22 ][ 23 ]] + [[ array->unsigned short ][ !!! *6* !!! ][ 115 ][ 19 ][ 23 ]] + [[ array->unsigned long int ][ !!! *7* !!! ][ 118 ][ 23 ][ 23 ]] + [[ array->unsigned long long ][ !!! *7* !!! ][ 109 ][ 20 ][ 24 ]] + [[ array->float ][ !!! *12* !!! ][ 160 ][ 53 ][ 38 ]] + [[ array->double ][ !!! *11* !!! ][ 147 ][ 57 ][ 41 ]] + [[ array->long double ][ 109 ][ 154 ][ 59 ][ !!! *42* !!! ]] + [[ array->array ][ !!! *1* !!! ][ 105 ][ 19 ][ 14 ]] + [[ array->string ][ !!! *8* !!! ][ 129 ][ 26 ][ --- ]] + [[ array->container::string ][ !!! *4* !!! ][ 116 ][ 25 ][ --- ]] + [[ int->int ][ !!! *<1* !!! ][ 118 ][ 24 ][ --- ]] + [[ float->double ][ !!! *<1* !!! ][ 242 ][ 132 ][ --- ]] + [[ char->signed char ][ !!! *<1* !!! ][ 94 ][ 8 ][ --- ]] +] +[endsect] + +[section GNU C++ version 4.5.3] +[table:id Performance Table ( GNU C++ version 4.5.3) +[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] + [[ string->char ][ !!! *<1* !!! ][ 153 ][ 15 ][ 9 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 134 ][ 8 ][ 10 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 97 ][ 8 ][ 14 ]] + [[ string->int ][ !!! *7* !!! ][ 115 ][ 22 ][ 22 ]] + [[ string->short ][ !!! *5* !!! ][ 112 ][ 19 ][ 21 ]] + [[ string->long int ][ !!! *7* !!! ][ 110 ][ 19 ][ 24 ]] + [[ string->long long ][ !!! *7* !!! ][ 115 ][ 21 ][ 23 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 113 ][ 20 ][ 23 ]] + [[ string->unsigned short ][ !!! *5* !!! ][ 116 ][ 18 ][ 23 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 111 ][ 20 ][ 23 ]] + [[ string->unsigned long long ][ !!! *7* !!! ][ 115 ][ 18 ][ 23 ]] + [[ string->float ][ !!! *14* !!! ][ 153 ][ 55 ][ 38 ]] + [[ string->double ][ !!! *11* !!! ][ 151 ][ 60 ][ 38 ]] + [[ string->long double ][ 107 ][ 151 ][ 59 ][ !!! *44* !!! ]] + [[ string->array ][ !!! *<1* !!! ][ 107 ][ 18 ][ 12 ]] + [[ string->string ][ !!! *2* !!! ][ 129 ][ 49 ][ --- ]] + [[ string->container::string ][ !!! *9* !!! ][ 199 ][ 22 ][ --- ]] + [[ string->char ][ !!! *7* !!! ][ 114 ][ 27 ][ 16 ]] + [[ string->signed char ][ !!! *7* !!! ][ 116 ][ 32 ][ 23 ]] + [[ string->unsigned char ][ !!! *7* !!! ][ 114 ][ 27 ][ 22 ]] + [[ int->string ][ !!! *11* !!! ][ 125 ][ 31 ][ 21 ]] + [[ short->string ][ !!! *11* !!! ][ 126 ][ 33 ][ 21 ]] + [[ long int->string ][ !!! *11* !!! ][ 126 ][ 32 ][ 22 ]] + [[ long long->string ][ !!! *11* !!! ][ 118 ][ 30 ][ 23 ]] + [[ unsigned int->string ][ !!! *11* !!! ][ 125 ][ 31 ][ 20 ]] + [[ unsigned short->string ][ !!! *12* !!! ][ 128 ][ 30 ][ 21 ]] + [[ unsigned long int->string ][ !!! *11* !!! ][ 131 ][ 30 ][ 21 ]] + [[ unsigned long long->string ][ !!! *11* !!! ][ 127 ][ 32 ][ 23 ]] + [[ float->string ][ 49 ][ 197 ][ 92 ][ !!! *39* !!! ]] + [[ double->string ][ 56 ][ 195 ][ 80 ][ !!! *43* !!! ]] + [[ long double->string ][ 60 ][ 222 ][ 88 ][ !!! *42* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 100 ][ 10 ][ 9 ]] + [[ char*->signed char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 10 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 106 ][ 10 ][ 10 ]] + [[ char*->int ][ !!! *7* !!! ][ 113 ][ 23 ][ 22 ]] + [[ char*->short ][ !!! *6* !!! ][ 113 ][ 21 ][ 23 ]] + [[ char*->long int ][ !!! *8* !!! ][ 116 ][ 21 ][ 23 ]] + [[ char*->long long ][ !!! *8* !!! ][ 115 ][ 21 ][ 21 ]] + [[ char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 25 ][ 22 ]] + [[ char*->unsigned short ][ !!! *6* !!! ][ 119 ][ 20 ][ 23 ]] + [[ char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 23 ][ 23 ]] + [[ char*->unsigned long long ][ !!! *7* !!! ][ 111 ][ 20 ][ 24 ]] + [[ char*->float ][ !!! *16* !!! ][ 154 ][ 54 ][ 38 ]] + [[ char*->double ][ !!! *12* !!! ][ 149 ][ 59 ][ 40 ]] + [[ char*->long double ][ 107 ][ 166 ][ 62 ][ !!! *44* !!! ]] + [[ char*->array ][ !!! *1* !!! ][ 108 ][ 20 ][ 12 ]] + [[ char*->string ][ !!! *8* !!! ][ 125 ][ 28 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 123 ][ 24 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 104 ][ 11 ][ 9 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 106 ][ 10 ][ 10 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 101 ][ 10 ][ 10 ]] + [[ unsigned char*->int ][ !!! *7* !!! ][ 117 ][ 22 ][ 24 ]] + [[ unsigned char*->short ][ !!! *6* !!! ][ 111 ][ 26 ][ 22 ]] + [[ unsigned char*->long int ][ !!! *8* !!! ][ 111 ][ 23 ][ 23 ]] + [[ unsigned char*->long long ][ !!! *8* !!! ][ 114 ][ 21 ][ 23 ]] + [[ unsigned char*->unsigned int ][ !!! *7* !!! ][ 115 ][ 20 ][ 25 ]] + [[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 113 ][ 20 ][ 22 ]] + [[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 115 ][ 25 ][ 24 ]] + [[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 113 ][ 25 ][ 25 ]] + [[ unsigned char*->float ][ !!! *16* !!! ][ 158 ][ 55 ][ 38 ]] + [[ unsigned char*->double ][ !!! *12* !!! ][ 155 ][ 62 ][ 40 ]] + [[ unsigned char*->long double ][ 108 ][ 153 ][ 60 ][ !!! *41* !!! ]] + [[ unsigned char*->array ][ !!! *1* !!! ][ 111 ][ 19 ][ 12 ]] + [[ unsigned char*->string ][ !!! *8* !!! ][ 125 ][ 30 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *4* !!! ][ 121 ][ 23 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 98 ][ 14 ][ 9 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 10 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 10 ]] + [[ signed char*->int ][ !!! *7* !!! ][ 111 ][ 22 ][ 24 ]] + [[ signed char*->short ][ !!! *6* !!! ][ 123 ][ 22 ][ 23 ]] + [[ signed char*->long int ][ !!! *8* !!! ][ 112 ][ 21 ][ 23 ]] + [[ signed char*->long long ][ !!! *8* !!! ][ 114 ][ 24 ][ 24 ]] + [[ signed char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 19 ][ 22 ]] + [[ signed char*->unsigned short ][ !!! *6* !!! ][ 112 ][ 21 ][ 24 ]] + [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 23 ][ 22 ]] + [[ signed char*->unsigned long long ][ !!! *8* !!! ][ 116 ][ 22 ][ 24 ]] + [[ signed char*->float ][ !!! *16* !!! ][ 156 ][ 55 ][ 38 ]] + [[ signed char*->double ][ !!! *12* !!! ][ 151 ][ 59 ][ 39 ]] + [[ signed char*->long double ][ 111 ][ 159 ][ 60 ][ !!! *44* !!! ]] + [[ signed char*->array ][ !!! *1* !!! ][ 107 ][ 24 ][ 12 ]] + [[ signed char*->string ][ !!! *8* !!! ][ 122 ][ 28 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 122 ][ 23 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 10 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 10 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 104 ][ 14 ][ 10 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 115 ][ 23 ][ 24 ]] + [[ iterator_range->short ][ !!! *7* !!! ][ 111 ][ 21 ][ 24 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 108 ][ 21 ][ 23 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 114 ][ 24 ][ 23 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 111 ][ 22 ][ 23 ]] + [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 114 ][ 20 ][ 23 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 119 ][ 25 ][ 24 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 110 ][ 20 ][ 24 ]] + [[ iterator_range->float ][ !!! *15* !!! ][ 148 ][ 38 ][ 40 ]] + [[ iterator_range->double ][ !!! *10* !!! ][ 146 ][ 41 ][ 40 ]] + [[ iterator_range->long double ][ 103 ][ 138 ][ !!! *39* !!! ][ 42 ]] + [[ iterator_range->array ][ !!! *<1* !!! ][ 109 ][ 22 ][ 13 ]] + [[ iterator_range->string ][ !!! *7* !!! ][ 121 ][ 32 ][ --- ]] + [[ iterator_range->container::string ][ !!! *3* !!! ][ 120 ][ 24 ][ --- ]] + [[ array->char ][ !!! *<1* !!! ][ 102 ][ 9 ][ 9 ]] + [[ array->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ 10 ]] + [[ array->unsigned char ][ !!! *<1* !!! ][ 99 ][ 9 ][ 10 ]] + [[ array->int ][ !!! *7* !!! ][ 114 ][ 22 ][ 23 ]] + [[ array->short ][ !!! *6* !!! ][ 116 ][ 21 ][ 23 ]] + [[ array->long int ][ !!! *7* !!! ][ 109 ][ 20 ][ 23 ]] + [[ array->long long ][ !!! *7* !!! ][ 114 ][ 21 ][ 23 ]] + [[ array->unsigned int ][ !!! *7* !!! ][ 119 ][ 20 ][ 25 ]] + [[ array->unsigned short ][ !!! *6* !!! ][ 120 ][ 20 ][ 23 ]] + [[ array->unsigned long int ][ !!! *7* !!! ][ 113 ][ 20 ][ 21 ]] + [[ array->unsigned long long ][ !!! *7* !!! ][ 112 ][ 20 ][ 24 ]] + [[ array->float ][ !!! *16* !!! ][ 155 ][ 57 ][ 38 ]] + [[ array->double ][ !!! *11* !!! ][ 152 ][ 59 ][ 42 ]] + [[ array->long double ][ 107 ][ 152 ][ 60 ][ !!! *41* !!! ]] + [[ array->array ][ !!! *1* !!! ][ 111 ][ 20 ][ 12 ]] + [[ array->string ][ !!! *8* !!! ][ 123 ][ 36 ][ --- ]] + [[ array->container::string ][ !!! *4* !!! ][ 128 ][ 23 ][ --- ]] + [[ int->int ][ !!! *<1* !!! ][ 118 ][ 26 ][ --- ]] + [[ float->double ][ !!! *<1* !!! ][ 233 ][ 120 ][ --- ]] + [[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 8 ][ --- ]] +] +[endsect] + +[section GNU C++ version 4.4.7] +[table:id Performance Table ( GNU C++ version 4.4.7) +[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] + [[ string->char ][ !!! *<1* !!! ][ 111 ][ 8 ][ 9 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 100 ][ 8 ][ 10 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 102 ][ 8 ][ 11 ]] + [[ string->int ][ !!! *6* !!! ][ 114 ][ 21 ][ 23 ]] + [[ string->short ][ !!! *5* !!! ][ 120 ][ 21 ][ 29 ]] + [[ string->long int ][ !!! *7* !!! ][ 114 ][ 22 ][ 26 ]] + [[ string->long long ][ !!! *7* !!! ][ 118 ][ 21 ][ 23 ]] + [[ string->unsigned int ][ !!! *7* !!! ][ 115 ][ 21 ][ 23 ]] + [[ string->unsigned short ][ !!! *5* !!! ][ 119 ][ 18 ][ 22 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 115 ][ 20 ][ 23 ]] + [[ string->unsigned long long ][ !!! *9* !!! ][ 116 ][ 26 ][ 24 ]] + [[ string->float ][ !!! *12* !!! ][ 165 ][ 53 ][ 40 ]] + [[ string->double ][ !!! *12* !!! ][ 154 ][ 54 ][ 40 ]] + [[ string->long double ][ 112 ][ 148 ][ 61 ][ !!! *45* !!! ]] + [[ string->array ][ !!! *<1* !!! ][ 120 ][ 19 ][ 14 ]] + [[ string->string ][ !!! *2* !!! ][ 141 ][ 55 ][ --- ]] + [[ string->container::string ][ !!! *2* !!! ][ 164 ][ 36 ][ --- ]] + [[ string->char ][ !!! *7* !!! ][ 161 ][ 24 ][ 18 ]] + [[ string->signed char ][ !!! *6* !!! ][ 109 ][ 25 ][ 24 ]] + [[ string->unsigned char ][ !!! *6* !!! ][ 109 ][ 25 ][ 25 ]] + [[ int->string ][ !!! *11* !!! ][ 128 ][ 32 ][ 23 ]] + [[ short->string ][ !!! *12* !!! ][ 136 ][ 54 ][ 34 ]] + [[ long int->string ][ !!! *15* !!! ][ 187 ][ 41 ][ 23 ]] + [[ long long->string ][ !!! *11* !!! ][ 128 ][ 30 ][ 29 ]] + [[ unsigned int->string ][ !!! *13* !!! ][ 124 ][ 29 ][ 23 ]] + [[ unsigned short->string ][ !!! *11* !!! ][ 128 ][ 30 ][ 22 ]] + [[ unsigned long int->string ][ !!! *11* !!! ][ 131 ][ 30 ][ 22 ]] + [[ unsigned long long->string ][ !!! *11* !!! ][ 133 ][ 33 ][ 29 ]] + [[ float->string ][ 52 ][ 187 ][ 90 ][ !!! *39* !!! ]] + [[ double->string ][ 58 ][ 190 ][ 86 ][ !!! *45* !!! ]] + [[ long double->string ][ 70 ][ 218 ][ 88 ][ !!! *47* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 99 ][ 11 ][ 9 ]] + [[ char*->signed char ][ !!! *<1* !!! ][ 99 ][ 11 ][ 10 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 100 ][ 12 ][ 10 ]] + [[ char*->int ][ !!! *6* !!! ][ 117 ][ 23 ][ 21 ]] + [[ char*->short ][ !!! *6* !!! ][ 115 ][ 28 ][ 23 ]] + [[ char*->long int ][ !!! *7* !!! ][ 119 ][ 22 ][ 24 ]] + [[ char*->long long ][ !!! *7* !!! ][ 114 ][ 23 ][ 22 ]] + [[ char*->unsigned int ][ !!! *6* !!! ][ 113 ][ 21 ][ 21 ]] + [[ char*->unsigned short ][ !!! *6* !!! ][ 120 ][ 21 ][ 21 ]] + [[ char*->unsigned long int ][ !!! *7* !!! ][ 117 ][ 25 ][ 23 ]] + [[ char*->unsigned long long ][ !!! *7* !!! ][ 119 ][ 23 ][ 21 ]] + [[ char*->float ][ !!! *13* !!! ][ 160 ][ 61 ][ 36 ]] + [[ char*->double ][ !!! *13* !!! ][ 152 ][ 54 ][ 40 ]] + [[ char*->long double ][ 116 ][ 173 ][ 58 ][ !!! *43* !!! ]] + [[ char*->array ][ !!! *1* !!! ][ 121 ][ 20 ][ 12 ]] + [[ char*->string ][ !!! *7* !!! ][ 126 ][ 29 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 119 ][ 27 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 96 ][ 12 ][ 9 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 95 ][ 11 ][ 12 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 95 ][ 12 ][ 12 ]] + [[ unsigned char*->int ][ !!! *6* !!! ][ 113 ][ 27 ][ 24 ]] + [[ unsigned char*->short ][ !!! *6* !!! ][ 120 ][ 23 ][ 21 ]] + [[ unsigned char*->long int ][ !!! *7* !!! ][ 114 ][ 22 ][ 23 ]] + [[ unsigned char*->long long ][ !!! *7* !!! ][ 114 ][ 23 ][ 23 ]] + [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 115 ][ 23 ][ 23 ]] + [[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 120 ][ 21 ][ 23 ]] + [[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 117 ][ 23 ][ 21 ]] + [[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 121 ][ 23 ][ 21 ]] + [[ unsigned char*->float ][ !!! *12* !!! ][ 161 ][ 58 ][ 39 ]] + [[ unsigned char*->double ][ !!! *13* !!! ][ 153 ][ 54 ][ 38 ]] + [[ unsigned char*->long double ][ 110 ][ 150 ][ 62 ][ !!! *43* !!! ]] + [[ unsigned char*->array ][ !!! *1* !!! ][ 113 ][ 20 ][ 12 ]] + [[ unsigned char*->string ][ !!! *8* !!! ][ 124 ][ 30 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *3* !!! ][ 118 ][ 27 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 99 ][ 11 ][ 9 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 102 ][ 12 ][ 10 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 99 ][ 12 ][ 10 ]] + [[ signed char*->int ][ !!! *6* !!! ][ 114 ][ 30 ][ 23 ]] + [[ signed char*->short ][ !!! *6* !!! ][ 118 ][ 23 ][ 23 ]] + [[ signed char*->long int ][ !!! *7* !!! ][ 119 ][ 22 ][ 21 ]] + [[ signed char*->long long ][ !!! *7* !!! ][ 114 ][ 23 ][ 26 ]] + [[ signed char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 26 ][ 23 ]] + [[ signed char*->unsigned short ][ !!! *6* !!! ][ 121 ][ 22 ][ 23 ]] + [[ signed char*->unsigned long int ][ !!! *7* !!! ][ 126 ][ 23 ][ 21 ]] + [[ signed char*->unsigned long long ][ !!! *7* !!! ][ 114 ][ 22 ][ 21 ]] + [[ signed char*->float ][ !!! *12* !!! ][ 163 ][ 57 ][ 39 ]] + [[ signed char*->double ][ !!! *13* !!! ][ 156 ][ 53 ][ 40 ]] + [[ signed char*->long double ][ 112 ][ 156 ][ 56 ][ !!! *42* !!! ]] + [[ signed char*->array ][ !!! *1* !!! ][ 117 ][ 20 ][ 12 ]] [[ signed char*->string ][ !!! *8* !!! ][ 127 ][ 28 ][ --- ]] - [[ signed char*->container::string ][ !!! *4* !!! ][ 124 ][ 27 ][ --- ]] - [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 8 ]] - [[ iterator_range->signed char ][ !!! *<1* !!! ][ 107 ][ 13 ][ 9 ]] - [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 121 ][ 26 ][ 13 ]] - [[ iterator_range->int ][ !!! *6* !!! ][ 165 ][ 33 ][ 23 ]] - [[ iterator_range->short ][ !!! *8* !!! ][ 175 ][ 34 ][ 29 ]] - [[ iterator_range->long int ][ !!! *14* !!! ][ 160 ][ 33 ][ 23 ]] - [[ iterator_range->long long ][ !!! *10* !!! ][ 199 ][ 35 ][ 28 ]] - [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 131 ][ 24 ][ 16 ]] - [[ iterator_range->unsigned short ][ !!! *7* !!! ][ 110 ][ 22 ][ 16 ]] - [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 111 ][ 22 ][ 14 ]] - [[ iterator_range->unsigned long long ][ !!! *8* !!! ][ 115 ][ 24 ][ 15 ]] - [[ iterator_range->float ][ !!! *13* !!! ][ 134 ][ 40 ][ 33 ]] - [[ iterator_range->double ][ !!! *15* !!! ][ 140 ][ 59 ][ 41 ]] - [[ iterator_range->long double ][ 131 ][ 146 ][ 53 ][ !!! *38* !!! ]] - [[ iterator_range->string ][ !!! *9* !!! ][ 121 ][ 31 ][ --- ]] - [[ iterator_range->container::string ][ !!! *4* !!! ][ 115 ][ 25 ][ --- ]] - [[ int->int ][ !!! *<1* !!! ][ 113 ][ 25 ][ --- ]] - [[ float->double ][ !!! *<1* !!! ][ 234 ][ 117 ][ --- ]] - [[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 112 ][ 27 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 14 ][ 9 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 104 ][ 16 ][ 10 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 103 ][ 16 ][ 10 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 121 ][ 22 ][ 21 ]] + [[ iterator_range->short ][ !!! *7* !!! ][ 112 ][ 23 ][ 23 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 115 ][ 24 ][ 23 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 113 ][ 24 ][ 23 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 117 ][ 26 ][ 23 ]] + [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 120 ][ 20 ][ 23 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 124 ][ 28 ][ 21 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 113 ][ 22 ][ 21 ]] + [[ iterator_range->float ][ !!! *11* !!! ][ 190 ][ 58 ][ 63 ]] + [[ iterator_range->double ][ !!! *20* !!! ][ 194 ][ 44 ][ 39 ]] + [[ iterator_range->long double ][ 116 ][ 145 ][ 46 ][ !!! *44* !!! ]] + [[ iterator_range->array ][ !!! *<1* !!! ][ 116 ][ 23 ][ 15 ]] + [[ iterator_range->string ][ !!! *7* !!! ][ 127 ][ 33 ][ --- ]] + [[ iterator_range->container::string ][ !!! *3* !!! ][ 112 ][ 24 ][ --- ]] + [[ array->char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 10 ]] + [[ array->signed char ][ !!! *<1* !!! ][ 99 ][ 12 ][ 15 ]] + [[ array->unsigned char ][ !!! *<1* !!! ][ 100 ][ 11 ][ 10 ]] + [[ array->int ][ !!! *6* !!! ][ 114 ][ 27 ][ 22 ]] + [[ array->short ][ !!! *5* !!! ][ 113 ][ 23 ][ 23 ]] + [[ array->long int ][ !!! *7* !!! ][ 118 ][ 22 ][ 23 ]] + [[ array->long long ][ !!! *7* !!! ][ 114 ][ 26 ][ 23 ]] + [[ array->unsigned int ][ !!! *6* !!! ][ 113 ][ 27 ][ 23 ]] + [[ array->unsigned short ][ !!! *5* !!! ][ 124 ][ 21 ][ 23 ]] + [[ array->unsigned long int ][ !!! *7* !!! ][ 116 ][ 23 ][ 21 ]] + [[ array->unsigned long long ][ !!! *7* !!! ][ 115 ][ 22 ][ 21 ]] + [[ array->float ][ !!! *11* !!! ][ 162 ][ 58 ][ 36 ]] + [[ array->double ][ !!! *13* !!! ][ 155 ][ 54 ][ 44 ]] + [[ array->long double ][ 111 ][ 149 ][ 55 ][ !!! *42* !!! ]] + [[ array->array ][ !!! *1* !!! ][ 114 ][ 18 ][ 14 ]] + [[ array->string ][ !!! *7* !!! ][ 129 ][ 29 ][ --- ]] + [[ array->container::string ][ !!! *3* !!! ][ 113 ][ 26 ][ --- ]] + [[ int->int ][ !!! *<1* !!! ][ 114 ][ 25 ][ --- ]] + [[ float->double ][ !!! *<1* !!! ][ 236 ][ 121 ][ --- ]] + [[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 8 ][ --- ]] ] [endsect] -[section GNU C++ version 4.6.1] -[table:id Performance Table ( GNU C++ version 4.6.1) -[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] - [[ string->char ][ !!! *<1* !!! ][ 140 ][ 17 ][ 13 ]] - [[ string->signed char ][ !!! *<1* !!! ][ 129 ][ 8 ][ 10 ]] - [[ string->unsigned char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 10 ]] - [[ string->int ][ !!! *6* !!! ][ 110 ][ 20 ][ 14 ]] - [[ string->short ][ !!! *5* !!! ][ 106 ][ 20 ][ 14 ]] - [[ string->long int ][ !!! *7* !!! ][ 107 ][ 22 ][ 14 ]] - [[ string->long long ][ !!! *7* !!! ][ 112 ][ 21 ][ 14 ]] - [[ string->unsigned int ][ !!! *6* !!! ][ 110 ][ 20 ][ 14 ]] - [[ string->unsigned short ][ !!! *5* !!! ][ 107 ][ 18 ][ 14 ]] - [[ string->unsigned long int ][ !!! *7* !!! ][ 108 ][ 23 ][ 14 ]] - [[ string->unsigned long long ][ !!! *7* !!! ][ 108 ][ 21 ][ 14 ]] - [[ string->float ][ !!! *12* !!! ][ 154 ][ 57 ][ 32 ]] - [[ string->double ][ !!! *11* !!! ][ 151 ][ 61 ][ 33 ]] - [[ string->long double ][ 109 ][ 187 ][ 79 ][ !!! *55* !!! ]] - [[ string->string ][ !!! *2* !!! ][ 122 ][ 27 ][ --- ]] - [[ string->container::string ][ !!! *3* !!! ][ 123 ][ 22 ][ --- ]] - [[ string->char ][ !!! *7* !!! ][ 109 ][ 27 ][ 17 ]] - [[ string->signed char ][ !!! *7* !!! ][ 110 ][ 25 ][ 22 ]] - [[ string->unsigned char ][ !!! *7* !!! ][ 112 ][ 27 ][ 24 ]] - [[ int->string ][ !!! *12* !!! ][ 187 ][ 48 ][ 37 ]] - [[ short->string ][ !!! *18* !!! ][ 133 ][ 33 ][ 20 ]] - [[ long int->string ][ !!! *12* !!! ][ 129 ][ 32 ][ 21 ]] - [[ long long->string ][ !!! *12* !!! ][ 127 ][ 35 ][ 23 ]] - [[ unsigned int->string ][ !!! *15* !!! ][ 133 ][ 31 ][ 21 ]] - [[ unsigned short->string ][ !!! *12* !!! ][ 133 ][ 31 ][ 21 ]] - [[ unsigned long int->string ][ !!! *12* !!! ][ 132 ][ 31 ][ 21 ]] - [[ unsigned long long->string ][ !!! *12* !!! ][ 127 ][ 29 ][ 24 ]] - [[ float->string ][ 53 ][ 215 ][ 103 ][ !!! *40* !!! ]] - [[ double->string ][ 58 ][ 215 ][ 103 ][ !!! *41* !!! ]] - [[ long double->string ][ 67 ][ 227 ][ 112 ][ !!! *45* !!! ]] - [[ char*->char ][ !!! *<1* !!! ][ 132 ][ 12 ][ 8 ]] - [[ char*->signed char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 9 ]] - [[ char*->unsigned char ][ !!! *<1* !!! ][ 96 ][ 10 ][ 9 ]] - [[ char*->int ][ !!! *6* !!! ][ 109 ][ 22 ][ 14 ]] - [[ char*->short ][ !!! *5* !!! ][ 109 ][ 26 ][ 14 ]] - [[ char*->long int ][ !!! *7* !!! ][ 111 ][ 23 ][ 14 ]] - [[ char*->long long ][ !!! *8* !!! ][ 112 ][ 25 ][ 16 ]] - [[ char*->unsigned int ][ !!! *6* !!! ][ 113 ][ 19 ][ 14 ]] - [[ char*->unsigned short ][ !!! *6* !!! ][ 111 ][ 20 ][ 14 ]] - [[ char*->unsigned long int ][ !!! *7* !!! ][ 109 ][ 21 ][ 14 ]] - [[ char*->unsigned long long ][ !!! *7* !!! ][ 111 ][ 22 ][ 14 ]] - [[ char*->float ][ !!! *12* !!! ][ 156 ][ 62 ][ 32 ]] - [[ char*->double ][ !!! *13* !!! ][ 156 ][ 65 ][ 33 ]] - [[ char*->long double ][ 108 ][ 156 ][ 59 ][ !!! *36* !!! ]] - [[ char*->string ][ !!! *7* !!! ][ 123 ][ 29 ][ --- ]] - [[ char*->container::string ][ !!! *2* !!! ][ 116 ][ 24 ][ --- ]] - [[ unsigned char*->char ][ !!! *<1* !!! ][ 96 ][ 12 ][ 8 ]] - [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ 9 ]] - [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 93 ][ 10 ][ 9 ]] - [[ unsigned char*->int ][ !!! *6* !!! ][ 110 ][ 22 ][ 14 ]] - [[ unsigned char*->short ][ !!! *6* !!! ][ 111 ][ 22 ][ 15 ]] - [[ unsigned char*->long int ][ !!! *8* !!! ][ 110 ][ 23 ][ 14 ]] - [[ unsigned char*->long long ][ !!! *7* !!! ][ 111 ][ 25 ][ 14 ]] - [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 111 ][ 21 ][ 16 ]] - [[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 110 ][ 21 ][ 15 ]] - [[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 21 ][ 14 ]] - [[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 108 ][ 23 ][ 15 ]] - [[ unsigned char*->float ][ !!! *12* !!! ][ 154 ][ 62 ][ 33 ]] - [[ unsigned char*->double ][ !!! *14* !!! ][ 157 ][ 65 ][ 32 ]] - [[ unsigned char*->long double ][ 107 ][ 154 ][ 56 ][ !!! *36* !!! ]] - [[ unsigned char*->string ][ !!! *9* !!! ][ 122 ][ 28 ][ --- ]] - [[ unsigned char*->container::string ][ !!! *4* !!! ][ 118 ][ 26 ][ --- ]] - [[ signed char*->char ][ !!! *<1* !!! ][ 94 ][ 10 ][ 8 ]] - [[ signed char*->signed char ][ !!! *<1* !!! ][ 94 ][ 12 ][ 9 ]] - [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 95 ][ 12 ][ 9 ]] - [[ signed char*->int ][ !!! *7* !!! ][ 109 ][ 22 ][ 14 ]] - [[ signed char*->short ][ !!! *5* !!! ][ 108 ][ 22 ][ 14 ]] - [[ signed char*->long int ][ !!! *7* !!! ][ 110 ][ 23 ][ 14 ]] - [[ signed char*->long long ][ !!! *7* !!! ][ 110 ][ 25 ][ 15 ]] - [[ signed char*->unsigned int ][ !!! *6* !!! ][ 109 ][ 20 ][ 15 ]] - [[ signed char*->unsigned short ][ !!! *6* !!! ][ 107 ][ 21 ][ 14 ]] - [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 111 ][ 21 ][ 14 ]] - [[ signed char*->unsigned long long ][ !!! *7* !!! ][ 109 ][ 23 ][ 14 ]] - [[ signed char*->float ][ !!! *12* !!! ][ 156 ][ 61 ][ 31 ]] - [[ signed char*->double ][ !!! *13* !!! ][ 156 ][ 68 ][ 33 ]] - [[ signed char*->long double ][ 109 ][ 159 ][ 56 ][ !!! *36* !!! ]] - [[ signed char*->string ][ !!! *9* !!! ][ 123 ][ 28 ][ --- ]] - [[ signed char*->container::string ][ !!! *4* !!! ][ 125 ][ 25 ][ --- ]] - [[ iterator_range->char ][ !!! *<1* !!! ][ 100 ][ 13 ][ 8 ]] - [[ iterator_range->signed char ][ !!! *<1* !!! ][ 98 ][ 14 ][ 9 ]] - [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 99 ][ 12 ][ 10 ]] - [[ iterator_range->int ][ !!! *6* !!! ][ 108 ][ 21 ][ 16 ]] - [[ iterator_range->short ][ !!! *5* !!! ][ 110 ][ 22 ][ 17 ]] - [[ iterator_range->long int ][ !!! *7* !!! ][ 107 ][ 22 ][ 15 ]] - [[ iterator_range->long long ][ !!! *7* !!! ][ 110 ][ 27 ][ 15 ]] - [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 107 ][ 24 ][ 15 ]] - [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 106 ][ 21 ][ 15 ]] - [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 110 ][ 21 ][ 16 ]] - [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 109 ][ 23 ][ 16 ]] - [[ iterator_range->float ][ !!! *11* !!! ][ 137 ][ 46 ][ 33 ]] - [[ iterator_range->double ][ !!! *11* !!! ][ 131 ][ 50 ][ 33 ]] - [[ iterator_range->long double ][ 107 ][ 136 ][ 44 ][ !!! *39* !!! ]] - [[ iterator_range->string ][ !!! *8* !!! ][ 117 ][ 32 ][ --- ]] - [[ iterator_range->container::string ][ !!! *3* !!! ][ 111 ][ 23 ][ --- ]] - [[ int->int ][ !!! *<1* !!! ][ 110 ][ 33 ][ --- ]] - [[ float->double ][ !!! *<1* !!! ][ 241 ][ 152 ][ --- ]] - [[ char->signed char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]] -] -[endsect] - -[section GNU C++ version 4.5.4] -[table:id Performance Table ( GNU C++ version 4.5.4) -[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] - [[ string->char ][ !!! *<1* !!! ][ 147 ][ 12 ][ 8 ]] - [[ string->signed char ][ !!! *<1* !!! ][ 138 ][ 13 ][ 10 ]] - [[ string->unsigned char ][ !!! *<1* !!! ][ 86 ][ 12 ][ 9 ]] - [[ string->int ][ !!! *7* !!! ][ 103 ][ 20 ][ 15 ]] - [[ string->short ][ !!! *5* !!! ][ 103 ][ 20 ][ 15 ]] - [[ string->long int ][ !!! *7* !!! ][ 103 ][ 22 ][ 15 ]] - [[ string->long long ][ !!! *7* !!! ][ 104 ][ 22 ][ 16 ]] - [[ string->unsigned int ][ !!! *6* !!! ][ 108 ][ 19 ][ 15 ]] - [[ string->unsigned short ][ !!! *5* !!! ][ 104 ][ 19 ][ 15 ]] - [[ string->unsigned long int ][ !!! *7* !!! ][ 103 ][ 20 ][ 16 ]] - [[ string->unsigned long long ][ !!! *7* !!! ][ 101 ][ 22 ][ 14 ]] - [[ string->float ][ !!! *13* !!! ][ 148 ][ 58 ][ 35 ]] - [[ string->double ][ !!! *13* !!! ][ 147 ][ 60 ][ 34 ]] - [[ string->long double ][ 103 ][ 149 ][ 56 ][ !!! *38* !!! ]] - [[ string->string ][ !!! *2* !!! ][ 127 ][ 27 ][ --- ]] - [[ string->container::string ][ !!! *3* !!! ][ 101 ][ 24 ][ --- ]] - [[ string->char ][ !!! *7* !!! ][ 108 ][ 35 ][ 17 ]] - [[ string->signed char ][ !!! *7* !!! ][ 112 ][ 26 ][ 23 ]] - [[ string->unsigned char ][ !!! *7* !!! ][ 113 ][ 25 ][ 25 ]] - [[ int->string ][ !!! *11* !!! ][ 183 ][ 47 ][ 40 ]] - [[ short->string ][ !!! *14* !!! ][ 153 ][ 35 ][ 23 ]] - [[ long int->string ][ !!! *12* !!! ][ 135 ][ 32 ][ 22 ]] - [[ long long->string ][ !!! *11* !!! ][ 131 ][ 30 ][ 24 ]] - [[ unsigned int->string ][ !!! *12* !!! ][ 137 ][ 31 ][ 22 ]] - [[ unsigned short->string ][ !!! *11* !!! ][ 137 ][ 33 ][ 22 ]] - [[ unsigned long int->string ][ !!! *11* !!! ][ 136 ][ 36 ][ 23 ]] - [[ unsigned long long->string ][ !!! *11* !!! ][ 127 ][ 29 ][ 23 ]] - [[ float->string ][ 56 ][ 218 ][ 107 ][ !!! *44* !!! ]] - [[ double->string ][ 63 ][ 223 ][ 106 ][ !!! *44* !!! ]] - [[ long double->string ][ 69 ][ 229 ][ 118 ][ !!! *49* !!! ]] - [[ char*->char ][ !!! *<1* !!! ][ 91 ][ 12 ][ 9 ]] - [[ char*->signed char ][ !!! *<1* !!! ][ 100 ][ 11 ][ 11 ]] - [[ char*->unsigned char ][ !!! *<1* !!! ][ 97 ][ 12 ][ 10 ]] - [[ char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]] - [[ char*->short ][ !!! *6* !!! ][ 116 ][ 23 ][ 16 ]] - [[ char*->long int ][ !!! *8* !!! ][ 113 ][ 23 ][ 16 ]] - [[ char*->long long ][ !!! *8* !!! ][ 122 ][ 28 ][ 16 ]] - [[ char*->unsigned int ][ !!! *6* !!! ][ 117 ][ 21 ][ 15 ]] - [[ char*->unsigned short ][ !!! *6* !!! ][ 113 ][ 21 ][ 16 ]] - [[ char*->unsigned long int ][ !!! *7* !!! ][ 118 ][ 22 ][ 16 ]] - [[ char*->unsigned long long ][ !!! *8* !!! ][ 113 ][ 22 ][ 17 ]] - [[ char*->float ][ !!! *11* !!! ][ 164 ][ 67 ][ 34 ]] - [[ char*->double ][ !!! *13* !!! ][ 163 ][ 66 ][ 35 ]] - [[ char*->long double ][ 110 ][ 164 ][ 63 ][ !!! *39* !!! ]] - [[ char*->string ][ !!! *8* !!! ][ 130 ][ 30 ][ --- ]] - [[ char*->container::string ][ !!! *2* !!! ][ 113 ][ 24 ][ --- ]] - [[ unsigned char*->char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 10 ]] - [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 97 ][ 12 ][ 10 ]] - [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 97 ][ 11 ][ 10 ]] - [[ unsigned char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]] - [[ unsigned char*->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 20 ]] - [[ unsigned char*->long int ][ !!! *8* !!! ][ 112 ][ 23 ][ 15 ]] - [[ unsigned char*->long long ][ !!! *8* !!! ][ 115 ][ 29 ][ 17 ]] - [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 21 ][ 14 ]] - [[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 112 ][ 22 ][ 15 ]] - [[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 115 ][ 23 ][ 14 ]] - [[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 112 ][ 24 ][ 15 ]] - [[ unsigned char*->float ][ !!! *12* !!! ][ 161 ][ 66 ][ 34 ]] - [[ unsigned char*->double ][ !!! *13* !!! ][ 162 ][ 66 ][ 36 ]] - [[ unsigned char*->long double ][ 112 ][ 161 ][ 63 ][ !!! *39* !!! ]] - [[ unsigned char*->string ][ !!! *9* !!! ][ 127 ][ 29 ][ --- ]] - [[ unsigned char*->container::string ][ !!! *4* !!! ][ 111 ][ 25 ][ --- ]] - [[ signed char*->char ][ !!! *<1* !!! ][ 104 ][ 11 ][ 8 ]] - [[ signed char*->signed char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 11 ]] - [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 11 ]] - [[ signed char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]] - [[ signed char*->short ][ !!! *7* !!! ][ 113 ][ 23 ][ 15 ]] - [[ signed char*->long int ][ !!! *8* !!! ][ 112 ][ 22 ][ 14 ]] - [[ signed char*->long long ][ !!! *8* !!! ][ 115 ][ 25 ][ 16 ]] - [[ signed char*->unsigned int ][ !!! *8* !!! ][ 114 ][ 21 ][ 18 ]] - [[ signed char*->unsigned short ][ !!! *6* !!! ][ 112 ][ 22 ][ 15 ]] - [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 116 ][ 22 ][ 15 ]] - [[ signed char*->unsigned long long ][ !!! *8* !!! ][ 113 ][ 23 ][ 16 ]] - [[ signed char*->float ][ !!! *13* !!! ][ 161 ][ 65 ][ 34 ]] - [[ signed char*->double ][ !!! *12* !!! ][ 172 ][ 67 ][ 34 ]] - [[ signed char*->long double ][ 110 ][ 164 ][ 63 ][ !!! *38* !!! ]] - [[ signed char*->string ][ !!! *9* !!! ][ 131 ][ 30 ][ --- ]] - [[ signed char*->container::string ][ !!! *4* !!! ][ 112 ][ 24 ][ --- ]] - [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 12 ][ 8 ]] - [[ iterator_range->signed char ][ !!! *<1* !!! ][ 101 ][ 13 ][ 9 ]] - [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 10 ]] - [[ iterator_range->int ][ !!! *7* !!! ][ 113 ][ 26 ][ 14 ]] - [[ iterator_range->short ][ !!! *5* !!! ][ 115 ][ 21 ][ 16 ]] - [[ iterator_range->long int ][ !!! *7* !!! ][ 115 ][ 22 ][ 15 ]] - [[ iterator_range->long long ][ !!! *7* !!! ][ 116 ][ 25 ][ 16 ]] - [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 115 ][ 24 ][ 23 ]] - [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 113 ][ 22 ][ 16 ]] - [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 117 ][ 20 ][ 16 ]] - [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 114 ][ 21 ][ 16 ]] - [[ iterator_range->float ][ !!! *11* !!! ][ 145 ][ 51 ][ 34 ]] - [[ iterator_range->double ][ !!! *11* !!! ][ 139 ][ 53 ][ 35 ]] - [[ iterator_range->long double ][ 109 ][ 147 ][ 44 ][ !!! *38* !!! ]] - [[ iterator_range->string ][ !!! *9* !!! ][ 123 ][ 36 ][ --- ]] - [[ iterator_range->container::string ][ !!! *3* !!! ][ 113 ][ 20 ][ --- ]] - [[ int->int ][ !!! *<1* !!! ][ 117 ][ 23 ][ --- ]] - [[ float->double ][ !!! *<1* !!! ][ 262 ][ 150 ][ --- ]] - [[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ --- ]] -] -[endsect] - -[section GNU C++ version 4.4.6] -[table:id Performance Table ( GNU C++ version 4.4.6) -[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] - [[ string->char ][ !!! *<1* !!! ][ 162 ][ 17 ][ 8 ]] - [[ string->signed char ][ !!! *<1* !!! ][ 103 ][ 9 ][ 9 ]] - [[ string->unsigned char ][ !!! *<1* !!! ][ 91 ][ 9 ][ 9 ]] - [[ string->int ][ !!! *6* !!! ][ 104 ][ 21 ][ 14 ]] - [[ string->short ][ !!! *5* !!! ][ 107 ][ 22 ][ 14 ]] - [[ string->long int ][ !!! *7* !!! ][ 106 ][ 23 ][ 15 ]] - [[ string->long long ][ !!! *7* !!! ][ 104 ][ 21 ][ 16 ]] - [[ string->unsigned int ][ !!! *6* !!! ][ 100 ][ 20 ][ 16 ]] - [[ string->unsigned short ][ !!! *5* !!! ][ 102 ][ 20 ][ 16 ]] - [[ string->unsigned long int ][ !!! *7* !!! ][ 106 ][ 25 ][ 16 ]] - [[ string->unsigned long long ][ !!! *7* !!! ][ 109 ][ 25 ][ 14 ]] - [[ string->float ][ !!! *13* !!! ][ 142 ][ 48 ][ 32 ]] - [[ string->double ][ !!! *13* !!! ][ 162 ][ 62 ][ 33 ]] - [[ string->long double ][ 119 ][ 164 ][ 62 ][ !!! *37* !!! ]] - [[ string->string ][ !!! *2* !!! ][ 122 ][ 27 ][ --- ]] - [[ string->container::string ][ !!! *2* !!! ][ 107 ][ 23 ][ --- ]] - [[ string->char ][ !!! *6* !!! ][ 110 ][ 24 ][ 15 ]] - [[ string->signed char ][ !!! *6* !!! ][ 107 ][ 24 ][ 21 ]] - [[ string->unsigned char ][ !!! *6* !!! ][ 106 ][ 27 ][ 21 ]] - [[ int->string ][ !!! *12* !!! ][ 122 ][ 31 ][ 21 ]] - [[ short->string ][ !!! *12* !!! ][ 136 ][ 29 ][ 20 ]] - [[ long int->string ][ !!! *12* !!! ][ 127 ][ 32 ][ 19 ]] - [[ long long->string ][ !!! *12* !!! ][ 121 ][ 32 ][ 21 ]] - [[ unsigned int->string ][ !!! *12* !!! ][ 133 ][ 32 ][ 19 ]] - [[ unsigned short->string ][ !!! *12* !!! ][ 126 ][ 33 ][ 20 ]] - [[ unsigned long int->string ][ !!! *11* !!! ][ 126 ][ 34 ][ 19 ]] - [[ unsigned long long->string ][ !!! *12* !!! ][ 125 ][ 28 ][ 21 ]] - [[ float->string ][ 47 ][ 183 ][ 86 ][ !!! *43* !!! ]] - [[ double->string ][ 57 ][ 184 ][ 90 ][ !!! *42* !!! ]] - [[ long double->string ][ 64 ][ 199 ][ 87 ][ !!! *46* !!! ]] - [[ char*->char ][ !!! *<1* !!! ][ 95 ][ 10 ][ 8 ]] - [[ char*->signed char ][ !!! *<1* !!! ][ 90 ][ 12 ][ 9 ]] - [[ char*->unsigned char ][ !!! *<1* !!! ][ 93 ][ 12 ][ 9 ]] - [[ char*->int ][ !!! *6* !!! ][ 108 ][ 24 ][ 14 ]] - [[ char*->short ][ !!! *6* !!! ][ 106 ][ 23 ][ 14 ]] - [[ char*->long int ][ !!! *7* !!! ][ 107 ][ 24 ][ 17 ]] - [[ char*->long long ][ !!! *7* !!! ][ 109 ][ 25 ][ 17 ]] - [[ char*->unsigned int ][ !!! *6* !!! ][ 104 ][ 23 ][ 17 ]] - [[ char*->unsigned short ][ !!! *6* !!! ][ 102 ][ 22 ][ 17 ]] - [[ char*->unsigned long int ][ !!! *7* !!! ][ 107 ][ 23 ][ 17 ]] - [[ char*->unsigned long long ][ !!! *7* !!! ][ 115 ][ 26 ][ 14 ]] - [[ char*->float ][ !!! *12* !!! ][ 150 ][ 56 ][ 30 ]] - [[ char*->double ][ !!! *12* !!! ][ 165 ][ 66 ][ 32 ]] - [[ char*->long double ][ 116 ][ 173 ][ 66 ][ !!! *37* !!! ]] - [[ char*->string ][ !!! *7* !!! ][ 120 ][ 28 ][ --- ]] - [[ char*->container::string ][ !!! *2* !!! ][ 108 ][ 26 ][ --- ]] - [[ unsigned char*->char ][ !!! *<1* !!! ][ 90 ][ 12 ][ 8 ]] - [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 91 ][ 11 ][ 9 ]] - [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 91 ][ 12 ][ 9 ]] - [[ unsigned char*->int ][ !!! *6* !!! ][ 106 ][ 24 ][ 14 ]] - [[ unsigned char*->short ][ !!! *6* !!! ][ 108 ][ 24 ][ 14 ]] - [[ unsigned char*->long int ][ !!! *7* !!! ][ 116 ][ 23 ][ 14 ]] - [[ unsigned char*->long long ][ !!! *7* !!! ][ 108 ][ 28 ][ 14 ]] - [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 107 ][ 22 ][ 14 ]] - [[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 105 ][ 21 ][ 16 ]] - [[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 106 ][ 25 ][ 16 ]] - [[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 105 ][ 24 ][ 17 ]] - [[ unsigned char*->float ][ !!! *14* !!! ][ 150 ][ 57 ][ 33 ]] - [[ unsigned char*->double ][ !!! *14* !!! ][ 171 ][ 72 ][ 34 ]] - [[ unsigned char*->long double ][ 118 ][ 171 ][ 73 ][ !!! *38* !!! ]] - [[ unsigned char*->string ][ !!! *8* !!! ][ 120 ][ 29 ][ --- ]] - [[ unsigned char*->container::string ][ !!! *3* !!! ][ 114 ][ 26 ][ --- ]] - [[ signed char*->char ][ !!! *<1* !!! ][ 92 ][ 12 ][ 8 ]] - [[ signed char*->signed char ][ !!! *<1* !!! ][ 92 ][ 12 ][ 9 ]] - [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 91 ][ 14 ][ 9 ]] - [[ signed char*->int ][ !!! *6* !!! ][ 109 ][ 22 ][ 15 ]] - [[ signed char*->short ][ !!! *6* !!! ][ 106 ][ 24 ][ 17 ]] - [[ signed char*->long int ][ !!! *7* !!! ][ 107 ][ 24 ][ 16 ]] - [[ signed char*->long long ][ !!! *7* !!! ][ 106 ][ 24 ][ 14 ]] - [[ signed char*->unsigned int ][ !!! *6* !!! ][ 106 ][ 22 ][ 14 ]] - [[ signed char*->unsigned short ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]] - [[ signed char*->unsigned long int ][ !!! *7* !!! ][ 105 ][ 22 ][ 16 ]] - [[ signed char*->unsigned long long ][ !!! *7* !!! ][ 108 ][ 24 ][ 15 ]] - [[ signed char*->float ][ !!! *14* !!! ][ 147 ][ 54 ][ 32 ]] - [[ signed char*->double ][ !!! *14* !!! ][ 170 ][ 68 ][ 37 ]] - [[ signed char*->long double ][ 133 ][ 167 ][ 66 ][ !!! *37* !!! ]] - [[ signed char*->string ][ !!! *8* !!! ][ 119 ][ 30 ][ --- ]] - [[ signed char*->container::string ][ !!! *3* !!! ][ 108 ][ 24 ][ --- ]] - [[ iterator_range->char ][ !!! *<1* !!! ][ 98 ][ 13 ][ 8 ]] - [[ iterator_range->signed char ][ !!! *<1* !!! ][ 98 ][ 15 ][ 9 ]] - [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 97 ][ 15 ][ 9 ]] - [[ iterator_range->int ][ !!! *6* !!! ][ 107 ][ 27 ][ 14 ]] - [[ iterator_range->short ][ !!! *5* !!! ][ 109 ][ 23 ][ 14 ]] - [[ iterator_range->long int ][ !!! *7* !!! ][ 109 ][ 22 ][ 14 ]] - [[ iterator_range->long long ][ !!! *7* !!! ][ 107 ][ 24 ][ 14 ]] - [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 120 ][ 23 ][ 14 ]] - [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 104 ][ 21 ][ 17 ]] - [[ iterator_range->unsigned long int ][ !!! *8* !!! ][ 108 ][ 25 ][ 16 ]] - [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 106 ][ 25 ][ 15 ]] - [[ iterator_range->float ][ !!! *13* !!! ][ 132 ][ 41 ][ 32 ]] - [[ iterator_range->double ][ !!! *12* !!! ][ 136 ][ 45 ][ 32 ]] - [[ iterator_range->long double ][ 113 ][ 138 ][ 50 ][ !!! *36* !!! ]] - [[ iterator_range->string ][ !!! *7* !!! ][ 114 ][ 33 ][ --- ]] - [[ iterator_range->container::string ][ !!! *2* !!! ][ 105 ][ 24 ][ --- ]] - [[ int->int ][ !!! *<1* !!! ][ 112 ][ 31 ][ --- ]] - [[ float->double ][ !!! *<1* !!! ][ 233 ][ 199 ][ --- ]] - [[ char->signed char ][ !!! *<1* !!! ][ 129 ][ 10 ][ --- ]] -] -[endsect] [/ END of section, generated by performance measuring program ] [endsect] diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 3e2e53f..c9d4a59 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -69,12 +69,12 @@ namespace boost { // exception used to indicate runtime lexical_cast failure class BOOST_SYMBOL_VISIBLE bad_lexical_cast : - // workaround MSVC bug with std::bad_cast when _HAS_EXCEPTIONS == 0 -#if defined(BOOST_MSVC) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS - public std::exception -#else - public std::bad_cast -#endif + // workaround MSVC bug with std::bad_cast when _HAS_EXCEPTIONS == 0 +#if defined(BOOST_MSVC) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS + public std::exception +#else + public std::bad_cast +#endif #if defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, < 0x560 ) // under bcc32 5.5.1 bad_cast doesn't derive from exception @@ -134,10 +134,16 @@ namespace boost } } // namespace boost -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__SUNPRO_CC) +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__SUNPRO_CC) && !defined(__PGIC__) #include #include + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) +#include +#endif + +#include #include #include #include @@ -168,13 +174,13 @@ namespace boost { { typedef CharT type; }; - + template <> struct widest_char< not_a_character_type, not_a_character_type > { typedef char type; }; - } + } namespace detail // is_char_or_wchar<...> and stream_char<...> templates { @@ -224,42 +230,68 @@ namespace boost { typedef char type; }; - template + template struct stream_char { typedef BOOST_DEDUCED_TYPENAME stream_char::type type; }; - template + template struct stream_char { typedef BOOST_DEDUCED_TYPENAME stream_char::type type; }; - template + template struct stream_char > { typedef BOOST_DEDUCED_TYPENAME stream_char::type type; }; - - template + + template struct stream_char > { typedef BOOST_DEDUCED_TYPENAME stream_char::type type; }; - template + template struct stream_char< std::basic_string > { typedef CharT type; }; - template + template struct stream_char< ::boost::container::basic_string > { typedef CharT type; }; + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; +#endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) + #if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T) template<> struct stream_char @@ -430,7 +462,7 @@ namespace boost { // -1.23456789e-123456 // ^ sign // ^ leading digit - // ^ decimal point + // ^ decimal point // ^^^^^^^^ lcast_precision::value // ^ "e" // ^ exponent sign @@ -1259,7 +1291,6 @@ namespace boost { return true; } -#ifndef BOOST_LCAST_NO_WCHAR_T template bool shl_char_array(T const* str) { @@ -1268,7 +1299,13 @@ namespace boost { "Use boost::locale instead" ); return shl_input_streamable(str); } -#endif + + bool shl_char_array_limited(CharT const* str, std::size_t max_size) + { + start = const_cast(str); + finish = std::find(start, start + max_size, static_cast(0)); + return true; + } template bool shl_input_streamable(InputStreamable& input) @@ -1403,14 +1440,14 @@ namespace boost { { start = rng.begin(); finish = rng.end(); - return true; + return true; } - + bool operator<<(const iterator_range& rng) { start = const_cast(rng.begin()); finish = const_cast(rng.end()); - return true; + return true; } bool operator<<(const iterator_range& rng) @@ -1494,8 +1531,58 @@ namespace boost { return shl_real_type(static_cast(val), start, finish); #endif } + + template + bool operator<<(boost::array const& input) + { return shl_char_array_limited(input.begin(), N); } - template + template + bool operator<<(boost::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(boost::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(boost::array const& input) + { return shl_char_array_limited(input.begin(), N); } + + template + bool operator<<(boost::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(boost::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) + template + bool operator<<(std::array const& input) + { return shl_char_array_limited(input.begin(), N); } + + template + bool operator<<(std::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(std::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(std::array const& input) + { return shl_char_array_limited(input.begin(), N); } + + template + bool operator<<(std::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(std::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } +#endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) + + template bool operator<<(const InStreamable& input) { return shl_input_streamable(input); } /************************************ HELPER FUNCTIONS FOR OPERATORS >> ( ... ) ********************************/ @@ -1674,6 +1761,70 @@ namespace boost { template bool operator>>(::boost::container::basic_string& str) { str.assign(start, finish); return true; } + + private: + template + bool shr_std_array(ArrayT& output, boost::mpl::bool_ /*is_T_char_tag*/) + { + using namespace std; + const std::size_t size = finish - start; + if (size > N - 1) { // `-1` because we need to store \0 at the end + return false; + } + + memcpy(output.begin(), start, size * sizeof(CharT)); + *(output.begin() + size) = static_cast(0); + return true; + } + + template + bool shr_std_array(ArrayT& output, boost::mpl::bool_ /*is_T_char_tag*/) + { + return shr_using_base_class(output); // Array consist of non character types or unmatching character type + } + public: + + template + bool operator>>(boost::array& output) + { + typedef boost::mpl::bool_ tag_type; + return shr_std_array(output, tag_type()); + } + + template + bool operator>>(boost::array& output) + { + return ((*this) >> reinterpret_cast& >(output)); + } + + template + bool operator>>(boost::array& output) + { + return ((*this) >> reinterpret_cast& >(output)); + } + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) + template + bool operator>>(std::array& output) + { + typedef boost::mpl::bool_ tag_type; + return shr_std_array(output, tag_type()); + } + + template + bool operator>>(std::array& output) + { + return ((*this) >> reinterpret_cast& >(output)); + } + + template + bool operator>>(std::array& in) + { + return ((*this) >> reinterpret_cast& >(output)); + } +#endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) + + /* * case "-0" || "0" || "+0" : output = false; return true; * case "1" || "+1": output = true; return true; @@ -1857,11 +2008,11 @@ namespace boost { }; - // this metafunction evaluates to true, if we have optimized comnversion - // from Float type to Char array. + // this metafunction evaluates to true, if we have optimized comnversion + // from Float type to Char array. // Must be in sync with lexical_stream_limited_src::shl_real_type(...) template - struct is_this_float_conversion_optimized + struct is_this_float_conversion_optimized { typedef ::boost::type_traits::ice_and< ::boost::is_float::value, @@ -1937,11 +2088,6 @@ namespace boost { "Your compiler does not have full support for char32_t" ); #endif - typedef detail::lcast_src_length lcast_src_length; - std::size_t const src_len = lcast_src_length::value; - char_type buf[src_len + 1]; - lcast_src_length::check_coverage(); - typedef BOOST_DEDUCED_TYPENAME ::boost::detail::deduce_char_traits< char_type, Target, Source >::type traits; @@ -1959,20 +2105,29 @@ namespace boost { ::boost::detail::is_char_or_wchar::value > is_source_input_optimized_t; + // Target type must be default constructible + Target result; + // If we have an optimized conversion for // Source, we do not need to construct stringbuf. const bool requires_stringbuf = ::boost::type_traits::ice_or< is_string_widening_required_t::value, ::boost::type_traits::ice_not< is_source_input_optimized_t::value >::value >::value; + + typedef detail::lexical_stream_limited_src interpreter_type; - detail::lexical_stream_limited_src - interpreter(buf, buf + src_len); + typedef detail::lcast_src_length lcast_src_length; + std::size_t const src_len = lcast_src_length::value; + char_type buf[src_len + 1]; + lcast_src_length::check_coverage(); + + interpreter_type interpreter(buf, buf + src_len); - Target result; // Disabling ADL, by directly specifying operators. if(!(interpreter.operator <<(arg) && interpreter.operator >>(result))) BOOST_LCAST_THROW_BAD_CAST(Source, Target); + return result; } }; @@ -2252,10 +2407,10 @@ namespace boost { template Target lexical_cast(Source arg) { - typedef typename detail::widest_char< - BOOST_DEDUCED_TYPENAME detail::stream_char::type - , BOOST_DEDUCED_TYPENAME detail::stream_char::type - >::type char_type; + typedef typename detail::widest_char< + BOOST_DEDUCED_TYPENAME detail::stream_char::type + , BOOST_DEDUCED_TYPENAME detail::stream_char::type + >::type char_type; typedef std::char_traits traits; detail::lexical_stream interpreter; diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 844ee71..e7adc86 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -4,7 +4,7 @@ // // Copyright Terje Sletteb and Kevlin Henney, 2005. // Copyright Alexander Nasonov, 2006. -// Copyright Antony Polukhin, 2011. +// Copyright Antony Polukhin, 2011-2012. // // Distributed under the Boost // Software License, Version 1.0. (See accompanying file @@ -57,13 +57,6 @@ struct my_allocator : std::allocator { }; -// Test all 65536 values if true: -bool const lcast_test_small_integral_types_completely = false; - -// lcast_integral_test_counter: use when testing all values of an integral -// types is not possible. Max. portable value is 32767. -int const lcast_integral_test_counter=1000; - using namespace boost; void test_conversion_to_char(); @@ -80,18 +73,6 @@ void test_conversion_from_wstring(); void test_conversion_to_wstring(); void test_bad_lexical_cast(); void test_no_whitespace_stripping(); -void test_conversion_from_to_short(); -void test_conversion_from_to_ushort(); -void test_conversion_from_to_int(); -void test_conversion_from_to_uint(); -void test_conversion_from_to_long(); -void test_conversion_from_to_ulong(); -void test_conversion_from_to_intmax_t(); -void test_conversion_from_to_uintmax_t(); -#ifdef LCAST_TEST_LONGLONG -void test_conversion_from_to_longlong(); -void test_conversion_from_to_ulonglong(); -#endif #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION void test_traits(); void test_wtraits(); @@ -107,7 +88,6 @@ void test_char16_conversions(); void test_char32_conversions(); #endif - unit_test::test_suite *init_unit_test_suite(int, char *[]) { unit_test::test_suite *suite = @@ -128,18 +108,6 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) #endif suite->add(BOOST_TEST_CASE(test_bad_lexical_cast)); suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_short)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ushort)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_int)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uint)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_long)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulong)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_intmax_t)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uintmax_t)); -#ifdef LCAST_TEST_LONGLONG - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong)); -#endif #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION suite->add(BOOST_TEST_CASE(&test_traits)); suite->add(BOOST_TEST_CASE(&test_wtraits)); @@ -399,6 +367,7 @@ void test_conversion_to_wchar_t() BOOST_CHECK_THROW( lexical_cast(std::wstring(L"Test")), bad_lexical_cast); #endif + BOOST_CHECK(true); } void test_conversion_from_wstring() @@ -417,6 +386,7 @@ void test_conversion_from_wstring() BOOST_CHECK_THROW( lexical_cast(std::wstring(L"Test")), bad_lexical_cast); #endif + BOOST_CHECK(true); } void test_conversion_to_wstring() @@ -441,6 +411,7 @@ void test_conversion_to_wstring() BOOST_CHECK(L" " == lexical_cast(std::wstring(L" "))); BOOST_CHECK(L"" == lexical_cast(std::wstring(L""))); #endif + BOOST_CHECK(true); } void test_bad_lexical_cast() @@ -464,444 +435,6 @@ void test_no_whitespace_stripping() BOOST_CHECK_THROW(lexical_cast("123 "), bad_lexical_cast); } -// Replace "-,999" with "-999". -template -std::basic_string to_str_gcc_workaround(std::basic_string str) -{ - std::locale loc; - std::numpunct const& np = BOOST_USE_FACET(std::numpunct, loc); - std::ctype const& ct = BOOST_USE_FACET(std::ctype, loc); - - if(np.grouping().empty()) - return str; - - CharT prefix[3] = { ct.widen('-'), np.thousands_sep(), CharT() }; - - if(str.find(prefix) != 0) - return str; - - prefix[1] = CharT(); - str.replace(0, 2, prefix); - return str; -} - -template -std::basic_string to_str(T t) -{ - std::basic_ostringstream o; - o << t; - return to_str_gcc_workaround(o.str()); -} - -template -void test_conversion_from_integral_to_char(CharT zero) -{ - BOOST_CHECK(lexical_cast(static_cast(0)) == zero + 0); - BOOST_CHECK(lexical_cast(static_cast(1)) == zero + 1); - BOOST_CHECK(lexical_cast(static_cast(2)) == zero + 2); - BOOST_CHECK(lexical_cast(static_cast(3)) == zero + 3); - BOOST_CHECK(lexical_cast(static_cast(4)) == zero + 4); - BOOST_CHECK(lexical_cast(static_cast(5)) == zero + 5); - BOOST_CHECK(lexical_cast(static_cast(6)) == zero + 6); - BOOST_CHECK(lexical_cast(static_cast(7)) == zero + 7); - BOOST_CHECK(lexical_cast(static_cast(8)) == zero + 8); - BOOST_CHECK(lexical_cast(static_cast(9)) == zero + 9); - - BOOST_CHECK_THROW(lexical_cast(static_cast(10)), bad_lexical_cast); - - T t = (std::numeric_limits::max)(); - BOOST_CHECK_THROW(lexical_cast(t), bad_lexical_cast); -} - -template -void test_conversion_from_char_to_integral(CharT zero) -{ - BOOST_CHECK(lexical_cast( static_cast(zero + 0)) == static_cast(0) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 1)) == static_cast(1) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 2)) == static_cast(2) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 3)) == static_cast(3) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 4)) == static_cast(4) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 5)) == static_cast(5) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 6)) == static_cast(6) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 7)) == static_cast(7) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 8)) == static_cast(8) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 9)) == static_cast(9) ); - - BOOST_CHECK_THROW(lexical_cast( static_cast(zero + 10)), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast( static_cast(zero - 1)), bad_lexical_cast); -} - -template -void test_conversion_from_integral_to_integral() -{ - T t = 0; - BOOST_CHECK(lexical_cast(t) == t); - - // Next two variables are used to supress warnings. - int st = 32767; unsigned int ut = st; - t = st; - BOOST_CHECK(lexical_cast(t) == st); - BOOST_CHECK(lexical_cast(t) == ut); - BOOST_CHECK(lexical_cast(t) == st); - BOOST_CHECK(lexical_cast(t) == ut); - BOOST_CHECK(lexical_cast(t) == st); - BOOST_CHECK(lexical_cast(t) == ut); - - t = (std::numeric_limits::max)(); - BOOST_CHECK(lexical_cast(t) == t); - - t = (std::numeric_limits::min)(); - BOOST_CHECK(lexical_cast(t) == t); -} - -template -void test_conversion_from_integral_to_string(CharT) -{ - typedef std::numeric_limits limits; - typedef std::basic_string string_type; - - T t; - - t = (limits::min)(); - BOOST_CHECK(lexical_cast(t) == to_str(t)); - - t = (limits::max)(); - BOOST_CHECK(lexical_cast(t) == to_str(t)); - - if(limits::digits <= 16 && lcast_test_small_integral_types_completely) - // min and max have already been tested. - for(t = 1 + (limits::min)(); t != (limits::max)(); ++t) - BOOST_CHECK(lexical_cast(t) == to_str(t)); - else - { - T const min_val = (limits::min)(); - T const max_val = (limits::max)(); - T const half_max_val = max_val / 2; - T const cnt = lcast_integral_test_counter; // to supress warnings - unsigned int const counter = cnt < half_max_val ? cnt : half_max_val; - - unsigned int i; - - // Test values around min: - t = min_val; - for(i = 0; i < counter; ++i, ++t) - BOOST_CHECK(lexical_cast(t) == to_str(t)); - - // Test values around max: - t = max_val; - for(i = 0; i < counter; ++i, --t) - BOOST_CHECK(lexical_cast(t) == to_str(t)); - - // Test values around zero: - if(limits::is_signed) - for(t = static_cast(-counter); t < static_cast(counter); ++t) - BOOST_CHECK(lexical_cast(t) == to_str(t)); - - // Test values around 100, 1000, 10000, ... - T ten_power = 100; - for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10) - { - // ten_power + 100 probably never overflows - for(t = ten_power - 100; t != ten_power + 100; ++t) - BOOST_CHECK(lexical_cast(t) == to_str(t)); - } - } -} - -template -void test_conversion_from_string_to_integral(CharT) -{ - typedef std::numeric_limits limits; - typedef std::basic_string string_type; - - string_type s; - string_type const zero = to_str(0); - string_type const nine = to_str(9); - T const min_val = (limits::min)(); - T const max_val = (limits::max)(); - - s = to_str(min_val); - BOOST_CHECK_EQUAL(lexical_cast(s), min_val); - if(limits::is_signed) - { - BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); - } - - s = to_str(max_val); - BOOST_CHECK_EQUAL(lexical_cast(s), max_val); - { - BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); - - s = to_str(max_val); - for (int i =1; i <=10; ++i) { - s[s.size()-1] += 1; - BOOST_CHECK_THROW(lexical_cast( s ), bad_lexical_cast); - } - - s = to_str(max_val); - std::locale loc; - typedef std::numpunct numpunct; - if ( BOOST_USE_FACET(numpunct, loc).grouping().empty() ) { - // Following tests work well for locale C - BOOST_CHECK_EQUAL(lexical_cast(to_str(0)+s), max_val); - BOOST_CHECK_EQUAL(lexical_cast(to_str(0)+to_str(0)+s), max_val); - BOOST_CHECK_EQUAL(lexical_cast(to_str(0)+to_str(0)+to_str(0)+s), max_val); - } - - for (int i =1; i <=256; ++i) { - BOOST_CHECK_THROW(lexical_cast( to_str(i)+s ), bad_lexical_cast); - } - - typedef BOOST_DEDUCED_TYPENAME boost::integral_promotion::type promoted; - if ( !(boost::is_same::value) ) - { - promoted prom = max_val; - s = to_str(max_val); - for (int i =1; i <=256; ++i) { - BOOST_CHECK_THROW(lexical_cast( to_str(prom+i) ), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast( to_str(i)+s ), bad_lexical_cast); - } - } - } - - if(limits::digits <= 16 && lcast_test_small_integral_types_completely) - // min and max have already been tested. - for(T t = 1 + min_val; t != max_val; ++t) - BOOST_CHECK(lexical_cast(to_str(t)) == t); - else - { - T const half_max_val = max_val / 2; - T const cnt = lcast_integral_test_counter; // to supress warnings - unsigned int const counter = cnt < half_max_val ? cnt : half_max_val; - - T t; - unsigned int i; - - // Test values around min: - t = min_val; - for(i = 0; i < counter; ++i, ++t) - BOOST_CHECK(lexical_cast(to_str(t)) == t); - - // Test values around max: - t = max_val; - for(i = 0; i < counter; ++i, --t) - BOOST_CHECK(lexical_cast(to_str(t)) == t); - - // Test values around zero: - if(limits::is_signed) - for(t = static_cast(-counter); t < static_cast(counter); ++t) - BOOST_CHECK(lexical_cast(to_str(t)) == t); - - // Test values around 100, 1000, 10000, ... - T ten_power = 100; - for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10) - { - // ten_power + 100 probably never overflows - for(t = ten_power - 100; t != ten_power + 100; ++t) - BOOST_CHECK(lexical_cast(to_str(t)) == t); - } - } -} - -template -void test_conversion_from_to_integral_for_locale() -{ - std::locale current_locale; - typedef std::numpunct numpunct; - numpunct const& np = BOOST_USE_FACET(numpunct, current_locale); - if ( !np.grouping().empty() ) - { - BOOST_CHECK_THROW( - lexical_cast( std::string("100") + np.thousands_sep() + np.thousands_sep() + "0" ) - , bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast( std::string("100") + np.thousands_sep() ), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast( np.thousands_sep() + std::string("100") ), bad_lexical_cast); - - // Exception must not be thrown, when we are using no separators at all - BOOST_CHECK( lexical_cast("30000") == static_cast(30000) ); - } - - test_conversion_from_integral_to_integral(); - test_conversion_from_integral_to_string('0'); - test_conversion_from_string_to_integral('0'); -#if !defined(BOOST_LCAST_NO_WCHAR_T) - test_conversion_from_integral_to_string(L'0'); - test_conversion_from_string_to_integral(L'0'); -#endif -} - -struct restore_oldloc -{ - std::locale oldloc; - ~restore_oldloc() { std::locale::global(oldloc); } -}; - -template -void test_conversion_from_to_integral() -{ - char const zero = '0'; - signed char const szero = '0'; - unsigned char const uzero = '0'; - test_conversion_from_integral_to_char(zero); - test_conversion_from_char_to_integral(zero); - test_conversion_from_integral_to_char(szero); - test_conversion_from_char_to_integral(szero); - test_conversion_from_integral_to_char(uzero); - test_conversion_from_char_to_integral(uzero); -#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) - wchar_t const wzero = L'0'; - test_conversion_from_integral_to_char(wzero); - test_conversion_from_char_to_integral(wzero); -#endif -#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) - char16_t const u16zero = u'0'; - test_conversion_from_integral_to_char(u16zero); - test_conversion_from_char_to_integral(u16zero); -#endif -#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) - char32_t const u32zero = u'0'; - test_conversion_from_integral_to_char(u32zero); - test_conversion_from_char_to_integral(u32zero); -#endif - - BOOST_CHECK(lexical_cast("-1") == static_cast(-1)); - BOOST_CHECK(lexical_cast("-9") == static_cast(-9)); - BOOST_CHECK(lexical_cast(-1) == static_cast(-1)); - BOOST_CHECK(lexical_cast(-9) == static_cast(-9)); - - BOOST_CHECK_THROW(lexical_cast("-1.0"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("-9.0"), bad_lexical_cast); - BOOST_CHECK(lexical_cast(-1.0) == static_cast(-1)); - BOOST_CHECK(lexical_cast(-9.0) == static_cast(-9)); - - BOOST_CHECK(lexical_cast(static_cast(1)) == static_cast(1)); - BOOST_CHECK(lexical_cast(static_cast(9)) == static_cast(9)); - BOOST_CHECK_THROW(lexical_cast(1.1f), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(1.1), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(1.1L), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(1.0001f), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(1.0001), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(1.0001L), bad_lexical_cast); - - BOOST_CHECK(lexical_cast("+1") == static_cast(1) ); - BOOST_CHECK(lexical_cast("+9") == static_cast(9) ); - BOOST_CHECK(lexical_cast("+10") == static_cast(10) ); - BOOST_CHECK(lexical_cast("+90") == static_cast(90) ); - BOOST_CHECK_THROW(lexical_cast("++1"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("-+9"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("--1"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("+-9"), bad_lexical_cast); - // test_conversion_from_to_integral_for_locale - - // Overflow test case from David W. Birdsall - std::string must_owerflow_str = "160000000000000000000"; - std::string must_owerflow_negative_str = "-160000000000000000000"; - for (int i = 0; i < 15; ++i) { - BOOST_CHECK_THROW(lexical_cast(must_owerflow_str), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(must_owerflow_negative_str), bad_lexical_cast); - - must_owerflow_str += '0'; - must_owerflow_negative_str += '0'; - } - - typedef std::numpunct numpunct; - - restore_oldloc guard; - std::locale const& oldloc = guard.oldloc; - - std::string grouping1 = BOOST_USE_FACET(numpunct, oldloc).grouping(); - std::string grouping2(grouping1); - - test_conversion_from_to_integral_for_locale(); - - try - { - std::locale newloc(""); - std::locale::global(newloc); - - grouping2 = BOOST_USE_FACET(numpunct, newloc).grouping(); - } - catch(std::exception const& ex) - { - std::string msg("Failed to set system locale: "); - msg += ex.what(); - BOOST_TEST_MESSAGE(msg); - } - - if(grouping1 != grouping2) - test_conversion_from_to_integral_for_locale(); - - if(grouping1.empty() && grouping2.empty()) - BOOST_TEST_MESSAGE("Formatting with thousands_sep has not been tested"); -} - -void test_conversion_from_to_short() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_ushort() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_int() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_uint() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_long() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_ulong() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_intmax_t() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_uintmax_t() -{ - test_conversion_from_to_integral(); -} - -#if defined(BOOST_HAS_LONG_LONG) - -void test_conversion_from_to_longlong() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_ulonglong() -{ - test_conversion_from_to_integral(); -} - -#elif defined(BOOST_HAS_MS_INT64) - -void test_conversion_from_to_longlong() -{ - test_conversion_from_to_integral<__int64>(); -} - -void test_conversion_from_to_ulonglong() -{ - test_conversion_from_to_integral(); -} - -#endif #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION void test_traits() @@ -960,6 +493,7 @@ void test_wallocator() #endif + void test_char_types_conversions() { const char c_arr[] = "Test array of chars"; @@ -1040,3 +574,4 @@ void test_char32_conversions() } #endif + diff --git a/perf/performance_test.cpp b/perf/performance_test.cpp index 8640bc4..7fbac4f 100644 --- a/perf/performance_test.cpp +++ b/perf/performance_test.cpp @@ -13,6 +13,7 @@ #define BOOST_CHRONO_HEADER_ONLY #include + #include #include #include @@ -21,6 +22,13 @@ // File to output data std::fstream fout; +namespace boost { +inline std::istream& operator>> (std::istream& in, boost::array& res) { + in >> res.begin(); + return in; +} +} + template static inline void test_lexical(const InT& in_val) { OutT out_val = boost::lexical_cast(in_val); @@ -37,6 +45,28 @@ static inline void test_ss_constr(const InT& in_val) { if (ss.fail()) throw std::logic_error("descr"); } +template +static inline void test_ss_constr(const boost::array& in_val) { + OutT out_val; + std::stringstream ss; + ss << in_val.begin(); + if (ss.fail()) throw std::logic_error("descr"); + ss >> out_val; + if (ss.fail()) throw std::logic_error("descr"); +} + +template +static inline void test_ss_noconstr(StringStreamT& ss, const boost::array& in_val) { + OutT out_val; + ss << in_val.begin(); // ss is an instance of std::stringstream + if (ss.fail()) throw std::logic_error("descr"); + ss >> out_val; + if (ss.fail()) throw std::logic_error("descr"); + /* reseting std::stringstream to use it again */ + ss.str(std::string()); + ss.clear(); +} + template static inline void test_ss_noconstr(StringStreamT& ss, const InT& in_val) { OutT out_val; @@ -64,6 +94,12 @@ struct structure_sprintf { }; struct structure_sscanf { + template + static inline void test(BufferT* /*buffer*/, const boost::array& in_val, const char* const conv) { + OutT out_val; + sscanf(in_val.cbegin(), conv, &out_val); + } + template static inline void test(BufferT* /*buffer*/, const InT& in_val, const char* const conv) { OutT out_val; @@ -229,7 +265,7 @@ void string_like_test_set(const std::string& from) { perf_test(from + "->float", conv("1.123"), "%f"); perf_test(from + "->double", conv("1.123"), "%lf"); perf_test(from + "->long double", conv("1.123"), "%Lf"); - + perf_test, ssc_t>(from + "->array", conv("1.123"), "%s"); perf_test(from + "->string", conv("string"), "%Lf"); perf_test(from + "->container::string" @@ -268,6 +304,14 @@ struct to_iterator_range { } }; +struct to_array_50 { + boost::array operator()(const char* const c) const { + boost::array ret; + std::strcpy(ret.begin(), c); + return ret; + } +}; + int main(int argc, char** argv) { BOOST_ASSERT(argc >= 2); std::string output_path(argv[1]); @@ -310,6 +354,7 @@ int main(int argc, char** argv) { string_like_test_set("unsigned char*"); string_like_test_set("signed char*"); string_like_test_set("iterator_range"); + string_like_test_set("array"); perf_test("int->int", 100, ""); perf_test("float->double", 100.0f, ""); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f8ee0d3..f77a845 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -47,5 +47,7 @@ test-suite conversion gcc-4.7:-fno-exceptions ] [ run lexical_cast_iterator_range_test.cpp ] + [ run lexical_cast_arrays_test.cpp ] + [ run lexical_cast_integral_types_test.cpp ] ; diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp index 8c3bc52..0cad067 100644 --- a/test/implicit_cast.cpp +++ b/test/implicit_cast.cpp @@ -28,7 +28,7 @@ int main() type f = check_return(boost::implicit_cast("hello")); type z = check_return(boost::implicit_cast(foo("hello"))); - + // warning supression: (void)x; (void)f; diff --git a/test/implicit_cast_fail.cpp b/test/implicit_cast_fail.cpp index 80143da..a7867a1 100644 --- a/test/implicit_cast_fail.cpp +++ b/test/implicit_cast_fail.cpp @@ -19,4 +19,6 @@ struct foo int test_main(int, char*[]) { foo x = implicit_cast("foobar"); + (void)x; // warning suppression. + return 0; } diff --git a/test/lexical_cast_arrays_test.cpp b/test/lexical_cast_arrays_test.cpp new file mode 100644 index 0000000..6aff2d9 --- /dev/null +++ b/test/lexical_cast_arrays_test.cpp @@ -0,0 +1,367 @@ +// Testing boost::lexical_cast with boost::container::string. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2012. +// +// 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). + +#include + +#include + +#include + +void testing_boost_array_output_conversion(); +void testing_std_array_output_conversion(); + +void testing_boost_array_input_conversion(); +void testing_std_array_input_conversion(); + +using namespace boost; + +boost::unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = + BOOST_TEST_SUITE("Testing boost::lexical_cast with boost::array and std::array"); + + suite->add(BOOST_TEST_CASE(testing_boost_array_output_conversion)); + suite->add(BOOST_TEST_CASE(testing_std_array_output_conversion)); + suite->add(BOOST_TEST_CASE(testing_boost_array_input_conversion)); + suite->add(BOOST_TEST_CASE(testing_std_array_input_conversion)); + + return suite; +} + +template