Skip to content

Commit 77b88a2

Browse files
Merge branch 'main' into main
2 parents ed4b43a + 2f58e95 commit 77b88a2

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
@@ -17,6 +17,7 @@
1717
# include "opentelemetry/config.h"
1818
# include "opentelemetry/nostd/detail/void.h" // IWYU pragma: export
1919
# include "opentelemetry/version.h"
20+
#endif
2021

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

74+
#if defined(OPENTELEMETRY_STL_VERSION) && OPENTELEMETRY_STL_VERSION >= 2017
75+
using std::is_nothrow_swappable;
76+
using std::is_swappable;
77+
#else
7378
/**
7479
* Back port of std::is_swappable
7580
*/
@@ -119,6 +124,7 @@ struct is_nothrow_swappable<false, T> : std::false_type
119124
} // namespace detail
120125
template <typename T>
121126
using is_nothrow_swappable = detail::swappable::is_nothrow_swappable<is_swappable<T>::value, T>;
127+
#endif
122128

123129
/**
124130
* Back port of
@@ -127,12 +133,12 @@ using is_nothrow_swappable = detail::swappable::is_nothrow_swappable<is_swappabl
127133
* std::is_trivialy_copy_assignable
128134
* std::is_trivialy_move_assignable
129135
*/
130-
# ifdef OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS
136+
#ifdef OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS
131137
using std::is_trivially_copy_assignable;
132138
using std::is_trivially_copy_constructible;
133139
using std::is_trivially_move_assignable;
134140
using std::is_trivially_move_constructible;
135-
# else
141+
#else
136142
template <typename T>
137143
struct is_trivially_copy_constructible
138144
{
@@ -156,7 +162,6 @@ struct is_trivially_move_assignable
156162
{
157163
static constexpr bool value = __is_trivial(T);
158164
};
159-
# endif
165+
#endif
160166
} // namespace nostd
161167
OPENTELEMETRY_END_NAMESPACE
162-
#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>
@@ -26,6 +25,7 @@
2625
#include "opentelemetry/ext/http/common/url_parser.h"
2726
#include "opentelemetry/nostd/shared_ptr.h"
2827
#include "opentelemetry/nostd/string_view.h"
28+
#include "opentelemetry/nostd/type_traits.h"
2929
#include "opentelemetry/sdk/common/thread_instrumentation.h"
3030
#include "opentelemetry/version.h"
3131

@@ -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)