Created
July 20, 2017 18:49
-
-
Save AlexBolotsin/fe493bc38406533dfe698937b3c8a432 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
#include <iostream> | |
#include <string> | |
//#include <string_view> | |
constexpr long operator"" _KB(unsigned long long int value) { return value * 1024; } | |
long operator"" _MB(unsigned long long int value) { return value * 1024 * 1024; } | |
long operator"" _GB(unsigned long long int value) { return value * 1024 * 1024 * 1024; } | |
class A | |
{ | |
public: | |
A(std::string str) { std::cout << "A(string) called\n"; } | |
//A(std::string_view str) { std::cout << "A(string_view) called\n"; } | |
A(const char* str) { std::cout << "A(const char*) called\n"; } | |
}; | |
int main(int argc, char** argv) | |
{ | |
//using namespace std::literals; | |
using namespace std::string_literals; | |
std::cout << "5 KB is " << 5_KB << " 7 MB is " << 7_MB << " 2 GB is " << 2_GB << "\n"; | |
A a("whats up\n"); | |
A b("whats up\n"s); | |
//A c("whats up\n"sv); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment