Skip to content

Commit 92cc068

Browse files
author
John Wellbelove
committed
Added etl::monostate as a separate header monostate.h so that it can be used without have to include variant.h
1 parent aacde24 commit 92cc068

File tree

5 files changed

+53
-11
lines changed

5 files changed

+53
-11
lines changed

include/etl/monostate.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
///\file
2+
3+
/******************************************************************************
4+
The MIT License(MIT)
5+
6+
Embedded Template Library.
7+
https://github.com/ETLCPP/etl
8+
https://www.etlcpp.com
9+
10+
Copyright(c) 2025 jwellbelove
11+
12+
Permission is hereby granted, free of charge, to any person obtaining a copy
13+
of this software and associated documentation files(the "Software"), to deal
14+
in the Software without restriction, including without limitation the rights
15+
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16+
copies of the Software, and to permit persons to whom the Software is
17+
furnished to do so, subject to the following conditions :
18+
19+
The above copyright notice and this permission notice shall be included in all
20+
copies or substantial portions of the Software.
21+
22+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28+
SOFTWARE.
29+
******************************************************************************/
30+
31+
#ifndef ETL_MONOSTATE_INCLUDED
32+
#define ETL_MONOSTATE_INCLUDED
33+
34+
#include "platform.h"
35+
36+
namespace etl
37+
{
38+
//***************************************************************************
39+
/// A 'no-value' placeholder.
40+
//***************************************************************************
41+
struct monostate
42+
{
43+
};
44+
}
45+
46+
#endif

include/etl/private/variant_legacy.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ SOFTWARE.
4040
#include "../error_handler.h"
4141
#include "../null_type.h"
4242
#include "../placement_new.h"
43+
#include "../monostate.h"
4344

4445
#include <stdint.h>
4546

@@ -75,9 +76,7 @@ namespace etl
7576
/// Monostate for variants.
7677
///\ingroup variant
7778
//***************************************************************************
78-
struct monostate
79-
{
80-
};
79+
typedef etl::monostate monostate;
8180

8281
//***************************************************************************
8382
/// Base exception for the variant class.

include/etl/private/variant_variadic.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ SOFTWARE.
4444
#include "../memory.h"
4545
#include "../compare.h"
4646
#include "../initializer_list.h"
47+
#include "../monostate.h"
4748

4849
#include <stdint.h>
4950

@@ -304,14 +305,6 @@ namespace etl
304305
#include "variant_select_do_operator.h"
305306
#endif
306307

307-
//***************************************************************************
308-
/// Monostate for variants.
309-
///\ingroup variant
310-
//***************************************************************************
311-
struct monostate
312-
{
313-
};
314-
315308
constexpr bool operator >(etl::monostate, etl::monostate) noexcept { return false; }
316309
constexpr bool operator <(etl::monostate, etl::monostate) noexcept { return false; }
317310
constexpr bool operator !=(etl::monostate, etl::monostate) noexcept { return false; }

test/vs2022/etl.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,6 +3173,7 @@
31733173
<ClInclude Include="..\..\include\etl\lcm.h" />
31743174
<ClInclude Include="..\..\include\etl\math.h" />
31753175
<ClInclude Include="..\..\include\etl\message_broker.h" />
3176+
<ClInclude Include="..\..\include\etl\monostate.h" />
31763177
<ClInclude Include="..\..\include\etl\poly_span.h" />
31773178
<ClInclude Include="..\..\include\etl\private\bitset_legacy.h" />
31783179
<ClInclude Include="..\..\include\etl\private\bitset_new.h" />

test/vs2022/etl.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,9 @@
14401440
<ClInclude Include="..\..\include\etl\private\variant_select_do_operator.h">
14411441
<Filter>ETL\Private</Filter>
14421442
</ClInclude>
1443+
<ClInclude Include="..\..\include\etl\monostate.h">
1444+
<Filter>ETL\Utilities</Filter>
1445+
</ClInclude>
14431446
</ItemGroup>
14441447
<ItemGroup>
14451448
<ClCompile Include="..\test_string_char.cpp">

0 commit comments

Comments
 (0)