diff --git a/include/ylt/easylog/record.hpp b/include/ylt/easylog/record.hpp index f5dacdd42..9ae1f0294 100644 --- a/include/ylt/easylog/record.hpp +++ b/include/ylt/easylog/record.hpp @@ -63,8 +63,8 @@ template struct has_data : std::false_type {}; template -struct has_data().data())>> - : std::true_type {}; +struct has_data().append( + std::declval().data()))>> : std::true_type {}; template constexpr inline bool has_data_v = has_data>::value; @@ -73,8 +73,8 @@ template struct has_str : std::false_type {}; template -struct has_str().str())>> - : std::true_type {}; +struct has_str().append( + std::declval().str()))>> : std::true_type {}; template constexpr inline bool has_str_v = has_str>::value; diff --git a/src/easylog/tests/test_easylog.cpp b/src/easylog/tests/test_easylog.cpp index b8718e9df..df7e40b10 100644 --- a/src/easylog/tests/test_easylog.cpp +++ b/src/easylog/tests/test_easylog.cpp @@ -42,6 +42,20 @@ TEST_CASE("test severity") { easylog::severity_str(easylog::Severity::FATAL)); } +struct dummy_t { + int* data() const { + static int val = 42; + return &val; + } + + friend std::ostream& operator<<(std::ostream& os, const dummy_t& t); +}; + +std::ostream& operator<<(std::ostream& os, const dummy_t& t) { + os << t.data(); + return os; +} + TEST_CASE("test basic") { std::string filename = "easylog.txt"; std::filesystem::remove(filename); @@ -65,6 +79,8 @@ TEST_CASE("test basic") { ELOG_INFO << "info log"; easylog::set_min_severity(Severity::DEBUG); + ELOG_INFO << dummy_t{}; + std::unique_ptr ptr(new int(42)); ELOG_INFO << ptr.get(); ELOG_INFO << 42 << " " << 4.5 << 'a' << Severity::DEBUG;