@@ -11,6 +11,24 @@ namespace plog
1111{
1212 namespace detail
1313 {
14+ namespace meta
15+ {
16+ template <class T >
17+ inline T& declval ()
18+ {
19+ #ifdef __INTEL_COMPILER
20+ # pragma warning(suppress: 327) // NULL reference is not allowed
21+ #endif
22+ return *reinterpret_cast <T*>(0 );
23+ }
24+
25+ template <bool B, class T = void >
26+ struct enableIf {};
27+
28+ template <class T >
29+ struct enableIf <true , T> { typedef T type; };
30+ }
31+
1432 // ////////////////////////////////////////////////////////////////////////
1533 // Stream output operators as free functions
1634
@@ -27,11 +45,22 @@ namespace plog
2745#endif
2846 }
2947
48+ inline void operator <<(util::nostringstream& stream, char * data)
49+ {
50+ plog::detail::operator <<(stream, const_cast <const char *>(data));
51+ }
52+
3053 inline void operator <<(util::nostringstream& stream, const std::string& data)
3154 {
3255 plog::detail::operator <<(stream, data.c_str ());
3356 }
3457
58+ template <typename T>
59+ inline typename meta::enableIf<!!sizeof (static_cast <std::basic_string<util::nchar> >(meta::declval<T>())), void >::type operator <<(util::nostringstream& stream, const T& data)
60+ {
61+ plog::detail::operator <<(stream, static_cast <std::basic_string<util::nchar> >(data));
62+ }
63+
3564#if PLOG_ENABLE_WCHAR_INPUT
3665 inline void operator <<(util::nostringstream& stream, const wchar_t * data)
3766 {
@@ -44,6 +73,11 @@ namespace plog
4473# endif
4574 }
4675
76+ inline void operator <<(util::nostringstream& stream, wchar_t * data)
77+ {
78+ plog::detail::operator <<(stream, const_cast <const wchar_t *>(data));
79+ }
80+
4781 inline void operator <<(util::nostringstream& stream, const std::wstring& data)
4882 {
4983 plog::detail::operator <<(stream, data.c_str ());
@@ -67,10 +101,7 @@ namespace plog
67101 template <class T , class Stream >
68102 struct isStreamable
69103 {
70- #ifdef __INTEL_COMPILER
71- # pragma warning(suppress: 327) // NULL reference is not allowed
72- #endif
73- enum { value = sizeof (operator <<(*reinterpret_cast <Stream*>(0 ), *reinterpret_cast <const T*>(0 ))) != sizeof (char ) };
104+ enum { value = sizeof (operator <<(meta::declval<Stream>(), meta::declval<const T>())) != sizeof (char ) };
74105 };
75106
76107 template <class Stream >
@@ -90,12 +121,6 @@ namespace plog
90121 {
91122 enum { value = false };
92123 };
93-
94- template <bool B, class T = void >
95- struct enableIf {};
96-
97- template <class T >
98- struct enableIf <true , T> { typedef T type; };
99124 }
100125
101126 template <class T >
0 commit comments