diff --git a/api/include/opentelemetry/nostd/type_traits.h b/api/include/opentelemetry/nostd/type_traits.h index 5a087075bf..3a64b5db1a 100644 --- a/api/include/opentelemetry/nostd/type_traits.h +++ b/api/include/opentelemetry/nostd/type_traits.h @@ -17,6 +17,7 @@ # include "opentelemetry/config.h" # include "opentelemetry/nostd/detail/void.h" // IWYU pragma: export # include "opentelemetry/version.h" +#endif OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd @@ -70,6 +71,10 @@ struct remove_all_extents> : remove_all_extents template using remove_all_extents_t = typename remove_all_extents::type; +#if defined(OPENTELEMETRY_STL_VERSION) && OPENTELEMETRY_STL_VERSION >= 2017 +using std::is_nothrow_swappable; +using std::is_swappable; +#else /** * Back port of std::is_swappable */ @@ -119,6 +124,7 @@ struct is_nothrow_swappable : std::false_type } // namespace detail template using is_nothrow_swappable = detail::swappable::is_nothrow_swappable::value, T>; +#endif /** * Back port of @@ -127,12 +133,12 @@ using is_nothrow_swappable = detail::swappable::is_nothrow_swappable struct is_trivially_copy_constructible { @@ -156,7 +162,6 @@ struct is_trivially_move_assignable { static constexpr bool value = __is_trivial(T); }; -# endif +#endif } // namespace nostd OPENTELEMETRY_END_NAMESPACE -#endif /* OPENTELEMETRY_HAVE_STD_TYPE_TRAITS */ diff --git a/api/include/opentelemetry/std/type_traits.h b/api/include/opentelemetry/std/type_traits.h index 074f796798..2d75f49fdb 100644 --- a/api/include/opentelemetry/std/type_traits.h +++ b/api/include/opentelemetry/std/type_traits.h @@ -5,18 +5,6 @@ // IWYU pragma: private, include "opentelemetry/nostd/type_traits.h" -#include +#include // IWYU pragma: keep -#include "opentelemetry/version.h" - -OPENTELEMETRY_BEGIN_NAMESPACE -// Standard Type aliases in nostd namespace -namespace nostd -{ - -// nostd::enable_if_t<...> -template -using enable_if_t = typename std::enable_if::type; - -} // namespace nostd -OPENTELEMETRY_END_NAMESPACE +#include "opentelemetry/version.h" // IWYU pragma: keep diff --git a/exporters/elasticsearch/src/es_log_recordable.cc b/exporters/elasticsearch/src/es_log_recordable.cc index 5c5f101282..39979a26fd 100644 --- a/exporters/elasticsearch/src/es_log_recordable.cc +++ b/exporters/elasticsearch/src/es_log_recordable.cc @@ -23,12 +23,25 @@ namespace nlohmann { +template +struct json_assign_visitor +{ + T *j_; + json_assign_visitor(T &j) : j_(&j) {} + + template + void operator()(const U &u) + { + *j_ = u; + } +}; + template <> struct adl_serializer { static void to_json(json &j, const opentelemetry::sdk::common::OwnedAttributeValue &v) { - opentelemetry::nostd::visit([&j](const auto &value) { j = value; }, v); + opentelemetry::nostd::visit(json_assign_visitor(j), v); } }; @@ -37,7 +50,7 @@ struct adl_serializer { static void to_json(json &j, const opentelemetry::common::AttributeValue &v) { - opentelemetry::nostd::visit([&j](const auto &value) { j = value; }, v); + opentelemetry::nostd::visit(json_assign_visitor(j), v); } }; } // namespace nlohmann diff --git a/ext/src/http/client/curl/http_client_curl.cc b/ext/src/http/client/curl/http_client_curl.cc index c22ce539db..597f0c7a28 100644 --- a/ext/src/http/client/curl/http_client_curl.cc +++ b/ext/src/http/client/curl/http_client_curl.cc @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -26,6 +25,7 @@ #include "opentelemetry/ext/http/common/url_parser.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/string_view.h" +#include "opentelemetry/nostd/type_traits.h" #include "opentelemetry/sdk/common/thread_instrumentation.h" #include "opentelemetry/version.h" @@ -116,7 +116,7 @@ int deflateInPlace(z_stream *strm, unsigned char *buf, uint32_t len, uint32_t *m // now empty input buffer (this will only occur for long incompressible streams, more than ~20 MB // for the default deflate memLevel of 8, or when *max_len is too small and less than the length // of the header plus one byte) - auto hold = static_cast>( + auto hold = static_cast>( strm->zalloc(strm->opaque, strm->avail_in, 1)); // allocated buffer to hold input data if (hold == Z_NULL) {