diff --git a/.gitignore b/.gitignore index cb627492..870ab075 100644 --- a/.gitignore +++ b/.gitignore @@ -315,3 +315,6 @@ test/sanity-check/c++17/Makefile test/vs2019/Debug LLVM test/vs2019/DebugLLVMNoSTL test/vs2019/DebugNoSTL +test/vs2022/Debug LLVM +test/vs2019/Debug MSVC - No STL - Built-ins/etl.exe +test/vs2019/Debug-LLVM-NoSTL-Builtins/etl.exe diff --git a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvoptx b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvoptx index 52e14341..fb554746 100644 --- a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvoptx +++ b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvoptx @@ -103,7 +103,7 @@ 1 0 0 - 5 + 6 diff --git a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx index ab543f66..9991280c 100644 --- a/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx +++ b/examples/ArmTimerCallbacks - C++/ArmTimerCallbacks.uvprojx @@ -16,7 +16,7 @@ STM32F401RETx STMicroelectronics - Keil.STM32F4xx_DFP.2.14.0 + Keil.STM32F4xx_DFP.2.15.0 http://www.keil.com/pack/ IRAM(0x20000000,0x18000) IROM(0x08000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE @@ -185,6 +185,7 @@ 0 2 0 + 0 0 0 8 @@ -351,7 +352,7 @@ 0 0 0 - 0 + 4 @@ -452,7 +453,7 @@ RTE\Device\STM32F401RETx\startup_stm32f401xe.s - + @@ -460,7 +461,7 @@ RTE\Device\STM32F401RETx\system_stm32f4xx.c - + @@ -468,4 +469,19 @@ + + + + <Project Info> + + + + + + 0 + 1 + + + + diff --git a/include/etl/bip_buffer_spsc_atomic.h b/include/etl/bip_buffer_spsc_atomic.h index 4b2427aa..ed47b7cc 100644 --- a/include/etl/bip_buffer_spsc_atomic.h +++ b/include/etl/bip_buffer_spsc_atomic.h @@ -181,7 +181,7 @@ namespace etl protected: //************************************************************************* - /// Construccts the buffer. + /// Constructs the buffer. //************************************************************************* bip_buffer_spsc_atomic_base(size_type reserved_) : read(0) diff --git a/include/etl/circular_buffer.h b/include/etl/circular_buffer.h index ebd3a634..a002c15e 100644 --- a/include/etl/circular_buffer.h +++ b/include/etl/circular_buffer.h @@ -41,6 +41,10 @@ SOFTWARE. #include "iterator.h" #include "static_assert.h" +#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL + #include +#endif + namespace etl { //*************************************************************************** diff --git a/include/etl/delegate.h b/include/etl/delegate.h index 7fa1eaf7..867ef958 100644 --- a/include/etl/delegate.h +++ b/include/etl/delegate.h @@ -107,7 +107,7 @@ namespace etl //************************************************************************* // Constructor from lambda or functor. //************************************************************************* - template ::value, void>::type> + template ::value, void>> delegate(const TLambda& instance) { assign((void*)(&instance), lambda_stub); @@ -125,7 +125,7 @@ namespace etl //************************************************************************* /// Create from Lambda or Functor. //************************************************************************* - template ::value, void>::type> + template ::value, void>> constexpr static delegate create(const TLambda& instance) { return delegate((void*)(&instance), lambda_stub); @@ -210,7 +210,7 @@ namespace etl //************************************************************************* /// Create from Lambda or Functor. //************************************************************************* - template ::value, void>::type> + template ::value, void>> delegate& operator =(const TLambda& instance) { assign((void*)(&instance), lambda_stub); diff --git a/include/etl/delegate_service.h b/include/etl/delegate_service.h index 1d02560e..3908d841 100644 --- a/include/etl/delegate_service.h +++ b/include/etl/delegate_service.h @@ -46,22 +46,70 @@ namespace etl { //*************************************************************************** /// An indexed delegate service. - /// \tparam RANGE The number of delegates to handle. - /// \tparam OFFSET The lowest delegate id value. - /// The delegate ids must range between OFFSET and OFFSET + RANGE - 1. + /// \tparam Range The number of delegates to handle. + /// \tparam Offset The lowest delegate id value. + /// \tparam Delegates Pointer to an array of delegate pointers. + /// The delegate ids must range between Offset and Offset + Range - 1. //*************************************************************************** - template + template * Delegates = nullptr> class delegate_service { public: //************************************************************************* - /// Reset the delegate service. + /// Executes the delegate function for the index. + /// Compile time assert if the id is out of range. + /// \tparam Id The id of the delegate. + //************************************************************************* + template + void call() const + { + ETL_STATIC_ASSERT(Id < (Offset + Range), "Callback Id out of range"); + ETL_STATIC_ASSERT(Id >= Offset, "Callback Id out of range"); + + Delegates[Id - Offset](Id); + } + + //************************************************************************* + /// Executes the delegate function for the index. + /// \param id Id of the delegate. + //************************************************************************* + void call(const size_t id) const + { + if ((id >= Offset) && (id < (Offset + Range))) + { + // Call the delegate with the specified Id. + Delegates[id - Offset](id); + } + else + { + // Call the 'unhandled' delegate. + Delegates[Range](id); + } + } + }; + + //*************************************************************************** + /// An indexed delegate service. + /// \tparam Range The number of delegates to handle. + /// \tparam Offset The lowest delegate id value. + /// The delegate ids must range between Offset and Offset + Range - 1. + //*************************************************************************** + template + class delegate_service + { + public: + + //************************************************************************* + /// Default constructor. /// Sets all delegates to the internal default. //************************************************************************* delegate_service() { - etl::delegate default_delegate = etl::delegate::create, &delegate_service::unhandled>(*this); + etl::delegate default_delegate = etl::delegate::create, &delegate_service::unhandled>(*this); lookup.fill(default_delegate); } @@ -69,16 +117,16 @@ namespace etl //************************************************************************* /// Registers a delegate for the specified id. /// Compile time assert if the id is out of range. - /// \tparam ID The id of the delegate. + /// \tparam Id The id of the delegate. /// \param delegate Reference to the delegate. //************************************************************************* - template + template void register_delegate(etl::delegate callback) { - ETL_STATIC_ASSERT(ID < (OFFSET + RANGE), "Callback Id out of range"); - ETL_STATIC_ASSERT(ID >= OFFSET, "Callback Id out of range"); + ETL_STATIC_ASSERT(Id < (Offset + Range), "Callback Id out of range"); + ETL_STATIC_ASSERT(Id >= Offset, "Callback Id out of range"); - lookup[ID - OFFSET] = callback; + lookup[Id - Offset] = callback; } //************************************************************************* @@ -89,9 +137,9 @@ namespace etl //************************************************************************* void register_delegate(const size_t id, etl::delegate callback) { - if ((id >= OFFSET) && (id < (OFFSET + RANGE))) + if ((id >= Offset) && (id < (Offset + Range))) { - lookup[id - OFFSET] = callback; + lookup[id - Offset] = callback; } } @@ -107,33 +155,32 @@ namespace etl //************************************************************************* /// Executes the delegate function for the index. /// Compile time assert if the id is out of range. - /// \tparam ID The id of the delegate. + /// \tparam Id The id of the delegate. //************************************************************************* - template - void call() + template + void call() const { - ETL_STATIC_ASSERT(ID < (OFFSET + RANGE), "Callback Id out of range"); - ETL_STATIC_ASSERT(ID >= OFFSET, "Callback Id out of range"); + ETL_STATIC_ASSERT(Id < (Offset + Range), "Callback Id out of range"); + ETL_STATIC_ASSERT(Id >= Offset, "Callback Id out of range"); - lookup[ID - OFFSET](ID); + lookup[Id - Offset](Id); } //************************************************************************* /// Executes the delegate function for the index. /// \param id Id of the delegate. //************************************************************************* - void call(const size_t id) + void call(const size_t id) const { - if ((id >= OFFSET) && (id < (OFFSET + RANGE))) + if ((id >= Offset) && (id < (Offset + Range))) { - lookup[id - OFFSET](id); + // Call the delegate with the specified Id. + lookup[id - Offset](id); } else { - if (unhandled_delegate.is_valid()) - { - unhandled_delegate(id); - } + // Call the 'unhandled' delegate. + unhandled(id); } } @@ -143,7 +190,7 @@ namespace etl /// The default callback function. /// Calls the user defined 'unhandled' callback if it exists. //************************************************************************* - void unhandled(size_t id) + void unhandled(size_t id) const { if (unhandled_delegate.is_valid()) { @@ -155,7 +202,7 @@ namespace etl etl::delegate unhandled_delegate; /// Lookup table of delegates. - etl::array, RANGE> lookup; + etl::array, Range> lookup; }; } diff --git a/include/etl/experimental/mem_cast.h b/include/etl/experimental/mem_cast.h new file mode 100644 index 00000000..d5840321 --- /dev/null +++ b/include/etl/experimental/mem_cast.h @@ -0,0 +1,78 @@ +#pragma once +template +class uni_type +{ +public: + + static constexpr size_t Size = Size_; + + //*********************************** + template + T& get() + { + return *reinterpret_cast(buffer); + } + + //*********************************** + template + const T& get() const + { + return *reinterpret_cast(buffer); + } + + template + operator T() + { + return *reinterpret_cast(buffer); + } + + //*********************************** + constexpr size_t size() const + { + return Size; + } + +private: + + char buffer[Size] +}; + + + +template +class uni_type_ptr +{ +public: + + static constexpr size_t Size = Size_; + + //*********************************** + template + T& get() + { + return *reinterpret_cast(pbuffer); + } + + //*********************************** + template + const T& get() const + { + return *reinterpret_cast(pbuffer); + } + + template + operator T() + { + return *reinterpret_cast(pbuffer); + } + + //*********************************** + constexpr size_t size() const + { + return Size; + } + +private: + + char* pbuffer; +}; \ No newline at end of file diff --git a/include/etl/functional.h b/include/etl/functional.h index 0c3f0f2c..5f274af1 100644 --- a/include/etl/functional.h +++ b/include/etl/functional.h @@ -232,7 +232,6 @@ namespace etl } //*************************************************************************** - template class binder2nd : public etl::unary_function { diff --git a/include/etl/generators/largest_generator.h b/include/etl/generators/largest_generator.h index 4f2512d1..0c3225a9 100644 --- a/include/etl/generators/largest_generator.h +++ b/include/etl/generators/largest_generator.h @@ -395,6 +395,14 @@ namespace etl using largest_t = typename largest::type; #endif +#if ETL_CPP17_SUPPORTED + template + inline constexpr size_t largest_size_v = largest::size; + + template + inline constexpr size_t largest_alignment_v = largest::alignment; +#endif + #else /*[[[cog import cog diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index b2d405fe..24653e00 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -135,6 +135,9 @@ namespace etl /// remove_reference template struct remove_reference { typedef T type; }; template struct remove_reference { typedef T type; }; +#if ETL_CPP11_SUPPORTED + template struct remove_reference { typedef T type; }; +#endif #if ETL_CPP11_SUPPORTED template @@ -449,61 +452,16 @@ namespace etl inline constexpr bool is_pod_v = etl::is_pod::value; #endif - //*************************************************************************** - /// is_trivially_constructible - /// Only POD types are recognised. - template struct is_trivially_constructible : etl::is_pod {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible::value; -#endif - - //*************************************************************************** - /// is_trivially_copy_constructible - /// Only POD types are recognised. - template struct is_trivially_copy_constructible : etl::is_pod {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible::value; -#endif - - //*************************************************************************** - /// is_trivially_destructible - /// Only POD types are recognised. - template struct is_trivially_destructible : etl::is_pod {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible::value; -#endif - - //*************************************************************************** - /// is_trivially_copy_assignable - /// Only POD types are recognised. - template struct is_trivially_copy_assignable : etl::is_pod {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable::value; -#endif - - //*************************************************************************** - /// is_trivially_copyable - /// Only POD types are recognised. - template struct is_trivially_copyable : etl::is_pod {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; -#endif - //*************************************************************************** /// conditional template struct conditional { typedef T type; }; template struct conditional { typedef F type; }; +#if ETL_CPP11_SUPPORTED + template + using conditional_t = typename conditional::type; +#endif + //*************************************************************************** /// make_signed template struct make_signed { typedef T type; }; @@ -645,7 +603,7 @@ namespace etl /// is_base_of template::value || etl::is_fundamental::value)> + const bool IsFundamental = (etl::is_fundamental::value || etl::is_fundamental::value || etl::is_array::value)> struct is_base_of { private: @@ -653,8 +611,10 @@ namespace etl template struct dummy {}; struct internal: TDerived, dummy{}; - static TBase* check(TBase*); - template static char check(dummy*); + static TBase* check(TBase*) { return (TBase*)0; } + + template + static char check(dummy*) { return 0; } public: @@ -781,6 +741,7 @@ namespace etl /// Specialisation of 'alignment_of' for 'void'. ///\ingroup type_traits template <> struct alignment_of : integral_constant {}; + template <> struct alignment_of : integral_constant {}; #if ETL_CPP17_SUPPORTED template @@ -1094,134 +1055,17 @@ namespace etl #endif #endif -#if !defined(ARDUINO) && ETL_NOT_USING_STLPORT && defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED) - //*************************************************************************** - /// is_trivially_constructible - ///\ingroup type_traits - template struct is_trivially_constructible : std::is_trivially_constructible {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_constructible_v = std::is_trivially_constructible_v; -#endif - - //*************************************************************************** - /// is_trivially_copy_constructible - ///\ingroup type_traits - template struct is_trivially_copy_constructible : std::is_trivially_copy_constructible {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_constructible_v = std::is_trivially_copy_constructible_v; -#endif - - //*************************************************************************** - /// is_trivially_destructible - ///\ingroup type_traits - template struct is_trivially_destructible : std::is_trivially_destructible {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_destructible_v = std::is_trivially_destructible_v; -#endif - - //*************************************************************************** - /// is_trivially_copy_assignable - ///\ingroup type_traits - template struct is_trivially_copy_assignable : std::is_trivially_copy_assignable {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_assignable_v = std::is_trivially_copy_assignable_v; -#endif - - //*************************************************************************** - /// is_trivially_copyable - ///\ingroup type_traits - template struct is_trivially_copyable : std::is_trivially_copyable {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copyable_v = std::is_trivially_copyable_v; -#endif -#else - //*************************************************************************** - /// is_trivially_constructible - ///\ingroup type_traits -#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - template struct is_trivially_constructible : std::is_trivially_constructible {}; -#else - template struct is_trivially_constructible : std::is_pod {}; -#endif - - #if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible::value; - #endif - - //*************************************************************************** - /// is_trivially_copy_constructible - ///\ingroup type_traits -#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - template struct is_trivially_copy_constructible : std::is_trivially_copy_constructible {}; -#else - template struct is_trivially_copy_constructible : std::is_pod {}; -#endif - - #if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible::value; - #endif - - //*************************************************************************** - /// is_trivially_destructible - ///\ingroup type_traits -#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - template struct is_trivially_destructible : std::is_trivially_destructible {}; -#else - template struct is_trivially_destructible : std::is_pod {}; -#endif - - #if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible::value; - #endif - - //*************************************************************************** - /// is_trivially_copy_assignable - ///\ingroup type_traits -#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - template struct is_trivially_copy_assignable : std::is_trivially_copy_assignable {}; -#else - template struct is_trivially_copy_assignable : std::is_pod {}; -#endif - - #if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable::value; - #endif - - //*************************************************************************** - /// is_trivially_copyable - ///\ingroup type_traits -#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - template struct is_trivially_copyable : std::is_trivially_copyable {}; -#else - template struct is_trivially_copyable : std::is_pod {}; -#endif - - #if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; - #endif -#endif - //*************************************************************************** /// conditional ///\ingroup type_traits template struct conditional { typedef T type; }; template struct conditional { typedef F type; }; +#if ETL_CPP11_SUPPORTED + template + using conditional_t = typename conditional::type; +#endif + //*************************************************************************** /// make_signed ///\ingroup type_traits @@ -1617,6 +1461,506 @@ namespace etl #if ETL_CPP17_SUPPORTED template inline constexpr bool are_all_same_v = are_all_same::value; +#endif + + //*************************************************************************** + /// conjunction +#if ETL_CPP11_SUPPORTED + template + struct conjunction : public etl::true_type + { + }; + + template + struct conjunction : public etl::conditional_t, T1> + { + }; + + template + struct conjunction : public T + { + }; +#endif + +#if ETL_CPP17_SUPPORTED + template + inline constexpr bool conjunction_v = conjunction::value; +#endif + + //*************************************************************************** + /// disjunction +#if ETL_CPP11_SUPPORTED + template + struct disjunction : public etl::false_type + { + }; + + template + struct disjunction : public etl::conditional_t> + { + }; + + template struct disjunction : public T1 + { + }; +#endif + +#if ETL_CPP17_SUPPORTED + template + inline constexpr bool disjunction_v = etl::disjunction::value; +#endif + + //*************************************************************************** +#if ETL_CPP11_SUPPORTED && ETL_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) && ((!defined(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)) + + //********************************************* + // Use the STL's definitions. + //********************************************* + + //********************************************* + // is_assignable + template + struct is_assignable : public std::is_assignable + { + }; + + //********************************************* + // is_constructible + template + struct is_constructible : public std::is_constructible + { + }; + + //********************************************* + // is_copy_constructible + template + struct is_copy_constructible : public std::is_copy_constructible + { + }; + + //********************************************* + // is_move_constructible + template + struct is_move_constructible : public std::is_move_constructible + { + }; + + //********************************************* + // is_trivially_constructible +#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template + struct is_trivially_constructible : public std::is_trivially_constructible + { + }; +#else + template ::value || etl::is_pointer::value> + struct is_trivially_constructible; + + template + struct is_trivially_constructible : public etl::true_type + { + }; + + template + struct is_trivially_constructible; +#endif + + //*************************************************************************** + // is_trivially_copy_constructible +#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template + struct is_trivially_copy_constructible : public std::is_trivially_copy_constructible + { + }; +#else + template ::value || etl::is_pointer::value> + struct is_trivially_copy_constructible; + + template + struct is_trivially_copy_constructible : public etl::true_type + { + }; + + template + struct is_trivially_copy_constructible; +#endif + + //*************************************************************************** + // is_trivially_destructible +#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template + struct is_trivially_destructible : public std::is_trivially_destructible + { + }; +#else + template ::value || etl::is_pointer::value> + struct is_trivially_destructible; + + template + struct is_trivially_destructible : public etl::true_type + { + }; + + template + struct is_trivially_destructible; +#endif + + //*************************************************************************** + // is_trivially_copy_assignable +#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template + struct is_trivially_copy_assignable : public std::is_trivially_copy_assignable + { + }; +#else + template ::value || etl::is_pointer::value> + struct is_trivially_copy_assignable; + + template + struct is_trivially_copy_assignable : public etl::true_type + { + }; + + template + struct is_trivially_copy_assignable; +#endif + + //*************************************************************************** + // is_trivially_copyable +#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template + struct is_trivially_copyable : public std::is_trivially_copyable + { + }; +#else + template ::value || etl::is_pointer::value> + struct is_trivially_copyable; + + template + struct is_trivially_copyable : public etl::true_type + { + }; + + template + struct is_trivially_copyable; +#endif + +#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) + + //********************************************* + // Use the compiler's builtins. + //********************************************* + + //********************************************* + // is_assignable + template + struct is_assignable : public etl::bool_constant<__is_assignable(T1, T2)> + { + }; + +#if ETL_CPP11_SUPPORTED + //********************************************* + // is_constructible + template + struct is_constructible : public etl::bool_constant<__is_constructible(T, TArgs...)> + { + }; +#endif + + //********************************************* + // is_copy_constructible + template + struct is_copy_constructible : public etl::is_constructible> + { + }; + + //********************************************* + // is_move_constructible + template + struct is_move_constructible : public etl::is_constructible + { + }; + + //********************************************* + // is_trivially_constructible + template + struct is_trivially_constructible : public etl::bool_constant<__is_trivially_constructible(T)> + { + }; + + //*************************************************************************** + // is_trivially_copy_constructible + template + struct is_trivially_copy_constructible : public etl::bool_constant<__is_trivially_copyable(T)> + { + }; + + //*************************************************************************** + // is_trivially_destructible + template + struct is_trivially_destructible : public etl::bool_constant<__is_trivially_destructible(T)> + { + }; + + //*************************************************************************** + // is_trivially_copy_assignable + template + struct is_trivially_copy_assignable : public etl::bool_constant<__is_trivially_copyable(T)> + { + }; + + //*************************************************************************** + // is_trivially_copyable + template + struct is_trivially_copyable : public etl::bool_constant<__is_trivially_copyable(T)> + { + }; + +#elif defined(ETL_USER_DEFINED_TYPE_TRAITS) + + //********************************************* + // Force the user to provide specialisations for + // anything other than arithmetics and pointers. + //********************************************* + + //********************************************* + // is_assignable + template ::value || etl::is_pointer::value) && (etl::is_arithmetic::value || etl::is_pointer::value)> + struct is_assignable; + + template + struct is_assignable : public etl::true_type + { + }; + + template + struct is_assignable; + +#if ETL_CPP11_SUPPORTED + //********************************************* + // is_constructible + template + struct is_constructible_helper; + + template + struct is_constructible_helper : public etl::true_type + { + }; + + template + struct is_constructible_helper; + + template + struct is_constructible : public is_constructible_helper::value || etl::is_pointer::value, TArgs...> + { + }; +#endif + + //********************************************* + // is_copy_constructible + template ::value || etl::is_pointer::value> + struct is_copy_constructible; + + template + struct is_copy_constructible : public etl::true_type + { + }; + + template + struct is_copy_constructible; + + //********************************************* + // is_move_constructible + template ::value || etl::is_pointer::value> + struct is_move_constructible; + + template + struct is_move_constructible : public etl::true_type + { + }; + + template + struct is_move_constructible; + + //********************************************* + // is_trivially_constructible + template ::value || etl::is_pointer::value> + struct is_trivially_constructible; + + template + struct is_trivially_constructible : public etl::true_type + { + }; + + template + struct is_trivially_constructible; + + //*************************************************************************** + // is_trivially_copy_constructible + template ::value || etl::is_pointer::value> + struct is_trivially_copy_constructible; + + template + struct is_trivially_copy_constructible : public etl::true_type + { + }; + + template + struct is_trivially_copy_constructible; + + //*************************************************************************** + // is_trivially_destructible + template ::value || etl::is_pointer::value> + struct is_trivially_destructible; + + template + struct is_trivially_destructible : public etl::true_type + { + }; + + template + struct is_trivially_destructible; + + //*************************************************************************** + // is_trivially_copy_assignable + template ::value || etl::is_pointer::value> + struct is_trivially_copy_assignable; + + template + struct is_trivially_copy_assignable : public etl::true_type + { + }; + + template + struct is_trivially_copy_assignable; + + //*************************************************************************** + // is_trivially_copyable + template ::value || etl::is_pointer::value> + struct is_trivially_copyable; + + template + struct is_trivially_copyable : public etl::true_type + { + }; + + template + struct is_trivially_copyable; + +#else + + //********************************************* + // Assume that anything other than arithmetics + // and pointers return false for the traits. + //********************************************* + + //********************************************* + // is_assignable + template + struct is_assignable : public etl::bool_constant<(etl::is_arithmetic::value || etl::is_pointer::value) && (etl::is_arithmetic::value || etl::is_pointer::value)> + { + }; + +#if ETL_CPP11_SUPPORTED + //********************************************* + // is_constructible + template + struct is_constructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; +#endif + + //********************************************* + // is_copy_constructible + template + struct is_copy_constructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //********************************************* + // is_move_constructible + template + struct is_move_constructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //********************************************* + // is_trivially_constructible + template + struct is_trivially_constructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //*************************************************************************** + // is_trivially_copy_constructible + template + struct is_trivially_copy_constructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //*************************************************************************** + // is_trivially_destructible + template + struct is_trivially_destructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //*************************************************************************** + // is_trivially_copy_assignable + template + struct is_trivially_copy_assignable : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //*************************************************************************** + // is_trivially_copyable + template + struct is_trivially_copyable : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + +#endif + + template + struct is_lvalue_assignable : public etl::is_assignable::type, + typename etl::add_lvalue_reference::type>::type> + { + }; + +#if ETL_CPP17_SUPPORTED + + template + inline constexpr bool is_assignable_v = etl::is_assignable::value; + + template + inline constexpr bool is_lvalue_assignable_v = etl::is_lvalue_assignable::value; + + template + inline constexpr bool is_constructible_v = etl::is_constructible::value; + + template + inline constexpr bool is_copy_constructible_v = etl::is_copy_constructible::value; + + template + inline constexpr bool is_move_constructible_v = etl::is_move_constructible::value; + + template + inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible::value; + + template + inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible::value; + + template + inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible::value; + + template + inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable::value; + + template + inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; + #endif } diff --git a/include/etl/overload.h b/include/etl/overload.h new file mode 100644 index 00000000..259aebeb --- /dev/null +++ b/include/etl/overload.h @@ -0,0 +1,89 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 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_OVERLOAD_INCLUDED +#define ETL_OVERLOAD_INCLUDED + +#include "platform.h" +#include "utility.h" +#include "type_traits.h" + +namespace etl +{ +#if ETL_CPP11_SUPPORTED +#if ETL_CPP17_SUPPORTED && !defined(ETL_OVERLOAD_FORCE_CPP14) + + //************************************************************************* + /// Variadic template definition of overload for C++17 and above. + //************************************************************************* + template + struct overload : TOverloads... + { + using TOverloads::operator()...; + }; + + //************************************************************************* + /// Template deduction guide. + //************************************************************************* + template overload(TOverloads...)->overload; + +#else + + //************************************************************************* + /// Variadic template definition of overload for C++14. + //************************************************************************* + template + struct overload : TFirst, overload + { + using TFirst::operator(); + using overload::operator(); + }; + + template + struct overload : TFirst + { + using TFirst::operator(); + }; + +#endif + + //************************************************************************* + /// Make an overload. + //************************************************************************* + template + constexpr overload make_overload(TOverloads&&... overloads) + { + return overload{ etl::forward(overloads)... }; + } + +#endif +} + +#endif diff --git a/include/etl/parameter_pack.h b/include/etl/parameter_pack.h index 1068d248..43942a9b 100644 --- a/include/etl/parameter_pack.h +++ b/include/etl/parameter_pack.h @@ -77,7 +77,7 @@ namespace etl static_assert(etl::is_one_of::value, "T is not in parameter pack"); - /// The idex value. + /// The index value. static constexpr size_t value = index_of_type_helper::value - 1; }; @@ -120,6 +120,14 @@ namespace etl template using type_from_index_t = typename type_from_index::type; }; + + template + using parameter_pack_t = typename etl::parameter_pack::template type_from_index_t; + +#if ETL_CPP17_SUPPORTED + template + inline constexpr size_t parameter_pack_v = etl::parameter_pack::template index_of_type::value; +#endif } #endif #endif diff --git a/include/etl/private/variant_legacy.h b/include/etl/private/variant_legacy.h new file mode 100644 index 00000000..cd85638e --- /dev/null +++ b/include/etl/private/variant_legacy.h @@ -0,0 +1,1028 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2014 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. +******************************************************************************/ + +#include + +#include "../platform.h" +#include "../utility.h" +#include "../array.h" +#include "../largest.h" +#include "../exception.h" +#include "../type_traits.h" +#include "../integral_limits.h" +#include "../static_assert.h" +#include "../alignment.h" +#include "../error_handler.h" +#include "../null_type.h" +#include "../placement_new.h" + +#if defined(ETL_COMPILER_KEIL) + #pragma diag_suppress 940 + #pragma diag_suppress 111 +#endif + +//***************************************************************************** +///\defgroup variant variant +/// A class that can contain one a several specified types in a type safe manner. +///\ingroup containers +//***************************************************************************** + +namespace etl +{ + namespace private_variant + { + //************************************************************************* + /// Placeholder for unused template parameters. + /// This class is never instantiated. + //************************************************************************* + template + struct no_type + { + }; + } + + //*************************************************************************** + /// Base exception for the variant class. + ///\ingroup variant + //*************************************************************************** + class variant_exception : public exception + { + public: + variant_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// 'Unsupported type' exception for the variant class. + ///\ingroup variant + //*************************************************************************** + class variant_incorrect_type_exception : public variant_exception + { + public: + variant_incorrect_type_exception(string_type file_name_, numeric_type line_number_) + : variant_exception(ETL_ERROR_TEXT("variant: unsupported type", ETL_VARIANT_FILE_ID"A"), file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// A template class that can store any of the types defined in the template parameter list. + /// Supports up to 8 types. + ///\ingroup variant + //*************************************************************************** + template , + typename T3 = etl::null_type<3>, + typename T4 = etl::null_type<4>, + typename T5 = etl::null_type<5>, + typename T6 = etl::null_type<6>, + typename T7 = etl::null_type<7>, + typename T8 = etl::null_type<8> > + class variant + { + public: + + //*************************************************************************** + /// The type used for ids. + //*************************************************************************** + typedef uint_least8_t type_id_t; + + //*************************************************************************** + /// The id a unsupported types. + //*************************************************************************** + static const type_id_t UNSUPPORTED_TYPE_ID = integral_limits::max; + + private: + + // All types of variant are friends. + template + friend class variant; + + //*************************************************************************** + /// The largest type. + //*************************************************************************** + typedef typename largest_type::type largest_t; + + //*************************************************************************** + /// The largest size. + //*************************************************************************** + static const size_t SIZE = sizeof(largest_t); + + //*************************************************************************** + /// The largest alignment. + //*************************************************************************** + static const size_t ALIGNMENT = etl::largest_alignment::value; + + //*************************************************************************** + /// Short form of no_type placeholders. + //*************************************************************************** + typedef etl::null_type<2> no_type2; + typedef etl::null_type<3> no_type3; + typedef etl::null_type<4> no_type4; + typedef etl::null_type<5> no_type5; + typedef etl::null_type<6> no_type6; + typedef etl::null_type<7> no_type7; + typedef etl::null_type<8> no_type8; + + //*************************************************************************** + /// Lookup the id of type. + //*************************************************************************** + template + struct Type_Id_Lookup + { + static const uint_least8_t type_id = etl::is_same::value ? 0 : + etl::is_same::value ? 1 : + etl::is_same::value ? 2 : + etl::is_same::value ? 3 : + etl::is_same::value ? 4 : + etl::is_same::value ? 5 : + etl::is_same::value ? 6 : + etl::is_same::value ? 7 : + UNSUPPORTED_TYPE_ID; + }; + + //*************************************************************************** + /// Lookup for the id of type. + //*************************************************************************** + template + struct Type_Is_Supported : public integral_constant::value || + is_same::value || + is_same::value || + is_same::value || + is_same::value || + is_same::value || + is_same::value || + is_same::value> + { + }; + + public: + + //*************************************************************************** + /// Destructor. + //*************************************************************************** + ~variant() + { + destruct_current(); + } + + //************************************************************************* + //**** Reader types ******************************************************* + //************************************************************************* + + //************************************************************************* + /// Base reader type functor class. + /// Allows for typesafe access to the stored value types. + /// Define the reader type for 8 types. + //************************************************************************* + template + class reader_type + { + public: + + friend class variant; + + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + }; + + //************************************************************************* + /// Define the reader type for 7 types. + //************************************************************************* + template + class reader_type + { + public: + + friend class variant; + + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + + private: + + void read(no_type8&) {}; + }; + + //************************************************************************* + /// Define the reader type for 6 types. + //************************************************************************* + template + class reader_type + { + public: + + friend class variant; + + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + + private: + + void read(no_type7&) {}; + void read(no_type8&) {}; + }; + + //************************************************************************* + /// Define the reader type for 5 types. + //************************************************************************* + template + class reader_type + { + public: + + friend class variant; + + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + + private: + + void read(no_type6&) {}; + void read(no_type7&) {}; + void read(no_type8&) {}; + }; + + //************************************************************************* + /// Define the reader type for 4 types. + //************************************************************************* + template + class reader_type + { + public: + + friend class variant; + + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + + private: + + void read(no_type5&) {}; + void read(no_type6&) {}; + void read(no_type7&) {}; + void read(no_type8&) {}; + }; + + //************************************************************************* + /// Define the reader type for 3 types. + //************************************************************************* + template + class reader_type + { + public: + + friend class variant; + + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + + private: + + void read(no_type4&) {}; + void read(no_type5&) {}; + void read(no_type6&) {}; + void read(no_type7&) {}; + void read(no_type8&) {}; + }; + + //************************************************************************* + /// Define the reader type for 2 types. + //************************************************************************* + template + class reader_type + { + public: + + friend class variant; + + virtual void read(typename etl::parameter_type::type value) = 0; + virtual void read(typename etl::parameter_type::type value) = 0; + + private: + + void read(no_type3&) {}; + void read(no_type4&) {}; + void read(no_type5&) {}; + void read(no_type6&) {}; + void read(no_type7&) {}; + void read(no_type8&) {}; + }; + + //************************************************************************* + /// Define the reader type for 1 type. + //************************************************************************* + template + class reader_type + { + public: + + friend class variant; + + virtual void read(typename etl::parameter_type::type value) = 0; + + private: + + void read(no_type2&) {}; + void read(no_type3&) {}; + void read(no_type4&) {}; + void read(no_type5&) {}; + void read(no_type6&) {}; + void read(no_type7&) {}; + void read(no_type8&) {}; + }; + + //*************************************************************************** + /// The base type for derived readers. + //*************************************************************************** + typedef reader_type reader; + + //*************************************************************************** + /// Default constructor. + /// Sets the state of the instance to containing no valid data. + //*************************************************************************** + variant() + : type_id(UNSUPPORTED_TYPE_ID) + { + } + + //*************************************************************************** + /// Constructor that catches any types that are not supported. + /// Forces a ETL_STATIC_ASSERT. + //*************************************************************************** + template + variant(const T& value) + { + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + + ::new (static_cast(data)) T(value); + type_id = Type_Id_Lookup::type_id; + } + + //*************************************************************************** + /// Copy constructor. + ///\param other The other variant object to copy. + //*************************************************************************** + variant(const variant& other) + { + switch (other.type_id) + { + case 0: ::new (static_cast(data)) T1(other.get()); break; + case 1: ::new (static_cast(data)) T2(other.get()); break; + case 2: ::new (static_cast(data)) T3(other.get()); break; + case 3: ::new (static_cast(data)) T4(other.get()); break; + case 4: ::new (static_cast(data)) T5(other.get()); break; + case 5: ::new (static_cast(data)) T6(other.get()); break; + case 6: ::new (static_cast(data)) T7(other.get()); break; + case 7: ::new (static_cast(data)) T8(other.get()); break; + default: break; + } + + type_id = other.type_id; + } + +#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && !defined(ETL_VARIANT_FORCE_CPP03) + //************************************************************************* + /// Emplace with variadic constructor parameters. + //************************************************************************* + template + T& emplace(Args&&... args) + { + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + + destruct_current(); + ::new (static_cast(data)) T(etl::forward(args)...); + type_id = Type_Id_Lookup::type_id; + + return *static_cast(data); + } +#else + //*************************************************************************** + /// Emplace with one constructor parameter. + //*************************************************************************** + template + T& emplace(const TP1& value1) + { + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + + destruct_current(); + ::new (static_cast(data)) T(value1); + type_id = Type_Id_Lookup::type_id; + + return *static_cast(data); + } + + //*************************************************************************** + /// Emplace with two constructor parameters. + //*************************************************************************** + template + T& emplace(const TP1& value1, const TP2& value2) + { + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + + destruct_current(); + ::new (static_cast(data)) T(value1, value2); + type_id = Type_Id_Lookup::type_id; + + return *static_cast(data); + } + + //*************************************************************************** + /// Emplace with three constructor parameters. + //*************************************************************************** + template + T& emplace(const TP1& value1, const TP2& value2, const TP3& value3) + { + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + + destruct_current(); + ::new (static_cast(data)) T(value1, value2, value3); + type_id = Type_Id_Lookup::type_id; + + return *static_cast(data); + } + + //*************************************************************************** + /// Emplace with four constructor parameters. + //*************************************************************************** + template + T& emplace(const TP1& value1, const TP2& value2, const TP3& value3, const TP4& value4) + { + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + + destruct_current(); + ::new (static_cast(data)) T(value1, value2, value3, value4); + type_id = Type_Id_Lookup::type_id; + + return *static_cast(data); + } +#endif + + //*************************************************************************** + /// Assignment operator for T1 type. + ///\param value The value to assign. + //*************************************************************************** + template + variant& operator =(const T& value) + { + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + + destruct_current(); + ::new (static_cast(data)) T(value); + type_id = Type_Id_Lookup::type_id; + + return *this; + } + + //*************************************************************************** + /// Assignment operator for variant type. + ///\param other The variant to assign. + //*************************************************************************** + variant& operator =(const variant& other) + { + if (this != &other) + { + destruct_current(); + + switch (other.type_id) + { + case 0: ::new (static_cast(data)) T1(other.get()); break; + case 1: ::new (static_cast(data)) T2(other.get()); break; + case 2: ::new (static_cast(data)) T3(other.get()); break; + case 3: ::new (static_cast(data)) T4(other.get()); break; + case 4: ::new (static_cast(data)) T5(other.get()); break; + case 5: ::new (static_cast(data)) T6(other.get()); break; + case 6: ::new (static_cast(data)) T7(other.get()); break; + case 7: ::new (static_cast(data)) T8(other.get()); break; + default: break; + } + + type_id = other.type_id; + } + + return *this; + } + + //*************************************************************************** + /// Checks if the type is the same as the current stored type. + /// For variants with the same type declarations. + ///\return true if the types are the same, otherwise false. + //*************************************************************************** + bool is_same_type(const variant& other) const + { + return type_id == other.type_id; + } + + //*************************************************************************** + /// Checks if the type is the same as the current stored type. + /// For variants with differing declarations. + ///\return true if the types are the same, otherwise false. + //*************************************************************************** + template + bool is_same_type(const variant& other) const + { + bool is_same = false; + + switch (other.type_id) + { + case 0: is_same = (type_id == Type_Id_Lookup::type_id); break; + case 1: is_same = (type_id == Type_Id_Lookup::type_id); break; + case 2: is_same = (type_id == Type_Id_Lookup::type_id); break; + case 3: is_same = (type_id == Type_Id_Lookup::type_id); break; + case 4: is_same = (type_id == Type_Id_Lookup::type_id); break; + case 5: is_same = (type_id == Type_Id_Lookup::type_id); break; + case 6: is_same = (type_id == Type_Id_Lookup::type_id); break; + case 7: is_same = (type_id == Type_Id_Lookup::type_id); break; + default: break; + } + + return is_same; + } + + //*************************************************************************** + /// Calls the supplied reader instance. + /// The 'read' function appropriate to the current type is called with the stored value. + //*************************************************************************** + void call(reader& r) + { + switch (type_id) + { + case 0: r.read(static_cast(data)); break; + case 1: r.read(static_cast(data)); break; + case 2: r.read(static_cast(data)); break; + case 3: r.read(static_cast(data)); break; + case 4: r.read(static_cast(data)); break; + case 5: r.read(static_cast(data)); break; + case 6: r.read(static_cast(data)); break; + case 7: r.read(static_cast(data)); break; + default: break; + } + } + + //*************************************************************************** + /// Checks whether a valid value is currently stored. + ///\return true if the value is valid, otherwise false. + //*************************************************************************** + bool is_valid() const + { + return type_id != UNSUPPORTED_TYPE_ID; + } + + //*************************************************************************** + /// Checks to see if the type currently stored is the same as that specified in the template parameter. + ///\return true if it is the specified type, otherwise false. + //*************************************************************************** + template + bool is_type() const + { + return type_id == Type_Id_Lookup::type_id; + } + + //*************************************************************************** + /// Gets the index of the type currently stored or UNSUPPORTED_TYPE_ID + //*************************************************************************** + size_t index() const + { + return type_id; + } + + //*************************************************************************** + /// Clears the value to 'no valid stored value'. + //*************************************************************************** + void clear() + { + destruct_current(); + } + + //*************************************************************************** + /// Gets the value stored as the specified template type. + /// Throws a variant_incorrect_type_exception if the actual type is not that specified. + ///\return A reference to the value. + //*************************************************************************** + template + T& get() + { + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_ASSERT(is_type(), ETL_ERROR(variant_incorrect_type_exception)); + + return static_cast(data); + } + + //*************************************************************************** + /// Gets the value stored as the specified template type. + /// Throws a variant_incorrect_type_exception if the actual type is not that specified. + ///\return A const reference to the value. + //*************************************************************************** + template + const T& get() const + { + ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + ETL_ASSERT(is_type(), ETL_ERROR(variant_incorrect_type_exception)); + + return static_cast(data); + } + + //*************************************************************************** + /// Gets the value stored as the specified template type. + ///\return A reference to the value. + //*************************************************************************** + template + TBase& upcast() + { + return *upcast_functor()(data, type_id); + } + + //*************************************************************************** + /// Gets the value stored as the specified template type. + ///\return A const reference to the value. + //*************************************************************************** + template + const TBase& upcast() const + { + return *upcast_functor()(data, type_id); + } + + //*************************************************************************** + /// Conversion operators for each type. + //*************************************************************************** + operator T1&() { return get(); } + operator T2&() { return get(); } + operator T3&() { return get(); } + operator T4&() { return get(); } + operator T5&() { return get(); } + operator T6&() { return get(); } + operator T7&() { return get(); } + operator T8&() { return get(); } + + //*************************************************************************** + /// Checks if the template type is supported by the implementation of variant.. + ///\return true if the type is supported, otherwise false. + //*************************************************************************** + template + static bool is_supported_type() + { + return Type_Is_Supported::value; + } + + private: + + //*************************************************************************** + /// Destruct the current occupant of the variant. + //*************************************************************************** + void destruct_current() + { + switch (type_id) + { + case 0: { static_cast(data)->~T1(); break; } + case 1: { static_cast(data)->~T2(); break; } + case 2: { static_cast(data)->~T3(); break; } + case 3: { static_cast(data)->~T4(); break; } + case 4: { static_cast(data)->~T5(); break; } + case 5: { static_cast(data)->~T6(); break; } + case 6: { static_cast(data)->~T7(); break; } + case 7: { static_cast(data)->~T8(); break; } + default: { break; } + } + + type_id = UNSUPPORTED_TYPE_ID; + } + + //************************************************************************* + //**** Up-cast functors *************************************************** + //************************************************************************* + + //************************************************************************* + /// Base upcast_functor for eight types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + case 6: return reinterpret_cast(p_data); + case 7: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + case 6: return reinterpret_cast(p_data); + case 7: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for seven types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + case 6: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + case 6: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for six types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + case 5: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for five types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + case 4: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for four types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + case 3: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for three types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + case 2: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for two types. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + case 1: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //************************************************************************* + /// Upcast_functor for one type. + //************************************************************************* + template + class upcast_functor + { + public: + + TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + + const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const + { + switch (typeId) + { + case 0: return reinterpret_cast(p_data); + default: return reinterpret_cast(0); + } + } + }; + + //*************************************************************************** + /// The internal storage. + /// Aligned on a suitable boundary, which should be good for all types. + //*************************************************************************** + typename etl::aligned_storage::type data; + + //*************************************************************************** + /// The id of the current stored type. + //*************************************************************************** + type_id_t type_id; + }; +} diff --git a/include/etl/private/variant_variadic.h b/include/etl/private/variant_variadic.h new file mode 100644 index 00000000..06ff1933 --- /dev/null +++ b/include/etl/private/variant_variadic.h @@ -0,0 +1,1272 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 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. +******************************************************************************/ + +#include + +#include "../platform.h" +#include "../utility.h" +#include "../largest.h" +#include "../exception.h" +#include "../type_traits.h" +#include "../integral_limits.h" +#include "../static_assert.h" +#include "../alignment.h" +#include "../error_handler.h" +#include "../parameter_pack.h" +#include "../placement_new.h" +#include "../visitor.h" +#include "../memory.h" + +#if defined(ETL_COMPILER_KEIL) + #pragma diag_suppress 940 + #pragma diag_suppress 111 +#endif + +#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL + #include +#endif + +#if ETL_CPP11_NOT_SUPPORTED + #if !defined(ETL_IN_UNIT_TEST) + #error NOT SUPPORTED FOR C++03 OR BELOW + #endif +#else +//***************************************************************************** +///\defgroup variant variant +/// A class that can contain one a several specified types in a type safe manner. +///\ingroup containers +//***************************************************************************** + +namespace etl +{ + namespace private_variant + { + //*************************************************************************** + // This is a copy of the normal etl::parameter_pack, but without the static_assert + // so that the C++11 versions of do_accept() & do_operator() do not throw a compile time error. + //*************************************************************************** + template + class parameter_pack + { + public: + + static constexpr size_t size = sizeof...(TTypes); + + //*************************************************************************** + /// index_of_type + //*************************************************************************** + template + class index_of_type + { + private: + + using type = etl::remove_reference_t; + + //*********************************** + template + struct index_of_type_helper + { + static constexpr size_t value = etl::is_same::value ? 1 : 1 + index_of_type_helper::value; + }; + + //*********************************** + template + struct index_of_type_helper + { + static constexpr size_t value = 1; + }; + + public: + + static_assert(etl::is_one_of::value, "T is not in parameter pack"); + + /// The index value. + static constexpr size_t value = index_of_type_helper::value - 1; + }; + + //*************************************************************************** + /// type_from_index + //*************************************************************************** + template + class type_from_index + { + private: + + //*********************************** + template + struct type_from_index_helper + { + using type = typename etl::conditional::type>::type; + }; + + //*********************************** + template + struct type_from_index_helper + { + using type = T1; + }; + + public: + + /// Template alias + using type = typename type_from_index_helper::type; + }; + + //*********************************** + template + using type_from_index_t = typename type_from_index::type; + }; + + //******************************************* + // The traits an object may have. + //******************************************* + static constexpr bool Copyable = true; + static constexpr bool Non_Copyable = false; + static constexpr bool Moveable = true; + static constexpr bool Non_Moveable = false; + + //******************************************* + // The types of operations we can perform. + //******************************************* + static constexpr int Copy = 0; + static constexpr int Move = 1; + static constexpr int Destroy = 2; + + //******************************************* + // operation_type + //******************************************* + template + struct operation_type; + + //******************************************* + // Specialisation for null operation. + template <> + struct operation_type + { + static void do_operation(int operation, char* pstorage, const char* pvalue) + { + // This should never occur. +#if defined(ETL_IN_UNIT_TEST) + assert(false); +#endif + } + }; + + //******************************************* + // Specialisation for no-copyable & non-moveable types. + template + struct operation_type + { + static void do_operation(int operation, char* pstorage, const char* pvalue) + { + switch (operation) + { + case Destroy: + { + reinterpret_cast(pstorage)->~T(); + break; + } + + default: + { + // This should never occur. + #if defined(ETL_IN_UNIT_TEST) + assert(false); + #endif + break; + } + } + } + }; + + //******************************************* + // Specialisation for no-copyable & moveable types. + template + struct operation_type + { + static void do_operation(int operation, char* pstorage, const char* pvalue) + { + switch (operation) + { + case Move: + { + ::new (pstorage) T(etl::move(*reinterpret_cast(const_cast(pvalue)))); + break; + } + + case Destroy: + { + reinterpret_cast(pstorage)->~T(); + break; + } + + default: + { + // This should never occur. + #if defined(ETL_IN_UNIT_TEST) + assert(false); + #endif + break; + } + } + } + }; + + //******************************************* + // Specialisation for copyable & non-moveable types. + template + struct operation_type + { + static void do_operation(int operation, char* pstorage, const char* pvalue) + { + switch (operation) + { + case Copy: + { + ::new (pstorage) T(*reinterpret_cast(pvalue)); + break; + } + + case Destroy: + { + reinterpret_cast(pstorage)->~T(); + break; + } + + default: + { + // This should never occur. + #if defined(ETL_IN_UNIT_TEST) + assert(false); + #endif + break; + } + } + } + }; + + //******************************************* + // Specialisation for copyable & moveable types. + template + struct operation_type + { + static void do_operation(int operation, char* pstorage, const char* pvalue) + { + switch (operation) + { + case Copy: + { + ::new (pstorage) T(*reinterpret_cast(pvalue)); + break; + } + + case Move: + { + ::new (pstorage) T(etl::move(*reinterpret_cast(const_cast(pvalue)))); + break; + } + + case Destroy: + { + reinterpret_cast(pstorage)->~T(); + break; + } + + default: + { + // This should never occur. +#if defined(ETL_IN_UNIT_TEST) + assert(false); +#endif + break; + } + } + } + }; + } + + /// Definition of variant_npos. + constexpr size_t variant_npos = etl::integral_limits::max; + + //*********************************** + // variant. Forward declaration + template + class variant; + + //*************************************************************************** + /// variant_alternative + //*************************************************************************** + template + struct variant_alternative; + + template + struct variant_alternative> + { + using type = typename etl::private_variant::parameter_pack::template type_from_index::type; + }; + + template + struct variant_alternative + { + using type = typename variant_alternative::type; + }; + + template + using variant_alternative_t = typename variant_alternative::type; + + //*********************************** + // holds_alternative. Forward declaration + template + ETL_CONSTEXPR14 bool holds_alternative(const etl::variant& v) noexcept; + + //*********************************** + // get. Forward declarations + template + ETL_CONSTEXPR14 etl::variant_alternative_t>& + get(etl::variant& v); + + template + ETL_CONSTEXPR14 etl::variant_alternative_t>&& + get(etl::variant&& v); + + template + ETL_CONSTEXPR14 const etl::variant_alternative_t>& + get(const etl::variant& v); + + template + ETL_CONSTEXPR14 const etl::variant_alternative_t>&& + get(const etl::variant&& v); + + template + ETL_CONSTEXPR14 T& get(etl::variant& v); + + template + ETL_CONSTEXPR14 T&& get(etl::variant&& v); + + template + ETL_CONSTEXPR14 const T& get(const etl::variant& v); + + template + ETL_CONSTEXPR14 const T&& get(const etl::variant&& v); + + //*************************************************************************** + /// 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; } + constexpr bool operator <=(etl::monostate, etl::monostate) noexcept { return true; } + constexpr bool operator >=(etl::monostate, etl::monostate) noexcept { return true; } + constexpr bool operator ==(etl::monostate, etl::monostate) noexcept { return true; } + +#if ETL_NOT_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) + template <> + struct is_copy_constructible : public etl::true_type + { + }; + + template <> + struct is_move_constructible : public etl::true_type + { + }; +#endif + + //*************************************************************************** + /// Base exception for the variant class. + ///\ingroup variant + //*************************************************************************** + class variant_exception : public exception + { + public: + variant_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// 'Unsupported type' exception for the variant class. + ///\ingroup variant + //*************************************************************************** + class variant_incorrect_type_exception : public variant_exception + { + public: + variant_incorrect_type_exception(string_type file_name_, numeric_type line_number_) + : variant_exception(ETL_ERROR_TEXT("variant:unsupported type", ETL_VARIANT_FILE_ID"A"), file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// A template class that can store any of the types defined in the template parameter list. + /// Supports up to 8 types. + ///\ingroup variant + //*************************************************************************** + template + class variant + { + public: + + //*************************************************************************** + /// The type used for ids. + //*************************************************************************** + using type_id_t = uint_least8_t ; + + //*************************************************************************** + /// get() is a friend function. + //*************************************************************************** + template + friend ETL_CONSTEXPR14 etl::variant_alternative_t>& + get(etl::variant& v); + + template + friend ETL_CONSTEXPR14 etl::variant_alternative_t>&& + get(etl::variant&& v); + + template + friend ETL_CONSTEXPR14 const etl::variant_alternative_t>& + get(const etl::variant& v); + + template + friend ETL_CONSTEXPR14 const etl::variant_alternative_t>&& + get(const etl::variant&& v); + + template + friend ETL_CONSTEXPR14 T& get(etl::variant& v); + + template + friend ETL_CONSTEXPR14 T&& get(etl::variant&& v); + + template + friend ETL_CONSTEXPR14 const T& get(const etl::variant& v); + + template + friend ETL_CONSTEXPR14 const T&& get(const etl::variant&& v); + + private: + + // All types of variant are friends. + template + friend class variant; + + //*************************************************************************** + /// The largest type. + //*************************************************************************** + using largest_t = typename largest_type::type; + + //*************************************************************************** + /// The largest size. + //*************************************************************************** + static const size_t Size = sizeof(largest_t); + + //*************************************************************************** + /// The largest alignment. + //*************************************************************************** + static const size_t Alignment = etl::largest_alignment::value; + + //*************************************************************************** + /// The operation templates. + //*************************************************************************** + template + using operation_type = private_variant::operation_type; + + //******************************************* + // The types of operations we can perform. + //******************************************* + static constexpr int Copy = private_variant::Copy; + static constexpr int Move = private_variant::Move; + static constexpr int Destroy = private_variant::Destroy; + + public: + + //*************************************************************************** + /// Default constructor. + /// Sets the state of the instance to containing no valid data. + //*************************************************************************** + ETL_CONSTEXPR14 variant() + : data() + { + using type = typename etl::private_variant::parameter_pack::template type_from_index<0U>::type; + + default_construct_in_place(data); + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + type_id = 0U; + } + + //*************************************************************************** + /// Constructor from a value. + //*************************************************************************** + template , variant>::value, int> = 0> + ETL_CONSTEXPR14 variant(T&& value) + : data() + , operation(operation_type, etl::is_copy_constructible>::value, etl::is_move_constructible>::value>::do_operation) + , type_id(etl::private_variant::parameter_pack::template index_of_type>::value) + { + static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); + + construct_in_place>(data, etl::forward(value)); + } + + //*************************************************************************** + /// Construct from arguments. + //*************************************************************************** + template + ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t, TArgs&&... args) + : data() + , operation(operation_type, etl::is_copy_constructible>::value, etl::is_move_constructible>::value>::do_operation) + , type_id(etl::private_variant::parameter_pack::template index_of_type>::value) + { + static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); + + construct_in_place_args>(data, etl::forward(args)...); + } + + //*************************************************************************** + /// Construct from arguments. + //*************************************************************************** + template + ETL_CONSTEXPR14 explicit variant(etl::in_place_index_t, TArgs&&... args) + : data() + , type_id(Index) + { + using type = typename private_variant::parameter_pack:: template type_from_index_t; + static_assert(etl::is_one_of ::value, "Unsupported type"); + + construct_in_place_args(data, etl::forward(args)...); + + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + } + +#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL + //*************************************************************************** + /// Construct from type, initializer_list and arguments. + //*************************************************************************** + template + ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t, std::initializer_list init, TArgs&&... args) + : data() + , operation(operation_type, etl::is_copy_constructible>::value, etl::is_move_constructible>::value>::do_operation) + , type_id(private_variant::parameter_pack:: template index_of_type>::value) + { + static_assert(etl::is_one_of, TTypes...> ::value, "Unsupported type"); + + construct_in_place_args>(data, init, etl::forward(args)...); + } + + //*************************************************************************** + /// Construct from index, initializer_list and arguments. + //*************************************************************************** + template + ETL_CONSTEXPR14 explicit variant(etl::in_place_index_t, std::initializer_list init, TArgs&&... args) + : data() + , type_id(Index) + { + using type = typename private_variant::parameter_pack:: template type_from_index_t; + static_assert(etl::is_one_of ::value, "Unsupported type"); + + construct_in_place_args(data, init, etl::forward(args)...); + + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + } +#endif + + //*************************************************************************** + /// Copy constructor. + ///\param other The other variant object to copy. + //*************************************************************************** + ETL_CONSTEXPR14 variant(const variant& other) + : data() + , operation(other.operation) + , type_id(other.type_id) + { + if (this != &other) + { + if (other.index() == variant_npos) + { + type_id = variant_npos; + } + else + { + operation(private_variant::Copy, data, other.data); + } + } + } + + //*************************************************************************** + /// Move constructor. + ///\param other The other variant object to copy. + //*************************************************************************** + ETL_CONSTEXPR14 variant(variant&& other) + : data() + , operation(other.operation) + , type_id(other.type_id) + { + if (this != &other) + { + if (other.index() == variant_npos) + { + type_id = variant_npos; + } + else + { + operation(private_variant::Move, data, other.data); + } + } + else + { + type_id = variant_npos; + } + } + + //*************************************************************************** + /// Destructor. + //*************************************************************************** + ~variant() + { + if (index() != variant_npos) + { + operation(private_variant::Destroy, data, nullptr); + } + + operation = operation_type::do_operation; // Null operation. + type_id = variant_npos; + } + + //*************************************************************************** + /// Emplace with variadic constructor parameters. + //*************************************************************************** + template + T& emplace(TArgs&&... args) + { + static_assert(etl::is_one_of::value, "Unsupported type"); + + using type = etl::remove_reference_t; + + operation(private_variant::Destroy, data, nullptr); + + construct_in_place_args(data, etl::forward(args)...); + + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + + type_id = etl::private_variant::parameter_pack::template index_of_type::value; + + return *static_cast(data); + } + + //*************************************************************************** + /// Move assignment operator for type. + ///\param value The value to assign. + //*************************************************************************** + template , variant>::value, int> = 0> + variant& operator =(T&& value) + { + using type = etl::remove_reference_t; + + static_assert(etl::is_one_of::value, "Unsupported type"); + + operation(private_variant::Destroy, data, nullptr); + + construct_in_place(data, etl::forward(value)); + + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + type_id = etl::private_variant::parameter_pack::template index_of_type::value; + + return *this; + } + + //*************************************************************************** + /// Assignment operator for variant type. + ///\param other The variant to assign. + //*************************************************************************** + variant& operator =(const variant& other) + { + if (this != &other) + { + if (other.index() == variant_npos) + { + type_id = variant_npos; + } + else + { + operation(Destroy, data, nullptr); + + operation = other.operation; + operation(Copy, data, other.data); + + type_id = other.type_id; + } + } + + return *this; + } + + //*************************************************************************** + /// Assignment operator for variant type. + ///\param other The variant to assign. + //*************************************************************************** + variant& operator =(variant&& other) + { + if (this != &other) + { + if (other.index() == variant_npos) + { + type_id = variant_npos; + } + else + { + operation(Destroy, data, nullptr); + + operation = other.operation; + operation(Move, data, other.data); + + type_id = other.type_id; + } + } + + return *this; + } + + //*************************************************************************** + /// Checks whether a valid value is currently stored. + ///\return true if the value is valid, otherwise false. + //*************************************************************************** + constexpr bool valueless_by_exception() const noexcept + { + return type_id == variant_npos; + } + + //*************************************************************************** + /// Gets the index of the type currently stored or variant_npos + //*************************************************************************** + constexpr size_t index() const noexcept + { + return type_id; + } + + //*************************************************************************** + /// Swaps this variant with another. + //*************************************************************************** + void swap(variant& rhs) noexcept + { + variant temp(etl::move(*this)); + *this = etl::move(rhs); + rhs = etl::move(temp); + } + + //*************************************************************************** + /// Accept an etl::visitor. + //*************************************************************************** + void accept_visitor(etl::visitor& v) + { +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) + do_accept(v, etl::make_index_sequence{}); +#else + do_accept(v); +#endif + } + + //*************************************************************************** + /// Accept a generic functor. + //*************************************************************************** + template + void accept_functor(TVisitor& v) + { +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) + do_operator(v, etl::make_index_sequence{}); +#else + do_operator(v); +#endif + } + + private: + + /// The operation function type. + using operation_function = void(*)(int, char*, const char*); + + //*************************************************************************** + /// Construct the type in-place. lvalue reference. + //*************************************************************************** + template + static void construct_in_place(char* pstorage, const T& value) + { + using type = etl::remove_reference_t; + + ::new (pstorage) type(value); + } + + //*************************************************************************** + /// Construct the type in-place. rvalue reference. + //*************************************************************************** + template + static void construct_in_place(char* pstorage, T&& value) + { + using type = etl::remove_reference_t; + + ::new (pstorage) type(etl::move(value)); + } + + //*************************************************************************** + /// Construct the type in-place. Variadic args. + //*************************************************************************** + template + static void construct_in_place_args(char* pstorage, TArgs&&... args) + { + using type = etl::remove_reference_t; + + ::new (pstorage) type(etl::forward(args)...); + } + + //*************************************************************************** + /// Default construct the type in-place. + //*************************************************************************** + template + static void default_construct_in_place(char* pstorage) + { + using type = etl::remove_reference_t; + + ::new (pstorage) type(); + } + +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) + //*************************************************************************** + /// Call the relevent visitor by attemptng each one. + //*************************************************************************** + template + void do_accept(etl::visitor& visitor, etl::index_sequence) + { + (attempt_visitor(visitor) || ...); + } +#else + //*************************************************************************** + /// /// Call the relevent visitor. + //*************************************************************************** + void do_accept(etl::visitor& visitor) + { + switch (index()) + { + case 0: visitor.visit(etl::get<0>(*this)); break; + case 1: visitor.visit(etl::get<1>(*this)); break; + case 2: visitor.visit(etl::get<2>(*this)); break; + case 3: visitor.visit(etl::get<3>(*this)); break; + case 4: visitor.visit(etl::get<4>(*this)); break; + case 5: visitor.visit(etl::get<5>(*this)); break; + case 6: visitor.visit(etl::get<6>(*this)); break; + case 7: visitor.visit(etl::get<7>(*this)); break; +#if !defined(ETL_VARIANT_CPP11_MAX_8_TYPES) + case 8: visitor.visit(etl::get<8>(*this)); break; + case 9: visitor.visit(etl::get<9>(*this)); break; + case 10: visitor.visit(etl::get<10>(*this)); break; + case 11: visitor.visit(etl::get<11>(*this)); break; + case 12: visitor.visit(etl::get<12>(*this)); break; + case 13: visitor.visit(etl::get<13>(*this)); break; + case 14: visitor.visit(etl::get<14>(*this)); break; + case 15: visitor.visit(etl::get<15>(*this)); break; +#if !defined(ETL_VARIANT_CPP11_MAX_16_TYPES) + case 16: visitor.visit(etl::get<16>(*this)); break; + case 17: visitor.visit(etl::get<17>(*this)); break; + case 18: visitor.visit(etl::get<18>(*this)); break; + case 19: visitor.visit(etl::get<19>(*this)); break; + case 20: visitor.visit(etl::get<20>(*this)); break; + case 21: visitor.visit(etl::get<21>(*this)); break; + case 22: visitor.visit(etl::get<22>(*this)); break; + case 23: visitor.visit(etl::get<23>(*this)); break; +#if !defined(ETL_VARIANT_CPP11_MAX_24_TYPES) + case 24: visitor.visit(etl::get<24>(*this)); break; + case 25: visitor.visit(etl::get<25>(*this)); break; + case 26: visitor.visit(etl::get<26>(*this)); break; + case 27: visitor.visit(etl::get<27>(*this)); break; + case 28: visitor.visit(etl::get<28>(*this)); break; + case 29: visitor.visit(etl::get<29>(*this)); break; + case 30: visitor.visit(etl::get<30>(*this)); break; + case 31: visitor.visit(etl::get<31>(*this)); break; +#endif +#endif +#endif + default: break; + } + } +#endif + + //*************************************************************************** + /// Attempt to call a visitor. + //*************************************************************************** + template + bool attempt_visitor(etl::visitor& visitor) + { + if (Index == index()) + { + visitor.visit(etl::get(*this)); + return true; + } + else + { + return false; + } + } + +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) + //*************************************************************************** + /// Call the relevent visitor by attemptng each one. + //*************************************************************************** + template + void do_operator(TVisitor& visitor, etl::index_sequence) + { + (attempt_operator(visitor) || ...); + } +#else + //*************************************************************************** + /// Call the relevent visitor. + //*************************************************************************** + template + void do_operator(TVisitor& visitor) + { +#if defined(ETL_VARIANT_CPP11_MAX_8_TYPES) + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 8U, "ETL_VARIANT_CPP11_MAX_8_TYPES - Only a maximum of 8 types are allowed in this variant"); +#endif + +#if defined(ETL_VARIANT_CPP11_MAX_16_TYPES) + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 16U, "ETL_VARIANT_CPP11_MAX_16_TYPES - Only a maximum of 16 types are allowed in this variant"); +#endif + +#if defined(ETL_VARIANT_CPP11_MAX_24_TYPES) + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 24U, "ETL_VARIANT_CPP11_MAX_24_TYPES - Only a maximum of 24 types are allowed in this variant"); +#endif + + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 32U, "A maximum of 32 types are allowed in this variant"); + + switch (index()) + { + case 0: visitor(etl::get<0>(*this)); break; + case 1: visitor(etl::get<1>(*this)); break; + case 2: visitor(etl::get<2>(*this)); break; + case 3: visitor(etl::get<3>(*this)); break; + case 4: visitor(etl::get<4>(*this)); break; + case 5: visitor(etl::get<5>(*this)); break; + case 6: visitor(etl::get<6>(*this)); break; + case 7: visitor(etl::get<7>(*this)); break; +#if !defined(ETL_VARIANT_CPP11_MAX_8_TYPES) + case 8: visitor(etl::get<8>(*this)); break; + case 9: visitor(etl::get<9>(*this)); break; + case 10: visitor(etl::get<10>(*this)); break; + case 11: visitor(etl::get<11>(*this)); break; + case 12: visitor(etl::get<12>(*this)); break; + case 13: visitor(etl::get<13>(*this)); break; + case 14: visitor(etl::get<14>(*this)); break; + case 15: visitor(etl::get<15>(*this)); break; +#if !defined(ETL_VARIANT_CPP11_MAX_16_TYPES) + case 16: visitor(etl::get<16>(*this)); break; + case 17: visitor(etl::get<17>(*this)); break; + case 18: visitor(etl::get<18>(*this)); break; + case 19: visitor(etl::get<19>(*this)); break; + case 20: visitor(etl::get<20>(*this)); break; + case 21: visitor(etl::get<21>(*this)); break; + case 22: visitor(etl::get<22>(*this)); break; + case 23: visitor(etl::get<23>(*this)); break; +#if !defined(ETL_VARIANT_CPP11_MAX_24_TYPES) + case 24: visitor(etl::get<24>(*this)); break; + case 25: visitor(etl::get<25>(*this)); break; + case 26: visitor(etl::get<26>(*this)); break; + case 27: visitor(etl::get<27>(*this)); break; + case 28: visitor(etl::get<28>(*this)); break; + case 29: visitor(etl::get<29>(*this)); break; + case 30: visitor(etl::get<30>(*this)); break; + case 31: visitor(etl::get<31>(*this)); break; +#endif +#endif +#endif + default: break; + } + } +#endif + + //*************************************************************************** + /// Attempt to call a visitor. + //*************************************************************************** + template + bool attempt_operator(TVisitor& visitor) + { + if (Index == index()) + { + visitor(etl::get(*this)); + return true; + } + else + { + return false; + } + } + + //*************************************************************************** + /// The internal storage. + /// Aligned on a suitable boundary, which should be good for all types. + //*************************************************************************** + etl::uninitialized_buffer data; + + //*************************************************************************** + /// The operation function. + //*************************************************************************** + operation_function operation; + + //*************************************************************************** + /// The id of the current stored type. + //*************************************************************************** + size_t type_id; + }; + + //*************************************************************************** + /// Checks if the variant v holds the alternative T. + //*************************************************************************** + template + ETL_CONSTEXPR14 bool holds_alternative(const etl::variant& v) noexcept + { + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; + + return (Index == variant_npos) ? false : (v.index() == Index); + } + + //*************************************************************************** + /// Checks if the variant v holds the alternative Index. + //*************************************************************************** + template + ETL_CONSTEXPR14 bool holds_alternative(const etl::variant& v) noexcept + { + return (Index == v.index()); + } + + //*************************************************************************** + /// Checks if the variant v holds the alternative Index. (Runtime) + //*************************************************************************** + template + ETL_CONSTEXPR14 bool holds_alternative(size_t index, const etl::variant& v) noexcept + { + return (index == v.index()); + } + + //*************************************************************************** + /// get + //*************************************************************************** + template + ETL_CONSTEXPR14 etl::variant_alternative_t>& + get(etl::variant& v) + { +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) + static_assert(Index < sizeof...(TTypes), "Index out of range"); +#endif + + ETL_ASSERT(Index == v.index(), ETL_ERROR(etl::variant_incorrect_type_exception)); + + using type = etl::variant_alternative_t>; + + return *static_cast(v.data); + } + + //*********************************** + template + ETL_CONSTEXPR14 etl::variant_alternative_t>&& + get(etl::variant&& v) + { +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) + static_assert(Index < sizeof...(TTypes), "Index out of range"); +#endif + + using type = etl::variant_alternative_t>; + + return etl::move(*static_cast(v.data)); + } + + //*********************************** + template + ETL_CONSTEXPR14 const etl::variant_alternative_t>& + get(const etl::variant& v) + { +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) + static_assert(Index < sizeof...(TTypes), "Index out of range"); +#endif + + ETL_ASSERT(Index == v.index(), ETL_ERROR(etl::variant_incorrect_type_exception)); + + using type = etl::variant_alternative_t>; + + return *static_cast(v.data); + } + + //*********************************** + template + ETL_CONSTEXPR14 const etl::variant_alternative_t>&& + get(const etl::variant&& v) + { +#if ETL_CPP17_SUPPORTED & !defined(ETL_VARIANT_FORCE_CPP11) + static_assert(Index < sizeof...(TTypes), "Index out of range"); +#endif + + ETL_ASSERT(Index == v.index(), ETL_ERROR(etl::variant_incorrect_type_exception)); + + using type = etl::variant_alternative_t>; + + return etl::move(*static_cast(v.data)); + } + + //*********************************** + template + ETL_CONSTEXPR14 T& get(etl::variant& v) + { + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; + + return get(v); + } + + //*********************************** + template + ETL_CONSTEXPR14 T&& get(etl::variant&& v) + { + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; + + return get(etl::move(v)); + } + + //*********************************** + template + ETL_CONSTEXPR14 const T& get(const etl::variant& v) + { + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; + + return get(v); + } + + //*********************************** + template + ETL_CONSTEXPR14 const T&& get(const etl::variant&& v) + { + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; + + return get(etl::move(v)); + } + + //*************************************************************************** + /// get_if + //*************************************************************************** + template< size_t Index, typename... TTypes > + ETL_CONSTEXPR14 etl::add_pointer_t>> + get_if(etl::variant* pv) noexcept + { + if ((pv != nullptr) && (pv->index() == Index)) + { + return &etl::get(*pv); + } + else + { + return nullptr; + } + } + + //*********************************** + template< size_t Index, typename... TTypes > + ETL_CONSTEXPR14 etl::add_pointer_t>> + get_if(const etl::variant* pv) noexcept + { + if ((pv != nullptr) && (pv->index() == Index)) + { + return &etl::get(*pv); + } + else + { + return nullptr; + } + } + + //*********************************** + template< class T, typename... TTypes > + ETL_CONSTEXPR14 etl::add_pointer_t get_if(etl::variant* pv) noexcept + { + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; + + if ((pv != nullptr) && (pv->index() == Index)) + { + return &etl::get(*pv); + } + else + { + return nullptr; + } + } + + //*********************************** + template< typename T, typename... TTypes > + ETL_CONSTEXPR14 etl::add_pointer_t get_if(const etl::variant* pv) noexcept + { + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; + + if ((pv != nullptr) && (pv->index() == Index)) + { + return &etl::get(*pv); + } + else + { + return nullptr; + } + } + + //*************************************************************************** + /// swap + //*************************************************************************** + template + void swap(etl::variant& lhs, etl::variant& rhs) + { + lhs.swap(rhs); + } + + //*************************************************************************** + /// variant_size + //*************************************************************************** + template + struct variant_size; + + template + struct variant_size> + : etl::integral_constant + { + }; + + template + struct variant_size + : etl::integral_constant::value> + { + }; + +#if ETL_CPP17_SUPPORTED + template + inline constexpr size_t variant_size_v = variant_size::value; +#endif +} +#endif diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 281b94bf..82bf041d 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -123,6 +123,9 @@ namespace etl /// remove_reference template struct remove_reference { typedef T type; }; template struct remove_reference { typedef T type; }; +#if ETL_CPP11_SUPPORTED + template struct remove_reference { typedef T type; }; +#endif #if ETL_CPP11_SUPPORTED template @@ -437,61 +440,16 @@ namespace etl inline constexpr bool is_pod_v = etl::is_pod::value; #endif - //*************************************************************************** - /// is_trivially_constructible - /// Only POD types are recognised. - template struct is_trivially_constructible : etl::is_pod {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible::value; -#endif - - //*************************************************************************** - /// is_trivially_copy_constructible - /// Only POD types are recognised. - template struct is_trivially_copy_constructible : etl::is_pod {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible::value; -#endif - - //*************************************************************************** - /// is_trivially_destructible - /// Only POD types are recognised. - template struct is_trivially_destructible : etl::is_pod {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible::value; -#endif - - //*************************************************************************** - /// is_trivially_copy_assignable - /// Only POD types are recognised. - template struct is_trivially_copy_assignable : etl::is_pod {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable::value; -#endif - - //*************************************************************************** - /// is_trivially_copyable - /// Only POD types are recognised. - template struct is_trivially_copyable : etl::is_pod {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; -#endif - //*************************************************************************** /// conditional template struct conditional { typedef T type; }; template struct conditional { typedef F type; }; +#if ETL_CPP11_SUPPORTED + template + using conditional_t = typename conditional::type; +#endif + //*************************************************************************** /// make_signed template struct make_signed { typedef T type; }; @@ -501,10 +459,10 @@ namespace etl template <> struct make_signed { typedef etl::conditional::type>::type type; + int16_t, + etl::conditional::type>::type type; }; template <> struct make_signed { typedef short type; }; @@ -633,7 +591,7 @@ namespace etl /// is_base_of template::value || etl::is_fundamental::value)> + const bool IsFundamental = (etl::is_fundamental::value || etl::is_fundamental::value || etl::is_array::value)> struct is_base_of { private: @@ -641,8 +599,10 @@ namespace etl template struct dummy {}; struct internal: TDerived, dummy{}; - static TBase* check(TBase*); - template static char check(dummy*); + static TBase* check(TBase*) { return (TBase*)0; } + + template + static char check(dummy*) { return 0; } public: @@ -769,6 +729,7 @@ namespace etl /// Specialisation of 'alignment_of' for 'void'. ///\ingroup type_traits template <> struct alignment_of : integral_constant {}; + template <> struct alignment_of : integral_constant {}; #if ETL_CPP17_SUPPORTED template @@ -1082,134 +1043,17 @@ namespace etl #endif #endif -#if !defined(ARDUINO) && ETL_NOT_USING_STLPORT && defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED) - //*************************************************************************** - /// is_trivially_constructible - ///\ingroup type_traits - template struct is_trivially_constructible : std::is_trivially_constructible {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_constructible_v = std::is_trivially_constructible_v; -#endif - - //*************************************************************************** - /// is_trivially_copy_constructible - ///\ingroup type_traits - template struct is_trivially_copy_constructible : std::is_trivially_copy_constructible {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_constructible_v = std::is_trivially_copy_constructible_v; -#endif - - //*************************************************************************** - /// is_trivially_destructible - ///\ingroup type_traits - template struct is_trivially_destructible : std::is_trivially_destructible {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_destructible_v = std::is_trivially_destructible_v; -#endif - - //*************************************************************************** - /// is_trivially_copy_assignable - ///\ingroup type_traits - template struct is_trivially_copy_assignable : std::is_trivially_copy_assignable {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_assignable_v = std::is_trivially_copy_assignable_v; -#endif - - //*************************************************************************** - /// is_trivially_copyable - ///\ingroup type_traits - template struct is_trivially_copyable : std::is_trivially_copyable {}; - -#if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copyable_v = std::is_trivially_copyable_v; -#endif -#else - //*************************************************************************** - /// is_trivially_constructible - ///\ingroup type_traits -#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - template struct is_trivially_constructible : std::is_trivially_constructible {}; -#else - template struct is_trivially_constructible : std::is_pod {}; -#endif - - #if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible::value; - #endif - - //*************************************************************************** - /// is_trivially_copy_constructible - ///\ingroup type_traits -#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - template struct is_trivially_copy_constructible : std::is_trivially_copy_constructible {}; -#else - template struct is_trivially_copy_constructible : std::is_pod {}; -#endif - - #if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible::value; - #endif - - //*************************************************************************** - /// is_trivially_destructible - ///\ingroup type_traits -#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - template struct is_trivially_destructible : std::is_trivially_destructible {}; -#else - template struct is_trivially_destructible : std::is_pod {}; -#endif - - #if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible::value; - #endif - - //*************************************************************************** - /// is_trivially_copy_assignable - ///\ingroup type_traits -#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - template struct is_trivially_copy_assignable : std::is_trivially_copy_assignable {}; -#else - template struct is_trivially_copy_assignable : std::is_pod {}; -#endif - - #if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable::value; - #endif - - //*************************************************************************** - /// is_trivially_copyable - ///\ingroup type_traits -#if ETL_CPP11_SUPPORTED && ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - template struct is_trivially_copyable : std::is_trivially_copyable {}; -#else - template struct is_trivially_copyable : std::is_pod {}; -#endif - - #if ETL_CPP17_SUPPORTED - template - inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; - #endif -#endif - //*************************************************************************** /// conditional ///\ingroup type_traits template struct conditional { typedef T type; }; template struct conditional { typedef F type; }; +#if ETL_CPP11_SUPPORTED + template + using conditional_t = typename conditional::type; +#endif + //*************************************************************************** /// make_signed ///\ingroup type_traits @@ -1355,6 +1199,7 @@ namespace etl ///\ingroup type_traits template struct alignment_of : std::alignment_of {}; template <> struct alignment_of : std::integral_constant {}; + template <> struct alignment_of : integral_constant {}; #if ETL_CPP17_SUPPORTED template @@ -1610,6 +1455,506 @@ namespace etl #if ETL_CPP17_SUPPORTED template inline constexpr bool are_all_same_v = are_all_same::value; +#endif + + //*************************************************************************** + /// conjunction +#if ETL_CPP11_SUPPORTED + template + struct conjunction : public etl::true_type + { + }; + + template + struct conjunction : public etl::conditional_t, T1> + { + }; + + template + struct conjunction : public T + { + }; +#endif + +#if ETL_CPP17_SUPPORTED + template + inline constexpr bool conjunction_v = conjunction::value; +#endif + + //*************************************************************************** + /// disjunction +#if ETL_CPP11_SUPPORTED + template + struct disjunction : public etl::false_type + { + }; + + template + struct disjunction : public etl::conditional_t> + { + }; + + template struct disjunction : public T1 + { + }; +#endif + +#if ETL_CPP17_SUPPORTED + template + inline constexpr bool disjunction_v = etl::disjunction::value; +#endif + + //*************************************************************************** +#if ETL_CPP11_SUPPORTED && ETL_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) && ((!defined(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)) + + //********************************************* + // Use the STL's definitions. + //********************************************* + + //********************************************* + // is_assignable + template + struct is_assignable : public std::is_assignable + { + }; + + //********************************************* + // is_constructible + template + struct is_constructible : public std::is_constructible + { + }; + + //********************************************* + // is_copy_constructible + template + struct is_copy_constructible : public std::is_copy_constructible + { + }; + + //********************************************* + // is_move_constructible + template + struct is_move_constructible : public std::is_move_constructible + { + }; + + //********************************************* + // is_trivially_constructible +#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template + struct is_trivially_constructible : public std::is_trivially_constructible + { + }; +#else + template ::value || etl::is_pointer::value> + struct is_trivially_constructible; + + template + struct is_trivially_constructible : public etl::true_type + { + }; + + template + struct is_trivially_constructible; +#endif + + //*************************************************************************** + // is_trivially_copy_constructible +#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template + struct is_trivially_copy_constructible : public std::is_trivially_copy_constructible + { + }; +#else + template ::value || etl::is_pointer::value> + struct is_trivially_copy_constructible; + + template + struct is_trivially_copy_constructible : public etl::true_type + { + }; + + template + struct is_trivially_copy_constructible; +#endif + + //*************************************************************************** + // is_trivially_destructible +#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template + struct is_trivially_destructible : public std::is_trivially_destructible + { + }; +#else + template ::value || etl::is_pointer::value> + struct is_trivially_destructible; + + template + struct is_trivially_destructible : public etl::true_type + { + }; + + template + struct is_trivially_destructible; +#endif + + //*************************************************************************** + // is_trivially_copy_assignable +#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template + struct is_trivially_copy_assignable : public std::is_trivially_copy_assignable + { + }; +#else + template ::value || etl::is_pointer::value> + struct is_trivially_copy_assignable; + + template + struct is_trivially_copy_assignable : public etl::true_type + { + }; + + template + struct is_trivially_copy_assignable; +#endif + + //*************************************************************************** + // is_trivially_copyable +#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + template + struct is_trivially_copyable : public std::is_trivially_copyable + { + }; +#else + template ::value || etl::is_pointer::value> + struct is_trivially_copyable; + + template + struct is_trivially_copyable : public etl::true_type + { + }; + + template + struct is_trivially_copyable; +#endif + +#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) + + //********************************************* + // Use the compiler's builtins. + //********************************************* + + //********************************************* + // is_assignable + template + struct is_assignable : public etl::bool_constant<__is_assignable(T1, T2)> + { + }; + +#if ETL_CPP11_SUPPORTED + //********************************************* + // is_constructible + template + struct is_constructible : public etl::bool_constant<__is_constructible(T, TArgs...)> + { + }; +#endif + + //********************************************* + // is_copy_constructible + template + struct is_copy_constructible : public etl::is_constructible> + { + }; + + //********************************************* + // is_move_constructible + template + struct is_move_constructible : public etl::is_constructible + { + }; + + //********************************************* + // is_trivially_constructible + template + struct is_trivially_constructible : public etl::bool_constant<__is_trivially_constructible(T)> + { + }; + + //*************************************************************************** + // is_trivially_copy_constructible + template + struct is_trivially_copy_constructible : public etl::bool_constant<__is_trivially_copyable(T)> + { + }; + + //*************************************************************************** + // is_trivially_destructible + template + struct is_trivially_destructible : public etl::bool_constant<__is_trivially_destructible(T)> + { + }; + + //*************************************************************************** + // is_trivially_copy_assignable + template + struct is_trivially_copy_assignable : public etl::bool_constant<__is_trivially_copyable(T)> + { + }; + + //*************************************************************************** + // is_trivially_copyable + template + struct is_trivially_copyable : public etl::bool_constant<__is_trivially_copyable(T)> + { + }; + +#elif defined(ETL_USER_DEFINED_TYPE_TRAITS) && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) + + //********************************************* + // Force the user to provide specialisations for + // anything other than arithmetics and pointers. + //********************************************* + + //********************************************* + // is_assignable + template ::value || etl::is_pointer::value) && (etl::is_arithmetic::value || etl::is_pointer::value)> + struct is_assignable; + + template + struct is_assignable : public etl::true_type + { + }; + + template + struct is_assignable; + +#if ETL_CPP11_SUPPORTED + //********************************************* + // is_constructible + template + struct is_constructible_helper; + + template + struct is_constructible_helper : public etl::true_type + { + }; + + template + struct is_constructible_helper; + + template + struct is_constructible : public is_constructible_helper::value || etl::is_pointer::value, TArgs...> + { + }; +#endif + + //********************************************* + // is_copy_constructible + template ::value || etl::is_pointer::value> + struct is_copy_constructible; + + template + struct is_copy_constructible : public etl::true_type + { + }; + + template + struct is_copy_constructible; + + //********************************************* + // is_move_constructible + template ::value || etl::is_pointer::value> + struct is_move_constructible; + + template + struct is_move_constructible : public etl::true_type + { + }; + + template + struct is_move_constructible; + + //********************************************* + // is_trivially_constructible + template ::value || etl::is_pointer::value> + struct is_trivially_constructible; + + template + struct is_trivially_constructible : public etl::true_type + { + }; + + template + struct is_trivially_constructible; + + //*************************************************************************** + // is_trivially_copy_constructible + template ::value || etl::is_pointer::value> + struct is_trivially_copy_constructible; + + template + struct is_trivially_copy_constructible : public etl::true_type + { + }; + + template + struct is_trivially_copy_constructible; + + //*************************************************************************** + // is_trivially_destructible + template ::value || etl::is_pointer::value> + struct is_trivially_destructible; + + template + struct is_trivially_destructible : public etl::true_type + { + }; + + template + struct is_trivially_destructible; + + //*************************************************************************** + // is_trivially_copy_assignable + template ::value || etl::is_pointer::value> + struct is_trivially_copy_assignable; + + template + struct is_trivially_copy_assignable : public etl::true_type + { + }; + + template + struct is_trivially_copy_assignable; + + //*************************************************************************** + // is_trivially_copyable + template ::value || etl::is_pointer::value> + struct is_trivially_copyable; + + template + struct is_trivially_copyable : public etl::true_type + { + }; + + template + struct is_trivially_copyable; + +#else + + //********************************************* + // Assume that anything other than arithmetics + // and pointers return false for the traits. + //********************************************* + + //********************************************* + // is_assignable + template + struct is_assignable : public etl::bool_constant<(etl::is_arithmetic::value || etl::is_pointer::value) && (etl::is_arithmetic::value || etl::is_pointer::value)> + { + }; + + #if ETL_CPP11_SUPPORTED + //********************************************* + // is_constructible + template + struct is_constructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + #endif + + //********************************************* + // is_copy_constructible + template + struct is_copy_constructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //********************************************* + // is_move_constructible + template + struct is_move_constructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //********************************************* + // is_trivially_constructible + template + struct is_trivially_constructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //*************************************************************************** + // is_trivially_copy_constructible + template + struct is_trivially_copy_constructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //*************************************************************************** + // is_trivially_destructible + template + struct is_trivially_destructible : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //*************************************************************************** + // is_trivially_copy_assignable + template + struct is_trivially_copy_assignable : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + + //*************************************************************************** + // is_trivially_copyable + template + struct is_trivially_copyable : public etl::bool_constant::value || etl::is_pointer::value> + { + }; + +#endif + + template + struct is_lvalue_assignable : public etl::is_assignable::type, + typename etl::add_lvalue_reference::type>::type> + { + }; + +#if ETL_CPP17_SUPPORTED + + template + inline constexpr bool is_assignable_v = etl::is_assignable::value; + + template + inline constexpr bool is_lvalue_assignable_v = etl::is_lvalue_assignable::value; + + template + inline constexpr bool is_constructible_v = etl::is_constructible::value; + + template + inline constexpr bool is_copy_constructible_v = etl::is_copy_constructible::value; + + template + inline constexpr bool is_move_constructible_v = etl::is_move_constructible::value; + + template + inline constexpr bool is_trivially_constructible_v = etl::is_trivially_constructible::value; + + template + inline constexpr bool is_trivially_copy_constructible_v = etl::is_trivially_copy_constructible::value; + + template + inline constexpr bool is_trivially_destructible_v = etl::is_trivially_destructible::value; + + template + inline constexpr bool is_trivially_copy_assignable_v = etl::is_trivially_copy_assignable::value; + + template + inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; + #endif } diff --git a/include/etl/utility.h b/include/etl/utility.h index 62d4237d..df3f86e0 100644 --- a/include/etl/utility.h +++ b/include/etl/utility.h @@ -332,8 +332,55 @@ namespace etl return t; } - //****************************************************************************** + //*************************************************************************** + /// integer_sequence + //*************************************************************************** +#if ETL_CPP11_SUPPORTED + template + class integer_sequence + { + public: + + ETL_STATIC_ASSERT(etl::is_integral::value, "Integral types only"); + + typedef T value_type; + + static ETL_CONSTEXPR size_t size() ETL_NOEXCEPT + { + return sizeof...(Integers); + } + }; + + namespace private_integer_sequence + { + template + struct make_index_sequence; + + template + struct make_index_sequence> + { + typedef typename make_index_sequence>::type type; + }; + + template + struct make_index_sequence<0, etl::integer_sequence> + { + typedef etl::integer_sequence type; + }; + } + + //*********************************** + template + using make_index_sequence = typename private_integer_sequence::make_index_sequence>::type; + + //*********************************** + template + using index_sequence = etl::integer_sequence; +#endif + + //*************************************************************************** /// 2D coordinate type. + //*************************************************************************** template struct coordinate_2d { @@ -362,6 +409,42 @@ namespace etl T x; T y; }; + + //*************************************************************************** + /// in_place disambiguation tags. + //*************************************************************************** + + //************************* + struct in_place_t + { + explicit ETL_CONSTEXPR in_place_t() {} + }; + +#if ETL_CPP17_SUPPORTED + inline constexpr in_place_t in_place; +#endif + + //************************* + template struct in_place_type_t + { + explicit ETL_CONSTEXPR in_place_type_t(){}; + }; + +#if ETL_CPP17_SUPPORTED + template + inline constexpr in_place_type_t in_place_type; +#endif + + //************************* + template struct in_place_index_t + { + explicit ETL_CONSTEXPR in_place_index_t() {} + }; + +#if ETL_CPP17_SUPPORTED + template + inline constexpr in_place_index_t in_place_index; +#endif } #endif diff --git a/include/etl/variant.h b/include/etl/variant.h index c466cf07..c8664590 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -31,1003 +31,10 @@ SOFTWARE. #ifndef ETL_VARIANT_INCLUDED #define ETL_VARIANT_INCLUDED -#include - -#include "platform.h" -#include "utility.h" -#include "array.h" -#include "largest.h" -#include "exception.h" -#include "type_traits.h" -#include "integral_limits.h" -#include "static_assert.h" -#include "alignment.h" -#include "error_handler.h" -#include "null_type.h" -#include "placement_new.h" - -#if defined(ETL_COMPILER_KEIL) - #pragma diag_suppress 940 - #pragma diag_suppress 111 -#endif - -//***************************************************************************** -///\defgroup variant variant -/// A class that can contain one a several specified types in a type safe manner. -///\ingroup containers -//***************************************************************************** - -namespace etl -{ - namespace private_variant - { - //************************************************************************* - /// Placeholder for unused template parameters. - /// This class is never instantiated. - //************************************************************************* - template - struct no_type - { - }; - } - - //*************************************************************************** - /// Base exception for the variant class. - ///\ingroup variant - //*************************************************************************** - class variant_exception : public exception - { - public: - variant_exception(string_type reason_, string_type file_name_, numeric_type line_number_) - : exception(reason_, file_name_, line_number_) - { - } - }; - - //*************************************************************************** - /// 'Unsupported type' exception for the variant class. - ///\ingroup variant - //*************************************************************************** - class variant_incorrect_type_exception : public variant_exception - { - public: - variant_incorrect_type_exception(string_type file_name_, numeric_type line_number_) - : variant_exception(ETL_ERROR_TEXT("variant: unsupported type", ETL_VARIANT_FILE_ID"A"), file_name_, line_number_) - { - } - }; - - //*************************************************************************** - /// A template class that can store any of the types defined in the template parameter list. - /// Supports up to 8 types. - ///\ingroup variant - //*************************************************************************** - template , - typename T3 = etl::null_type<3>, - typename T4 = etl::null_type<4>, - typename T5 = etl::null_type<5>, - typename T6 = etl::null_type<6>, - typename T7 = etl::null_type<7>, - typename T8 = etl::null_type<8> > - class variant - { - public: - - //*************************************************************************** - /// The type used for ids. - //*************************************************************************** - typedef uint_least8_t type_id_t; - - //*************************************************************************** - /// The id a unsupported types. - //*************************************************************************** - static const type_id_t UNSUPPORTED_TYPE_ID = integral_limits::max; - - private: - - // All types of variant are friends. - template - friend class variant; - - //*************************************************************************** - /// The largest type. - //*************************************************************************** - typedef typename largest_type::type largest_t; - - //*************************************************************************** - /// The largest size. - //*************************************************************************** - static const size_t SIZE = sizeof(largest_t); - - //*************************************************************************** - /// The largest alignment. - //*************************************************************************** - static const size_t ALIGNMENT = etl::largest_alignment::value; - - //*************************************************************************** - /// Short form of no_type placeholders. - //*************************************************************************** - typedef etl::null_type<2> no_type2; - typedef etl::null_type<3> no_type3; - typedef etl::null_type<4> no_type4; - typedef etl::null_type<5> no_type5; - typedef etl::null_type<6> no_type6; - typedef etl::null_type<7> no_type7; - typedef etl::null_type<8> no_type8; - - //*************************************************************************** - /// Lookup the id of type. - //*************************************************************************** - template - struct Type_Id_Lookup - { - static const uint_least8_t type_id = etl::is_same::value ? 0 : - etl::is_same::value ? 1 : - etl::is_same::value ? 2 : - etl::is_same::value ? 3 : - etl::is_same::value ? 4 : - etl::is_same::value ? 5 : - etl::is_same::value ? 6 : - etl::is_same::value ? 7 : - UNSUPPORTED_TYPE_ID; - }; - - //*************************************************************************** - /// Lookup for the id of type. - //*************************************************************************** - template - struct Type_Is_Supported : public integral_constant::value || - is_same::value || - is_same::value || - is_same::value || - is_same::value || - is_same::value || - is_same::value || - is_same::value> - { - }; - - public: - - //*************************************************************************** - /// Destructor. - //*************************************************************************** - ~variant() - { - destruct_current(); - } - - //************************************************************************* - //**** Reader types ******************************************************* - //************************************************************************* - - //************************************************************************* - /// Base reader type functor class. - /// Allows for typesafe access to the stored value types. - /// Define the reader type for 8 types. - //************************************************************************* - template - class reader_type - { - public: - - friend class variant; - - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - }; - - //************************************************************************* - /// Define the reader type for 7 types. - //************************************************************************* - template - class reader_type - { - public: - - friend class variant; - - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - - private: - - void read(no_type8&) {}; - }; - - //************************************************************************* - /// Define the reader type for 6 types. - //************************************************************************* - template - class reader_type - { - public: - - friend class variant; - - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - - private: - - void read(no_type7&) {}; - void read(no_type8&) {}; - }; - - //************************************************************************* - /// Define the reader type for 5 types. - //************************************************************************* - template - class reader_type - { - public: - - friend class variant; - - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - - private: - - void read(no_type6&) {}; - void read(no_type7&) {}; - void read(no_type8&) {}; - }; - - //************************************************************************* - /// Define the reader type for 4 types. - //************************************************************************* - template - class reader_type - { - public: - - friend class variant; - - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - - private: - - void read(no_type5&) {}; - void read(no_type6&) {}; - void read(no_type7&) {}; - void read(no_type8&) {}; - }; - - //************************************************************************* - /// Define the reader type for 3 types. - //************************************************************************* - template - class reader_type - { - public: - - friend class variant; - - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - - private: - - void read(no_type4&) {}; - void read(no_type5&) {}; - void read(no_type6&) {}; - void read(no_type7&) {}; - void read(no_type8&) {}; - }; - - //************************************************************************* - /// Define the reader type for 2 types. - //************************************************************************* - template - class reader_type - { - public: - - friend class variant; - - virtual void read(typename etl::parameter_type::type value) = 0; - virtual void read(typename etl::parameter_type::type value) = 0; - - private: - - void read(no_type3&) {}; - void read(no_type4&) {}; - void read(no_type5&) {}; - void read(no_type6&) {}; - void read(no_type7&) {}; - void read(no_type8&) {}; - }; - - //************************************************************************* - /// Define the reader type for 1 type. - //************************************************************************* - template - class reader_type - { - public: - - friend class variant; - - virtual void read(typename etl::parameter_type::type value) = 0; - - private: - - void read(no_type2&) {}; - void read(no_type3&) {}; - void read(no_type4&) {}; - void read(no_type5&) {}; - void read(no_type6&) {}; - void read(no_type7&) {}; - void read(no_type8&) {}; - }; - - //*************************************************************************** - /// The base type for derived readers. - //*************************************************************************** - typedef reader_type reader; - - //*************************************************************************** - /// Default constructor. - /// Sets the state of the instance to containing no valid data. - //*************************************************************************** - variant() - : type_id(UNSUPPORTED_TYPE_ID) - { - } - - //*************************************************************************** - /// Constructor that catches any types that are not supported. - /// Forces a ETL_STATIC_ASSERT. - //*************************************************************************** - template - variant(const T& value) - { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); - - ::new (static_cast(data)) T(value); - type_id = Type_Id_Lookup::type_id; - } - - //*************************************************************************** - /// Copy constructor. - ///\param other The other variant object to copy. - //*************************************************************************** - variant(const variant& other) - { - switch (other.type_id) - { - case 0: ::new (static_cast(data)) T1(other.get()); break; - case 1: ::new (static_cast(data)) T2(other.get()); break; - case 2: ::new (static_cast(data)) T3(other.get()); break; - case 3: ::new (static_cast(data)) T4(other.get()); break; - case 4: ::new (static_cast(data)) T5(other.get()); break; - case 5: ::new (static_cast(data)) T6(other.get()); break; - case 6: ::new (static_cast(data)) T7(other.get()); break; - case 7: ::new (static_cast(data)) T8(other.get()); break; - default: break; - } - - type_id = other.type_id; - } - -#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && !defined(ETL_VARIANT_FORCE_CPP03) - //************************************************************************* - /// Emplace with variadic constructor parameters. - //************************************************************************* - template - T& emplace(Args&&... args) - { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); - - destruct_current(); - ::new (static_cast(data)) T(etl::forward(args)...); - type_id = Type_Id_Lookup::type_id; - - return *static_cast(data); - } +#if !ETL_CPP11_SUPPORTED || ETL_USE_LEGACY_VARIANT + #include "private/variant_legacy.h" #else - //*************************************************************************** - /// Emplace with one constructor parameter. - //*************************************************************************** - template - T& emplace(const TP1& value1) - { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); - - destruct_current(); - ::new (static_cast(data)) T(value1); - type_id = Type_Id_Lookup::type_id; - - return *static_cast(data); - } - - //*************************************************************************** - /// Emplace with two constructor parameters. - //*************************************************************************** - template - T& emplace(const TP1& value1, const TP2& value2) - { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); - - destruct_current(); - ::new (static_cast(data)) T(value1, value2); - type_id = Type_Id_Lookup::type_id; - - return *static_cast(data); - } - - //*************************************************************************** - /// Emplace with three constructor parameters. - //*************************************************************************** - template - T& emplace(const TP1& value1, const TP2& value2, const TP3& value3) - { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); - - destruct_current(); - ::new (static_cast(data)) T(value1, value2, value3); - type_id = Type_Id_Lookup::type_id; - - return *static_cast(data); - } - - //*************************************************************************** - /// Emplace with four constructor parameters. - //*************************************************************************** - template - T& emplace(const TP1& value1, const TP2& value2, const TP3& value3, const TP4& value4) - { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); - - destruct_current(); - ::new (static_cast(data)) T(value1, value2, value3, value4); - type_id = Type_Id_Lookup::type_id; - - return *static_cast(data); - } + #include "private/variant_variadic.h" #endif - //*************************************************************************** - /// Assignment operator for T1 type. - ///\param value The value to assign. - //*************************************************************************** - template - variant& operator =(const T& value) - { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); - - destruct_current(); - ::new (static_cast(data)) T(value); - type_id = Type_Id_Lookup::type_id; - - return *this; - } - - //*************************************************************************** - /// Assignment operator for variant type. - ///\param other The variant to assign. - //*************************************************************************** - variant& operator =(const variant& other) - { - if (this != &other) - { - destruct_current(); - - switch (other.type_id) - { - case 0: ::new (static_cast(data)) T1(other.get()); break; - case 1: ::new (static_cast(data)) T2(other.get()); break; - case 2: ::new (static_cast(data)) T3(other.get()); break; - case 3: ::new (static_cast(data)) T4(other.get()); break; - case 4: ::new (static_cast(data)) T5(other.get()); break; - case 5: ::new (static_cast(data)) T6(other.get()); break; - case 6: ::new (static_cast(data)) T7(other.get()); break; - case 7: ::new (static_cast(data)) T8(other.get()); break; - default: break; - } - - type_id = other.type_id; - } - - return *this; - } - - //*************************************************************************** - /// Checks if the type is the same as the current stored type. - /// For variants with the same type declarations. - ///\return true if the types are the same, otherwise false. - //*************************************************************************** - bool is_same_type(const variant& other) const - { - return type_id == other.type_id; - } - - //*************************************************************************** - /// Checks if the type is the same as the current stored type. - /// For variants with differing declarations. - ///\return true if the types are the same, otherwise false. - //*************************************************************************** - template - bool is_same_type(const variant& other) const - { - bool is_same = false; - - switch (other.type_id) - { - case 0: is_same = (type_id == Type_Id_Lookup::type_id); break; - case 1: is_same = (type_id == Type_Id_Lookup::type_id); break; - case 2: is_same = (type_id == Type_Id_Lookup::type_id); break; - case 3: is_same = (type_id == Type_Id_Lookup::type_id); break; - case 4: is_same = (type_id == Type_Id_Lookup::type_id); break; - case 5: is_same = (type_id == Type_Id_Lookup::type_id); break; - case 6: is_same = (type_id == Type_Id_Lookup::type_id); break; - case 7: is_same = (type_id == Type_Id_Lookup::type_id); break; - default: break; - } - - return is_same; - } - - //*************************************************************************** - /// Calls the supplied reader instance. - /// The 'read' function appropriate to the current type is called with the stored value. - //*************************************************************************** - void call(reader& r) - { - switch (type_id) - { - case 0: r.read(static_cast(data)); break; - case 1: r.read(static_cast(data)); break; - case 2: r.read(static_cast(data)); break; - case 3: r.read(static_cast(data)); break; - case 4: r.read(static_cast(data)); break; - case 5: r.read(static_cast(data)); break; - case 6: r.read(static_cast(data)); break; - case 7: r.read(static_cast(data)); break; - default: break; - } - } - - //*************************************************************************** - /// Checks whether a valid value is currently stored. - ///\return true if the value is valid, otherwise false. - //*************************************************************************** - bool is_valid() const - { - return type_id != UNSUPPORTED_TYPE_ID; - } - - //*************************************************************************** - /// Checks to see if the type currently stored is the same as that specified in the template parameter. - ///\return true if it is the specified type, otherwise false. - //*************************************************************************** - template - bool is_type() const - { - return type_id == Type_Id_Lookup::type_id; - } - - //*************************************************************************** - /// Gets the index of the type currently stored or UNSUPPORTED_TYPE_ID - //*************************************************************************** - size_t index() const - { - return type_id; - } - - //*************************************************************************** - /// Clears the value to 'no valid stored value'. - //*************************************************************************** - void clear() - { - destruct_current(); - } - - //*************************************************************************** - /// Gets the value stored as the specified template type. - /// Throws a variant_incorrect_type_exception if the actual type is not that specified. - ///\return A reference to the value. - //*************************************************************************** - template - T& get() - { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); - ETL_ASSERT(is_type(), ETL_ERROR(variant_incorrect_type_exception)); - - return static_cast(data); - } - - //*************************************************************************** - /// Gets the value stored as the specified template type. - /// Throws a variant_incorrect_type_exception if the actual type is not that specified. - ///\return A const reference to the value. - //*************************************************************************** - template - const T& get() const - { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); - ETL_ASSERT(is_type(), ETL_ERROR(variant_incorrect_type_exception)); - - return static_cast(data); - } - - //*************************************************************************** - /// Gets the value stored as the specified template type. - ///\return A reference to the value. - //*************************************************************************** - template - TBase& upcast() - { - return *upcast_functor()(data, type_id); - } - - //*************************************************************************** - /// Gets the value stored as the specified template type. - ///\return A const reference to the value. - //*************************************************************************** - template - const TBase& upcast() const - { - return *upcast_functor()(data, type_id); - } - - //*************************************************************************** - /// Conversion operators for each type. - //*************************************************************************** - operator T1&() { return get(); } - operator T2&() { return get(); } - operator T3&() { return get(); } - operator T4&() { return get(); } - operator T5&() { return get(); } - operator T6&() { return get(); } - operator T7&() { return get(); } - operator T8&() { return get(); } - - //*************************************************************************** - /// Checks if the template type is supported by the implementation of variant.. - ///\return true if the type is supported, otherwise false. - //*************************************************************************** - template - static bool is_supported_type() - { - return Type_Is_Supported::value; - } - - private: - - //*************************************************************************** - /// Destruct the current occupant of the variant. - //*************************************************************************** - void destruct_current() - { - switch (type_id) - { - case 0: { static_cast(data)->~T1(); break; } - case 1: { static_cast(data)->~T2(); break; } - case 2: { static_cast(data)->~T3(); break; } - case 3: { static_cast(data)->~T4(); break; } - case 4: { static_cast(data)->~T5(); break; } - case 5: { static_cast(data)->~T6(); break; } - case 6: { static_cast(data)->~T7(); break; } - case 7: { static_cast(data)->~T8(); break; } - default: { break; } - } - - type_id = UNSUPPORTED_TYPE_ID; - } - - //************************************************************************* - //**** Up-cast functors *************************************************** - //************************************************************************* - - //************************************************************************* - /// Base upcast_functor for eight types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - case 3: return reinterpret_cast(p_data); - case 4: return reinterpret_cast(p_data); - case 5: return reinterpret_cast(p_data); - case 6: return reinterpret_cast(p_data); - case 7: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - - const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - case 3: return reinterpret_cast(p_data); - case 4: return reinterpret_cast(p_data); - case 5: return reinterpret_cast(p_data); - case 6: return reinterpret_cast(p_data); - case 7: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - }; - - //************************************************************************* - /// Upcast_functor for seven types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - case 3: return reinterpret_cast(p_data); - case 4: return reinterpret_cast(p_data); - case 5: return reinterpret_cast(p_data); - case 6: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - - const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - case 3: return reinterpret_cast(p_data); - case 4: return reinterpret_cast(p_data); - case 5: return reinterpret_cast(p_data); - case 6: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - }; - - //************************************************************************* - /// Upcast_functor for six types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - case 3: return reinterpret_cast(p_data); - case 4: return reinterpret_cast(p_data); - case 5: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - - const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - case 3: return reinterpret_cast(p_data); - case 4: return reinterpret_cast(p_data); - case 5: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - }; - - //************************************************************************* - /// Upcast_functor for five types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - case 3: return reinterpret_cast(p_data); - case 4: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - - const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - case 3: return reinterpret_cast(p_data); - case 4: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - }; - - //************************************************************************* - /// Upcast_functor for four types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - case 3: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - - const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - case 3: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - }; - - //************************************************************************* - /// Upcast_functor for three types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - - const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - case 2: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - }; - - //************************************************************************* - /// Upcast_functor for two types. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - - const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - case 1: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - }; - - //************************************************************************* - /// Upcast_functor for one type. - //************************************************************************* - template - class upcast_functor - { - public: - - TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - - const TBase* operator()(uint_least8_t* p_data, uint_least8_t typeId) const - { - switch (typeId) - { - case 0: return reinterpret_cast(p_data); - default: return reinterpret_cast(0); - } - } - }; - - //*************************************************************************** - /// The internal storage. - /// Aligned on a suitable boundary, which should be good for all types. - //*************************************************************************** - typename etl::aligned_storage::type data; - - //*************************************************************************** - /// The id of the current stored type. - //*************************************************************************** - type_id_t type_id; - }; -} - #endif diff --git a/include/etl/version.h b/include/etl/version.h index a763d4fc..3d86d6ee 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,8 +38,8 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 20 -#define ETL_VERSION_MINOR 12 -#define ETL_VERSION_PATCH 0 +#define ETL_VERSION_MINOR 14 +#define ETL_VERSION_PATCH 1 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 6a2af629..e6ec5ef2 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.12.0", + "version": "20.14.1", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index aa7cb1c7..ec1698a8 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.12.0 +version=20.14.1 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index aa473f82..f5ac7c02 100644 --- a/meson.build +++ b/meson.build @@ -8,7 +8,7 @@ project('PROJECT_NAME', 'cpp_std=c++17', 'build.cpp_std=c++17', ], meson_version: '>=0.54.0', - version: '20.12.0' + version: '20.14.1' ) ###################### diff --git a/support/Release notes.txt b/support/Release notes.txt index ab82c5b0..f815aadf 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,22 @@ +=============================================================================== +20.14.1 +Changed std::forward to etl::forward in etl::variant (variadic) + +=============================================================================== +20.14.0 +Added a vaiadic version of etl::variant. Usable for C++11 and up. +Added etl::overload pattern class. Groups lambdas into a functor class. +Refactored type_traits.h. Uses STL, compiler built-ins or user defined specialisations, dependent on settings. +Added etl::conditional_t to type_traits.h +Added etl::conjunction and etl::disjunction to type_traits.h +Added etl::integer_sequence to utility.h +Added etl::in_place, etl::in_place_t and etl::in_place_index_t. +Fixed missing etl::alignment_of specialisation for const void. + +=============================================================================== +20.13.0 +Added a specialisation of etl::delegate_service to allow constexpr service. + =============================================================================== 20.12.0 Added the option to derived etl::message<> from a parent class other than etl::imessage. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e0035f04..a9780307 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -101,6 +101,7 @@ set(TEST_SOURCE_FILES test_debounce.cpp test_delegate.cpp test_delegate_service.cpp + test_delegate_service_compile_time.cpp test_deque.cpp test_endian.cpp test_enum_type.cpp @@ -237,7 +238,8 @@ set(TEST_SOURCE_FILES test_user_type.cpp test_utility.cpp test_variance.cpp - test_variant.cpp + test_variant_legacy.cpp + test_variant_variadic.cpp test_variant_pool.cpp test_vector.cpp test_vector_external_buffer.cpp diff --git a/test/etl_profile.h b/test/etl_profile.h index c1652ae3..f4c983ce 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -78,8 +78,6 @@ SOFTWARE. //#define ETL_MESSAGES_ARE_VIRTUAL //#define ETL_POLYMORPHIC_MESSAGES -//#define ETL_NO_STL - #if defined(ETL_FORCE_TEST_CPP03) #define ETL_FUNCTION_FORCE_CPP03 #define ETL_PRIORITY_QUEUE_FORCE_CPP03 @@ -98,6 +96,10 @@ SOFTWARE. #define ETL_MEM_CAST_FORCE_CPP03 #endif +//#define ETL_OVERLOAD_FORCE_CPP11 +//#define ETL_VARIANT_FORCE_CPP11 +//#define ETL_VARIANT_CPP11_MAX_16_TYPES + #if defined(ETL_NO_STL) #define ETL_TIMER_SEMAPHORE_TYPE uint32_t #endif diff --git a/test/runsanitychecks.sh b/test/runsanitychecks.sh index 6806be53..42f7adbb 100755 --- a/test/runsanitychecks.sh +++ b/test/runsanitychecks.sh @@ -16,22 +16,42 @@ echo "-----------------------------------------------" echo "GCC - STL"; } >> ../log.txt g++ --version | head --lines=1 >> ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bgcc || echo "**** Failed ****" >> ../log.txt +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "GCC - No STL"; } >> ../log.txt g++ --version | head --lines=1 >> ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bgcc || echo "**** Failed ****" >> ../log.txt +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "GCC - No STL - Builtins"; } >> ../log.txt +g++ --version | head --lines=1 >> ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "GCC - No STL - User defined traits"; } >> ../log.txt +g++ --version | head --lines=1 >> ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "Clang - STL"; } >> ../log.txt clang++ --version | head --lines=1 >> ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bclang || echo "**** Failed ****" >> ../log.txt +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "Clang - No STL"; } >> ../log.txt clang++ --version | head --lines=1 >> ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bclang || echo "**** Failed ****" >> ../log.txt +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "Clang - No STL - Builtins"; } >> ../log.txt +clang++ --version | head --lines=1 >> ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "Clang - No STL - User defined traits"; } >> ../log.txt +clang++ --version | head --lines=1 >> ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt ############################################################################### cd ../c++11 || exit 1 @@ -44,22 +64,42 @@ echo "-----------------------------------------------" echo "GCC - STL"; } >> ../log.txt g++ --version | head --lines=1 >> ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bgcc || echo "**** Failed ****" >> ../log.txt +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "GCC - No STL"; } >> ../log.txt g++ --version | head --lines=1 >> ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bgcc || echo "**** Failed ****" >> ../log.txt +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "GCC - No STL - Builtins"; } >> ../log.txt +g++ --version | head --lines=1 >> ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "GCC - No STL - User defined traits"; } >> ../log.txt +g++ --version | head --lines=1 >> ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "Clang - STL"; } >> ../log.txt clang++ --version | head --lines=1 >> ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bclang || echo "**** Failed ****" >> ../log.txt +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "Clang - No STL"; } >> ../log.txt clang++ --version | head --lines=1 >> ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bclang || echo "**** Failed ****" >> ../log.txt +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "Clang - No STL - Builtins"; } >> ../log.txt +clang++ --version | head --lines=1 >> ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "Clang - No STL - User defined traits"; } >> ../log.txt +clang++ --version | head --lines=1 >> ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt ############################################################################### cd ../c++14 || exit 1 @@ -69,27 +109,47 @@ echo "-----------------------------------------------" echo " C++14" echo "-----------------------------------------------" -echo " GCC - STL"; } >> ../log.txt +echo "GCC - STL"; } >> ../log.txt g++ --version | head --lines=1 >> ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bgcc || echo "**** Failed ****" >> ../log.txt +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "GCC - No STL"; } >> ../log.txt g++ --version | head --lines=1 >> ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bgcc || echo "**** Failed ****" >> ../log.txt +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "GCC - No STL - Builtins"; } >> ../log.txt +g++ --version | head --lines=1 >> ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "GCC - No STL - User defined traits"; } >> ../log.txt +g++ --version | head --lines=1 >> ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "Clang - STL"; } >> ../log.txt clang++ --version | head --lines=1 >> ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bclang || echo "**** Failed ****" >> ../log.txt +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "Clang - No STL"; } >> ../log.txt clang++ --version | head --lines=1 >> ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bclang || echo "**** Failed ****" >> ../log.txt +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt - ############################################################################### +{ echo ""; echo "Clang - No STL - Builtins"; } >> ../log.txt +clang++ --version | head --lines=1 >> ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "Clang - No STL - User defined traits"; } >> ../log.txt +clang++ --version | head --lines=1 >> ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +############################################################################### cd ../c++17 || exit 1 cmake -E make_directory bgcc bclang { echo "" @@ -100,22 +160,42 @@ echo "-----------------------------------------------" echo "GCC - STL"; } >> ../log.txt g++ --version | head --lines=1 >> ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bgcc || echo "**** Failed ****" >> ../log.txt +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "GCC - No STL"; } >> ../log.txt g++ --version | head --lines=1 >> ../log.txt CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bgcc || echo "**** Failed ****" >> ../log.txt +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "GCC - No STL - Builtins"; } >> ../log.txt +g++ --version | head --lines=1 >> ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "GCC - No STL - User defined traits"; } >> ../log.txt +g++ --version | head --lines=1 >> ../log.txt +CC=gcc CXX=g++ cmake -E chdir bgcc cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +cmake --build bgcc || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "Clang - STL"; } >> ../log.txt clang++ --version | head --lines=1 >> ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=OFF .. -cmake --build bclang || echo "**** Failed ****" >> ../log.txt +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo ""; echo "Clang - No STL"; } >> ../log.txt clang++ --version | head --lines=1 >> ../log.txt CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON .. -cmake --build bclang || echo "**** Failed ****" >> ../log.txt +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "Clang - No STL - Builtins"; } >> ../log.txt +clang++ --version | head --lines=1 >> ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt + +{ echo ""; echo "Clang - No STL - User defined traits"; } >> ../log.txt +clang++ --version | head --lines=1 >> ../log.txt +CC=clang CXX=clang++ cmake -E chdir bclang cmake --cmake-clean-cache -DNO_STL=ON -DETL_USER_DEFINED_TYPE_TRAITS=ON .. +cmake --build bclang || echo "****************\n**** Failed ****\n****************" >> ../log.txt { echo "" echo "-----------------------------------------------" diff --git a/test/runtests.sh b/test/runtests.sh index e50b6006..51feeff5 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -2,40 +2,56 @@ #sudo ntpdate ntp.ubuntu.com cd build || exit 1 -echo "ETL Tests" > etl_test_log.txt +echo "ETL Tests" > log.txt echo "" -echo "-----------------------------------------------" >> etl_test_log.txt -echo " GCC" >> etl_test_log.txt -echo "-----------------------------------------------" >> etl_test_log.txt -gcc --version | grep gcc >> etl_test_log.txt +echo "-----------------------------------------------" >> log.txt +echo " GCC" >> log.txt +echo "-----------------------------------------------" >> log.txt +gcc --version | grep gcc >> log.txt CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=OFF .. -make -j8 -./etl_tests | tee etl_test_log.txt +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +./etl_tests | tee log.txt echo "" -echo "-----------------------------------------------" >> etl_test_log.txt -echo " GCC - No STL" >> etl_test_log.txt -echo "-----------------------------------------------" >> etl_test_log.txt -gcc --version | grep gcc >> etl_test_log.txt +echo "-----------------------------------------------" >> log.txt +echo " GCC - No STL" >> log.txt +echo "-----------------------------------------------" >> log.txt +gcc --version | grep gcc >> log.txt CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=ON .. -make -j8 -./etl_tests | tee etl_test_log.txt +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +./etl_tests | tee log.txt echo "" -echo "-----------------------------------------------" >> etl_test_log.txt -echo " Clang" >> etl_test_log.txt -echo "-----------------------------------------------" >> etl_test_log.txt -clang --version | grep clang >> etl_test_log.txt +echo "-----------------------------------------------" >> log.txt +echo " GCC - No STL - Builtins" >> log.txt +echo "-----------------------------------------------" >> log.txt +gcc --version | grep gcc >> log.txt +CC=gcc CXX=g++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +./etl_tests | tee log.txt +echo "" +echo "-----------------------------------------------" >> log.txt +echo " Clang" >> log.txt +echo "-----------------------------------------------" >> log.txt +clang --version | grep clang >> log.txt CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=OFF .. -make -j8 -./etl_tests | tee etl_test_log.txt +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +./etl_tests | tee log.txt echo "" -echo "-----------------------------------------------" >> etl_test_log.txt -echo " Clang - No STL" >> etl_test_log.txt -echo "-----------------------------------------------" >> etl_test_log.txt -clang --version | grep clang >> etl_test_log.txt +echo "-----------------------------------------------" >> log.txt +echo " Clang - No STL" >> log.txt +echo "-----------------------------------------------" >> log.txt +clang --version | grep clang >> log.txt CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON .. -make -j8 -./etl_tests | tee etl_test_log.txt +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +./etl_tests | tee log.txt echo "" -echo "-----------------------------------------------" >> etl_test_log.txt -echo " Tests Completed" >> etl_test_log.txt -echo "-----------------------------------------------" >> etl_test_log.txt +echo "-----------------------------------------------" >> log.txt +echo " Clang - No STL - Builtins" >> log.txt +echo "-----------------------------------------------" >> log.txt +clang --version | grep clang >> log.txt +CC=clang CXX=clang++ cmake --cmake-clean-cache -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=ON .. +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt +./etl_tests | tee log.txt +echo "" +echo "-----------------------------------------------" >> log.txt +echo " Tests Completed" >> log.txt +echo "-----------------------------------------------" >> log.txt diff --git a/test/sanity-check/c++03/CMakeLists.txt b/test/sanity-check/c++03/CMakeLists.txt index 809b1668..ff78e74f 100644 --- a/test/sanity-check/c++03/CMakeLists.txt +++ b/test/sanity-check/c++03/CMakeLists.txt @@ -174,6 +174,7 @@ target_sources(t98 PRIVATE etl_profile.h ../numeric.h.t.cpp ../observer.h.t.cpp ../optional.h.t.cpp + ../overload.h.t.cpp ../packet.h.t.cpp ../parameter_pack.h.t.cpp ../parameter_type.h.t.cpp @@ -243,7 +244,8 @@ target_sources(t98 PRIVATE etl_profile.h ../user_type.h.t.cpp ../utility.h.t.cpp ../variance.h.t.cpp - ../variant.h.t.cpp + ../variant_legacy.h.t.cpp + ../variant_variadic.h.t.cpp ../variant_pool.h.t.cpp ../vector.h.t.cpp ../version.h.t.cpp diff --git a/test/sanity-check/c++11/CMakeLists.txt b/test/sanity-check/c++11/CMakeLists.txt index 4443cc6e..aa401782 100644 --- a/test/sanity-check/c++11/CMakeLists.txt +++ b/test/sanity-check/c++11/CMakeLists.txt @@ -174,6 +174,7 @@ target_sources(t11 PRIVATE etl_profile.h ../numeric.h.t.cpp ../observer.h.t.cpp ../optional.h.t.cpp + ../overload.h.t.cpp ../packet.h.t.cpp ../parameter_pack.h.t.cpp ../parameter_type.h.t.cpp @@ -243,7 +244,8 @@ target_sources(t11 PRIVATE etl_profile.h ../user_type.h.t.cpp ../utility.h.t.cpp ../variance.h.t.cpp - ../variant.h.t.cpp + ../variant_legacy.h.t.cpp + ../variant_variadic.h.t.cpp ../variant_pool.h.t.cpp ../vector.h.t.cpp ../version.h.t.cpp diff --git a/test/sanity-check/c++14/CMakeLists.txt b/test/sanity-check/c++14/CMakeLists.txt index d991fca0..40996189 100644 --- a/test/sanity-check/c++14/CMakeLists.txt +++ b/test/sanity-check/c++14/CMakeLists.txt @@ -174,6 +174,7 @@ target_sources(t14 PRIVATE etl_profile.h ../numeric.h.t.cpp ../observer.h.t.cpp ../optional.h.t.cpp + ../overload.h.t.cpp ../packet.h.t.cpp ../parameter_pack.h.t.cpp ../parameter_type.h.t.cpp @@ -243,7 +244,8 @@ target_sources(t14 PRIVATE etl_profile.h ../user_type.h.t.cpp ../utility.h.t.cpp ../variance.h.t.cpp - ../variant.h.t.cpp + ../variant_legacy.h.t.cpp + ../variant_variadic.h.t.cpp ../variant_pool.h.t.cpp ../vector.h.t.cpp ../version.h.t.cpp diff --git a/test/sanity-check/c++17/CMakeLists.txt b/test/sanity-check/c++17/CMakeLists.txt index 2a96532e..81cdbb4a 100644 --- a/test/sanity-check/c++17/CMakeLists.txt +++ b/test/sanity-check/c++17/CMakeLists.txt @@ -174,6 +174,7 @@ target_sources(t17 PRIVATE etl_profile.h ../numeric.h.t.cpp ../observer.h.t.cpp ../optional.h.t.cpp + ../overload.h.t.cpp ../packet.h.t.cpp ../parameter_pack.h.t.cpp ../parameter_type.h.t.cpp @@ -243,7 +244,8 @@ target_sources(t17 PRIVATE etl_profile.h ../user_type.h.t.cpp ../utility.h.t.cpp ../variance.h.t.cpp - ../variant.h.t.cpp + ../variant_legacy.h.t.cpp + ../variant_variadic.h.t.cpp ../variant_pool.h.t.cpp ../vector.h.t.cpp ../version.h.t.cpp diff --git a/test/sanity-check/overload.h.t.cpp b/test/sanity-check/overload.h.t.cpp new file mode 100644 index 00000000..500f4bcb --- /dev/null +++ b/test/sanity-check/overload.h.t.cpp @@ -0,0 +1,29 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 John Wellbelove + +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. +******************************************************************************/ + +#include diff --git a/test/sanity-check/variant_legacy.h.t.cpp b/test/sanity-check/variant_legacy.h.t.cpp new file mode 100644 index 00000000..d95072de --- /dev/null +++ b/test/sanity-check/variant_legacy.h.t.cpp @@ -0,0 +1,29 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 John Wellbelove + +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. +******************************************************************************/ + +#include diff --git a/test/sanity-check/variant_old.h.t.cpp b/test/sanity-check/variant_old.h.t.cpp new file mode 100644 index 00000000..c306bbfb --- /dev/null +++ b/test/sanity-check/variant_old.h.t.cpp @@ -0,0 +1,29 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 John Wellbelove + +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. +******************************************************************************/ + +#include diff --git a/test/sanity-check/variant_variadic.h.t.cpp b/test/sanity-check/variant_variadic.h.t.cpp new file mode 100644 index 00000000..82835c85 --- /dev/null +++ b/test/sanity-check/variant_variadic.h.t.cpp @@ -0,0 +1,29 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 John Wellbelove + +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. +******************************************************************************/ + +#include diff --git a/test/test_delegate.cpp b/test/test_delegate.cpp index cd8f4cd9..9d2858ba 100644 --- a/test/test_delegate.cpp +++ b/test/test_delegate.cpp @@ -133,13 +133,13 @@ namespace void member_reference(const Data& data, int j) { function_called = true; - parameter_correct = (data.d == VALUE1) && (j = VALUE2); + parameter_correct = (data.d == VALUE1) && (j == VALUE2); } void member_reference_const(const Data& data, int j) const { function_called = true; - parameter_correct = (data.d == VALUE1) && (j = VALUE2); + parameter_correct = (data.d == VALUE1) && (j == VALUE2); } //******************************************* @@ -155,7 +155,7 @@ namespace static void member_static(const Data& data, int j) { function_called = true; - parameter_correct = (data.d == VALUE1) && (j = VALUE2); + parameter_correct = (data.d == VALUE1) && (j == VALUE2); } //******************************************* diff --git a/test/test_delegate_service.cpp b/test/test_delegate_service.cpp index 8e20f10b..f6613370 100644 --- a/test/test_delegate_service.cpp +++ b/test/test_delegate_service.cpp @@ -33,10 +33,10 @@ SOFTWARE. namespace { - const size_t SIZE = 3U; - const size_t OFFSET = 5U; + const size_t Size = 3U; + const size_t Offset = 5U; - using Service = etl::delegate_service; + using Service = etl::delegate_service; //***************************************************************************** bool global_called = false; @@ -94,13 +94,13 @@ namespace Test test; // Callback for 'member2'. - etl::delegate member_callback = etl::delegate::create(); + constexpr etl::delegate member_callback = etl::delegate::create(); // Callback for 'global'. - etl::delegate global_callback = etl::delegate::create(); + constexpr etl::delegate global_callback = etl::delegate::create(); // Callback for 'unhandled'. - etl::delegate unhandled_callback = etl::delegate::create(); + constexpr etl::delegate unhandled_callback = etl::delegate::create(); //***************************************************************************** // Initialises the test results. @@ -109,10 +109,10 @@ namespace { SetupFixture() { - called_id = UINT_MAX; - global_called = false; - member1_called = false; - member2_called = false; + called_id = UINT_MAX; + global_called = false; + member1_called = false; + member2_called = false; unhandled_called = false; } }; @@ -122,10 +122,10 @@ namespace { enum { - GLOBAL = OFFSET, - MEMBER1, - MEMBER2, - OUT_OF_RANGE + Global = Offset, + Member1, + Member2, + Out_Of_Range }; SUITE(test_delegate_service) @@ -135,13 +135,13 @@ namespace { Service service; - service.register_delegate(global_callback); - service.register_delegate(test.callback); - service.register_delegate(member_callback); + service.register_delegate(global_callback); + service.register_delegate(test.callback); + service.register_delegate(member_callback); - service.call(); + service.call(); - CHECK_EQUAL(GLOBAL, called_id); + CHECK_EQUAL(Global, called_id); CHECK(global_called); CHECK(!member1_called); CHECK(!member2_called); @@ -153,13 +153,13 @@ namespace { Service service; - service.register_delegate(GLOBAL, global_callback); - service.register_delegate(MEMBER1, test.callback); - service.register_delegate(MEMBER2, member_callback); + service.register_delegate(Global, global_callback); + service.register_delegate(Member1, test.callback); + service.register_delegate(Member2, member_callback); - service.call(GLOBAL); + service.call(Global); - CHECK_EQUAL(GLOBAL, called_id); + CHECK_EQUAL(Global, called_id); CHECK(global_called); CHECK(!member1_called); CHECK(!member2_called); @@ -171,13 +171,13 @@ namespace { Service service; - service.register_delegate(global_callback); - service.register_delegate(test.callback); - service.register_delegate(member_callback); + service.register_delegate(global_callback); + service.register_delegate(test.callback); + service.register_delegate(member_callback); - service.call(); + service.call(); - CHECK_EQUAL(MEMBER1, called_id); + CHECK_EQUAL(Member1, called_id); CHECK(!global_called); CHECK(member1_called); CHECK(!member2_called); @@ -189,13 +189,13 @@ namespace { Service service; - service.register_delegate(GLOBAL, global_callback); - service.register_delegate(MEMBER1, test.callback); - service.register_delegate(MEMBER2, member_callback); + service.register_delegate(Global, global_callback); + service.register_delegate(Member1, test.callback); + service.register_delegate(Member2, member_callback); - service.call(MEMBER1); + service.call(Member1); - CHECK_EQUAL(MEMBER1, called_id); + CHECK_EQUAL(Member1, called_id); CHECK(!global_called); CHECK(member1_called); CHECK(!member2_called); @@ -207,13 +207,13 @@ namespace { Service service; - service.register_delegate(global_callback); - service.register_delegate(test.callback); - service.register_delegate(member_callback); + service.register_delegate(global_callback); + service.register_delegate(test.callback); + service.register_delegate(member_callback); - service.call(); + service.call(); - CHECK_EQUAL(MEMBER2, called_id); + CHECK_EQUAL(Member2, called_id); CHECK(!global_called); CHECK(!member1_called); CHECK(member2_called); @@ -225,11 +225,11 @@ namespace { Service service; - service.register_delegate(global_callback); - service.register_delegate(test.callback); - service.register_delegate(member_callback); + service.register_delegate(global_callback); + service.register_delegate(test.callback); + service.register_delegate(member_callback); - service.call(OUT_OF_RANGE); + service.call(Out_Of_Range); CHECK_EQUAL(UINT_MAX, called_id); CHECK(!global_called); @@ -243,15 +243,15 @@ namespace { Service service; - service.register_delegate(global_callback); - service.register_delegate(test.callback); - service.register_delegate(member_callback); + service.register_delegate(global_callback); + service.register_delegate(test.callback); + service.register_delegate(member_callback); service.register_unhandled_delegate(unhandled_callback); - service.call(OUT_OF_RANGE); + service.call(Out_Of_Range); - CHECK_EQUAL(OUT_OF_RANGE, called_id); + CHECK_EQUAL(Out_Of_Range, called_id); CHECK(!global_called); CHECK(!member1_called); CHECK(!member2_called); @@ -263,10 +263,10 @@ namespace { Service service; - service.register_delegate(global_callback); - service.register_delegate(member_callback); + service.register_delegate(global_callback); + service.register_delegate(member_callback); - service.call(); + service.call(); CHECK_EQUAL(UINT_MAX, called_id); CHECK(!global_called); @@ -280,10 +280,10 @@ namespace { Service service; - service.register_delegate(GLOBAL, global_callback); - service.register_delegate(MEMBER2, member_callback); + service.register_delegate(Global, global_callback); + service.register_delegate(Member2, member_callback); - service.call(MEMBER1); + service.call(Member1); CHECK_EQUAL(UINT_MAX, called_id); CHECK(!global_called); @@ -297,14 +297,14 @@ namespace { Service service; - service.register_delegate(global_callback); - service.register_delegate(member_callback); + service.register_delegate(global_callback); + service.register_delegate(member_callback); service.register_unhandled_delegate(unhandled_callback); - service.call(); + service.call(); - CHECK_EQUAL(MEMBER1, called_id); + CHECK_EQUAL(Member1, called_id); CHECK(!global_called); CHECK(!member1_called); CHECK(!member2_called); @@ -316,14 +316,14 @@ namespace { Service service; - service.register_delegate(GLOBAL, global_callback); - service.register_delegate(MEMBER2, member_callback); + service.register_delegate(Global, global_callback); + service.register_delegate(Member2, member_callback); service.register_unhandled_delegate(unhandled_callback); - service.call(MEMBER1); + service.call(Member1); - CHECK_EQUAL(MEMBER1, called_id); + CHECK_EQUAL(Member1, called_id); CHECK(!global_called); CHECK(!member1_called); CHECK(!member2_called); diff --git a/test/test_delegate_service_compile_time.cpp b/test/test_delegate_service_compile_time.cpp new file mode 100644 index 00000000..14b5faf8 --- /dev/null +++ b/test/test_delegate_service_compile_time.cpp @@ -0,0 +1,161 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2019 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. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include "etl/delegate.h" +#include "etl/delegate_service.h" + +namespace +{ + const size_t Size = 2U; + const size_t Offset = 5U; + + using Service = etl::delegate_service; + + //***************************************************************************** + bool global_called = false; + bool member_called = false; + bool unhandled_called = false; + size_t called_id = UINT_MAX; + + //***************************************************************************** + // The global function taking no parameters. + //***************************************************************************** + void global(size_t id) + { + global_called = true; + called_id = id; + } + + //***************************************************************************** + // The external unhandled callback. + //***************************************************************************** + void unhandled(size_t id) + { + unhandled_called = true; + called_id = id; + } + + //***************************************************************************** + // The test class with member functions. + //***************************************************************************** + class Test + { + public: + + Test() + { + } + + void member(size_t id) + { + member_called = true; + called_id = id; + } + }; + + Test test; + + // Callback for 'member'. + constexpr etl::delegate member_callback = etl::delegate::create(); + + // Callback for 'global'. + constexpr etl::delegate global_callback = etl::delegate::create(); + + // Callback for 'unhandled'. + constexpr etl::delegate unhandled_callback = etl::delegate::create(); + + constexpr etl::delegate delegate_list[] + { + global_callback, + member_callback, + unhandled_callback + }; + + //***************************************************************************** + // Initialises the test results. + //***************************************************************************** + struct SetupFixture + { + SetupFixture() + { + called_id = UINT_MAX; + global_called = false; + member_called = false; + unhandled_called = false; + } + }; +} + +namespace +{ + enum + { + Global = Offset, + Member, + Out_Of_Range + }; + + SUITE(test_delegate_service) + { + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_delegate_compile_time_constexpr) + { + etl::delegate_service service; + + service.call(); + CHECK_EQUAL(Global, called_id); + CHECK(global_called); + CHECK(!member_called); + CHECK(!unhandled_called); + + called_id = UINT_MAX; + global_called = false; + member_called = false; + unhandled_called = false; + + service.call(); + CHECK_EQUAL(Member, called_id); + CHECK(!global_called); + CHECK(member_called); + CHECK(!unhandled_called); + + called_id = UINT_MAX; + global_called = false; + member_called = false; + unhandled_called = false; + + service.call(Out_Of_Range); + CHECK_EQUAL(Out_Of_Range, called_id); + CHECK(!global_called); + CHECK(!member_called); + CHECK(unhandled_called); + } + }; +} diff --git a/test/test_mem_cast.cpp b/test/test_mem_cast.cpp index 304be224..f233a81f 100644 --- a/test/test_mem_cast.cpp +++ b/test/test_mem_cast.cpp @@ -68,9 +68,7 @@ namespace using MemCast = etl::mem_cast; using MemCastTypes = etl::mem_cast_types; - char c; - double d; - Data data; + Data data; SUITE(test_mem_cast) { diff --git a/test/test_mem_cast_ptr.cpp b/test/test_mem_cast_ptr.cpp index 582d9c7a..2cc88738 100644 --- a/test/test_mem_cast_ptr.cpp +++ b/test/test_mem_cast_ptr.cpp @@ -65,8 +65,6 @@ namespace // Test variant types. using MemCast = etl::mem_cast_ptr; - char c; - double d; Data data; char* Ptr(int i) @@ -83,8 +81,6 @@ namespace { MemCast memCast; - char* p = nullptr; - memCast.data(Ptr(1)); CHECK_EQUAL(1U , memCast.alignment()); diff --git a/test/test_mem_type.cpp b/test/test_mem_type.cpp new file mode 100644 index 00000000..b0d1db30 --- /dev/null +++ b/test/test_mem_type.cpp @@ -0,0 +1,88 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 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. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include "etl/experimental/mem_type.h" +#include "etl/largest.h" + +#include +#include +#include +#include + +namespace +{ + struct Data + { + char c; + short s; + std::array a; + }; + + // Test variant types. + using MemType = etl::mem_type::size, + etl::largest::alignment>; + + SUITE(test_mem_type) + { + TEST(test_alignment) + { + MemType memType; + + CHECK(alignof(char) <= MemType::Alignment); + CHECK(alignof(short) <= MemType::Alignment); + CHECK(alignof(Data) <= MemType::Alignment); + + CHECK(alignof(char) <= memType.Alignment); + CHECK(alignof(short) <= memType.Alignment); + CHECK(alignof(Data) <= memType.Alignment); + + CHECK(alignof(char) <= memType.alignment()); + CHECK(alignof(short) <= memType.alignment()); + CHECK(alignof(Data) <= memType.alignment()); + } + + TEST(test_size) + { + MemType memType; + + CHECK(sizeof(char) <= MemType::Size); + CHECK(sizeof(short) <= MemType::Size); + CHECK(sizeof(Data) <= MemType::Size); + + CHECK(sizeof(char) <= memType.Size); + CHECK(sizeof(short) <= memType.Size); + CHECK(sizeof(Data) <= memType.Size); + + CHECK(sizeof(char) <= memType.size()); + CHECK(sizeof(short) <= memType.size()); + CHECK(sizeof(Data) <= memType.size()); + } + }; +} diff --git a/test/test_overload.cpp b/test/test_overload.cpp new file mode 100644 index 00000000..a9f50369 --- /dev/null +++ b/test/test_overload.cpp @@ -0,0 +1,164 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2015 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. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include "etl/overload.h" + +#include + +namespace +{ + struct Result + { + Result() + : bi(false) + , bd(false) + , bs(false) + { + } + + void clear() + { + bi = false; + bd = false; + bs = false; + } + + bool bi; + bool bd; + bool bs; + }; + + Result result; + + struct Visitor + { + void operator ()(int i) { result.bi = true; } + void operator ()(double d) { result.bd = true; } + void operator ()(const std::string& s) { result.bs = true; } + }; + + template + void Function(T value, TOverload&& ol) + { + ol(value); + } + + SUITE(test_overload) + { + //************************************************************************* + TEST(test_overload_lambdas) + { + auto overload = etl::make_overload([](int i) { result.bi = true; }, + [](double d) { result.bd = true; }, + [](const std::string& s) { result.bs = true; }); + + result.clear(); + Function(int(1), overload); + CHECK(result.bi == true); + CHECK(result.bd == false); + CHECK(result.bs == false); + + result.clear(); + Function(double(2.0), overload); + CHECK(result.bi == false); + CHECK(result.bd == true); + CHECK(result.bs == false); + + result.clear(); + Function(std::string("3"), overload); + CHECK(result.bi == false); + CHECK(result.bd == false); + CHECK(result.bs == true); + } + + //************************************************************************* + TEST(test_overload_lambdas_cpp17) + { +#if !defined(ETL_OVERLOAD_FORCE_CPP14) + result.clear(); + Function(int(1), etl::overload + { + [](int i) { result.bi = true; }, + [](double d) { result.bd = true; }, + [](const std::string& s) { result.bs = true; } + }); + CHECK(result.bi == true); + CHECK(result.bd == false); + CHECK(result.bs == false); + + result.clear(); + Function(double(2.0), etl::overload + { + [](int i) { result.bi = true; }, + [](double d) { result.bd = true; }, + [](const std::string& s) { result.bs = true; } + }); + CHECK(result.bi == false); + CHECK(result.bd == true); + CHECK(result.bs == false); + + result.clear(); + Function(std::string("3"), etl::overload + { + [](int i) { result.bi = true; }, + [](double d) { result.bd = true; }, + [](const std::string& s) { result.bs = true; } + }); + CHECK(result.bi == false); + CHECK(result.bd == false); + CHECK(result.bs == true); +#endif + } + + //************************************************************************* + TEST(test_visitor_overload) + { + auto overload = etl::make_overload(Visitor()); + + result.clear(); + Function(int(1), overload); + CHECK(result.bi == true); + CHECK(result.bd == false); + CHECK(result.bs == false); + + result.clear(); + Function(double(2.0), overload); + CHECK(result.bi == false); + CHECK(result.bd == true); + CHECK(result.bs == false); + + result.clear(); + Function(std::string("3"), overload); + CHECK(result.bi == false); + CHECK(result.bd == false); + CHECK(result.bs == true); + } + }; +} diff --git a/test/test_parameter_pack.cpp b/test/test_parameter_pack.cpp index 1ab28fd5..66a91296 100644 --- a/test/test_parameter_pack.cpp +++ b/test/test_parameter_pack.cpp @@ -30,8 +30,6 @@ SOFTWARE. #include "etl/parameter_pack.h" -#include - namespace { using Pack = etl::parameter_pack; @@ -47,6 +45,13 @@ namespace // Static assert //CHECK_EQUAL(0U, Pack::index_of_type_v); + + CHECK_EQUAL(0U, (etl::parameter_pack_v)); + CHECK_EQUAL(1U, (etl::parameter_pack_v)); + CHECK_EQUAL(2U, (etl::parameter_pack_v)); + + // Static assert + //CHECK_EQUAL(0U, (etl::parameter_pack_v)); } //************************************************************************* @@ -58,6 +63,13 @@ namespace // Static assert //CHECK((std::is_same_v>)); + + CHECK((std::is_same_v>)); + CHECK((std::is_same_v>)); + CHECK((std::is_same_v>)); + + // Static assert + //CHECK((std::is_same_v>)); } }; } diff --git a/test/test_pool.cpp b/test/test_pool.cpp index 4c6d32a8..0779e33e 100644 --- a/test/test_pool.cpp +++ b/test/test_pool.cpp @@ -448,6 +448,27 @@ namespace int* i = pool.allocate(); pool.release(i); + } + + //************************************************************************* + TEST(test_issue_406_pool_of_c_array) + { + using elem_type = uint8_t[10]; + + etl::pool memPool{}; + + CHECK_EQUAL(3, memPool.available()); + CHECK_EQUAL(0, memPool.size()); + + elem_type* memory = memPool.allocate(); + + CHECK_EQUAL(2, memPool.available()); + CHECK_EQUAL(1, memPool.size()); + + memPool.release(memory); + + CHECK_EQUAL(3, memPool.available()); + CHECK_EQUAL(0, memPool.size()); } } diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index 8230581f..b3f8b938 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -56,6 +56,113 @@ namespace { }; + //********************************************* + struct Copyable + { + Copyable() {} + Copyable(const Copyable& other) noexcept {} + Copyable& operator =(const Copyable& rhs) noexcept { return *this; } + + Copyable(Copyable&& other) = delete; + Copyable& operator =(Copyable& rhs) = delete; + }; + + //********************************************* + struct Moveable + { + Moveable() {} + Moveable(Moveable&& other) noexcept { } + Moveable& operator =(Moveable&& rhs) noexcept { return *this; } + + Moveable(const Moveable& other) = delete; + Moveable& operator =(const Moveable& rhs) = delete; + }; + + //********************************************* + struct MoveableCopyable + { + MoveableCopyable() {} + MoveableCopyable(MoveableCopyable&& other) noexcept {} + MoveableCopyable& operator =(MoveableCopyable&& rhs) noexcept { return *this; } + MoveableCopyable(const MoveableCopyable& other) {} + MoveableCopyable& operator =(const MoveableCopyable& rhs) { return *this; } + }; +} + +// Definitions for when the STL and compiler built-ins are not avalable. +#if ETL_NOT_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) + +using etl::is_assignable; +using etl::is_constructible; +using etl::is_copy_constructible; +using etl::is_move_constructible; + +//************************* +template <> +struct etl::is_assignable : public etl::true_type +{ +}; + +template <> +struct etl::is_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::false_type +{ +}; + +//************************* +template <> +struct etl::is_assignable : public etl::true_type +{ +}; + +template <> +struct etl::is_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_copy_constructible : public etl::false_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; + +//************************* +template <> +struct etl::is_assignable : public etl::true_type +{ +}; + +template <> +struct etl::is_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; +#endif + +namespace +{ SUITE(test_type_traits) { //************************************************************************* @@ -871,4 +978,110 @@ namespace CHECK((etl::are_all_same::value == true)); CHECK((etl::are_all_same::value == false)); } + + //************************************************************************* + TEST(test_conjunction) + { + CHECK((etl::conjunction_v)); + CHECK((!etl::conjunction_v)); + } + + //************************************************************************* + TEST(test_disjunction) + { + CHECK((etl::disjunction_v)); + CHECK((!etl::disjunction_v)); + } + + //************************************************************************* + TEST(test_is_assignable) + { + CHECK((etl::is_assignable_v) == (std::is_assignable_v)); + CHECK((etl::is_assignable_v) == (std::is_assignable_v)); + CHECK((etl::is_assignable_v) == (std::is_assignable_v)); + } + + //************************************************************************* + TEST(test_is_lvalue_assignable) + { +#if ETL_USING_STL || defined(ETL_USE_TYPE_TRAITS_BUILTINS) || defined(ETL_USER_DEFINED_TYPE_TRAITS) + CHECK((etl::is_lvalue_assignable_v)); + CHECK(!(etl::is_lvalue_assignable_v)); + CHECK((etl::is_lvalue_assignable_v)); +#endif + } + + //************************************************************************* + TEST(test_is_constructible) + { + CHECK((etl::is_constructible_v) == (std::is_constructible_v)); + CHECK((etl::is_constructible_v) == (std::is_constructible_v)); + CHECK((etl::is_constructible_v) == (std::is_constructible_v)); + } + + //************************************************************************* + TEST(test_is_copy_constructible) + { + CHECK((etl::is_copy_constructible_v) == (std::is_copy_constructible_v)); + CHECK((etl::is_copy_constructible_v) == (std::is_copy_constructible_v)); + CHECK((etl::is_copy_constructible_v) == (std::is_copy_constructible_v)); + } + + //************************************************************************* + TEST(test_is_move_constructible) + { + CHECK((etl::is_move_constructible_v) == (std::is_move_constructible_v)); + CHECK((etl::is_move_constructible_v) == (std::is_move_constructible_v)); + CHECK((etl::is_move_constructible_v) == (std::is_move_constructible_v)); + } + + //************************************************************************* + TEST(test_is_trivially_constructible) + { +#if ETL_USING_STL || defined(ETL_USE_TYPE_TRAITS_BUILTINS) || defined(ETL_USER_DEFINED_TYPE_TRAITS) + CHECK((etl::is_trivially_constructible_v) == (std::is_trivially_constructible_v)); + CHECK((etl::is_trivially_constructible_v) == (std::is_trivially_constructible_v)); + CHECK((etl::is_trivially_constructible_v) == (std::is_trivially_constructible_v)); +#endif + } + + //************************************************************************* + TEST(test_is_trivially_copy_constructible) + { +#if ETL_USING_STL || defined(ETL_USE_TYPE_TRAITS_BUILTINS) || defined(ETL_USER_DEFINED_TYPE_TRAITS) + CHECK((etl::is_trivially_copy_constructible_v) == (std::is_trivially_copy_constructible_v)); + CHECK((etl::is_trivially_copy_constructible_v) == (std::is_trivially_copy_constructible_v)); + CHECK((etl::is_trivially_copy_constructible_v) == (std::is_trivially_copy_constructible_v)); +#endif + } + + //************************************************************************* + TEST(test_is_trivially_destructible) + { +#if ETL_USING_STL || defined(ETL_USE_TYPE_TRAITS_BUILTINS) || defined(ETL_USER_DEFINED_TYPE_TRAITS) + CHECK((etl::is_trivially_destructible_v) == (std::is_trivially_destructible_v)); + CHECK((etl::is_trivially_destructible_v) == (std::is_trivially_destructible_v)); + CHECK((etl::is_trivially_destructible_v) == (std::is_trivially_destructible_v)); +#endif + } + + //************************************************************************* + TEST(test_is_trivially_copy_assignable) + { +#if ETL_USING_STL || defined(ETL_USE_TYPE_TRAITS_BUILTINS) || defined(ETL_USER_DEFINED_TYPE_TRAITS) + CHECK((etl::is_trivially_copy_assignable_v) == (std::is_trivially_copy_assignable_v)); + CHECK((etl::is_trivially_copy_assignable_v) == (std::is_trivially_copy_assignable_v)); + CHECK((etl::is_trivially_copy_assignable_v) == (std::is_trivially_copy_assignable_v)); +#endif + } + + //************************************************************************* + TEST(test_is_trivially_copyable) + { +#if ETL_USING_STL || defined(ETL_USE_TYPE_TRAITS_BUILTINS) || defined(ETL_USER_DEFINED_TYPE_TRAITS) + CHECK((etl::is_trivially_copyable_v) == (std::is_trivially_copyable_v)); + CHECK((etl::is_trivially_copyable_v) == (std::is_trivially_copyable_v)); + CHECK((etl::is_trivially_copyable_v) == (std::is_trivially_copyable_v)); +#endif + } } diff --git a/test/test_variant.cpp b/test/test_variant_legacy.cpp similarity index 99% rename from test/test_variant.cpp rename to test/test_variant_legacy.cpp index 1d6a40b2..208f8a53 100644 --- a/test/test_variant.cpp +++ b/test/test_variant_legacy.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "unit_test_framework.h" -#include "etl/variant.h" +#include "etl/private/variant_legacy.h" #include #include diff --git a/test/test_variant_variadic.cpp b/test/test_variant_variadic.cpp new file mode 100644 index 00000000..3da00fd2 --- /dev/null +++ b/test/test_variant_variadic.cpp @@ -0,0 +1,1171 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2021 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. +******************************************************************************/ + +#include "unit_test_framework.h" + +#include "etl/private/variant_variadic.h" +#include "etl/visitor.h" +#include "etl/overload.h" + +#include +#include +#include +#include +#include +#include + +namespace +{ + // Test variant_etl types. + using test_variant_etl_3 = etl::variant; + using test_variant_std_3 = std::variant; + + struct D1 + { + D1(const std::string& a_) + : a(a_) + { + copied = false; + moved = false; + } + + D1(const D1& other) + : a(other.a) + { + copied = true; + moved = false; + } + + D1(D1&& other) + : a(std::move(other.a)) + { + copied = false; + moved = true; + } + + std::string a; + bool copied; + bool moved; + }; + + struct D2 + { + D2(const std::string& a_, const std::string& b_) + : a(a_), + b(b_) + { + } + + std::string a; + std::string b; + }; + + struct D3 + { + D3(const std::string& a_, const std::string& b_, const std::string& c_) + : a(a_), + b(b_), + c(c_) + { + } + + std::string a; + std::string b; + std::string c; + }; + + struct D4 + { + D4(const std::string& a_, const std::string& b_, const std::string& c_, const std::string& d_) + : a(a_), + b(b_), + c(c_), + d(d_) + { + } + + std::string a; + std::string b; + std::string c; + std::string d; + }; + + bool operator == (const D1& lhs, const D1& rhs) + { + return (lhs.a == rhs.a); + } + + bool operator == (const D2& lhs, const D2& rhs) + { + return (lhs.a == rhs.a) && (lhs.b == rhs.b); + } + + bool operator == (const D3& lhs, const D3& rhs) + { + return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c); + } + + bool operator == (const D4& lhs, const D4& rhs) + { + return (lhs.a == rhs.a) && (lhs.b == rhs.b) && (lhs.c == rhs.c) && (lhs.d == rhs.d); + } + + std::ostream& operator <<(std::ostream& os, const D1& d1) + { + os << d1.a; + + return os; + } + + std::ostream& operator <<(std::ostream& os, const D2& d2) + { + os << d2.a << " " << d2.b; + + return os; + } + + std::ostream& operator <<(std::ostream& os, const D3& d3) + { + os << d3.a << " " << d3.b << " " << d3.c; + + return os; + } + + std::ostream& operator <<(std::ostream& os, const D4& d4) + { + os << d4.a << " " << d4.b << " " << d4.c << " " << d4.d; + + return os; + } + + typedef etl::variant test_variant_emplace; + + //********************************************* + struct Copyable + { + Copyable() + : moved_from(false) + , moved_to(false) + , copied_to(false) + { + } + + Copyable(const Copyable& other) noexcept + { + moved_from = false; + moved_to = false; + copied_to = true; + } + + Copyable& operator =(const Copyable& rhs) noexcept + { + moved_from = false; + moved_to = false; + copied_to = true; + + return *this; + } + + bool moved_from; + bool moved_to; + bool copied_to; + }; + + //********************************************* + struct Moveable + { + Moveable() + : moved_from(false) + , moved_to(false) + , copied_to(false) + { + } + + Moveable(Moveable&& other) noexcept + { + moved_from = false; + moved_to = true; + copied_to = false; + other.moved_from = true; + other.moved_to = false; + other.copied_to = false; + } + + Moveable& operator =(Moveable&& rhs) noexcept + { + moved_from = false; + moved_to = true; + copied_to = false; + rhs.moved_from = true; + rhs.moved_to = false; + rhs.copied_to = false; + + return *this; + } + + Moveable(const Moveable& other) = delete; + Moveable& operator =(const Moveable& rhs) = delete; + + bool moved_from; + bool moved_to; + bool copied_to; + }; + + //********************************************* + struct MoveableCopyable + { + MoveableCopyable() + : moved_from(false) + , moved_to(false) + , copied_to(false) + { + } + + MoveableCopyable(MoveableCopyable&& other) noexcept + { + moved_from = false; + moved_to = true; + copied_to = false; + other.moved_from = true; + other.moved_to = false; + other.copied_to = false; + } + + MoveableCopyable& operator =(MoveableCopyable&& rhs) noexcept + { + moved_from = false; + moved_to = true; + copied_to = false; + rhs.moved_from = true; + rhs.moved_to = false; + rhs.copied_to = false; + + return *this; + } + + MoveableCopyable(const MoveableCopyable& other) + { + moved_from = false; + moved_to = false; + copied_to = true; + } + + MoveableCopyable& operator =(const MoveableCopyable& rhs) + { + moved_to = false; + moved_from = false; + copied_to = true; + + return *this; + } + + bool moved_from; + bool moved_to; + bool copied_to; + }; +} + +// Definitions for when the STL and compiler built-ins are not avalable. +#if ETL_NOT_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) + +using etl::is_copy_constructible; +using etl::is_move_constructible; + +//************************* +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; + +//************************* +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; + +//************************* +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; + +//************************* +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; + +//************************* +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; + +//************************* +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::false_type +{ +}; + +//************************* +template <> +struct etl::is_copy_constructible : public etl::false_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; + +//************************* +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; + +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; +#endif + +namespace +{ + SUITE(test_variant) + { + TEST(test_alignment) + { + typedef etl::variant test_variant_a; + typedef etl::variant test_variant_b; + typedef etl::variant test_variant_c; + typedef etl::variant test_variant_d; + + static test_variant_a a(char('1')); + static test_variant_b b(short(2)); + static test_variant_c c(3); + static test_variant_d d(4.5); + + CHECK((uintptr_t(&etl::get(a)) % uintptr_t(etl::alignment_of::value)) == 0); + CHECK((uintptr_t(&etl::get(b)) % uintptr_t(etl::alignment_of::value)) == 0); + CHECK((uintptr_t(&etl::get(c)) % uintptr_t(etl::alignment_of::value)) == 0); + CHECK((uintptr_t(&etl::get(d)) % uintptr_t(etl::alignment_of::value)) == 0); + } + + //************************************************************************* + TEST(test_constructor_default) + { + CHECK_NO_THROW(test_variant_etl_3 variant_etl); + + test_variant_etl_3 variant_etl; + + CHECK(etl::holds_alternative(variant_etl)); + CHECK(!etl::holds_alternative(variant_etl)); + CHECK(!etl::holds_alternative(variant_etl)); + + CHECK(etl::holds_alternative<0U>(variant_etl)); + CHECK(!etl::holds_alternative<1U>(variant_etl)); + CHECK(!etl::holds_alternative<2U>(variant_etl)); + + CHECK(etl::holds_alternative(0U, variant_etl)); + CHECK(!etl::holds_alternative(1U, variant_etl)); + CHECK(!etl::holds_alternative(2U, variant_etl)); + CHECK(!etl::holds_alternative(99U, variant_etl)); + } + + //************************************************************************* + TEST(test_constructor_value) + { + // Char. + char c = 'a'; + test_variant_etl_3 variant_char_etl(c); + CHECK(c == 'a'); + CHECK(etl::holds_alternative(variant_char_etl)); + CHECK_EQUAL(c, etl::get(variant_char_etl)); + + // Int. + int i = 1; + test_variant_etl_3 variant_int_etl(i); + CHECK(i == 1); + CHECK(etl::holds_alternative(variant_int_etl)); + CHECK_EQUAL(i, etl::get(variant_int_etl)); + + // String. + std::string text("Some Text"); + test_variant_etl_3 variant_text_etl(text); + CHECK(text == "Some Text"); + CHECK(etl::holds_alternative(variant_text_etl)); + CHECK_EQUAL(text, etl::get(variant_text_etl)); + } + + //************************************************************************* + TEST(test_constructor_move_value) + { + // Char. + char c = 'a'; + test_variant_etl_3 variant_char_etl(etl::move(c)); + CHECK(etl::holds_alternative(variant_char_etl)); + CHECK_EQUAL(c, etl::get(variant_char_etl)); + + // Int. + int i = 1; + test_variant_etl_3 variant_int_etl(etl::move(i)); + CHECK(etl::holds_alternative(variant_int_etl)); + CHECK_EQUAL(i, etl::get(variant_int_etl)); + + // String. + std::string text("Some Text"); + test_variant_etl_3 variant_text_etl(etl::move(text)); + CHECK(etl::holds_alternative(variant_text_etl)); + CHECK_EQUAL(std::string("Some Text"), etl::get(variant_text_etl)); + } + + //************************************************************************* + TEST(test_construct_multiple_parameters_by_type) + { + test_variant_emplace variant_etl1(etl::in_place_type_t(), "1"); + CHECK(etl::holds_alternative(variant_etl1)); + CHECK_EQUAL(D1("1"), etl::get(variant_etl1)); + + test_variant_emplace variant_etl2(etl::in_place_type_t{}, "1", "2"); + CHECK(etl::holds_alternative(variant_etl2)); + CHECK_EQUAL(D2("1", "2"), etl::get(variant_etl2)); + + test_variant_emplace variant_etl3(etl::in_place_type_t{}, "1", "2", "3"); + CHECK(etl::holds_alternative(variant_etl3)); + CHECK_EQUAL(D3("1", "2", "3"), etl::get(variant_etl3)); + + test_variant_emplace variant_etl4(etl::in_place_type_t{}, "1", "2", "3", "4"); + CHECK(etl::holds_alternative(variant_etl4)); + CHECK_EQUAL(D4("1", "2", "3", "4"), etl::get(variant_etl4)); + } + + //************************************************************************* + TEST(test_construct_multiple_parameters_by_index) + { + test_variant_emplace variant_etl1(etl::in_place_index_t<1U>{}, "1"); + CHECK(etl::holds_alternative(variant_etl1)); + CHECK_EQUAL(D1("1"), etl::get(variant_etl1)); + + test_variant_emplace variant_etl2(etl::in_place_index_t<2>{}, "1", "2"); + CHECK(etl::holds_alternative(variant_etl2)); + CHECK_EQUAL(D2("1", "2"), etl::get(variant_etl2)); + + test_variant_emplace variant_etl3(etl::in_place_index_t<3>{}, "1", "2", "3"); + CHECK(etl::holds_alternative(variant_etl3)); + CHECK_EQUAL(D3("1", "2", "3"), etl::get(variant_etl3)); + + test_variant_emplace variant_etl4(etl::in_place_index_t<4U>{}, "1", "2", "3", "4"); + CHECK(etl::holds_alternative(variant_etl4)); + CHECK_EQUAL(D4("1", "2", "3", "4"), etl::get(variant_etl4)); + } + +#if ETL_USING_STL + //************************************************************************* + TEST(test_construct_with_initializer_list_by_type) + { + etl::variant, std::string> v(etl::in_place_type_t>{}, { 0, 1, 2, 3 }); + + std::vector expected = { 0, 1, 2, 3 }; + std::vector result = etl::get>(v); + + CHECK_EQUAL(expected.size(), result.size()); + CHECK_ARRAY_EQUAL(expected.data(), result.data(), expected.size()); + } + + //************************************************************************* + TEST(test_construct_with_initializer_list_by_index) + { + etl::variant, std::string> v(etl::in_place_index_t<0U>{}, { 0, 1, 2, 3 }); + + std::vector expected = { 0, 1, 2, 3 }; + std::vector result = etl::get>(v); + + CHECK_EQUAL(expected.size(), result.size()); + CHECK_ARRAY_EQUAL(expected.data(), result.data(), expected.size()); + } +#endif + + //************************************************************************* + TEST(test_emplace_value) + { + // Char. + char c = 'a'; + test_variant_etl_3 variant_char_etl; + + variant_char_etl.emplace(c); + CHECK(c == 'a'); + CHECK(etl::holds_alternative(variant_char_etl)); + CHECK_EQUAL(c, etl::get(variant_char_etl)); + + // Int. + int i = 1; + test_variant_etl_3 variant_int_etl; + + variant_int_etl.emplace(i); + CHECK(i == 1); + CHECK(etl::holds_alternative(variant_int_etl)); + CHECK_EQUAL(i, etl::get(variant_int_etl)); + + // String. + std::string text("Some Text"); + test_variant_etl_3 variant_text_etl; + + variant_text_etl.emplace(text); + CHECK(text == "Some Text"); + CHECK(etl::holds_alternative(variant_text_etl)); + CHECK_EQUAL(text, etl::get(variant_text_etl)); + } + + //************************************************************************* + TEST(test_copy_constructor) + { + std::string text("Some Text"); + test_variant_etl_3 variant_1_etl(text); + + test_variant_etl_3 variant_2_etl(variant_1_etl); + + CHECK_EQUAL(variant_1_etl.index(), variant_2_etl.index()); + CHECK_EQUAL(etl::get(variant_1_etl), etl::get(variant_2_etl)); + } + + //************************************************************************* + TEST(test_copy_constructor_from_empty) + { + test_variant_etl_3 variant_1_etl; + + test_variant_etl_3 variant_2_etl(variant_1_etl); + + CHECK_EQUAL(variant_1_etl.index(), variant_2_etl.index()); + } + + //************************************************************************* + TEST(test_move_constructor) + { + std::string text("Some Text"); + test_variant_etl_3 variant_1_etl(text); + + test_variant_etl_3 variant_2_etl(etl::move(variant_1_etl)); + + CHECK_EQUAL(variant_1_etl.index(), variant_2_etl.index()); + CHECK(etl::get(variant_1_etl) != etl::get(variant_2_etl)); + } + + //************************************************************************* + TEST(test_move_constructor_from_empty) + { + std::string text("Some Text"); + test_variant_etl_3 variant_1_etl; + + test_variant_etl_3 variant_2_etl(etl::move(variant_1_etl)); + + CHECK_EQUAL(variant_1_etl.index(), variant_2_etl.index()); + } + + //************************************************************************* + TEST(test_assign_from_value) + { + std::string text("Some Text"); + test_variant_etl_3 variant_etl; + + variant_etl = text; + + CHECK_EQUAL(text, etl::get(variant_etl)); + } + + //************************************************************************* + TEST(test_assign_from_variant) + { + std::string text("Some Text"); + test_variant_etl_3 variant_1_etl; + test_variant_etl_3 variant_2_etl; + + variant_1_etl = text; + variant_2_etl = variant_1_etl; + + CHECK_EQUAL(text, etl::get(variant_2_etl)); + } + + //************************************************************************* + TEST(test_assign_from_variant2) + { + std::string text("Some Text"); + int integer(99); + test_variant_etl_3 variant_1_etl; + test_variant_etl_3 variant_2_etl; + + variant_1_etl = text; + variant_2_etl = integer; + variant_2_etl = variant_1_etl; + + CHECK_EQUAL(text, etl::get(variant_2_etl)); + } + + //************************************************************************* + TEST(test_assignment_incorrect_type_exception) + { + std::string text("Some Text"); + test_variant_etl_3 variant_etl(text); + + int i; + CHECK_THROW(etl::get(variant_etl), etl::variant_incorrect_type_exception); + (void)i; + } + + //************************************************************************* + TEST(test_self_assignment) + { + test_variant_etl_3 variant_etl; + + variant_etl = 1; + variant_etl = variant_etl; + + CHECK_EQUAL(1, etl::get(variant_etl)); + } + + //************************************************************************* + TEST(test_member_swap_variants) + { + std::string text("Some Text"); + int integer(99); + test_variant_etl_3 variant_1_etl(text); + test_variant_etl_3 variant_2_etl(integer); + + variant_1_etl.swap(variant_2_etl); + + CHECK(etl::holds_alternative(variant_1_etl)); + CHECK_EQUAL(integer, etl::get(variant_1_etl)); + + CHECK(etl::holds_alternative(variant_2_etl)); + CHECK_EQUAL(text, etl::get(variant_2_etl)); + } + + //************************************************************************* + TEST(test_global_swap_variants) + { + std::string text("Some Text"); + int integer(99); + test_variant_etl_3 variant_1_etl(text); + test_variant_etl_3 variant_2_etl(integer); + + etl::swap(variant_1_etl, variant_2_etl); + + CHECK(etl::holds_alternative(variant_1_etl)); + CHECK_EQUAL(integer, etl::get(variant_1_etl)); + + CHECK(etl::holds_alternative(variant_2_etl)); + CHECK_EQUAL(text, etl::get(variant_2_etl)); + } + + //************************************************************************* + TEST(test_emplace_multiple_parameters) + { + test_variant_emplace variant_etl; + + variant_etl.emplace("1"); + CHECK(etl::holds_alternative(variant_etl)); + CHECK_EQUAL(D1("1"), etl::get(variant_etl)); + + variant_etl.emplace("1", "2"); + CHECK(etl::holds_alternative(variant_etl)); + CHECK_EQUAL(D2("1", "2"), etl::get(variant_etl)); + + variant_etl.emplace("1", "2", "3"); + CHECK(etl::holds_alternative(variant_etl)); + CHECK_EQUAL(D3("1", "2", "3"), etl::get(variant_etl)); + + variant_etl.emplace("1", "2", "3", "4"); + CHECK(etl::holds_alternative(variant_etl)); + CHECK_EQUAL(D4("1", "2", "3", "4"), etl::get(variant_etl)); + } + + //************************************************************************* + TEST(test_variant_accept_visitor) + { + struct Visitor : public etl::visitor + { + Visitor() + : result_c(0) + , result_i(0) + , result_s("") + { + } + + void visit(char& c) + { + result_c = c; + } + + void visit(int& i) + { + result_i = i; + } + + void visit(std::string& s) + { + result_s = s; + } + + char result_c; + int result_i; + std::string result_s; + }; + + Visitor visitor; + + test_variant_etl_3 variant_etl; + + variant_etl = char(1); + variant_etl.accept_visitor(visitor); + CHECK_EQUAL(1, visitor.result_c); + + variant_etl = int(2); + variant_etl.accept_visitor(visitor); + CHECK_EQUAL(2, visitor.result_i); + + variant_etl = std::string("3"); + variant_etl.accept_visitor(visitor); + CHECK_EQUAL("3", visitor.result_s); + } + + //************************************************************************* + TEST(test_variant_accept_functor_with_functor_class) + { + struct Visitor + { + Visitor() + : result_c(0) + , result_i(0) + , result_s("") + { + } + + void operator()(char& c) + { + result_c = c; + } + + void operator()(int& i) + { + result_i = i; + } + + void operator()(const std::string& s) + { + result_s = s; + } + + char result_c; + int result_i; + std::string result_s; + }; + + Visitor visitor; + + test_variant_etl_3 variant_etl; + + variant_etl = char(1); + variant_etl.accept_functor(visitor); + CHECK_EQUAL(1, visitor.result_c); + + variant_etl = int(2); + variant_etl.accept_functor(visitor); + CHECK_EQUAL(2, visitor.result_i); + + variant_etl = std::string("3"); + variant_etl.accept_functor(visitor); + CHECK_EQUAL("3", visitor.result_s); + } + + //************************************************************************* + + TEST(test_variant__accept_functor_with_overload) + { + char result_c; + int result_i; + std::string result_s; + + auto visitor = etl::make_overload([&result_c](char c) { result_c = 1; }, + [&result_i](int i) { result_i = 2; }, + [&result_s](const std::string& s) { result_s = "3"; }); + + test_variant_etl_3 variant_etl; + + variant_etl = char(1); + variant_etl.accept_functor(visitor); + CHECK_EQUAL(1, result_c); + + variant_etl = int(2); + variant_etl.accept_functor(visitor); + CHECK_EQUAL(2, result_i); + + variant_etl = std::string("3"); + variant_etl.accept_functor(visitor); + CHECK_EQUAL("3", result_s); + } + + //************************************************************************* + TEST(test_get_if_index) + { + test_variant_etl_3 variant_etl; + + variant_etl = char(1); + CHECK(etl::get_if<0>(&variant_etl) != nullptr); + CHECK(etl::get_if<1>(&variant_etl) == nullptr); + CHECK(etl::get_if<2>(&variant_etl) == nullptr); + + variant_etl = int(2); + CHECK(etl::get_if<0>(&variant_etl) == nullptr); + CHECK(etl::get_if<1>(&variant_etl) != nullptr); + CHECK(etl::get_if<2>(&variant_etl) == nullptr); + + variant_etl = std::string("3"); + CHECK(etl::get_if<0>(&variant_etl) == nullptr); + CHECK(etl::get_if<1>(&variant_etl) == nullptr); + CHECK(etl::get_if<2>(&variant_etl) != nullptr); + } + + //************************************************************************* + TEST(test_get_if_type) + { + test_variant_etl_3 variant_etl; + + variant_etl = char(1); + CHECK(etl::get_if(&variant_etl) != nullptr); + CHECK(etl::get_if(&variant_etl) == nullptr); + CHECK(etl::get_if(&variant_etl) == nullptr); + + variant_etl = int(2); + CHECK(etl::get_if(&variant_etl) == nullptr); + CHECK(etl::get_if(&variant_etl) != nullptr); + CHECK(etl::get_if(&variant_etl) == nullptr); + + variant_etl = std::string("3"); + CHECK(etl::get_if(&variant_etl) == nullptr); + CHECK(etl::get_if(&variant_etl) == nullptr); + CHECK(etl::get_if(&variant_etl) != nullptr); + } + + //************************************************************************* + TEST(test_variant_size) + { + test_variant_etl_3 variant_etl; + + CHECK_EQUAL(3U, etl::variant_size_v); + } + + //************************************************************************* + TEST(test_compare_etl_and_stl_variant_with_moveable_type) + { + Moveable from_etl; + Moveable to_etl; + + Moveable from_std; + Moveable to_std; + + etl::variant variant_etl(etl::move(from_etl)); + std::variant variant_std(etl::move(from_std)); + + variant_etl = etl::move(from_etl); + variant_std = etl::move(from_std); + + CHECK_EQUAL(from_std.moved_from, from_etl.moved_from); + CHECK_EQUAL(from_std.moved_to, from_etl.moved_to); + CHECK_EQUAL(from_std.copied_to, from_etl.copied_to); + + to_etl = etl::move(etl::get<0>(variant_etl)); + to_std = etl::move(std::get<0>(variant_std)); + + CHECK_EQUAL(to_std.moved_from, to_etl.moved_from); + CHECK_EQUAL(to_std.moved_to, to_etl.moved_to); + CHECK_EQUAL(to_std.copied_to, to_etl.copied_to); + } + + //************************************************************************* + TEST(test_compare_etl_and_stl_variant_with_copyable_type) + { + Copyable from_etl; + Copyable to_etl; + + Copyable from_std; + Copyable to_std; + + etl::variant variant_etl; + std::variant variant_std; + + variant_etl = from_etl; + variant_std = from_std; + + CHECK_EQUAL(from_std.moved_from, from_etl.moved_from); + CHECK_EQUAL(from_std.moved_to, from_etl.moved_to); + CHECK_EQUAL(from_std.copied_to, from_etl.copied_to); + + to_etl = etl::get<0>(variant_etl); + to_std = std::get<0>(variant_std); + + CHECK_EQUAL(to_std.moved_from, to_etl.moved_from); + CHECK_EQUAL(to_std.moved_to, to_etl.moved_to); + CHECK_EQUAL(to_std.copied_to, to_etl.copied_to); + } + + //************************************************************************* + TEST(test_compare_etl_and_stl_variant_with_moveable_copyable_type) + { + MoveableCopyable from_etl; + MoveableCopyable to_etl; + + MoveableCopyable from_std; + MoveableCopyable to_std; + + etl::variant variant_etl; + std::variant variant_std; + + variant_etl = from_etl; + variant_std = from_std; + + CHECK_EQUAL(from_std.moved_from, from_etl.moved_from); + CHECK_EQUAL(from_std.moved_to, from_etl.moved_to); + CHECK_EQUAL(from_std.copied_to, from_etl.copied_to); + + variant_etl = etl::move(from_etl); + variant_std = etl::move(from_std); + + CHECK_EQUAL(from_std.moved_from, from_etl.moved_from); + CHECK_EQUAL(from_std.moved_to, from_etl.moved_to); + CHECK_EQUAL(from_std.copied_to, from_etl.copied_to); + + to_etl = etl::get<0>(variant_etl); + to_std = std::get<0>(variant_std); + + CHECK_EQUAL(to_std.moved_from, to_etl.moved_from); + CHECK_EQUAL(to_std.moved_to, to_etl.moved_to); + CHECK_EQUAL(to_std.copied_to, to_etl.copied_to); + + to_etl = etl::move(etl::get<0>(variant_etl)); + to_std = etl::move(std::get<0>(variant_std)); + + CHECK_EQUAL(to_std.moved_from, to_etl.moved_from); + CHECK_EQUAL(to_std.moved_to, to_etl.moved_to); + CHECK_EQUAL(to_std.copied_to, to_etl.copied_to); + } + + //************************************************************************* + TEST(test_get_by_type) + { + MoveableCopyable value1; + MoveableCopyable value2; + MoveableCopyable value3; + + etl::variant v_etl(value1); + const etl::variant cv_etl(value2); + etl::variant& rv_etl(v_etl); + const etl::variant& crv_etl(value3); + + std::variant v_std(value1); + const std::variant cv_std(value2); + std::variant& rv_std(v_std); + const std::variant& crv_std(value3); + + // From variant reference + MoveableCopyable value_vr_etl = etl::get(rv_etl); + MoveableCopyable value_vr_std = std::get(rv_std); + CHECK_EQUAL(value_vr_std.moved_from, value_vr_etl.moved_from); + CHECK_EQUAL(value_vr_std.moved_to, value_vr_etl.moved_to); + CHECK_EQUAL(value_vr_std.copied_to, value_vr_etl.copied_to); + + // From variant const reference + const MoveableCopyable& value_vcr_etl = etl::get(crv_etl); + const MoveableCopyable& value_vcr_std = std::get(crv_std); + CHECK_EQUAL(value_vcr_std.moved_from, value_vcr_etl.moved_from); + CHECK_EQUAL(value_vcr_std.moved_to, value_vcr_etl.moved_to); + CHECK_EQUAL(value_vcr_std.copied_to, value_vcr_etl.copied_to); + + // From variant rvalue reference + MoveableCopyable&& value_vrr_etl = etl::get(etl::move(v_etl)); + MoveableCopyable&& value_vrr_std = std::get(etl::move(v_std)); + CHECK_EQUAL(value_vrr_std.moved_from, value_vrr_etl.moved_from); + CHECK_EQUAL(value_vrr_std.moved_to, value_vrr_etl.moved_to); + CHECK_EQUAL(value_vrr_std.copied_to, value_vrr_etl.copied_to); + + // From variant const rvalue reference + const MoveableCopyable&& value_vcrr_etl = etl::get(etl::move(cv_etl)); + const MoveableCopyable&& value_vcrr_std = std::get(etl::move(cv_std)); + CHECK_EQUAL(value_vcrr_std.moved_from, value_vcrr_etl.moved_from); + CHECK_EQUAL(value_vcrr_std.moved_to, value_vcrr_etl.moved_to); + CHECK_EQUAL(value_vcrr_std.copied_to, value_vcrr_etl.copied_to); + } + + //************************************************************************* + TEST(test_get_by_index) + { + MoveableCopyable value1; + MoveableCopyable value2; + MoveableCopyable value3; + + etl::variant v_etl(value1); + const etl::variant cv_etl(value2); + etl::variant& rv_etl(v_etl); + const etl::variant& crv_etl(value3); + + std::variant v_std(value1); + const std::variant cv_std(value2); + std::variant& rv_std(v_std); + const std::variant& crv_std(value3); + + // From variant reference + MoveableCopyable value_vr_etl = etl::get<0U>(rv_etl); + MoveableCopyable value_vr_std = std::get<0U>(rv_std); + CHECK_EQUAL(value_vr_std.moved_from, value_vr_etl.moved_from); + CHECK_EQUAL(value_vr_std.moved_to, value_vr_etl.moved_to); + CHECK_EQUAL(value_vr_std.copied_to, value_vr_etl.copied_to); + + // From variant const reference + const MoveableCopyable& value_vcr_etl = etl::get<0U>(crv_etl); + const MoveableCopyable& value_vcr_std = std::get<0U>(crv_std); + CHECK_EQUAL(value_vcr_std.moved_from, value_vcr_etl.moved_from); + CHECK_EQUAL(value_vcr_std.moved_to, value_vcr_etl.moved_to); + CHECK_EQUAL(value_vcr_std.copied_to, value_vcr_etl.copied_to); + + // From variant rvalue reference + MoveableCopyable&& value_vrr_etl = etl::get<0U>(etl::move(v_etl)); + MoveableCopyable&& value_vrr_std = std::get<0U>(etl::move(v_std)); + CHECK_EQUAL(value_vrr_std.moved_from, value_vrr_etl.moved_from); + CHECK_EQUAL(value_vrr_std.moved_to, value_vrr_etl.moved_to); + CHECK_EQUAL(value_vrr_std.copied_to, value_vrr_etl.copied_to); + + // From variant const rvalue reference + const MoveableCopyable&& value_vcrr_etl = etl::get<0U>(etl::move(cv_etl)); + const MoveableCopyable&& value_vcrr_std = std::get<0U>(etl::move(cv_std)); + CHECK_EQUAL(value_vcrr_std.moved_from, value_vcrr_etl.moved_from); + CHECK_EQUAL(value_vcrr_std.moved_to, value_vcrr_etl.moved_to); + CHECK_EQUAL(value_vcrr_std.copied_to, value_vcrr_etl.copied_to); + } + + //************************************************************************* + TEST(test_get_if_by_type) + { + int value; + + etl::variant v(value); + const etl::variant cv(value); + etl::variant& rv(v); + const etl::variant& crv(v); + + int* pi; + const int* pci; + double* pd; + const double* pcd; + + etl::variant* pv = nullptr; + + // From nullptr + pi = etl::get_if(pv); + CHECK(pi == nullptr); + + // From variant reference + pi = etl::get_if(&rv); + CHECK(pi != nullptr); + + pd = etl::get_if(&rv); + CHECK(pd == nullptr); + + // From variant const reference + pci = etl::get_if(&crv); + CHECK(pci != nullptr); + + pcd = etl::get_if(&crv); + CHECK(pcd == nullptr); + } + + //************************************************************************* + TEST(test_get_if_by_index) + { + int value; + + etl::variant v(value); + const etl::variant cv(value); + etl::variant& rv(v); + const etl::variant& crv(v); + + int* pi; + const int* pci; + double* pd; + const double* pcd; + + etl::variant* pv = nullptr; + + // From nullptr + pi = etl::get_if<0U>(pv); + CHECK(pi == nullptr); + + // From variant reference + pi = etl::get_if<0U>(&rv); + CHECK(pi != nullptr); + + pd = etl::get_if<1U>(&rv); + CHECK(pd == nullptr); + + // From variant const reference + pci = etl::get_if<0U>(&crv); + CHECK(pci != nullptr); + + pcd = etl::get_if<1U>(&crv); + CHECK(pcd == nullptr); + } + }; +} diff --git a/test/vs2019/etl.sln b/test/vs2019/etl.sln index ce177c05..7e198816 100644 --- a/test/vs2019/etl.sln +++ b/test/vs2019/etl.sln @@ -11,6 +11,8 @@ Global Debug LLVM - No STL|x64 = Debug LLVM - No STL|x64 Debug LLVM|Win32 = Debug LLVM|Win32 Debug LLVM|x64 = Debug LLVM|x64 + Debug MSVC - No STL - Builtins|Win32 = Debug MSVC - No STL - Builtins|Win32 + Debug MSVC - No STL - Builtins|x64 = Debug MSVC - No STL - Builtins|x64 Debug MSVC - No STL - Force No Advanced|Win32 = Debug MSVC - No STL - Force No Advanced|Win32 Debug MSVC - No STL - Force No Advanced|x64 = Debug MSVC - No STL - Force No Advanced|x64 Debug MSVC - No STL|Win32 = Debug MSVC - No STL|Win32 @@ -27,6 +29,8 @@ Global Debug MSVC No Checks|x64 = Debug MSVC No Checks|x64 Debug MSVC|Win32 = Debug MSVC|Win32 Debug MSVC|x64 = Debug MSVC|x64 + Debug LLVM - No STL - Builtins|Win32 = Debug LLVM - No STL - Builtins|Win32 + Debug LLVM - No STL - Builtins|x64 = Debug LLVM - No STL - Builtins|x64 LLVM New|Win32 = LLVM New|Win32 LLVM New|x64 = LLVM New|x64 MSVCDebugAppveyor|Win32 = MSVCDebugAppveyor|Win32 @@ -45,6 +49,10 @@ Global {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|Win32.Build.0 = Debug LLVM|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|x64.ActiveCfg = Debug LLVM|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|x64.Build.0 = Debug LLVM|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Builtins|Win32.ActiveCfg = Debug|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Builtins|Win32.Build.0 = Debug|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Builtins|x64.ActiveCfg = Debug-MSVC-No-STL-Builtins|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Builtins|x64.Build.0 = Debug-MSVC-No-STL-Builtins|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|Win32.ActiveCfg = DebugNoSTLForceNoAdvanced|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|Win32.Build.0 = DebugNoSTLForceNoAdvanced|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|x64.ActiveCfg = DebugNoSTLForceNoAdvanced|x64 @@ -60,7 +68,7 @@ Global {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - Small Strings|Win32.ActiveCfg = DebugMSVCSmallStrings|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - Small Strings|Win32.Build.0 = DebugMSVCSmallStrings|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - Small Strings|x64.ActiveCfg = DebugMSVCSmallStrings|x64 - {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - Small Strings|x64.Build.0 = DebugMSVCSmall Strings|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - Small Strings|x64.Build.0 = DebugMSVCSmallStrings|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - String Truncation Is Error|Win32.ActiveCfg = DebugStringTruncationIsError|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - String Truncation Is Error|Win32.Build.0 = DebugStringTruncationIsError|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - String Truncation Is Error|x64.ActiveCfg = DebugStringTruncationIsError|x64 @@ -77,6 +85,10 @@ Global {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|Win32.Build.0 = Debug|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|x64.ActiveCfg = Debug|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|x64.Build.0 = Debug|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Builtins|Win32.ActiveCfg = Debug-LLVM-NoSTL-Builtins|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Builtins|Win32.Build.0 = Debug-LLVM-NoSTL-Builtins|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Builtins|x64.ActiveCfg = Debug-LLVM-NoSTL-Builtins|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL - Builtins|x64.Build.0 = Debug-LLVM-NoSTL-Builtins|x64 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.LLVM New|Win32.ActiveCfg = LLVM New|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.LLVM New|Win32.Build.0 = LLVM New|Win32 {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.LLVM New|x64.ActiveCfg = LLVM New|x64 diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index e22b1840..c010d82a 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -9,6 +9,14 @@ Debug Clang x64 + + Debug LLVM - No STL - Built-ins + Win32 + + + Debug LLVM - No STL - Built-ins + x64 + Debug LLVM Win32 @@ -17,6 +25,22 @@ Debug LLVM x64 + + Debug MSVC - No STL - Built-ins + Win32 + + + Debug MSVC - No STL - Built-ins + x64 + + + Debug-LLVM-NoSTL-Builtins + Win32 + + + Debug-LLVM-NoSTL-Builtins + x64 + DebugMSVCSmallStrings Win32 @@ -174,6 +198,13 @@ Unicode false + + Application + true + v142 + Unicode + false + Application true @@ -198,6 +229,18 @@ ClangCL Unicode + + Application + true + ClangCL + Unicode + + + Application + true + ClangCL + Unicode + Application true @@ -246,6 +289,12 @@ v142 Unicode + + Application + true + v142 + Unicode + Application true @@ -270,6 +319,18 @@ v142 Unicode + + Application + true + v142 + Unicode + + + Application + true + v142 + Unicode + Application true @@ -338,6 +399,9 @@ + + + @@ -350,6 +414,12 @@ + + + + + + @@ -374,6 +444,9 @@ + + + @@ -386,6 +459,12 @@ + + + + + + @@ -443,6 +522,11 @@ true \$(IntDir) + + true + true + \$(IntDir) + true true @@ -463,6 +547,16 @@ true \$(IntDir) + + false + true + \$(IntDir) + + + false + true + \$(IntDir) + false true @@ -496,6 +590,10 @@ true true + + true + true + true true @@ -512,6 +610,14 @@ true true + + true + true + + + true + true + true true @@ -690,6 +796,28 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING;ETL_NO_STL;ETL_USE_TYPE_TRAITS_BUILTINS;%(PreprocessorDefinitions) + ./;../../../unittest-cpp/;../../include;../../test + + + true + stdcpp17 + ProgramDatabase + + + Console + true + + + $(OutDir)\etl.exe + + @@ -780,6 +908,54 @@ "$(OutDir)etl.exe" + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;__clang__;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + false + ProgramDatabase + -Wno-self-assign /Zc:__cplusplus %(AdditionalOptions) + + + Console + false + + + "$(OutDir)etl.exe" + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_STL;ETL_USE_TYPE_TRAITS_BUILTINS;__clang__;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + false + ProgramDatabase + -Wno-self-assign /Zc:__cplusplus %(AdditionalOptions) + + + Console + false + + + "$(OutDir)etl.exe" + + @@ -975,6 +1151,27 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + @@ -1059,6 +1256,48 @@ $(OutDir)\etl.exe + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../include/etl;../../test + + + false + stdcpp14 + + + Console + true + + + $(OutDir)\etl.exe + + @@ -1310,6 +1549,7 @@ + @@ -1348,6 +1588,7 @@ + @@ -1355,6 +1596,8 @@ + + @@ -1567,136 +1810,224 @@ - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true true @@ -1716,2740 +2047,4444 @@ true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true + true true true - true - true + true + true true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - true - true - - - true - true - true - true + true true true true - true true true + true true - true - true + true + true true + true + true true + true + true + + + true true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true @@ -4511,6 +6546,7 @@ + @@ -4564,10 +6600,13 @@ false false false + false false false false false + false + false false false false @@ -4577,10 +6616,13 @@ false false false + false false false false false + false + false false false false @@ -4609,10 +6651,13 @@ false false false + false false false false false + false + false false false false @@ -4622,10 +6667,13 @@ false false false + false false false false false + false + false false false false @@ -4649,10 +6697,13 @@ false false false + false false false false false + false + false false false false @@ -4662,10 +6713,13 @@ false false false + false false false false false + false + false false false false @@ -4679,10 +6733,13 @@ false false false + false false false false false + false + false false false false @@ -4692,10 +6749,13 @@ false false false + false false false false false + false + false false false false @@ -4709,10 +6769,13 @@ false false false + false false false false false + false + false false false false @@ -4722,10 +6785,13 @@ false false false + false false false false false + false + false false false false @@ -4739,10 +6805,13 @@ false false false + false false false false false + false + false false false false @@ -4752,10 +6821,13 @@ false false false + false false false false false + false + false false false false @@ -4769,10 +6841,13 @@ false false false + false false false false false + false + false false false false @@ -4782,10 +6857,13 @@ false false false + false false false false false + false + false false false false @@ -4804,10 +6882,13 @@ false false false + false false false false false + false + false false false false @@ -4817,10 +6898,13 @@ false false false + false false false false false + false + false false false false @@ -4838,10 +6922,13 @@ false false false + false false false false false + false + false false false false @@ -4851,10 +6938,13 @@ false false false + false false false false false + false + false false false false @@ -4878,10 +6968,13 @@ false false false + false false false false false + false + false false false false @@ -4891,10 +6984,13 @@ false false false + false false false false false + false + false false false false @@ -4902,6 +6998,7 @@ false + @@ -4982,7 +7079,8 @@ - + + @@ -5050,4 +7148,4 @@ - \ No newline at end of file + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 3b6ef855..3cb7534e 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -118,6 +118,9 @@ {0e4d2126-b9b7-4eef-b5ca-18363b1e01ce} + + {5b76fd56-eb83-489f-b9a6-798c07c5fa76} + @@ -1113,12 +1116,33 @@ ETL\Frameworks + + ETL\Private + + + ETL\Private + ETL\Utilities ETL\Containers + + ETL\Private + + + ETL\Private + + + ETL\Patterns + + + ETL\Patterns + + + Header Files + @@ -1172,7 +1196,7 @@ Source Files - + Source Files @@ -1673,6 +1697,210 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + Source Files\Sanity Checks @@ -1751,30 +1979,108 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks + + Source Files\Sanity Checks + Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks + + Source Files\Sanity Checks + Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -1793,12 +2099,24 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -1886,12 +2204,18 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + Source Files\Sanity Checks Source Files\Sanity Checks + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -1922,6 +2246,9 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -1940,6 +2267,9 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -1958,6 +2288,12 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -2021,6 +2357,9 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -2051,6 +2390,9 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -2099,6 +2441,12 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -2123,6 +2471,9 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -2147,6 +2498,9 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + Source Files\Sanity Checks @@ -2504,49 +2858,40 @@ Source Files\Sanity Checks - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - Source Files\Sanity Checks - - Source Files + + Source Files\Sanity Checks - - Source Files + + Source Files\Sanity Checks - - Source Files + + Source Files\Sanity Checks - - Source Files + + Source Files\Sanity Checks - + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + Source Files\Sanity Checks @@ -2668,7 +3013,7 @@ Source Files\Sanity Checks\C++17 - Source Files\Sanity Checks + Source Files\Sanity Checks\Logs @@ -2696,4 +3041,4 @@ Resource Files - \ No newline at end of file +