Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ License (MIT): | |
|
||
#if __cplusplus >= 201703L | ||
#include <optional> | ||
#include <variant> | ||
#endif | ||
|
||
namespace dbg_macro { | ||
|
@@ -328,21 +329,6 @@ bool pretty_print(std::ostream& stream, const std::tuple<>& value) { | |
return true; | ||
} | ||
|
||
#if __cplusplus >= 201703L | ||
|
||
template <typename T> | ||
bool pretty_print(std::ostream& stream, const std::optional<T>& value) { | ||
if (value) { | ||
stream << '{' << *value << '}'; | ||
} else { | ||
stream << "nullopt"; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
#endif // __cplusplus >= 201703L | ||
|
||
template <typename Container> | ||
typename std::enable_if<detail::has_begin_end_size<const Container&>::value, | ||
bool>::type | ||
|
@@ -384,6 +370,30 @@ inline bool pretty_print(std::ostream& stream, const std::string& value) { | |
return true; | ||
} | ||
|
||
#if __cplusplus >= 201703L | ||
|
||
template <typename T> | ||
bool pretty_print(std::ostream& stream, const std::optional<T>& value) { | ||
if (value) { | ||
stream << '{' << *value << '}'; | ||
} else { | ||
stream << "nullopt"; | ||
} | ||
|
||
return true; | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hmenke
Contributor
|
||
|
||
template <typename... Ts> | ||
bool pretty_print(std::ostream& stream, const std::variant<Ts...>& value) { | ||
stream << "{"; | ||
std::visit([&stream](auto&& arg) { pretty_print(stream, arg); }, value); | ||
stream << "}"; | ||
|
||
return true; | ||
} | ||
|
||
#endif // __cplusplus >= 201703L | ||
|
||
class DebugOutput { | ||
public: | ||
DebugOutput(const char* filepath, | ||
|
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
This doesn't add curly braces around the value but I don't see why they are necessary here.