Skip to content

Commit f267eaa

Browse files
committed
Support [[msvc::no_unique_address]] with cl.
* [[no_unique_address]] with cl is silently ignored. * Don't either with with clang-cl, they are unrecognised. https://reviews.llvm.org/D110485
1 parent d1b62d5 commit f267eaa

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

include/tuplet/tuple.hpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
#include <type_traits>
77
#include <utility>
88

9+
#if (defined _MSC_VER)
10+
#if (defined __clang__)
11+
#define TUPLET_NO_UNIQUE_ADDRESS
12+
#else
13+
#define TUPLET_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
14+
#endif
15+
#else
16+
#define TUPLET_NO_UNIQUE_ADDRESS [[no_unique_address]]
17+
#endif
18+
919
// tuplet concepts and traits
1020
namespace tuplet {
1121
template <class T>
@@ -94,7 +104,7 @@ struct tuple_elem {
94104
static T decl_elem(tag<I>);
95105
using type = T;
96106

97-
[[no_unique_address]] T value;
107+
TUPLET_NO_UNIQUE_ADDRESS T value;
98108

99109
constexpr decltype(auto) operator[](tag<I>) & { return (value); }
100110
constexpr decltype(auto) operator[](tag<I>) const& { return (value); }
@@ -242,8 +252,8 @@ namespace tuplet {
242252
template <class First, class Second>
243253
struct pair {
244254
constexpr static size_t N = 2;
245-
[[no_unique_address]] First first;
246-
[[no_unique_address]] Second second;
255+
TUPLET_NO_UNIQUE_ADDRESS First first;
256+
TUPLET_NO_UNIQUE_ADDRESS Second second;
247257

248258
constexpr decltype(auto) operator[](tag<0>) & { return (first); }
249259
constexpr decltype(auto) operator[](tag<0>) const& { return (first); }

0 commit comments

Comments
 (0)