[units] Unable to print temperature quantity

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? Thanks. -- Noel Belcourt

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

AMDG On 11/12/2011 06:04 AM, Vicente J. Botet Escriba wrote:
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>.
If so, it's a compiler bug. Explicit template arguments shouldn't disable partial ordering. In Christ, Steven Watanabe

Le 13/11/11 21:11, Steven Watanabe a écrit :
AMDG
On 11/12/2011 06:04 AM, Vicente J. Botet Escriba wrote:
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>.
If so, it's a compiler bug. Explicit template arguments shouldn't disable partial ordering.
I'm not a language layer. I thought this was the case. Sorry for the noise. Best, Vicente

Hi, On Nov 13, 2011, at 1:11 PM, Steven Watanabe wrote:
On 11/12/2011 06:04 AM, Vicente J. Botet Escriba wrote:
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>.
If so, it's a compiler bug. Explicit template arguments shouldn't disable partial ordering.
Interestingly it works with Intel and Pathscale on Linux. Seems it's a Darwin Intel specific issue. I'll file a bug with Intel though they won't fix it in v. 11. Is there some workaround we can apply to get this working with Intel on Darwin? -- Noel

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; }
FWIW, this works fine under Xcode 4.2… Matthias

A quick followup. On Nov 11, 2011, at 10:55 PM, Belcourt, K. Noel wrote:
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.
This appears to be broken with Xcode 3.1.x (for users with OSX 10.5.x). It appears to compile and link fine with Xcode 3.2.x. A report has been filed with Intel, not sure if they'll patch. -- Noel
participants (4)
-
Belcourt, K. Noel
-
Matthias Schabel
-
Steven Watanabe
-
Vicente J. Botet Escriba