
Le 12/11/11 06:55, Belcourt, K. Noel a écrit :
Hi,
I'm a complete neophyte with the units library. I have cause to use it so I'm trying to do something simple and am getting compile problems. This code:
#include <iostream> #include <boost/units/io.hpp> #include <boost/units/quantity.hpp> #include <boost/units/systems/temperature/fahrenheit.hpp>
int main(int, char **) { using namespace boost::units; quantity<fahrenheit::temperature> t; std::cout << t << std::endl; return 0; }
Generates this error with Intel 11.1 on Darwin using trunk.
/Users/kbelco/boost/boost/units/io.hpp(967): error: more than one instance of overloaded function "boost::units::detail::do_print_prefixed" matches the argument list: function template "void boost::units::detail::do_print_prefixed<Prefixes,CharT,Traits,Dimension,System,T>(std::basic_ostream<_CharT, _Traits> &, const boost::units::quantity<boost::units::unit<Dimension, System, void>, T> &)" function template "void boost::units::detail::do_print_prefixed<Prefixes,CharT,Traits,Unit,T>(std::basic_ostream<_CharT, _Traits> &, const boost::units::quantity<Unit, T> &)" argument types are: (std::basic_ostream<char, std::char_traits<char>>, const boost::units::quantity<boost::units::fahrenheit::temperature, double>) detail::do_print_prefixed<Prefixes>(os, q); ^ detected during: instantiation of "void boost::units::detail::maybe_print_prefixed<Prefixes,CharT,Traits,Unit,T>(std::basic_ostream<_CharT, _Traits> &, const boost::units::quantity<Unit, T> &, boost::mpl::true_) [with Prefixes=boost::units::detail::engineering_prefixes, CharT=char, Traits=std::char_traits<char>, Unit=boost::units::fahrenheit::temperature, T=double]" at line 1050 instantiation of "std::basic_ostream<_CharT, _Traits> &boost::units::operator<<(std::basic_ostream<_CharT, _Traits> &, const boost::units::quantity<Unit2, T2> &) [with Char=char, Traits=std::char_traits<char>, Unit=boost::units::fahrenheit::temperature, T=double]" at line 14 of "/Users/kbelco/core_simulator/test/integration/main_test_5.cpp"
Any ideas what I'm doing wrong?
Hi, I think this is a bug in Boost.Units. I suspect that the call to detail::do_print_prefixed<Prefixes>(os, q) will not use overload resolution as it is used with <Prefixes>. HTH, Vicente