// Boost.Convert test and usage example
-// Copyright (c) 2009-2016 Vladimir Batov.
+// Copyright (c) 2009-2020 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.
#include <boost/convert/strtol.hpp>
#include <boost/convert/spirit.hpp>
#include <boost/convert/lexical_cast.hpp>
-#include <boost/detail/lightweight_test.hpp>
#include <boost/timer/timer.hpp>
-#include <boost/array.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int_distribution.hpp>
-#include <cstdlib>
-#include <cstdio>
+#include <array>
using std::string;
using boost::convert;
template<typename Type>
struct array
{
- typedef boost::array<Type, 20> type;
+ typedef std::array<Type, 20> type;
};
template<typename T> static typename array<T>::type const& get();
double
raw_str_to(Converter const& cnv)
{
- local::strings strings = local::get_strs(); // Create strings on the stack
- int const size = strings.size();
- local::timer timer;
+ auto strings = local::get_strs(); // Create strings on the stack
+ int size = strings.size();
+ auto timer = local::timer();
for (int t = 0; t < local::num_cycles; ++t)
for (int k = 0; k < size; ++k)
double
local::str_to(Converter const& try_converter)
{
- local::strings strings = local::get_strs(); // Create strings on the stack
- int const size = strings.size();
- local::timer timer;
+ auto strings = local::get_strs(); // Create strings on the stack
+ int size = strings.size();
+ auto timer = local::timer();
for (int t = 0; t < local::num_cycles; ++t)
for (int k = 0; k < size; ++k)
double
local::to_str(Converter const& try_converter)
{
- typedef typename local::array<Type>::type collection;
-
- collection values = local::get<Type>();
- int const size = values.size();
- local::timer timer;
+ auto values = local::get<Type>();
+ int size = values.size();
+ auto timer = local::timer();
for (int t = 0; t < local::num_cycles; ++t)
for (int k = 0; k < size; ++k)
double
performance_type_to_str(Converter const& try_converter)
{
- boost::array<change, 3> input = {{ change::no, change::up, change::dn }};
- boost::array<string, 3> results = {{ "no", "up", "dn" }};
- local::timer timer;
+ std::array<change, 3> input = {{ change::no, change::up, change::dn }};
+ std::array<string, 3> results = {{ "no", "up", "dn" }};
+ local::timer timer;
for (int k = 0; k < local::num_cycles; ++k)
{