Boost logo

Boost Users :

Subject: Re: [Boost-users] problem with boost units
From: Michael (mwpowellhtx_at_[hidden])
Date: 2015-09-17 05:17:17


On September 17, 2015 1:31:28 AM EDT, Robert Ramey <ramey_at_[hidden]> wrote:
>the following small example fails to compile and points to error in
>assignment. For the life of me I can't figure why this should fail.
>Any help appreciated.
>
>Robert Ramey
>
>
>// include headers to implement output operations for quantities with
>units
>#include <iostream>
>#include <boost/units/io.hpp>
>
>#include <boost/units/systems/si/volume.hpp>
>
>int main(){
> boost::units::si::volume fuel_capacity;
> fuel_capacity = 9.0f * boost::units::si::cubic_meters;
>------------------^
> std::cout << " " << fuel_capacity << "\n";
> return 0;
>}

It's because you are trying to assign a quantity to a dimension.

quantity<volume> my_vol = 9f * cubic_meters;

Or if your compiler has auto support.

auto my_vol = 9f * cubic_meters;

See the examples for clarification as well.

HTH

>_______________________________________________
>Boost-users mailing list
>Boost-users_at_[hidden]
>http://lists.boost.org/mailman/listinfo.cgi/boost-users

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net