mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-08-30 21:51:12 +02:00
do we need to include sstream to concat strings in MSVC
This commit is contained in:
parent
9df557c951
commit
75e8f650ca
1 changed files with 9 additions and 4 deletions
|
@ -1,11 +1,20 @@
|
||||||
#include <greeter.h>
|
#include <greeter.h>
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(WIN32)
|
||||||
|
// apparently this is required to concat strings
|
||||||
|
# include <sstream>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace greeter;
|
using namespace greeter;
|
||||||
|
|
||||||
Greeter::Greeter(std::string _name) : name(_name) {}
|
Greeter::Greeter(std::string _name) : name(_name) {}
|
||||||
|
|
||||||
std::string Greeter::greet(LanguageCode lang) const {
|
std::string Greeter::greet(LanguageCode lang) const {
|
||||||
switch (lang) {
|
switch (lang) {
|
||||||
|
#if defined(_WIN32) || defined(WIN32)
|
||||||
|
// this silences MSVC as it does not seem to understand strongly-typed enums
|
||||||
|
default:
|
||||||
|
#endif
|
||||||
case LanguageCode::EN:
|
case LanguageCode::EN:
|
||||||
return "Hello, " + name + "!";
|
return "Hello, " + name + "!";
|
||||||
case LanguageCode::DE:
|
case LanguageCode::DE:
|
||||||
|
@ -13,10 +22,6 @@ std::string Greeter::greet(LanguageCode lang) const {
|
||||||
case LanguageCode::ES:
|
case LanguageCode::ES:
|
||||||
return "¡Hola " + name + "!";
|
return "¡Hola " + name + "!";
|
||||||
case LanguageCode::FR:
|
case LanguageCode::FR:
|
||||||
#if defined(_WIN32) || defined(WIN32)
|
|
||||||
// this silences a warning as MSVC does not seem to understand strongly-typed enums
|
|
||||||
default:
|
|
||||||
#endif
|
|
||||||
return "Bonjour " + name + "!";
|
return "Bonjour " + name + "!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue