Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2006-01-22 08:28:45


Hi ,

I thought I'd download and try out VC8 . (Actual version at the bottom of
post), however when used on my Tentative Boost quantities library, if I Use
expressions on quantities at global function body scope(IOW functions not in
boost::pqs namespace ) it complains that :

: error C2676: binary '-' : 'const
boost::pqs::t1_quantity<AbstractQuantity,Units,Value_type>'
does not define this operator or a conversion to a type acceptable to the
predefined operator
        with
        [
            AbstractQuantity=boost::pqs::meta::components::of_velocity::type,
            Units=boost::pqs::meta::si_unit::none,
            Value_type=boost::pqs::quantity_traits::default_value_type
        ]

(operator - is defined in same namespace as the type however.)
The current workaround is just to define the operators in global namespace for
this compiler( I know its not legal! but it gets around the problem). I'm
wondering if anyone else has found this sort of problem in VC8.0? OTOH If there
may be some reason , some two-phase lookup rule or something that is preventing
these operations being found. (It seems simple to me. The types are defined in
namespace boost::pqs. The operations on them are defined in boost::pqs. Whats
the problem?)

Note: I have tried to get the effect with other simpler types with operators
defined in their own namepace, but these compile ok .

regards
Andy Little

Heres a sample program that exhibits the problem

#include <boost/pqs/t1_quantity/types/out/velocity.hpp>
#include <boost/pqs/t1_quantity/types/out/mass.hpp>
#include <boost/pqs/t1_quantity/types/out/force.hpp>
#include <boost/pqs/t1_quantity/types/out/time.hpp>

boost::pqs::force::N Func(
 const boost::pqs::mass::kg & mass_in,
 const boost::pqs::velocity::mm_div_s & initial_veloc,
 const boost::pqs::velocity::m_div_s & final_veloc,
 const boost::pqs::time::s & t
)
{
    boost::pqs::force::N result = mass_in * (final_veloc - initial_veloc) / t;
 return result;
}

int main()
{
 boost::pqs::mass::kg mass(2);
 boost::pqs::velocity::m_div_s initial_velocity(9);
 boost::pqs::velocity::m_div_s final_velocity(10);
 boost::pqs::time::s time(10);
 std::cout << Func(mass,initial_velocity,final_velocity,time) <<'\n';
}

FWIW compler version:

Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727

Installed Edition: VC Express

Microsoft Visual C++ 2005 76542-000-0000011-00125
Microsoft Visual C++ 2005


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk