diff options
Diffstat (limited to 'boost/convert')
-rw-r--r-- | boost/convert/base.hpp | 2 | ||||
-rw-r--r-- | boost/convert/detail/boost_parameter_ext.hpp | 2 | ||||
-rw-r--r-- | boost/convert/detail/char.hpp | 2 | ||||
-rw-r--r-- | boost/convert/detail/forward.hpp | 2 | ||||
-rw-r--r-- | boost/convert/detail/has_member.hpp | 2 | ||||
-rw-r--r-- | boost/convert/detail/is_callable.hpp | 2 | ||||
-rw-r--r-- | boost/convert/detail/is_converter.hpp | 2 | ||||
-rw-r--r-- | boost/convert/detail/is_fun.hpp | 2 | ||||
-rw-r--r-- | boost/convert/detail/is_string.hpp | 2 | ||||
-rw-r--r-- | boost/convert/detail/range.hpp | 2 | ||||
-rw-r--r-- | boost/convert/lexical_cast.hpp | 2 | ||||
-rw-r--r-- | boost/convert/parameters.hpp | 2 | ||||
-rw-r--r-- | boost/convert/printf.hpp | 2 | ||||
-rw-r--r-- | boost/convert/spirit.hpp | 2 | ||||
-rw-r--r-- | boost/convert/stream.hpp | 2 | ||||
-rw-r--r-- | boost/convert/strtol.hpp | 36 |
16 files changed, 30 insertions, 36 deletions
diff --git a/boost/convert/base.hpp b/boost/convert/base.hpp index 3d446641d2..41c0e4b29b 100644 --- a/boost/convert/base.hpp +++ b/boost/convert/base.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/detail/boost_parameter_ext.hpp b/boost/convert/detail/boost_parameter_ext.hpp index a384018cfb..8d2ee3c402 100644 --- a/boost/convert/detail/boost_parameter_ext.hpp +++ b/boost/convert/detail/boost_parameter_ext.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/detail/char.hpp b/boost/convert/detail/char.hpp index 5b3cbda10e..1d375bad51 100644 --- a/boost/convert/detail/char.hpp +++ b/boost/convert/detail/char.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/detail/forward.hpp b/boost/convert/detail/forward.hpp index 8d86d8c6a1..0fc55c3aca 100644 --- a/boost/convert/detail/forward.hpp +++ b/boost/convert/detail/forward.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/detail/has_member.hpp b/boost/convert/detail/has_member.hpp index fafc39f5c4..68e53807a9 100644 --- a/boost/convert/detail/has_member.hpp +++ b/boost/convert/detail/has_member.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/detail/is_callable.hpp b/boost/convert/detail/is_callable.hpp index d516fdc05b..838c248c63 100644 --- a/boost/convert/detail/is_callable.hpp +++ b/boost/convert/detail/is_callable.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/detail/is_converter.hpp b/boost/convert/detail/is_converter.hpp index b35470cd19..7633b6daba 100644 --- a/boost/convert/detail/is_converter.hpp +++ b/boost/convert/detail/is_converter.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/detail/is_fun.hpp b/boost/convert/detail/is_fun.hpp index 5e1eae2ca6..9fa4d96f9b 100644 --- a/boost/convert/detail/is_fun.hpp +++ b/boost/convert/detail/is_fun.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/detail/is_string.hpp b/boost/convert/detail/is_string.hpp index ab682b0c72..ea6ca82e90 100644 --- a/boost/convert/detail/is_string.hpp +++ b/boost/convert/detail/is_string.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/detail/range.hpp b/boost/convert/detail/range.hpp index cdfe7b7401..345321039e 100644 --- a/boost/convert/detail/range.hpp +++ b/boost/convert/detail/range.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/lexical_cast.hpp b/boost/convert/lexical_cast.hpp index 5a9f77b845..49b96a15df 100644 --- a/boost/convert/lexical_cast.hpp +++ b/boost/convert/lexical_cast.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/parameters.hpp b/boost/convert/parameters.hpp index ae5511bfae..fc427c19b5 100644 --- a/boost/convert/parameters.hpp +++ b/boost/convert/parameters.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/printf.hpp b/boost/convert/printf.hpp index d33b873d05..443464f0e2 100644 --- a/boost/convert/printf.hpp +++ b/boost/convert/printf.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/spirit.hpp b/boost/convert/spirit.hpp index 34ad811b2b..22a88b9b3f 100644 --- a/boost/convert/spirit.hpp +++ b/boost/convert/spirit.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/stream.hpp b/boost/convert/stream.hpp index c0f4890b36..086d836175 100644 --- a/boost/convert/stream.hpp +++ b/boost/convert/stream.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. diff --git a/boost/convert/strtol.hpp b/boost/convert/strtol.hpp index 5d10bde5a7..de5aa29a8a 100644 --- a/boost/convert/strtol.hpp +++ b/boost/convert/strtol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2014 Vladimir Batov. +// Copyright (c) 2009-2016 Vladimir Batov. // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt. @@ -31,18 +31,6 @@ namespace boost { namespace cnv struct boost::cnv::strtol : public boost::cnv::cnvbase<boost::cnv::strtol> { - // C2. Old C-strings have an advantage over [begin, end) ranges. They do not need the 'end' iterator! - // Instead, they provide a sentinel (0 terminator). Consequently, C strings can be traversed - // without the need to compare if the 'end' has been reached (i.e. "for (; it != end; ++it)"). - // Instead, the current character is checked if it's 0 (i.e. "for (; *p; ++p)") which is faster. - // - // So, the implementation takes advantage of the fact. Namely, we simply check if *cnv_end == 0 - // instead of traversing once with strlen() to find the end iterator and then comparing to it as in - // - // char const* str_end = str + strlen(str); // Unnecessary traversal! - // ... - // bool const good = ... && cnv_end == str_end; - typedef boost::cnv::strtol this_type; typedef boost::cnv::cnvbase<this_type> base_type; @@ -209,14 +197,20 @@ template<typename string_type, typename out_type> void boost::cnv::strtol::str_to_d(cnv::range<string_type> range, optional<out_type>& result_out) const { - typedef cnv::range<string_type> range_type; - typedef typename range_type::value_type char_type; - - char_type const* str = &*range.begin(); // Currently only works with 'char' - char* cnv_end = 0; - ldbl_type const result = strtold(str, &cnv_end); - bool const good = result != -HUGE_VALL && result != HUGE_VALL && *cnv_end == 0/*C2*/; - out_type const max = (std::numeric_limits<out_type>::max)(); + // C2. Simply check if the end-of-string was reached -- *cnv_end == 0 + // instead of traversing once with strlen() to find the end iterator + // and then comparing to it as in + // char const* end = str + strlen(str); // Unnecessary traversal! + // bool const good = ... && cnv_end == end; + + typedef cnv::range<string_type> range_type; + typedef typename range_type::value_type ch_type; + + ch_type const* str = &*range.begin(); // Currently only works with 'char' + char* cnv_end = 0; + ldbl_type result = strtold(str, &cnv_end); + bool good = result != -HUGE_VALL && result != HUGE_VALL && *cnv_end == 0/*C2*/; + out_type max = (std::numeric_limits<out_type>::max)(); if (good && -max <= result && result <= max) result_out = out_type(result); |