Last active
November 9, 2015 13:32
-
-
Save martinmoene/21d897444d39219e139a to your computer and use it in GitHub Desktop.
Apples and bears
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
#include <iostream> | |
#include "phys/units/io.hpp" | |
#include "phys/units/quantity.hpp" | |
using namespace phys::units; | |
using namespace phys::units::io; | |
auto apple( unit( "apple", extend() ) ); | |
auto box ( unit( "box" , extend() ) ); | |
quantity operator "" _apple(unsigned long long x) { return x * apple; } | |
quantity operator "" _box (unsigned long long x) { return x * box; } | |
int main() | |
{ | |
std::cout << | |
"3 * box * 5 * apple/box = " << | |
(3 * box * 5 * apple/box ) << "\n" | |
<< | |
"3_box * 5_apple/box = " << | |
(3_box * 5_apple/box ) << "\n"; | |
} | |
#if 0 | |
g++ -Wall -std=c++11 -I"D:/GitHub/PhysUnits-RT-git" -o apples.exe apples.cpp & apples.exe | |
3 * box * 5 * apple/box = 15 apple | |
3_box * 5_apple/box = 15 apple | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment