Skip to content

Commit 8f0d72c

Browse files
committed
Rename override macros to use variant_CONFIG_OVERRIDE_*, move-up override sections
variant_CONFIG_OVERRIDE_MONOSTATE variant_CONFIG_OVERRIDE_BAD_VARIANT_ACCESS
1 parent c5f7cf5 commit 8f0d72c

3 files changed

Lines changed: 36 additions & 42 deletions

File tree

README.md

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,26 @@ At default, *variant lite* uses `std::variant` if it is available and lets you u
215215
-D<b>variant\_CONFIG\_SELECT\_VARIANT</b>=variant_VARIANT_DEFAULT
216216
Define this to `variant_VARIANT_STD` to select `std::variant` as `nonstd::variant`. Define this to `variant_VARIANT_NONSTD` to select `nonstd::variant` as `nonstd::variant`. Default is undefined, which has the same effect as defining to `variant_VARIANT_DEFAULT`.
217217
218+
#### Override `bad_variant_access`
219+
220+
\-D<b>variant_CONFIG_OVERRIDE_BAD_VARIANT_ACCESS</b>=type
221+
222+
Define this macro to override the default definition of `bad_variant_access`. This is useful when integrating with other compatibility libraries or the standard library to avoid conflicting exception types.
223+
224+
For example: `#define variant_CONFIG_OVERRIDE_BAD_VARIANT_ACCESS std::bad_variant_access`
225+
226+
If not defined, variant-lite uses its own `nonstd::bad_variant_access`.
227+
228+
#### Override `monostate`
229+
230+
\-D<b>variant_CONFIG_OVERRIDE_MONOSTATE</b>=type
231+
232+
Define this macro to override the default `monostate` type used by variant-lite. This helps prevent type conflicts when multiple libraries define their own monostate.
233+
234+
For example: `#define variant_CONFIG_OVERRIDE_MONOSTATE std::monostate`
235+
236+
If not defined, variant-lite uses its own `nonstd::monostate`.
237+
218238
#### Disable exceptions
219239
220240
-D<b>variant_CONFIG_NO_EXCEPTIONS</b>=0
@@ -248,32 +268,6 @@ Define this to the pod-type you want to align to (no default).
248268
\-D<b>variant\_CONFIG\_ALIGN\_AS\_FALLBACK</b>=*pod_type*
249269
Define this to the pod-type to use for alignment if the algorithm of *variant lite* cannot find a suitable POD type to use for alignment. Default is `double`.
250270
251-
#### Override `bad_variant_access`
252-
<b>variant_CONFIG_BAD_VARIANT_ACCESS</b>=type
253-
254-
Define this macro to override the default definition of `bad_variant_access`.
255-
256-
This is useful when integrating with other compatibility libraries or the standard library to avoid conflicting exception types.
257-
258-
Example:
259-
```cpp
260-
#define variant_CONFIG_BAD_VARIANT_ACCESS std::bad_variant_access
261-
```
262-
If not defined, variant-lite uses its own `nonstd::bad_variant_access`.
263-
264-
#### Override `monostate`
265-
<b>variant_CONFIG_MONOSTATE</b>=type
266-
267-
Define this macro to override the default `monostate` type used by variant-lite.
268-
269-
This helps prevent type conflicts when multiple libraries define their own monostate.
270-
271-
Example:
272-
```cpp
273-
#define variant_CONFIG_MONOSTATE std::monostate
274-
```
275-
If not defined, variant-lite uses its own `nonstd::monostate`.
276-
277271
## Reported to work with
278272
279273
The table below mentions the compiler versions *variant lite* is reported to work with.

include/nonstd/variant.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,9 +1212,9 @@ class variant;
12121212

12131213
// 19.7.8 Class monostate
12141214

1215-
#ifdef variant_CONFIG_MONOSTATE
1215+
#ifdef variant_CONFIG_OVERRIDE_MONOSTATE
12161216

1217-
using variant_CONFIG_MONOSTATE;
1217+
using variant_CONFIG_OVERRIDE_MONOSTATE;
12181218

12191219
#else
12201220

@@ -1228,7 +1228,7 @@ inline variant_constexpr bool operator>=( monostate, monostate ) variant_noexcep
12281228
inline variant_constexpr bool operator==( monostate, monostate ) variant_noexcept { return true; }
12291229
inline variant_constexpr bool operator!=( monostate, monostate ) variant_noexcept { return false; }
12301230

1231-
#endif // variant_CONFIG_MONOSTATE
1231+
#endif // variant_CONFIG_OVERRIDE_MONOSTATE
12321232

12331233
// 19.7.4 variant helper classes
12341234

@@ -1287,8 +1287,8 @@ static const std::size_t variant_npos = static_cast<std::size_t>( -1 );
12871287

12881288
// 19.7.11 Class bad_variant_access
12891289

1290-
#ifdef variant_CONFIG_BAD_VARIANT_ACCESS
1291-
using variant_CONFIG_BAD_VARIANT_ACCESS;
1290+
#ifdef variant_CONFIG_OVERRIDE_BAD_VARIANT_ACCESS
1291+
using variant_CONFIG_OVERRIDE_BAD_VARIANT_ACCESS;
12921292
#else
12931293
class variant_nodiscard bad_variant_access : public std::exception
12941294
{
@@ -1302,7 +1302,7 @@ class variant_nodiscard bad_variant_access : public std::exception
13021302
return "bad variant access";
13031303
}
13041304
};
1305-
#endif // variant_CONFIG_BAD_VARIANT_ACCESS
1305+
#endif // variant_CONFIG_OVERRIDE_BAD_VARIANT_ACCESS
13061306

13071307
#endif // variant_CONFIG_NO_EXCEPTIONS
13081308

@@ -2715,7 +2715,7 @@ using namespace variants;
27152715

27162716
namespace std {
27172717

2718-
#ifndef variant_CONFIG_MONOSTATE
2718+
#ifndef variant_CONFIG_OVERRIDE_MONOSTATE
27192719

27202720
template<>
27212721
struct hash< nonstd::monostate >
@@ -2726,7 +2726,7 @@ struct hash< nonstd::monostate >
27262726
}
27272727
};
27282728

2729-
#endif // variant_CONFIG_MONOSTATE
2729+
#endif // variant_CONFIG_OVERRIDE_MONOSTATE
27302730

27312731
template< class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15 >
27322732
struct hash< nonstd::variant<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> >

template/variant.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,9 +1087,9 @@ class variant;
10871087

10881088
// 19.7.8 Class monostate
10891089

1090-
#ifdef variant_CONFIG_MONOSTATE
1090+
#ifdef variant_CONFIG_OVERRIDE_MONOSTATE
10911091

1092-
using variant_CONFIG_MONOSTATE;
1092+
using variant_CONFIG_OVERRIDE_MONOSTATE;
10931093

10941094
#else
10951095

@@ -1103,7 +1103,7 @@ inline variant_constexpr bool operator>=( monostate, monostate ) variant_noexcep
11031103
inline variant_constexpr bool operator==( monostate, monostate ) variant_noexcept { return true; }
11041104
inline variant_constexpr bool operator!=( monostate, monostate ) variant_noexcept { return false; }
11051105

1106-
#endif // variant_CONFIG_MONOSTATE
1106+
#endif // variant_CONFIG_OVERRIDE_MONOSTATE
11071107

11081108
// 19.7.4 variant helper classes
11091109

@@ -1162,8 +1162,8 @@ static const std::size_t variant_npos = static_cast<std::size_t>( -1 );
11621162

11631163
// 19.7.11 Class bad_variant_access
11641164

1165-
#ifdef variant_CONFIG_BAD_VARIANT_ACCESS
1166-
using variant_CONFIG_BAD_VARIANT_ACCESS;
1165+
#ifdef variant_CONFIG_OVERRIDE_BAD_VARIANT_ACCESS
1166+
using variant_CONFIG_OVERRIDE_BAD_VARIANT_ACCESS;
11671167
#else
11681168
class variant_nodiscard bad_variant_access : public std::exception
11691169
{
@@ -1177,7 +1177,7 @@ class variant_nodiscard bad_variant_access : public std::exception
11771177
return "bad variant access";
11781178
}
11791179
};
1180-
#endif // variant_CONFIG_BAD_VARIANT_ACCESS
1180+
#endif // variant_CONFIG_OVERRIDE_BAD_VARIANT_ACCESS
11811181

11821182
#endif // variant_CONFIG_NO_EXCEPTIONS
11831183

@@ -2060,7 +2060,7 @@ using namespace variants;
20602060

20612061
namespace std {
20622062

2063-
#ifndef variant_CONFIG_MONOSTATE
2063+
#ifndef variant_CONFIG_OVERRIDE_MONOSTATE
20642064

20652065
template<>
20662066
struct hash< nonstd::monostate >
@@ -2071,7 +2071,7 @@ struct hash< nonstd::monostate >
20712071
}
20722072
};
20732073

2074-
#endif // variant_CONFIG_MONOSTATE
2074+
#endif // variant_CONFIG_OVERRIDE_MONOSTATE
20752075

20762076
template< {{TplParamsList}} >
20772077
struct hash< nonstd::variant<{{TplArgsList}}> >

0 commit comments

Comments
 (0)