Skip to content

Instantly share code, notes, and snippets.

@ThePhD
Created March 28, 2014 21:00
Show Gist options
  • Save ThePhD/9842898 to your computer and use it in GitHub Desktop.
Save ThePhD/9842898 to your computer and use it in GitHub Desktop.
#pragma once
struct adder {
template <typename Tl, typename Tr>
auto operator()( Tl&& left, Tr&& right )
-> decltype( left + right ) {
return left + right;
}
};
struct subtracter {
template <typename Tl, typename Tr>
auto operator()( Tl&& left, Tr&& right )
-> decltype( left - right ) {
return left - right;
}
};
struct multiplier {
template <typename Tl, typename Tr>
auto operator()( Tl&& left, Tr&& right )
-> decltype( left * right ) {
return left * right;
}
};
struct divider {
template <typename Tl, typename Tr>
auto operator()( Tl&& left, Tr&& right )
-> decltype( left / right ) {
return left / right;
}
};
struct modulus {
template <typename Tl, typename Tr>
auto operator()( Tl&& left, Tr&& right )
-> decltype( left % right ) {
return left % right;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment