Skip to content

Commit 858386d

Browse files
committed
merged from upstream
2 parents 79c624a + 2f58e95 commit 858386d

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

api/include/opentelemetry/nostd/type_traits.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
# include "opentelemetry/config.h"
2020
# include "opentelemetry/nostd/detail/void.h" // IWYU pragma: export
21+
#endif
2122

2223
OPENTELEMETRY_BEGIN_NAMESPACE
2324
namespace nostd
@@ -71,6 +72,10 @@ struct remove_all_extents<std::array<T, N>> : remove_all_extents<T>
7172
template <typename T>
7273
using remove_all_extents_t = typename remove_all_extents<T>::type;
7374

75+
#if defined(OPENTELEMETRY_STL_VERSION) && OPENTELEMETRY_STL_VERSION >= 2017
76+
using std::is_nothrow_swappable;
77+
using std::is_swappable;
78+
#else
7479
/**
7580
* Back port of std::is_swappable
7681
*/
@@ -120,6 +125,7 @@ struct is_nothrow_swappable<false, T> : std::false_type
120125
} // namespace detail
121126
template <typename T>
122127
using is_nothrow_swappable = detail::swappable::is_nothrow_swappable<is_swappable<T>::value, T>;
128+
#endif
123129

124130
/**
125131
* Back port of
@@ -128,12 +134,12 @@ using is_nothrow_swappable = detail::swappable::is_nothrow_swappable<is_swappabl
128134
* std::is_trivialy_copy_assignable
129135
* std::is_trivialy_move_assignable
130136
*/
131-
# ifdef OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS
137+
#ifdef OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS
132138
using std::is_trivially_copy_assignable;
133139
using std::is_trivially_copy_constructible;
134140
using std::is_trivially_move_assignable;
135141
using std::is_trivially_move_constructible;
136-
# else
142+
#else
137143
template <typename T>
138144
struct is_trivially_copy_constructible
139145
{
@@ -157,7 +163,6 @@ struct is_trivially_move_assignable
157163
{
158164
static constexpr bool value = __is_trivial(T);
159165
};
160-
# endif
166+
#endif
161167
} // namespace nostd
162168
OPENTELEMETRY_END_NAMESPACE
163-
#endif /* OPENTELEMETRY_HAVE_STD_TYPE_TRAITS */

api/include/opentelemetry/std/type_traits.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,6 @@
55

66
// IWYU pragma: private, include "opentelemetry/nostd/type_traits.h"
77

8-
#include <type_traits>
8+
#include <type_traits> // IWYU pragma: keep
99

10-
#include "opentelemetry/version.h"
11-
12-
OPENTELEMETRY_BEGIN_NAMESPACE
13-
// Standard Type aliases in nostd namespace
14-
namespace nostd
15-
{
16-
17-
// nostd::enable_if_t<...>
18-
template <bool B, class T = void>
19-
using enable_if_t = typename std::enable_if<B, T>::type;
20-
21-
} // namespace nostd
22-
OPENTELEMETRY_END_NAMESPACE
10+
#include "opentelemetry/version.h" // IWYU pragma: keep

exporters/elasticsearch/src/es_log_recordable.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,25 @@
2323

2424
namespace nlohmann
2525
{
26+
template <class T>
27+
struct json_assign_visitor
28+
{
29+
T *j_;
30+
json_assign_visitor(T &j) : j_(&j) {}
31+
32+
template <class U>
33+
void operator()(const U &u)
34+
{
35+
*j_ = u;
36+
}
37+
};
38+
2639
template <>
2740
struct adl_serializer<opentelemetry::sdk::common::OwnedAttributeValue>
2841
{
2942
static void to_json(json &j, const opentelemetry::sdk::common::OwnedAttributeValue &v)
3043
{
31-
opentelemetry::nostd::visit([&j](const auto &value) { j = value; }, v);
44+
opentelemetry::nostd::visit(json_assign_visitor<json>(j), v);
3245
}
3346
};
3447

@@ -37,7 +50,7 @@ struct adl_serializer<opentelemetry::common::AttributeValue>
3750
{
3851
static void to_json(json &j, const opentelemetry::common::AttributeValue &v)
3952
{
40-
opentelemetry::nostd::visit([&j](const auto &value) { j = value; }, v);
53+
opentelemetry::nostd::visit(json_assign_visitor<json>(j), v);
4154
}
4255
};
4356
} // namespace nlohmann

ext/src/http/client/curl/http_client_curl.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <mutex>
1616
#include <string>
1717
#include <thread>
18-
#include <type_traits>
1918
#include <unordered_map>
2019
#include <unordered_set>
2120
#include <utility>
@@ -27,6 +26,7 @@
2726
#include "opentelemetry/ext/http/common/url_parser.h"
2827
#include "opentelemetry/nostd/shared_ptr.h"
2928
#include "opentelemetry/nostd/string_view.h"
29+
#include "opentelemetry/nostd/type_traits.h"
3030
#include "opentelemetry/sdk/common/thread_instrumentation.h"
3131

3232
#ifdef ENABLE_OTLP_COMPRESSION_PREVIEW
@@ -116,7 +116,7 @@ int deflateInPlace(z_stream *strm, unsigned char *buf, uint32_t len, uint32_t *m
116116
// now empty input buffer (this will only occur for long incompressible streams, more than ~20 MB
117117
// for the default deflate memLevel of 8, or when *max_len is too small and less than the length
118118
// of the header plus one byte)
119-
auto hold = static_cast<std::remove_const_t<decltype(z_stream::next_in)>>(
119+
auto hold = static_cast<nostd::remove_const_t<decltype(z_stream::next_in)>>(
120120
strm->zalloc(strm->opaque, strm->avail_in, 1)); // allocated buffer to hold input data
121121
if (hold == Z_NULL)
122122
{

0 commit comments

Comments
 (0)