Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Abhishek Dasgupta <abhi2743@gmail.com>
Abhishek Parmar <abhishek@orng.net>
Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
Andy Ying <andy@trailofbits.com>
Bret McKee <bretmckee@google.com>
Brian Silverman <bsilver16384@gmail.com>
Fumitoshi Ukai <ukai@google.com>
Guillaume Dumont <dumont.guillaume@gmail.com>
Expand Down
7 changes: 7 additions & 0 deletions src/glog/logging.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,13 @@ void MakeCheckOpValueString(std::ostream* os, const signed char& v);
template <> GOOGLE_GLOG_DLL_DECL
void MakeCheckOpValueString(std::ostream* os, const unsigned char& v);

// This is required because nullptr is only present in c++ 11 and later.
#if __cplusplus >= 201103L
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this check is unreliable (e.g., under MSVC). Instead, you should test for std::nullptr_t using CMake and CheckCXXSymbolExists and provide a define (e.g., HAVE_NULLPTR_T) that is eventually used here. The __cplusplus check can be left as a backup.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@sergiud sergiud Jan 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be used as fallback. The actual check should be performed by the build system as previously explained.

// Provide printable value for nullptr_t
template <> GOOGLE_GLOG_DLL_DECL
void MakeCheckOpValueString(std::ostream* os, const std::nullptr_t& v);
#endif

// Build the error message string. Specify no inlining for code size.
template <typename T1, typename T2>
std::string* MakeCheckOpString(const T1& v1, const T2& v2, const char* exprtext)
Expand Down
7 changes: 7 additions & 0 deletions src/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +2163,13 @@ void MakeCheckOpValueString(std::ostream* os, const unsigned char& v) {
}
}

#if __cplusplus >= 201103L
template <>
void MakeCheckOpValueString(std::ostream* os, const std::nullptr_t& v) {
(*os) << "nullptr";
}
#endif

void InitGoogleLogging(const char* argv0) {
glog_internal_namespace_::InitGoogleLoggingUtilities(argv0);
}
Expand Down