|
@@ -119,29 +119,41 @@ public:
|
|
|
* work for const references, so many function prototypes will
|
|
|
* include const basic_formatter<T>& s but might still want to
|
|
|
* modify the formatted string without the need for a full copy.*/
|
|
|
- template <typename TToken>
|
|
|
- const basic_formatter& operator << (const TToken& s) const {
|
|
|
+ template <typename TToken, typename std::enable_if<!std::is_base_of<std::exception, TToken>::value>::type * = nullptr>
|
|
|
+ const basic_formatter &operator<<(const TToken &s) const {
|
|
|
underlying << s;
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
- template <typename TToken>
|
|
|
- basic_formatter& operator << (const TToken& s) {
|
|
|
+ template <typename TToken, typename std::enable_if<std::is_base_of<std::exception, TToken>::value>::type * = nullptr>
|
|
|
+ const basic_formatter &operator<<(const TToken &s) const {
|
|
|
+ underlying << s.what();
|
|
|
+ return *this;
|
|
|
+ }
|
|
|
+
|
|
|
+ template <typename TToken, typename std::enable_if<!std::is_base_of<std::exception, TToken>::value>::type * = nullptr>
|
|
|
+ basic_formatter &operator<<(const TToken &s) {
|
|
|
underlying << s;
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
+ template <typename TToken, typename std::enable_if<std::is_base_of<std::exception, TToken>::value>::type * = nullptr>
|
|
|
+ basic_formatter &operator<<(const TToken &s) {
|
|
|
+ underlying << s.what();
|
|
|
+ return *this;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// comma operator overloaded as well, choose your preferred way.
|
|
|
template <typename TToken>
|
|
|
const basic_formatter& operator, (const TToken& s) const {
|
|
|
- underlying << s;
|
|
|
+ *this << s;
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
|
template <typename TToken>
|
|
|
basic_formatter& operator, (const TToken& s) {
|
|
|
- underlying << s;
|
|
|
+ *this << s;
|
|
|
return *this;
|
|
|
}
|
|
|
|
|
@@ -149,7 +161,7 @@ public:
|
|
|
// See https://sourceforge.net/projects/assimp/forums/forum/817654/topic/4372824
|
|
|
template <typename TToken>
|
|
|
basic_formatter& operator, (TToken& s) {
|
|
|
- underlying << s;
|
|
|
+ *this << s;
|
|
|
return *this;
|
|
|
}
|
|
|
|