Added etl::monostate as a separate header monostate.h so that it can be used without have to include variant.h

This commit is contained in:
John Wellbelove 2025-03-26 08:34:13 +00:00
parent 2bbc3c3f81
commit af725afc79
5 changed files with 53 additions and 11 deletions

46
include/etl/monostate.h Normal file
View File

@ -0,0 +1,46 @@
///\file
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2025 jwellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_MONOSTATE_INCLUDED
#define ETL_MONOSTATE_INCLUDED
#include "platform.h"
namespace etl
{
//***************************************************************************
/// A 'no-value' placeholder.
//***************************************************************************
struct monostate
{
};
}
#endif

View File

@ -40,6 +40,7 @@ SOFTWARE.
#include "../error_handler.h"
#include "../null_type.h"
#include "../placement_new.h"
#include "../monostate.h"
#include <stdint.h>
@ -75,9 +76,7 @@ namespace etl
/// Monostate for variants.
///\ingroup variant
//***************************************************************************
struct monostate
{
};
typedef etl::monostate monostate;
//***************************************************************************
/// Base exception for the variant class.

View File

@ -44,6 +44,7 @@ SOFTWARE.
#include "../memory.h"
#include "../compare.h"
#include "../initializer_list.h"
#include "../monostate.h"
#include <stdint.h>
@ -304,14 +305,6 @@ namespace etl
#include "variant_select_do_operator.h"
#endif
//***************************************************************************
/// Monostate for variants.
///\ingroup variant
//***************************************************************************
struct monostate
{
};
constexpr bool operator >(etl::monostate, etl::monostate) noexcept { return false; }
constexpr bool operator <(etl::monostate, etl::monostate) noexcept { return false; }
constexpr bool operator !=(etl::monostate, etl::monostate) noexcept { return false; }

View File

@ -3173,6 +3173,7 @@
<ClInclude Include="..\..\include\etl\lcm.h" />
<ClInclude Include="..\..\include\etl\math.h" />
<ClInclude Include="..\..\include\etl\message_broker.h" />
<ClInclude Include="..\..\include\etl\monostate.h" />
<ClInclude Include="..\..\include\etl\poly_span.h" />
<ClInclude Include="..\..\include\etl\private\bitset_legacy.h" />
<ClInclude Include="..\..\include\etl\private\bitset_new.h" />

View File

@ -1440,6 +1440,9 @@
<ClInclude Include="..\..\include\etl\private\variant_select_do_operator.h">
<Filter>ETL\Private</Filter>
</ClInclude>
<ClInclude Include="..\..\include\etl\monostate.h">
<Filter>ETL\Utilities</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\test_string_char.cpp">