Last active
December 17, 2015 22:38
-
-
Save mythagel/5682908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
g++ -std=c++11 boost_units.cpp -o boost_units | |
*/ | |
#include <iostream> | |
#include <boost/units/systems/si/prefixes.hpp> | |
#include <boost/units/systems/si/length.hpp> | |
#include <boost/units/systems/si/io.hpp> | |
#include <boost/units/systems/si/velocity.hpp> | |
#include <boost/units/base_units/metric/minute.hpp> | |
using namespace boost::units; | |
using namespace boost::units::si; | |
int main() | |
{ | |
auto l1 = 2 * meter; | |
auto l2 = static_cast<quantity<decltype(milli*meter)>>(l1); | |
std::cout << l1 << " -> " << l2 << "\n"; | |
auto minute = metric::minute_base_unit::unit_type(); | |
auto speed = 2000 * ((milli*meter) / minute); | |
std::cout << speed << "\n"; | |
auto s2 = static_cast<quantity<velocity>>(speed); | |
std::cout << s2 << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment