N
Noah Roberts
I'm trying to override boost::lexical_cast for a particular type. I
think I'm doing it right but it isn't compiling. Says "illegal use of
explicit template arguments".
Code:
namespace boost {
template <typename Source>
esi::utility::strange_double
lexical_cast<esi::utility::strange_double, Source>(Source in)
{
return lexical_cast<double>(in);
}
}
strange_double has an implicit constructor so the return should be ok.
A similar function also doesn't compile:
template < typename unit_t, typename type_t, typename Source >
esi::units::quantity<unit_t, type_t>
lexical_cast<esi::units::quantity<unit_t, type_t>, Source >(Source in)
{
return lexical_cast<type_t>(in) * unit_t();
}
Use of cast is something like:
quantity<pressure, strange_double> q = boost::lexical_cast<
quantity<pressure, strange_double> >(argv[0]);
What am I doing wrong? Help me understand the flaw in my understanding
of templates that is causing this error. The website for the compiler
error isn't much help, it doesn't seem to speak to what my code is
actually attempting...it seems to me that it should work still.
http://msdn2.microsoft.com/en-us/library/e338tex6(VS.80).aspx
Thanks.
think I'm doing it right but it isn't compiling. Says "illegal use of
explicit template arguments".
Code:
namespace boost {
template <typename Source>
esi::utility::strange_double
lexical_cast<esi::utility::strange_double, Source>(Source in)
{
return lexical_cast<double>(in);
}
}
strange_double has an implicit constructor so the return should be ok.
A similar function also doesn't compile:
template < typename unit_t, typename type_t, typename Source >
esi::units::quantity<unit_t, type_t>
lexical_cast<esi::units::quantity<unit_t, type_t>, Source >(Source in)
{
return lexical_cast<type_t>(in) * unit_t();
}
Use of cast is something like:
quantity<pressure, strange_double> q = boost::lexical_cast<
quantity<pressure, strange_double> >(argv[0]);
What am I doing wrong? Help me understand the flaw in my understanding
of templates that is causing this error. The website for the compiler
error isn't much help, it doesn't seem to speak to what my code is
actually attempting...it seems to me that it should work still.
http://msdn2.microsoft.com/en-us/library/e338tex6(VS.80).aspx
Thanks.