Files
lexical_cast/example/args_to_numbers.cpp
T
Fedor Osetrov 35d8af6ce2 fix ci: turn on import std tests, fix libc++ build (#96)
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++'
2026-04-24 18:03:48 +03:00

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]