Created
August 1, 2018 17:29
-
-
Save michaelbartnett/e1ba88d3035bf2dba445238a522794b6 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 <string> | |
#define STR1 "Hello" | |
//#define STR2 "World" | |
#define STR2 "12345678123456781234567812345678" | |
//#define STR2 "Worlda" | |
#define METHOD 3 | |
std::string get_value(const bool b) | |
{ | |
#if METHOD == 1 | |
std::string ret; | |
if (b) { | |
ret = STR1; | |
} else { | |
ret = STR2; | |
} | |
return ret; | |
#elif METHOD == 2 | |
if (b) { | |
return STR1; | |
} else { | |
return STR2; | |
} | |
#elif METHOD == 3 | |
return b ? STR1 : STR2; | |
#elif METHOD == 4 | |
return b ? STR1 : "World"; | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment