mirror of
https://github.com/boostorg/lexical_cast.git
synced 2026-07-21 13:23:34 +00:00
35d8af6ce2
This PR: - enables tests with `import std` usage in CI - add all tests to build with cmake_subdir_test (because there was only a subset of tests supported) - fixes tests build with `libc++` - disables some tests with wchar_t with 'libc++'
37 lines
773 B
C++
37 lines
773 B
C++
// Copyright Antony Polukhin, 2013-2026.
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
// (See the accompanying file LICENSE_1_0.txt
|
|
// or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
|
|
|
|
//[lexical_cast_args_example
|
|
//`The following example treats command line arguments as a sequence of numeric data
|
|
|
|
#include <vector>
|
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
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(const bad_lexical_cast &)
|
|
{
|
|
args.push_back(0);
|
|
}
|
|
}
|
|
|
|
// ...
|
|
}
|
|
|
|
//] [/lexical_cast_args_example]
|