id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 11012,chrono_io v2 fail to compile with boost::chrono::duration< boost::rational >,Sébastien Barthélémy ,viboes,"When using {{{ boost::chrono::duration< boost::rational > }}} as duration type, chrono_io v2 fails to build with error {{{ include/boost/chrono/io/duration_units.hpp:136:91: error: invalid static_cast from type ‘boost::chrono::duration >::rep {aka boost::rational}’ to type ‘intmax_t {aka long int}’ }}} while chrono_io v1 builds and works as expected. Here is the full compilation log for the attached example. {{{ $ gcc --version gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ make g++ -c -g -fPIC -Iinclude -I/home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include -o src/chrono_rational.o src/chrono_rational.cc In file included from /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/time_point_put.hpp:16:0, from /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/time_point_io.hpp:22, from /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/chrono_io.hpp:26, from src/chrono_rational.cc:5: /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp: In instantiation of ‘boost::chrono::duration_put::iter_type boost::chrono::duration_put::put_value(boost::chrono::duration_put::iter_type, std::ios_base&, boost::chrono::duration_put::char_type, const boost::chrono::duration&) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; OutputIterator = std::ostreambuf_iterator >; boost::chrono::duration_put::iter_type = std::ostreambuf_iterator >; boost::chrono::duration_put::char_type = char]’: /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp:128:44: required from ‘boost::chrono::duration_put::iter_type boost::chrono::duration_put::put(const boost::chrono::duration_units&, boost::chrono::duration_put::iter_type, std::ios_base&, boost::chrono::duration_put::char_type, const boost::chrono::duration&, const CharT*, const CharT*) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; OutputIterator = std::ostreambuf_iterator >; boost::chrono::duration_put::iter_type = std::ostreambuf_iterator >; boost::chrono::duration_put::char_type = char]’ /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp:168:81: required from ‘boost::chrono::duration_put::iter_type boost::chrono::duration_put::put(boost::chrono::duration_put::iter_type, std::ios_base&, boost::chrono::duration_put::char_type, const boost::chrono::duration&) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; OutputIterator = std::ostreambuf_iterator >; boost::chrono::duration_put::iter_type = std::ostreambuf_iterator >; boost::chrono::duration_put::char_type = char]’ /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_io.hpp:135:15: required from ‘std::basic_ostream<_CharT, _Traits>& boost::chrono::operator<<(std::basic_ostream<_CharT, _Traits>&, const boost::chrono::duration&) [with CharT = char; Traits = std::char_traits; Rep = boost::rational; Period = boost::ratio<1l>]’ src/chrono_rational.cc:11:18: required from here /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp:191:46: error: invalid static_cast from type ‘boost::chrono::duration >::rep {aka boost::rational}’ to type ‘long int’ static_cast (d.count())); ^ In file included from /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp:15:0, from /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/time_point_put.hpp:16, from /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/time_point_io.hpp:22, from /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/chrono_io.hpp:26, from src/chrono_rational.cc:5: /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_units.hpp: In instantiation of ‘boost::chrono::duration_units::string_type boost::chrono::duration_units::get_unit(boost::chrono::duration_style, const boost::chrono::duration&) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; boost::chrono::duration_units::string_type = std::basic_string]’: /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp:230:70: required from ‘boost::chrono::duration_put::iter_type boost::chrono::duration_put::put_unit(const boost::chrono::duration_units&, boost::chrono::duration_put::iter_type, std::ios_base&, boost::chrono::duration_put::char_type, const boost::chrono::duration&) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; OutputIterator = std::ostreambuf_iterator >; boost::chrono::duration_put::iter_type = std::ostreambuf_iterator >; boost::chrono::duration_put::char_type = char]’ /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp:133:56: required from ‘boost::chrono::duration_put::iter_type boost::chrono::duration_put::put(const boost::chrono::duration_units&, boost::chrono::duration_put::iter_type, std::ios_base&, boost::chrono::duration_put::char_type, const boost::chrono::duration&, const CharT*, const CharT*) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; OutputIterator = std::ostreambuf_iterator >; boost::chrono::duration_put::iter_type = std::ostreambuf_iterator >; boost::chrono::duration_put::char_type = char]’ /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp:168:81: required from ‘boost::chrono::duration_put::iter_type boost::chrono::duration_put::put(boost::chrono::duration_put::iter_type, std::ios_base&, boost::chrono::duration_put::char_type, const boost::chrono::duration&) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; OutputIterator = std::ostreambuf_iterator >; boost::chrono::duration_put::iter_type = std::ostreambuf_iterator >; boost::chrono::duration_put::char_type = char]’ /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_io.hpp:135:15: required from ‘std::basic_ostream<_CharT, _Traits>& boost::chrono::operator<<(std::basic_ostream<_CharT, _Traits>&, const boost::chrono::duration&) [with CharT = char; Traits = std::char_traits; Rep = boost::rational; Period = boost::ratio<1l>]’ src/chrono_rational.cc:11:18: required from here /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_units.hpp:127:87: error: invalid static_cast from type ‘boost::chrono::duration >::rep {aka boost::rational}’ to type ‘intmax_t {aka long int}’ return do_get_unit(style, rt_ratio(Period()), static_cast(d.count())); ^ /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_units.hpp: In instantiation of ‘boost::chrono::duration_units::string_type boost::chrono::duration_units::get_n_d_unit(boost::chrono::duration_style, const boost::chrono::duration&) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; boost::chrono::duration_units::string_type = std::basic_string]’: /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp:238:74: required from ‘boost::chrono::duration_put::iter_type boost::chrono::duration_put::put_unit(const boost::chrono::duration_units&, boost::chrono::duration_put::iter_type, std::ios_base&, boost::chrono::duration_put::char_type, const boost::chrono::duration&) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; OutputIterator = std::ostreambuf_iterator >; boost::chrono::duration_put::iter_type = std::ostreambuf_iterator >; boost::chrono::duration_put::char_type = char]’ /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp:133:56: required from ‘boost::chrono::duration_put::iter_type boost::chrono::duration_put::put(const boost::chrono::duration_units&, boost::chrono::duration_put::iter_type, std::ios_base&, boost::chrono::duration_put::char_type, const boost::chrono::duration&, const CharT*, const CharT*) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; OutputIterator = std::ostreambuf_iterator >; boost::chrono::duration_put::iter_type = std::ostreambuf_iterator >; boost::chrono::duration_put::char_type = char]’ /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_put.hpp:168:81: required from ‘boost::chrono::duration_put::iter_type boost::chrono::duration_put::put(boost::chrono::duration_put::iter_type, std::ios_base&, boost::chrono::duration_put::char_type, const boost::chrono::duration&) const [with Rep = boost::rational; Period = boost::ratio<1l>; CharT = char; OutputIterator = std::ostreambuf_iterator >; boost::chrono::duration_put::iter_type = std::ostreambuf_iterator >; boost::chrono::duration_put::char_type = char]’ /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_io.hpp:135:15: required from ‘std::basic_ostream<_CharT, _Traits>& boost::chrono::operator<<(std::basic_ostream<_CharT, _Traits>&, const boost::chrono::duration&) [with CharT = char; Traits = std::char_traits; Rep = boost::rational; Period = boost::ratio<1l>]’ src/chrono_rational.cc:11:18: required from here /home/sbarthelemy/.local/share/qi/toolchains/linux64/boost/include/boost/chrono/io/duration_units.hpp:136:91: error: invalid static_cast from type ‘boost::chrono::duration >::rep {aka boost::rational}’ to type ‘intmax_t {aka long int}’ return do_get_n_d_unit(style, rt_ratio(Period()), static_cast(d.count())); ^ make: *** [src/chrono_rational.o] Error 1 }}} }}}",Bugs,closed,Boost 1.58.0,chrono,Boost 1.57.0,Problem,fixed,,