Created
April 11, 2018 07:42
-
-
Save othrayte/98798cd48e7f5ba1bfb62257edb447e0 to your computer and use it in GitHub Desktop.
Using c++ user defined literals to provide squared literal numbers
This file contains hidden or 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
| constexpr auto operator "" _²(long double x) { | |
| return x*x; | |
| } | |
| constexpr unsigned long long int operator "" _²(unsigned long long int x) { | |
| return x*x; | |
| } | |
| int main() { | |
| return 4_²; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment