Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca5eed0

Browse files
authored
Conditional compile generic lambda (#381)
1 parent 8c455f7 commit ca5eed0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ endif()
3030

3131
find_package(Threads)
3232

33-
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
33+
if(MSVC)
3434
# Options for Visual C++ compiler: /Zc:__cplusplus - report an updated value
3535
# for recent C++ language standards. Without this option MSVC returns the
3636
# value of __cplusplus="199711L"

exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ class OStreamSpanExporter final : public sdktrace::SpanExporter
8989
sout_ << ']';
9090
}
9191

92+
// Prior to C++14, generic lambda is not available so fallback to functor.
93+
#if __cplusplus < 201402L
94+
9295
class SpanDataAttributeValueVisitor
9396
{
9497
public:
@@ -104,9 +107,15 @@ class OStreamSpanExporter final : public sdktrace::SpanExporter
104107
OStreamSpanExporter &exporter_;
105108
};
106109

110+
#endif
111+
107112
void print_value(sdktrace::SpanDataAttributeValue &value)
108113
{
114+
#if __cplusplus < 201402L
109115
nostd::visit(SpanDataAttributeValueVisitor(*this), value);
116+
#else
117+
nostd::visit([this](auto &&arg) { print_value(arg); }, value);
118+
#endif
110119
}
111120

112121
void printAttributes(std::unordered_map<std::string, sdktrace::SpanDataAttributeValue> map)

0 commit comments

Comments
 (0)