Skip to content

Instantly share code, notes, and snippets.

@michaelbartnett
Created August 1, 2018 17:29
Show Gist options
  • Save michaelbartnett/e1ba88d3035bf2dba445238a522794b6 to your computer and use it in GitHub Desktop.
Save michaelbartnett/e1ba88d3035bf2dba445238a522794b6 to your computer and use it in GitHub Desktop.
#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