Skip to content

Instantly share code, notes, and snippets.

@martinmoene
Last active November 9, 2015 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinmoene/21d897444d39219e139a to your computer and use it in GitHub Desktop.
Save martinmoene/21d897444d39219e139a to your computer and use it in GitHub Desktop.
Apples and bears
#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