id summary reporter owner description type status milestone component version severity resolution keywords cc 7971 [C++11] Boost::Format doesn't like to be fed nullptr/std::nullptr_t Roger Leigh James E. King, III "As the following code example shows, boost::format is not happy being fed a C++11 nullptr. It would be nice if it could cope with this as a valid, but null, argument, e.g. equivalent to """", i.e. no output but a valid argument. I've done this in my own code as a workaround for now by specialising for std::nullptr_t and then feeding it """" instead. This might not be an issue with boost::format itself if this should be done elsewhere e.g. lexical_cast. Regards, Roger {{{ #include #include int main() { boost::format fmt(""%1% %2% %3%\n""); fmt % std::string(""String"") % 543 % nullptr; } }}} ==> {{{ % g++ -std=c++11 -o test test.cc In file included from /usr/include/boost/format.hpp:49:0, from test.cc:1: /usr/include/boost/format/feed_args.hpp: In instantiation of ‘void boost::io::detail::put_last(std::basic_ostream<_CharT, _Traits>&, const T&) [with Ch = char; Tr = std::char_traits; T = std::nullptr_t]’: /usr/include/boost/format/feed_args.hpp:159:13: required from ‘void boost::io::detail::put(T, const boost::io::detail::format_item&, typename boost::basic_format::string_type&, typename boost::basic_format::internal_streambuf_t&, boost::io::detail::locale_t*) [with Ch = char; Tr = std::char_traits; Alloc = std::allocator; T = std::nullptr_t&; typename boost::basic_format::string_type = std::basic_string; typename boost::basic_format::internal_streambuf_t = boost::io::basic_altstringbuf, std::allocator >; boost::io::detail::locale_t = std::locale]’ /usr/include/boost/format/feed_args.hpp:253:17: required from ‘void boost::io::detail::distribute(boost::basic_format&, T) [with Ch = char; Tr = std::char_traits; Alloc = std::allocator; T = std::nullptr_t&]’ /usr/include/boost/format/feed_args.hpp:263:9: required from ‘boost::basic_format& boost::io::detail::feed(boost::basic_format&, T) [with Ch = char; Tr = std::char_traits; Alloc = std::allocator; T = std::nullptr_t&]’ /usr/include/boost/format/format_class.hpp:64:74: required from ‘boost::basic_format& boost::basic_format::operator%(const T&) [with T = std::nullptr_t; Ch = char; Tr = std::char_traits; Alloc = std::allocator; boost::basic_format = boost::basic_format]’ test.cc:9:39: required from here /usr/include/boost/format/feed_args.hpp:100:9: error: ambiguous overload for ‘operator<<’ in ‘os << x’ /usr/include/boost/format/feed_args.hpp:100:9: note: candidates are: In file included from /usr/include/boost/format/detail/compat_workarounds.hpp:60:0, from /usr/include/boost/format.hpp:27, from test.cc:1: /usr/include/c++/4.7/ostream:106:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char; _Traits = std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.7/ostream:115:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream; std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios] /usr/include/c++/4.7/ostream:125:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.7/ostream:172:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] /usr/include/c++/4.7/ostream:243:7: note: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream] In file included from /usr/include/c++/4.7/ostream:607:0, from /usr/include/boost/format/detail/compat_workarounds.hpp:60, from /usr/include/boost/format.hpp:27, from test.cc:1: /usr/include/c++/4.7/bits/ostream.tcc:121:5: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits; std::basic_ostream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf] In file included from /usr/include/boost/format/detail/compat_workarounds.hpp:60:0, from /usr/include/boost/format.hpp:27, from test.cc:1: /usr/include/c++/4.7/ostream:600:5: note: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits; _Tp = std::nullptr_t] /usr/include/c++/4.7/ostream:600:5: note: no known conversion for argument 1 from ‘std::basic_ostream’ to ‘std::basic_ostream&&’ /usr/include/c++/4.7/ostream:546:5: note: std::basic_ostream& std::operator<<(std::basic_ostream&, const unsigned char*) [with _Traits = std::char_traits] /usr/include/c++/4.7/ostream:541:5: note: std::basic_ostream& std::operator<<(std::basic_ostream&, const signed char*) [with _Traits = std::char_traits] /usr/include/c++/4.7/ostream:528:5: note: std::basic_ostream& std::operator<<(std::basic_ostream&, const char*) [with _Traits = std::char_traits] In file included from /usr/include/c++/4.7/ostream:607:0, from /usr/include/boost/format/detail/compat_workarounds.hpp:60, from /usr/include/boost/format.hpp:27, from test.cc:1: /usr/include/c++/4.7/bits/ostream.tcc:323:5: note: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*) [with _CharT = char; _Traits = std::char_traits] }}}" Bugs closed Boost 1.66.0 format Boost 1.50.0 Problem wontfix