boostorg / convert Goto Github PK
View Code? Open in Web Editor NEWBoost.Convert
Boost.Convert
boost::cnv::strtol cnv;
std::string str = "0";
auto intValue = boost::convert<uint32_t>(
str,
cnv
(boost::cnv::parameter::skipws = true)
(boost::cnv::parameter::base = boost::cnv::base::hex)
).value();
this sentence will trigger exception.
Environment:
VS 2017 + Windows Server 2016
Issue description:
One test from boost libraries failed to run after boost submodule convert updated from 8b6a8e to 72a571 boost/convert@89f0ab7.Could you please take a look?
Reproduce steps:.
ErrorMessage:
.\boost/convert/stream.hpp(47): fatal error C1083: Cannot open include file: 'boost/parameter/is_argument_pack.hpp': No such file or directory
.\boost/mpl/has_key.hpp(33): error C2504: 'boost::mpl::has_key_implboost::parameter::aux::arg_list_tag::apply<AssociativeSequence,Key>': base class undefined
with
[
AssociativeSequence=boost::parameter::aux::tagged_argument<boost::cnv::parameter::type::base,const boost::cnv::base>,
Key=boost::cnv::parameter::type::base
]
.\boost/convert/base.hpp(118): error C2039: 'type': is not a member of 'boost::mpl::has_key<argument_pack,boost::cnv::parameter::type::base>'
with
[
argument_pack=boost::parameter::aux::tagged_argument<boost::cnv::parameter::type::base,const boost::cnv::base>
]
.\boost/convert/base.hpp(118): error C2512: 'boost::type': no appropriate default constructor available
.\boost/convert/base.hpp(118): note: The target type has no constructors
.\boost/convert/base.hpp(118): error C2672: 'boost::cnv::cnvbaseboost::cnv::printf::_assign': no matching overloaded function found
.\boost/convert/base.hpp(118): error C2780: 'void boost::cnv::cnvbaseboost::cnv::printf::assign(const argument_pack &,boost::cnv::parameter::type::fill,boost::mpl::true)': expects 3 arguments - 2 provided
.\boost/convert/base.hpp(120): error C2512: 'boost::type': no appropriate default constructor available
.\boost/convert/base.hpp(120): note: The target type has no constructors
.\boost/convert/base.hpp(120): error C2672: 'boost::cnv::cnvbaseboost::cnv::printf::_assign': no matching overloaded function found
Environment:
VS 2017 + Windows Server 2016
Issue description:
We build and run test for Boost. And we found grammar_fail.cpp failed to build due to error C2664: 'bool boost::function4<R,T0,T1,T2,T3>::operator ()(T0,T1,T2,T3) const': cannot convert argument 4 from 'const Skipper' to 'T3'. Could you pleaes take a look? Thanks in advance.
Error info:
compile-c-c++ ..\out\x86rel\boost\bin.v2\libs\spirit\test\qi\qi_grammar_fail.test\msvc-14.1\release\threading-multi\qi_grammar_fail.obj
grammar_fail.cpp
.\boost/spirit/home/qi/nonterminal/rule.hpp(304): error C2664: 'bool
log_x86_test_99.log
boost::function4<R,T0,T1,T2,T3>::operator ()(T0,T1,T2,T3) const': cannot convert argument 4 from 'const Skipper' to 'T3'
with
[
R=bool,
T0=const char *&,
T1=const char *const &,
T2=boost::spirit::context<boost::fusion::cons<boost::spirit::unused_type &,boost::fusion::nil_>,boost::fusion::vector<>> &,
T3=const boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type>> &
]
and
[
Skipper=skipper_type
]
and
[
T3=const boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type>> &
]
.\boost/spirit/home/qi/nonterminal/rule.hpp(304): note: Reason: cannot convert from 'const Skipper' to 'const boost::spirit::qi::reference<const boost::spirit::qi::rule<const char *,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type>>'
with
[
Skipper=skipper_type
]
.\boost/spirit/home/qi/nonterminal/rule.hpp(304): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
.\boost/spirit/home/qi/reference.hpp(43): note: see reference to function template instantiation 'bool boost::spirit::qi::rule<Iterator,T1,T2,T3,T4>::parse<Context,Skipper,Attribute>(Iterator &,const Iterator &,Context &,const Skipper &,Attribute &) const' being compiled
with
[
Iterator=const char *,
T1=boost::spirit::qi::rule<const char *,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type>,
T2=boost::spirit::unused_type,
T3=boost::spirit::unused_type,
T4=boost::spirit::unused_type,
Context=const boost::spirit::unused_type,
Skipper=skipper_type,
Attribute=const boost::spirit::unused_type
]
.\boost/spirit/home/qi/reference.hpp(43): note: see reference to function template instantiation 'bool boost::spirit::qi::rule<Iterator,T1,T2,T3,T4>::parse<Context,Skipper,Attribute>(Iterator &,const Iterator &,Context &,const Skipper &,Attribute &) const' being compiled
with
[
Iterator=const char *,
T1=boost::spirit::qi::rule<const char *,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type>,
T2=boost::spirit::unused_type,
T3=boost::spirit::unused_type,
T4=boost::spirit::unused_type,
Context=const boost::spirit::unused_type,
Skipper=skipper_type,
Attribute=const boost::spirit::unused_type
]
.\boost/spirit/home/qi/detail/parse.hpp(85): note: see reference to function template instantiation 'bool boost::spirit::qi::reference<const boost::spirit::qi::rule<Iterator,T1,T2,T3,T4>>::parse<Iterator,const boost::spirit::unused_type,skipper_type,const boost::spirit::unused_type>(Iterator &,const Iterator &,Context &,const Skipper &,Attribute &) const' being compiled
with
[
Iterator=const char *,
T1=boost::spirit::qi::rule<const char *,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type>,
T2=boost::spirit::unused_type,
T3=boost::spirit::unused_type,
T4=boost::spirit::unused_type,
Context=const boost::spirit::unused_type,
Skipper=skipper_type,
Attribute=const boost::spirit::unused_type
]
.\boost/spirit/home/qi/detail/parse.hpp(84): note: see reference to function template instantiation 'bool boost::spirit::qi::reference<const boost::spirit::qi::rule<Iterator,T1,T2,T3,T4>>::parse<Iterator,const boost::spirit::unused_type,skipper_type,const boost::spirit::unused_type>(Iterator &,const Iterator &,Context &,const Skipper &,Attribute &) const' being compiled
with
[
Iterator=const char *,
T1=boost::spirit::qi::rule<const char *,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type,boost::spirit::unused_type>,
T2=boost::spirit::unused_type,
T3=boost::spirit::unused_type,
T4=boost::spirit::unused_type,
Context=const boost::spirit::unused_type,
Skipper=skipper_type,
Attribute=const boost::spirit::unused_type
]
.\boost/spirit/home/qi/parse.hpp(121): note: see reference to function template instantiation 'bool boost::spirit::qi::detail::phrase_parse_impl<Expr,void>::call<Iterator,Skipper>(Iterator &,Iterator,const Expr &,const Skipper &,boost::spirit::qi::skip_flag)' being compiled
with
[
Expr=num_list,
Iterator=const char *,
Skipper=boost::proto::exprns_::expr<boost::proto::tagns_::tag::bitwise_or,boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::spirit::tag::char_codeboost::spirit::tag::space,boost::spirit::char_encoding::standard>,0> &,const boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right,boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right,boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<const char &>,0>,const boost::proto::exprns_::expr<boost::proto::tagns_::tag::dereference,boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::complement,boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::spirit::terminal_ex<boost::spirit::tag::standard::char_,boost::fusion::vector>>,0> &>,1> &>,1> &>,2> &,boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<const char &>,0>>,2> &>,2>
]
.\boost/spirit/home/qi/parse.hpp(120): note: see reference to function template instantiation 'bool boost::spirit::qi::detail::phrase_parse_impl<Expr,void>::call<Iterator,Skipper>(Iterator &,Iterator,const Expr &,const Skipper &,boost::spirit::qi::skip_flag)' being compiled
with
[
Expr=num_list,
Iterator=const char ,
Skipper=boost::proto::exprns_::expr<boost::proto::tagns_::tag::bitwise_or,boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::spirit::tag::char_codeboost::spirit::tag::space,boost::spirit::char_encoding::standard>,0> &,const boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right,boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right,boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<const char &>,0>,const boost::proto::exprns_::expr<boost::proto::tagns_::tag::dereference,boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::complement,boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::spirit::terminal_ex<boost::spirit::tag::standard::char_,boost::fusion::vector>>,0> &>,1> &>,1> &>,2> &,boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<const char &>,0>>,2> &>,2>
]
libs\spirit\test\qi\grammar_fail.cpp(36): note: see reference to function template instantiation 'bool boost::spirit::qi::phrase_parse<const char,num_list,boost::proto::exprns_::expr<Tag,Args,2>>(Iterator &,Iterator,const Expr &,const Skipper &,boost::spirit::qi::skip_flag)' being compiled
with
[
Tag=boost::proto::tagns_::tag::bitwise_or,
Args=boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::spirit::tag::char_codeboost::spirit::tag::space,boost::spirit::char_encoding::standard>,0> &,const boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right,boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right,boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<const char &>,0>,const boost::proto::exprns_::expr<boost::proto::tagns_::tag::dereference,boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::complement,boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::spirit::terminal_ex<boost::spirit::tag::standard::char_,boost::fusion::vector>>,0> &>,1> &>,1> &>,2> &,boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<const char &>,0>>,2> &>,
Iterator=const char *,
Expr=num_list,
Skipper=boost::proto::exprns_::expr<boost::proto::tagns_::tag::bitwise_or,boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::spirit::tag::char_codeboost::spirit::tag::space,boost::spirit::char_encoding::standard>,0> &,const boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right,boost::proto::argsns_::list2<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::shift_right,boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<const char &>,0>,const boost::proto::exprns_::expr<boost::proto::tagns_::tag::dereference,boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::complement,boost::proto::argsns_::list1<const boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<boost::spirit::terminal_ex<boost::spirit::tag::standard::char_,boost::fusion::vector>>,0> &>,1> &>,1> &>,2> &,boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,boost::proto::argsns_::term<const char &>,0>>,2> &>,2>
]
boost\convert\base.hpp(112): warning C6330: 'const char' passed as _Param_(1) when 'unsigned char' is required in call to 'isspace'.
boost\convert\base.hpp(115): warning C6330: 'const char' passed as _Param_(1) when 'unsigned char' is required in call to 'isspace'.
Environment:
VS 2017 + Windows Server 2016
Issue description:
We build and run test for Boost. And we found fallbacks.cpp failed to build due to error C2039: 'noncopyable': is not a member of 'boost'. After we added #include <boost/noncopyable.hpp> into ".\boost/convert/stream.hpp" . It build fine. Could you pleaes take a look? Thanks in advance.
Error info:
compile-c-c++ ..\out\x86rel\boost\bin.v2\libs\convert\test\convert_test_fallbacks.test\msvc-14.1\release\asynch-exceptions-on\threading-multi\fallbacks.obj
fallbacks.cpp
.\boost/convert/stream.hpp(32): error C2039: 'noncopyable': is not a member of 'boost'
.\boost/bind/placeholders.hpp(26): note: see declaration of 'boost'
libs\convert\test\fallbacks.cpp(37): note: see reference to class template instantiation 'boost::cnv::basic_stream' being compiled
.\boost/bind/placeholders.hpp(54): note: see reference to class template instantiation 'boost::arg<9>' being compiled
.\boost/bind/placeholders.hpp(53): note: see reference to class template instantiation 'boost::arg<8>' being compiled
.\boost/bind/placeholders.hpp(52): note: see reference to class template instantiation 'boost::arg<7>' being compiled
.\boost/bind/placeholders.hpp(51): note: see reference to class template instantiation 'boost::arg<6>' being compiled
.\boost/bind/placeholders.hpp(50): note: see reference to class template instantiation 'boost::arg<5>' being compiled
.\boost/bind/placeholders.hpp(49): note: see reference to class template instantiation 'boost::arg<4>' being compiled
.\boost/bind/placeholders.hpp(48): note: see reference to class template instantiation 'boost::arg<3>' being compiled
.\boost/bind/placeholders.hpp(47): note: see reference to class template instantiation 'boost::arg<2>' being compiled
.\boost/bind/placeholders.hpp(46): note: see reference to class template instantiation 'boost::arg<1>' being compiled
.\boost/convert/stream.hpp(33): error C2504: 'noncopyable': base class undefined
call "..\out\x86rel\boost\bin.v2\standalone\msvc\msvc-14.1\msvc-setup.bat" >nul
cl /Zm800 -nologo @"..\out\x86rel\boost\bin.v2\libs\convert\test\convert_test_fallbacks.test\msvc-14.1\release\asynch-exceptions-on\threading-multi\fallbacks.obj.rsp"
...failed compile-c-c++ ..\out\x86rel\boost\bin.v2\libs\convert\test\convert_test_fallbacks.test\msvc-14.1\release\asynch-exceptions-on\threading-multi\fallbacks.obj...
The correct sscanf
format for double
is %lf
while current code uses %f
:
convert/include/boost/convert/printf.hpp
Line 75 in 2eec956
This results in wrong value when converting a string to double
:
fmt::print("{}\n", boost::convert<double>("3.14", cnv).value()); // prints 5.32861326e-315
strtol.hpp:
ch_type str[sz] = {0}; std::strncpy(str, &*range.begin(), std::min(sz - 1, range.size()));
// boost\convert\strtol.hpp(209): error C2589: '(': illegal token on right side of '::'
I think this isn't properly guarded against Windows's macro named min.
MSVC 15.8
Hello.
Boost-1.84
OS Windows 11.
Microsoft Visual Studio 2022 (Version 17.9.3)
Sample program:
`
#include
#include <boost/convert.hpp>
// If I comment line below, program not compiled
#include <boost/make_default.hpp>
#include <boost/convert/charconv.hpp>
int main()
{
auto cnv4 = boost::cnv::charconv();
std::string PuNum = "2";
const auto optPuNum = boost::convert<size_t>(PuNum, cnv4);
if (optPuNum)
std::cout << *optPuNum << "\n";
else
std::cout << "nullopt\n";
return 0;
}
`
If I comment out the line "#include <boost/make_default.hpp>" the program will not compile.
The use of this header is not obvious.
This program crashes with an error when calling boost::convert<size_t>().
Since the library uses C++11 type_traits, along with Boost type_traits, the library is a C++11 library and should be documented as such. I actually see no reason to use both C++11 type_traits as well as Boost type_traits. If it is a C++11 library why not use C++11 type_traits throughout the library ?
const char* a = "42";
boost::string_ref b(a, 1);
float c = boost::convert<float>(b, boost::cnv::strtol(), -1);
assert(c == 4);
The following files failed to build:
../libs/convert/test/performance.cpp:31:38: error: 'namespace arg = boost::cnv::boost::cnv::parameter;' redeclared as different kind of symbol
../libs/convert/test/spirit_converter.cpp:22:38: error: 'namespace arg = boost::cnv::boost::cnv::parameter;' redeclared as different kind of symbol
../libs/convert/test/stream_converter.cpp:26:38: error: 'namespace arg = boost::cnv::boost::cnv::parameter;' redeclared as different kind of symbol
../libs/convert/test/printf_converter.cpp:19:38: error: 'namespace arg = boost::cnv::boost::cnv::parameter;' redeclared as different kind of symbol
../libs/convert/test/strtol_converter.cpp:166:38: error: 'namespace arg = boost::cnv::boost::cnv::parameter;' redeclared as different kind of symbol
According to http://www.cplusplus.com/reference/complex/arg/, arg should be declared in complex as below:
complex (1) | template T arg (const complex& x);
arithmetic type (2) | double arg (ArithmeticType x); // additional overloads
As a result, the arg declared in boost test files should be renamed.
clang-vxworks.link ../bin.v2/libs/convert/test/clang-vxworks/debug/cross-compile-vxworks/convert_test_performance.vxe
/llvm-8.0.0.1/LINUX64/bin/ldpentium: warning: ../bin.v2/libs/chrono/build/clang-vxworks/debug/cross-compile-vxworks/libboost_chrono.so.1.70.0, needed by ../bin.v2/libs/timer/build/clang-vxworks/debug/cross-compile-vxworks/libboost_timer.so.1.70.0, not found (try using -rpath or -rpath-link)
/llvm-8.0.0.1/LINUX64/bin/ldpentium: ../bin.v2/libs/timer/build/clang-vxworks/debug/cross-compile-vxworks/libboost_timer.so.1.70.0: undefined reference to `boost::chrono::steady_clock::now()'
/llvm-8.0.0.1/LINUX64/bin/ldpentium -m elf_x86_64 -L"/usr/lib/common" -o "../bin.v2/libs/convert/test/clang-vxworks/debug/cross-compile-vxworks/convert_test_performance.vxe" --defsym __wrs_rtp_base=0x200000 -u __wr_need_frame_add -u tls -T/usr/ldscripts/rtp.ld /usr/lib/common//crt0.o "../bin.v2/libs/convert/test/clang-vxworks/debug/cross-compile-vxworks/performance.o" "../bin.v2/libs/timer/build/clang-vxworks/debug/cross-compile-vxworks/libboost_timer.so.1.70.0" --as-needed -E --start-group -lunix -lnet -lc -lc_internal -lllvm -lcplusplus -lllvmcplus -ldl --end-group
...failed clang-vxworks.link ../bin.v2/libs/convert/test/clang-vxworks/debug/cross-compile-vxworks/convert_test_performance.vxe...
The link can succeed after I updated following line in libs/convert/test/jamfile.v2.
From:
exe convert_test_performance : performance.cpp /boost/timer//boost_timer ;
To:
exe convert_test_performance : performance.cpp /boost/timer//boost_timer /boost/chrono//boost_chrono ;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.