From 820bc36aa621c33e644b24eba23fca07479eb9ce Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 21 May 2021 18:05:02 +0100 Subject: [PATCH 01/81] Initial commit --- include/etl/private/variant_legacy.h | 1028 +++++++++++++++++++++++++ include/etl/private/variant_new.h | 1037 ++++++++++++++++++++++++++ include/etl/variant.h | 999 +------------------------ test/vs2019/etl.vcxproj | 2 + test/vs2019/etl.vcxproj.filters | 6 + 5 files changed, 2076 insertions(+), 996 deletions(-) create mode 100644 include/etl/private/variant_legacy.h create mode 100644 include/etl/private/variant_new.h 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_new.h b/include/etl/private/variant_new.h new file mode 100644 index 00000000..c40985e1 --- /dev/null +++ b/include/etl/private/variant_new.h @@ -0,0 +1,1037 @@ +///\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 + { + }; + + template + struct index_of_type; + + template + struct index_of_type : etl::integral_constant {}; + + template + struct index_of_type : etl::integral_constant::value> {}; + } + + //*************************************************************************** + /// 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/variant.h b/include/etl/variant.h index c466cf07..8702eeed 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 1 //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_new.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/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 80c7a26d..1cea32c9 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1353,6 +1353,8 @@ + + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 8b11f5cf..04825358 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1101,6 +1101,12 @@ ETL\Frameworks + + ETL\Private + + + ETL\Private + From c3bef2c493ae8454c8ac5c89f92fe4f22727a22b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 22 May 2021 17:11:48 +0100 Subject: [PATCH 02/81] Interim commit --- include/etl/parameter_pack.h | 2 +- include/etl/private/variant_new.h | 1049 ++++------------- ...st_variant.cpp => test_variant_legacy.cpp} | 2 +- test/test_variant_new.cpp | 446 +++++++ test/vs2019/etl.vcxproj | 3 +- test/vs2019/etl.vcxproj.filters | 5 +- 6 files changed, 703 insertions(+), 804 deletions(-) rename test/{test_variant.cpp => test_variant_legacy.cpp} (99%) create mode 100644 test/test_variant_new.cpp diff --git a/include/etl/parameter_pack.h b/include/etl/parameter_pack.h index 1068d248..577f95c3 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; }; diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index c40985e1..379e9ab8 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -40,7 +40,7 @@ SOFTWARE. #include "../static_assert.h" #include "../alignment.h" #include "../error_handler.h" -#include "../null_type.h" +#include "../parameter_pack.h" #include "../placement_new.h" #if defined(ETL_COMPILER_KEIL) @@ -56,26 +56,9 @@ SOFTWARE. namespace etl { - namespace private_variant - { - //************************************************************************* - /// Placeholder for unused template parameters. - /// This class is never instantiated. - //************************************************************************* - template - struct no_type - { - }; + static_assert(ETL_CPP11_SUPPORTED, "Only supported for C++11 or above"); - template - struct index_of_type; - - template - struct index_of_type : etl::integral_constant {}; - - template - struct index_of_type : etl::integral_constant::value> {}; - } + static size_t variant_npos = etl::integral_limits::max; //*************************************************************************** /// Base exception for the variant class. @@ -108,14 +91,7 @@ namespace etl /// 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> > + template class variant { public: @@ -123,413 +99,127 @@ namespace etl //*************************************************************************** /// 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; + using type_id_t = uint_least8_t ; private: + // The type of actions we can perform. + enum class action_type : char + { + Construct, + Destruct, + Move + }; + // All types of variant are friends. - template + template friend class variant; //*************************************************************************** /// The largest type. //*************************************************************************** - typedef typename largest_type::type largest_t; + using largest_t = typename largest_type::type; //*************************************************************************** /// The largest size. //*************************************************************************** - static const size_t SIZE = sizeof(largest_t); + 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> - { - }; + static const size_t Alignment = etl::largest_alignment::value; public: //*************************************************************************** - /// Destructor. + /// The internal storage. + /// Aligned on a suitable boundary, which should be good for all types. //*************************************************************************** - ~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; + typename etl::aligned_storage::type data; //*************************************************************************** /// Default constructor. /// Sets the state of the instance to containing no valid data. //*************************************************************************** - variant() - : type_id(UNSUPPORTED_TYPE_ID) + constexpr variant() + : data() + , operation(null_operation) + , type_id(variant_npos) { } //*************************************************************************** /// Constructor that catches any types that are not supported. - /// Forces a ETL_STATIC_ASSERT. + /// Forces a static_assert. //*************************************************************************** template - variant(const T& value) + constexpr variant(const T& value) + : data() + , operation(do_operation) + , type_id(etl::parameter_pack::index_of_type::value) { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + static_assert(etl::is_one_of::value, "Unsupported type"); - ::new (static_cast(data)) T(value); - type_id = Type_Id_Lookup::type_id; + operation(action_type::Construct, data, &value); } //*************************************************************************** /// Copy constructor. ///\param other The other variant object to copy. //*************************************************************************** - variant(const variant& other) + constexpr variant(const variant& other) + : data() + , operation(other.operation) + , type_id(other.type_id) { - 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; + operation(action_type::Construct, data, other.data); + } + + //*************************************************************************** + /// Destructor. + //*************************************************************************** + ~variant() + { + operation(action_type::Destruct, data, nullptr); + operation = null_operation; + + type_id = variant_npos; } -#if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && !defined(ETL_VARIANT_FORCE_CPP03) //************************************************************************* /// Emplace with variadic constructor parameters. //************************************************************************* - template - T& emplace(Args&&... args) + template + T& emplace(TArgs&&... args) { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + static_assert(etl::is_one_of::value, "Unsupported type"); - destruct_current(); - ::new (static_cast(data)) T(etl::forward(args)...); - type_id = Type_Id_Lookup::type_id; + T temp(etl::forward(args)...); - 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"); + operation(action_type::Destruct, data, nullptr); + operation(action_type::Construct, data, &temp); - destruct_current(); - ::new (static_cast(data)) T(value1); - type_id = Type_Id_Lookup::type_id; + type_id = etl::parameter_pack::index_of_type::value; 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. + /// Assignment operator for type. ///\param value The value to assign. //*************************************************************************** template variant& operator =(const T& value) { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + static_assert(etl::is_one_of::value, "Unsupported type"); - destruct_current(); - ::new (static_cast(data)) T(value); - type_id = Type_Id_Lookup::type_id; + operation(action_type::Destruct, data, nullptr); + + operation = do_operation; + operation(action_type::Construct, data, &value); + + type_id = etl::parameter_pack::index_of_type::value; return *this; } @@ -542,20 +232,10 @@ namespace etl { if (this != &other) { - destruct_current(); + operation(action_type::Destruct, data, nullptr); - 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; - } + operation = other.operation; + operation(action_type::Construct, data, other.data); type_id = other.type_id; } @@ -563,95 +243,31 @@ namespace etl 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 + constexpr bool valueless_by_exception() const noexcept { - return type_id != UNSUPPORTED_TYPE_ID; + return type_id != variant_npos; } //*************************************************************************** - /// 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. + /// Gets the index of the type currently stored or variant_npos //*************************************************************************** - 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 + constexpr size_t index() const noexcept { return type_id; } //*************************************************************************** - /// Clears the value to 'no valid stored value'. + /// Swaps this variant with another. //*************************************************************************** - void clear() + void swap(variant& rhs) noexcept { - destruct_current(); + variant temp(*this); + *this = rhs; + rhs = temp; } //*************************************************************************** @@ -662,8 +278,8 @@ namespace etl template T& get() { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); - ETL_ASSERT(is_type(), ETL_ERROR(variant_incorrect_type_exception)); + static_assert(etl::is_one_of::value, "Unsupported type"); + ETL_ASSERT(etl::holds_alternative(*this), ETL_ERROR(variant_incorrect_type_exception)); return static_cast(data); } @@ -676,362 +292,195 @@ namespace etl template const T& get() const { - ETL_STATIC_ASSERT(Type_Is_Supported::value, "Unsupported type"); + static_assert(etl::is_one_of::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; } - } + using operation_type = void(*)(action_type, void*, const void*); - type_id = UNSUPPORTED_TYPE_ID; + //*************************************************************************** + /// Do an operation determined by type. + //*************************************************************************** + template + static void do_operation(action_type action, void* pstorage, const void* pvalue) + { + switch (action) + { + case action_type::Construct: + { + ::new (pstorage) T(*reinterpret_cast(pvalue)); + break; + } + + case action_type::Move: + { + ::new (pstorage) T(etl::move(*reinterpret_cast(pvalue))); + break; + } + + case action_type::Destruct: + { + reinterpret_cast(pstorage)->~T(); + break; + } + + default: + { + break; + } + } } - //************************************************************************* - //**** Up-cast functors *************************************************** - //************************************************************************* - - //************************************************************************* - /// Base upcast_functor for eight types. - //************************************************************************* - template - class upcast_functor + //*************************************************************************** + /// Default operation. + //*************************************************************************** + template + static void null_operation(action_type action, void* pstorage, TArgs... args) { - 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. + /// The operation function. //*************************************************************************** - typename etl::aligned_storage::type data; + operation_type operation; //*************************************************************************** - /// The id of the current stored type. + /// The id of the current stored type. //*************************************************************************** - type_id_t type_id; + size_t type_id; }; + + //*************************************************************************** + /// Checks if the variant v holds the alternative T. + //*************************************************************************** + template + constexpr bool holds_alternative(const etl::variant& v) noexcept + { + constexpr size_t Index = etl::parameter_pack::index_of_type::value; + + return (Index == variant_npos) ? false : (v.index() == Index); + } + + //*************************************************************************** + /// variant_alternative + //*************************************************************************** + template + struct variant_alternative; + + template + struct variant_alternative> + { + using type = typename etl::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; + + //*************************************************************************** + /// get + //*************************************************************************** + template + constexpr etl::variant_alternative_t>& + get(etl::variant& v) + { + static_assert(Index < sizeof...(TTypes), "Index out of range"); + ETL_ASSERT(Index == v.index(), ETL_ERROR(etl::variant_incorrect_type_exception)); + + using type = etl::variant_alternative_t>; + + return *static_cast(v.data); + } + + //*********************************** + template + constexpr etl::variant_alternative_t>&& + get(etl::variant&& v) + { + static_assert(Index < sizeof...(TTypes), "Index out of range"); + + using type = etl::variant_alternative_t>; + + return etl::move(*static_cast(v.data)); + } + + //*********************************** + template + constexpr const etl::variant_alternative_t>& + get(const etl::variant& v) + { + static_assert(Index < sizeof...(TTypes), "Index out of range"); + ETL_ASSERT(Index == v.index(), ETL_ERROR(etl::variant_incorrect_type_exception)); + + using type = etl::variant_alternative_t>; + + return *static_cast(v.data); + } + + //*********************************** + template + constexpr const etl::variant_alternative_t>&& + get(const etl::variant&& v) + { + static_assert(Index < sizeof...(TTypes), "Index out of range"); + 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 + constexpr T& get(etl::variant& v) + { + constexpr size_t Index = etl::parameter_pack::index_of_type::value; + + return get(v); + } + + //*********************************** + template + constexpr T&& get(etl::variant&& v) + { + constexpr size_t Index = etl::parameter_pack::index_of_type::value; + + return get(v); + } + + //*********************************** + template + constexpr const T& get(const etl::variant& v) + { + constexpr size_t Index = etl::parameter_pack::index_of_type::value; + + return get(v); + } + + //*********************************** + template + constexpr const T&& get(const etl::variant&& v) + { + constexpr size_t Index = etl::parameter_pack::index_of_type::value; + + return get(v); + } + + //*************************************************************************** + /// swap + //*************************************************************************** + template + void swap(etl::variant& lhs, etl::variant& rhs) + { + lhs.swap(rhs); + } } 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_new.cpp b/test/test_variant_new.cpp new file mode 100644 index 00000000..68ac1c05 --- /dev/null +++ b/test/test_variant_new.cpp @@ -0,0 +1,446 @@ +/****************************************************************************** +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 "unit_test_framework.h" + +#include "etl/private/variant_new.h" + +#include +#include +#include +#include + +namespace +{ + // Test classes for polymorphic tests. + struct base + { + virtual ~base() + { + } + + base() + : value(0) + { + } + + virtual void set() = 0; + int value; + }; + + struct not_base + { + not_base() + : value(0) + { + } + + virtual void set() = 0; + int value; + }; + + struct derived_1 : public base + { + void set() + { + value = 1; + } + }; + + struct derived_2 : public base + { + void set() + { + value = 2; + } + }; + + // Test variant types. + typedef etl::variant test_variant_3a; + typedef etl::variant test_variant_3b; + + typedef etl::variant test_variant_1; + typedef etl::variant test_variant_2; + typedef etl::variant test_variant_3; + typedef etl::variant test_variant_4; + typedef etl::variant test_variant_5; + typedef etl::variant test_variant_6; + typedef etl::variant test_variant_7; + typedef etl::variant test_variant_8; + + typedef etl::variant test_variant_polymorphic; + typedef etl::variant test_variant_max_types; + + // This line should compile with no errors. + test_variant_max_types variant_max; + + struct D1 + { + D1(const std::string& a_) + : a(a_) + { + } + + std::string a; + }; + + 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; + + 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(&a.get()) % uintptr_t(etl::alignment_of::value)) == 0); + CHECK((uintptr_t(&b.get()) % uintptr_t(etl::alignment_of::value)) == 0); + CHECK((uintptr_t(&c.get()) % uintptr_t(etl::alignment_of::value)) == 0); + CHECK((uintptr_t(&d.get()) % uintptr_t(etl::alignment_of::value)) == 0); + } + + //************************************************************************* + TEST(test_constructor_default) + { + CHECK_NO_THROW(test_variant_3a variant); + + test_variant_1 variant; + + CHECK(!etl::holds_alternative(variant)); + } + + //************************************************************************* + TEST(test_constructor_value) + { + // Char. + char c = 'a'; + test_variant_3a variant_char(c); + + CHECK(etl::holds_alternative(variant_char)); + CHECK_EQUAL(c, etl::get(variant_char)); + + // Int. + int i = 1; + test_variant_3a variant_int(i); + + CHECK(etl::holds_alternative(variant_int)); + CHECK_EQUAL(i, etl::get(variant_int)); + + // String. + std::string text("Some Text"); + test_variant_3a variant_text(text); + + CHECK(etl::holds_alternative(variant_text)); + CHECK_EQUAL(text, etl::get(variant_text)); + } + + //************************************************************************* + TEST(test_copy_constructor) + { + std::string text("Some Text"); + test_variant_3a variant_1(text); + + test_variant_3a variant_2(variant_1); + + CHECK_EQUAL(variant_1.index(), variant_2.index()); + CHECK_EQUAL(variant_1.get(), variant_2.get()); + } + + //************************************************************************* + TEST(test_assign_from_value) + { + std::string text("Some Text"); + test_variant_3a variant; + + variant = text; + + CHECK_EQUAL(text, variant.get()); + } + + //************************************************************************* + TEST(test_assign_from_variant) + { + std::string text("Some Text"); + test_variant_3a variant_1; + test_variant_3a variant_2; + + variant_1 = text; + variant_2 = variant_1; + + CHECK_EQUAL(text, variant_2.get()); + } + + //************************************************************************* + TEST(test_assign_from_variant2) + { + std::string text("Some Text"); + int integer(99); + test_variant_3a variant_1; + test_variant_3a variant_2; + + variant_1 = text; + variant_2 = integer; + variant_2 = variant_1; + + CHECK_EQUAL(text, variant_2.get()); + } + + //************************************************************************* + TEST(test_member_swap_variants) + { + std::string text("Some Text"); + int integer(99); + test_variant_3a variant_1(text); + test_variant_3a variant_2(integer); + + variant_1.swap(variant_2); + + CHECK(etl::holds_alternative(variant_1)); + CHECK_EQUAL(integer, etl::get(variant_1)); + + CHECK(etl::holds_alternative(variant_2)); + CHECK_EQUAL(text, etl::get(variant_2)); + } + + //************************************************************************* + TEST(test_global_swap_variants) + { + std::string text("Some Text"); + int integer(99); + test_variant_3a variant_1(text); + test_variant_3a variant_2(integer); + + etl::swap(variant_1, variant_2); + + CHECK(etl::holds_alternative(variant_1)); + CHECK_EQUAL(integer, etl::get(variant_1)); + + CHECK(etl::holds_alternative(variant_2)); + CHECK_EQUAL(text, etl::get(variant_2)); + } + + //************************************************************************* + TEST(test_assignment_incorrect_type_exception) + { + std::string text("Some Text"); + test_variant_3a variant(text); + + int i; + CHECK_THROW(etl::get(variant), etl::variant_incorrect_type_exception); + (void)i; + } + + ////************************************************************************* + //TEST(test_get) + //{ + // test_variant_3a variant; + + // variant = 1; + // CHECK_EQUAL(1, variant.get()); + + // variant = 'a'; + // CHECK_EQUAL('a', variant.get()); + + // variant = std::string("Some Text"); + // CHECK_EQUAL(std::string("Some Text"), variant.get()); + //} + + ////************************************************************************* + //TEST(test_get_const) + //{ + // test_variant_3a variant; + + // variant = 1; + // const test_variant_3a cvariant1(variant); + // CHECK_EQUAL(1, cvariant1.get()); + + // variant = 'a'; + // const test_variant_3a cvariant2(variant); + // CHECK_EQUAL('a', cvariant2.get()); + + // variant = std::string("Some Text"); + // const test_variant_3a cvariant3(variant); + // CHECK_EQUAL(std::string("Some Text"), cvariant3.get()); + //} + + ////************************************************************************* + //TEST(test_self_assignment) + //{ + // test_variant_3a variant; + + // variant = 1; + // variant = variant; + + // CHECK_EQUAL(1, variant.get()); + //} + + ////************************************************************************* + //TEST(TestGetException) + //{ + // test_variant_3a variant; + // variant = 1; + + // char c; + // CHECK_THROW(c = variant.get(), etl::variant_incorrect_type_exception); + // (void)c; + //} + + ////************************************************************************* + //TEST(TestPolymorphic) + //{ + // test_variant_polymorphic variant; + + // variant = derived_1(); + // variant.upcast().set(); + // CHECK_EQUAL(1, variant.get().value); + + // variant = derived_2(); + // variant.upcast().set(); + // CHECK_EQUAL(2, variant.get().value); + //} + + ////************************************************************************* + //TEST(TestEmplace) + //{ + // test_variant_emplace variant; + + // variant.emplace("1"); + // CHECK(variant.is_type()); + // CHECK_EQUAL(D1("1"), variant.get()); + + // variant.emplace("1", "2"); + // CHECK(variant.is_type()); + // CHECK_EQUAL(D2("1", "2"), variant.get()); + + // variant.emplace("1", "2", "3"); + // CHECK(variant.is_type()); + // CHECK_EQUAL(D3("1", "2", "3"), variant.get()); + + // variant.emplace("1", "2", "3", "4"); + // CHECK(variant.is_type()); + // CHECK_EQUAL(D4("1", "2", "3", "4"), variant.get()); + //} + }; +} diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 1cea32c9..2836b588 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -4946,7 +4946,8 @@ - + + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 04825358..fbe70298 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1160,7 +1160,7 @@ Source Files - + Source Files @@ -2525,6 +2525,9 @@ Source Files + + Source Files + From 92515111d906ed557e84f5eccc5ac77463257c7b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 22 May 2021 20:28:40 +0100 Subject: [PATCH 03/81] Interim commit --- include/etl/private/variant_new.h | 85 ++++++++++++++++++- test/test_variant_new.cpp | 136 +++++++++--------------------- 2 files changed, 121 insertions(+), 100 deletions(-) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 379e9ab8..1c2d36d4 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -58,7 +58,15 @@ namespace etl { static_assert(ETL_CPP11_SUPPORTED, "Only supported for C++11 or above"); - static size_t variant_npos = etl::integral_limits::max; + constexpr size_t variant_npos = etl::integral_limits::max; + + //*************************************************************************** + /// Monostate for variants. + ///\ingroup variant + //*************************************************************************** + struct monostate + { + }; //*************************************************************************** /// Base exception for the variant class. @@ -193,11 +201,13 @@ namespace etl template T& emplace(TArgs&&... args) { - static_assert(etl::is_one_of::value, "Unsupported type"); + static_assert(etl::is_one_of::value, "Unsupported type"); T temp(etl::forward(args)...); operation(action_type::Destruct, data, nullptr); + + operation = do_operation; operation(action_type::Construct, data, &temp); type_id = etl::parameter_pack::index_of_type::value; @@ -292,7 +302,7 @@ namespace etl template const T& get() const { - static_assert(etl::is_one_of::value, "Unsupported type"); + static_assert(etl::is_one_of::value, "Unsupported type"); ETL_ASSERT(is_type(), ETL_ERROR(variant_incorrect_type_exception)); return static_cast(data); @@ -475,6 +485,56 @@ namespace etl return get(v); } + //*************************************************************************** + /// get_if + //*************************************************************************** + template < size_t Index, class... Types > + constexpr 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, class... Types > + constexpr 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, class... Types > + constexpr etl::add_pointer_t get_if(etl::variant* pv) noexcept + { + constexpr size_t Index = etl::parameter_pack::index_of_type::value; + + return etl::get_if(pv); + } + + //*********************************** + template< class T, class... Types > + constexpr etl::add_pointer_t get_if(const etl::variant* pv) noexcept + { + constexpr size_t Index = etl::parameter_pack::index_of_type::value; + + return etl::get_if(pv); + } + //*************************************************************************** /// swap //*************************************************************************** @@ -483,4 +543,23 @@ namespace etl { lhs.swap(rhs); } + + //*************************************************************************** + /// variant_size + //*************************************************************************** + template + struct variant_size; + + template + struct variant_size> + : etl::integral_constant + { + }; + + template + struct variant_size + : etl::integral_constant::value> + { + }; + } diff --git a/test/test_variant_new.cpp b/test/test_variant_new.cpp index 68ac1c05..a99a6e83 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -307,6 +307,28 @@ namespace CHECK_EQUAL(text, variant_2.get()); } + //************************************************************************* + TEST(test_assignment_incorrect_type_exception) + { + std::string text("Some Text"); + test_variant_3a variant(text); + + int i; + CHECK_THROW(etl::get(variant), etl::variant_incorrect_type_exception); + (void)i; + } + + //************************************************************************* + TEST(test_self_assignment) + { + test_variant_3a variant; + + variant = 1; + variant = variant; + + CHECK_EQUAL(1, etl::get(variant)); + } + //************************************************************************* TEST(test_member_swap_variants) { @@ -342,105 +364,25 @@ namespace } //************************************************************************* - TEST(test_assignment_incorrect_type_exception) + TEST(test_emplace) { - std::string text("Some Text"); - test_variant_3a variant(text); + test_variant_emplace variant; - int i; - CHECK_THROW(etl::get(variant), etl::variant_incorrect_type_exception); - (void)i; + variant.emplace("1"); + CHECK(etl::holds_alternative(variant)); + CHECK_EQUAL(D1("1"), etl::get(variant)); + + variant.emplace("1", "2"); + CHECK(etl::holds_alternative(variant)); + CHECK_EQUAL(D2("1", "2"), etl::get(variant)); + + variant.emplace("1", "2", "3"); + CHECK(etl::holds_alternative(variant)); + CHECK_EQUAL(D3("1", "2", "3"), etl::get(variant)); + + variant.emplace("1", "2", "3", "4"); + CHECK(etl::holds_alternative(variant)); + CHECK_EQUAL(D4("1", "2", "3", "4"), etl::get(variant)); } - - ////************************************************************************* - //TEST(test_get) - //{ - // test_variant_3a variant; - - // variant = 1; - // CHECK_EQUAL(1, variant.get()); - - // variant = 'a'; - // CHECK_EQUAL('a', variant.get()); - - // variant = std::string("Some Text"); - // CHECK_EQUAL(std::string("Some Text"), variant.get()); - //} - - ////************************************************************************* - //TEST(test_get_const) - //{ - // test_variant_3a variant; - - // variant = 1; - // const test_variant_3a cvariant1(variant); - // CHECK_EQUAL(1, cvariant1.get()); - - // variant = 'a'; - // const test_variant_3a cvariant2(variant); - // CHECK_EQUAL('a', cvariant2.get()); - - // variant = std::string("Some Text"); - // const test_variant_3a cvariant3(variant); - // CHECK_EQUAL(std::string("Some Text"), cvariant3.get()); - //} - - ////************************************************************************* - //TEST(test_self_assignment) - //{ - // test_variant_3a variant; - - // variant = 1; - // variant = variant; - - // CHECK_EQUAL(1, variant.get()); - //} - - ////************************************************************************* - //TEST(TestGetException) - //{ - // test_variant_3a variant; - // variant = 1; - - // char c; - // CHECK_THROW(c = variant.get(), etl::variant_incorrect_type_exception); - // (void)c; - //} - - ////************************************************************************* - //TEST(TestPolymorphic) - //{ - // test_variant_polymorphic variant; - - // variant = derived_1(); - // variant.upcast().set(); - // CHECK_EQUAL(1, variant.get().value); - - // variant = derived_2(); - // variant.upcast().set(); - // CHECK_EQUAL(2, variant.get().value); - //} - - ////************************************************************************* - //TEST(TestEmplace) - //{ - // test_variant_emplace variant; - - // variant.emplace("1"); - // CHECK(variant.is_type()); - // CHECK_EQUAL(D1("1"), variant.get()); - - // variant.emplace("1", "2"); - // CHECK(variant.is_type()); - // CHECK_EQUAL(D2("1", "2"), variant.get()); - - // variant.emplace("1", "2", "3"); - // CHECK(variant.is_type()); - // CHECK_EQUAL(D3("1", "2", "3"), variant.get()); - - // variant.emplace("1", "2", "3", "4"); - // CHECK(variant.is_type()); - // CHECK_EQUAL(D4("1", "2", "3", "4"), variant.get()); - //} }; } From 34479a3e316d4d2db7c95a093f91a31275fba48e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 23 May 2021 16:10:58 +0100 Subject: [PATCH 04/81] Working. No move functionality. --- include/etl/private/variant_new.h | 20 ++-- test/test_variant_new.cpp | 168 ++++++++++++++++-------------- 2 files changed, 97 insertions(+), 91 deletions(-) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 1c2d36d4..45447fc0 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -152,14 +152,18 @@ namespace etl //*************************************************************************** constexpr variant() : data() - , operation(null_operation) - , type_id(variant_npos) { + using type = typename etl::parameter_pack::type_from_index<0>::type; + + type temp; + + operation = do_operation; + operation(action_type::Construct, data, &temp); + type_id = 0; } //*************************************************************************** - /// Constructor that catches any types that are not supported. - /// Forces a static_assert. + /// Constructor for lvalues //*************************************************************************** template constexpr variant(const T& value) @@ -169,7 +173,7 @@ namespace etl { static_assert(etl::is_one_of::value, "Unsupported type"); - operation(action_type::Construct, data, &value); + operation(action_type::Construct, data, &const_cast(value)); } //*************************************************************************** @@ -326,12 +330,6 @@ namespace etl break; } - case action_type::Move: - { - ::new (pstorage) T(etl::move(*reinterpret_cast(pvalue))); - break; - } - case action_type::Destruct: { reinterpret_cast(pstorage)->~T(); diff --git a/test/test_variant_new.cpp b/test/test_variant_new.cpp index a99a6e83..69fcd47a 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -37,76 +37,35 @@ SOFTWARE. namespace { - // Test classes for polymorphic tests. - struct base - { - virtual ~base() - { - } - - base() - : value(0) - { - } - - virtual void set() = 0; - int value; - }; - - struct not_base - { - not_base() - : value(0) - { - } - - virtual void set() = 0; - int value; - }; - - struct derived_1 : public base - { - void set() - { - value = 1; - } - }; - - struct derived_2 : public base - { - void set() - { - value = 2; - } - }; - // Test variant types. - typedef etl::variant test_variant_3a; - typedef etl::variant test_variant_3b; - - typedef etl::variant test_variant_1; - typedef etl::variant test_variant_2; - typedef etl::variant test_variant_3; - typedef etl::variant test_variant_4; - typedef etl::variant test_variant_5; - typedef etl::variant test_variant_6; - typedef etl::variant test_variant_7; - typedef etl::variant test_variant_8; - - typedef etl::variant test_variant_polymorphic; - typedef etl::variant test_variant_max_types; - - // This line should compile with no errors. - test_variant_max_types variant_max; + typedef etl::variant test_variant_3; 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 @@ -199,7 +158,7 @@ namespace return os; } - typedef etl::variant test_variant_emplace; + typedef etl::variant test_variant_emplace; SUITE(test_variant) { @@ -224,11 +183,11 @@ namespace //************************************************************************* TEST(test_constructor_default) { - CHECK_NO_THROW(test_variant_3a variant); + CHECK_NO_THROW(test_variant_3 variant); - test_variant_1 variant; + test_variant_3 variant; - CHECK(!etl::holds_alternative(variant)); + CHECK(etl::holds_alternative(variant)); } //************************************************************************* @@ -236,21 +195,46 @@ namespace { // Char. char c = 'a'; - test_variant_3a variant_char(c); + test_variant_3 variant_char(c); CHECK(etl::holds_alternative(variant_char)); CHECK_EQUAL(c, etl::get(variant_char)); // Int. int i = 1; - test_variant_3a variant_int(i); + test_variant_3 variant_int(i); CHECK(etl::holds_alternative(variant_int)); CHECK_EQUAL(i, etl::get(variant_int)); // String. std::string text("Some Text"); - test_variant_3a variant_text(text); + test_variant_3 variant_text(text); + + CHECK(etl::holds_alternative(variant_text)); + CHECK_EQUAL(text, etl::get(variant_text)); + } + + //************************************************************************* + TEST(test_constructor_move_value) + { + // Char. + char c = 'a'; + test_variant_3 variant_char(etl::move(c)); + + CHECK(etl::holds_alternative(variant_char)); + CHECK_EQUAL(c, etl::get(variant_char)); + + // Int. + int i = 1; + test_variant_3 variant_int(etl::move(i)); + + CHECK(etl::holds_alternative(variant_int)); + CHECK_EQUAL(i, etl::get(variant_int)); + + // String. + std::string text("Some Text"); + test_variant_3 variant_text(etl::move(text)); CHECK(etl::holds_alternative(variant_text)); CHECK_EQUAL(text, etl::get(variant_text)); @@ -260,9 +244,21 @@ namespace TEST(test_copy_constructor) { std::string text("Some Text"); - test_variant_3a variant_1(text); + test_variant_3 variant_1(text); - test_variant_3a variant_2(variant_1); + test_variant_3 variant_2(variant_1); + + CHECK_EQUAL(variant_1.index(), variant_2.index()); + CHECK_EQUAL(variant_1.get(), variant_2.get()); + } + + //************************************************************************* + TEST(test_move_constructor) + { + std::string text("Some Text"); + test_variant_3 variant_1(text); + + test_variant_3 variant_2(etl::move(variant_1)); CHECK_EQUAL(variant_1.index(), variant_2.index()); CHECK_EQUAL(variant_1.get(), variant_2.get()); @@ -272,7 +268,7 @@ namespace TEST(test_assign_from_value) { std::string text("Some Text"); - test_variant_3a variant; + test_variant_3 variant; variant = text; @@ -283,8 +279,8 @@ namespace TEST(test_assign_from_variant) { std::string text("Some Text"); - test_variant_3a variant_1; - test_variant_3a variant_2; + test_variant_3 variant_1; + test_variant_3 variant_2; variant_1 = text; variant_2 = variant_1; @@ -297,8 +293,8 @@ namespace { std::string text("Some Text"); int integer(99); - test_variant_3a variant_1; - test_variant_3a variant_2; + test_variant_3 variant_1; + test_variant_3 variant_2; variant_1 = text; variant_2 = integer; @@ -311,7 +307,7 @@ namespace TEST(test_assignment_incorrect_type_exception) { std::string text("Some Text"); - test_variant_3a variant(text); + test_variant_3 variant(text); int i; CHECK_THROW(etl::get(variant), etl::variant_incorrect_type_exception); @@ -321,7 +317,7 @@ namespace //************************************************************************* TEST(test_self_assignment) { - test_variant_3a variant; + test_variant_3 variant; variant = 1; variant = variant; @@ -334,8 +330,8 @@ namespace { std::string text("Some Text"); int integer(99); - test_variant_3a variant_1(text); - test_variant_3a variant_2(integer); + test_variant_3 variant_1(text); + test_variant_3 variant_2(integer); variant_1.swap(variant_2); @@ -351,8 +347,8 @@ namespace { std::string text("Some Text"); int integer(99); - test_variant_3a variant_1(text); - test_variant_3a variant_2(integer); + test_variant_3 variant_1(text); + test_variant_3 variant_2(integer); etl::swap(variant_1, variant_2); @@ -384,5 +380,17 @@ namespace CHECK(etl::holds_alternative(variant)); CHECK_EQUAL(D4("1", "2", "3", "4"), etl::get(variant)); } + + //************************************************************************* + TEST(test_move) + { + test_variant_emplace variant; + + D1 da("1"); + + variant = da; + + D1 db = etl::move(etl::get(variant)); + } }; } From f4060bc9eadf6547ea221de4ee2cd3cf5a9d82d7 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 23 May 2021 16:59:10 +0100 Subject: [PATCH 05/81] Working. No move functionality. --- include/etl/private/variant_new.h | 4 ++-- test/test_variant_new.cpp | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 45447fc0..97f918df 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -199,9 +199,9 @@ namespace etl type_id = variant_npos; } - //************************************************************************* + //*************************************************************************** /// Emplace with variadic constructor parameters. - //************************************************************************* + //*************************************************************************** template T& emplace(TArgs&&... args) { diff --git a/test/test_variant_new.cpp b/test/test_variant_new.cpp index 69fcd47a..f0516e55 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -382,13 +382,16 @@ namespace } //************************************************************************* + D1 getD1() + { + return D1("1"); + } + TEST(test_move) { - test_variant_emplace variant; - D1 da("1"); - - variant = da; + + test_variant_emplace variant(etl::move(getD1())); D1 db = etl::move(etl::get(variant)); } From 67c19bb0dcf2c9a758ebc13fdecbe93eb9c60c62 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 23 May 2021 20:37:29 +0100 Subject: [PATCH 06/81] Fold expression experiment --- include/etl/private/variant_new.h | 96 +++++++++++++++++++++++++++++-- test/test_variant_new.cpp | 38 +++++++++++- 2 files changed, 128 insertions(+), 6 deletions(-) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 97f918df..487cd945 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -7,7 +7,7 @@ Embedded Template Library. https://github.com/ETLCPP/etl https://www.etlcpp.com -Copyright(c) 2014 jwellbelove +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 @@ -43,11 +43,56 @@ SOFTWARE. #include "../parameter_pack.h" #include "../placement_new.h" +#include + #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 940 #pragma diag_suppress 111 #endif +namespace etl +{ + //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, integer_sequence> + // { + // typedef integer_sequence type; + // }; + //} + + //template + //using make_index_sequence = typename private_integer_sequence::make_index_sequence>::type; + + //template + //using index_sequence = integer_sequence; +} + + //***************************************************************************** ///\defgroup variant variant /// A class that can contain one a several specified types in a type safe manner. @@ -68,6 +113,13 @@ namespace etl { }; + 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; } + //*************************************************************************** /// Base exception for the variant class. ///\ingroup variant @@ -207,11 +259,11 @@ namespace etl { static_assert(etl::is_one_of::value, "Unsupported type"); - T temp(etl::forward(args)...); - operation(action_type::Destruct, data, nullptr); operation = do_operation; + + T temp(etl::forward(args)...); operation(action_type::Construct, data, &temp); type_id = etl::parameter_pack::index_of_type::value; @@ -312,6 +364,15 @@ namespace etl return static_cast(data); } + //*************************************************************************** + /// Do an operation determined by type. + //*************************************************************************** + template + void accept(TVisitor& visitor) + { + do_accept(visitor, std::make_index_sequence{}); + } + private: using operation_type = void(*)(action_type, void*, const void*); @@ -343,6 +404,32 @@ namespace etl } } + //*************************************************************************** + /// Loop through the types until a match is found. + //*************************************************************************** + template + void do_accept(TVisitor& visitor, std::index_sequence) + { + (attempt_visitor(visitor) || ...); + } + + //*************************************************************************** + /// Attempt to call a visitor. + //*************************************************************************** + template + bool attempt_visitor(TVisitor& visitor) + { + if (Index == index()) + { + visitor.visit(etl::get(*this)); + return true; + } + else + { + return false; + } + } + //*************************************************************************** /// Default operation. //*************************************************************************** @@ -401,7 +488,7 @@ namespace etl constexpr etl::variant_alternative_t>& get(etl::variant& v) { - static_assert(Index < sizeof...(TTypes), "Index out of range"); + //static_assert(Index < sizeof...(TTypes), "Index out of range"); ETL_ASSERT(Index == v.index(), ETL_ERROR(etl::variant_incorrect_type_exception)); using type = etl::variant_alternative_t>; @@ -559,5 +646,4 @@ namespace etl : etl::integral_constant::value> { }; - } diff --git a/test/test_variant_new.cpp b/test/test_variant_new.cpp index f0516e55..700780f8 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -5,7 +5,7 @@ Embedded Template Library. https://github.com/ETLCPP/etl https://www.etlcpp.com -Copyright(c) 2014 jwellbelove +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 @@ -29,6 +29,7 @@ SOFTWARE. #include "unit_test_framework.h" #include "etl/private/variant_new.h" +#include "etl/visitor.h" #include #include @@ -395,5 +396,40 @@ namespace D1 db = etl::move(etl::get(variant)); } + + //************************************************************************* + TEST(test_variant_visitor) + { + struct Visitor : public etl::visitor + { + void visit(char& c) + { + + } + + void visit(int& i) + { + + } + + void visit(std::string& s) + { + + } + }; + + Visitor visitor; + + test_variant_3 variant; + + variant = char(1); + variant.accept(visitor); + + variant = int(2); + variant.accept(visitor); + + variant = std::string("3"); + variant.accept(visitor); + } }; } From 84e1241c39835e971f25b4d430c4922a7632fa72 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 25 May 2021 11:02:24 +0100 Subject: [PATCH 07/81] Added experimental uni_type --- include/etl/experimental/uni_type.h | 78 +++++++++++++++++++++++++++++ test/vs2019/etl.vcxproj | 1 + test/vs2019/etl.vcxproj.filters | 6 +++ 3 files changed, 85 insertions(+) create mode 100644 include/etl/experimental/uni_type.h diff --git a/include/etl/experimental/uni_type.h b/include/etl/experimental/uni_type.h new file mode 100644 index 00000000..d5840321 --- /dev/null +++ b/include/etl/experimental/uni_type.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/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 2836b588..d6802bf2 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1309,6 +1309,7 @@ + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index fbe70298..1efda090 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -106,6 +106,9 @@ {562466b5-677d-4448-9e9e-f70805cd71ad} + + {79c578f6-5400-4b4d-b2a4-9a8c589f7c81} + @@ -1107,6 +1110,9 @@ ETL\Private + + ETL\Experimental + From 3cbd432a29f3b3464498ed36f967d3445cff38a9 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 25 May 2021 11:02:24 +0100 Subject: [PATCH 08/81] Added experimental uni_type --- include/etl/experimental/uni_type.h | 33 ++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/include/etl/experimental/uni_type.h b/include/etl/experimental/uni_type.h index d5840321..1aec8899 100644 --- a/include/etl/experimental/uni_type.h +++ b/include/etl/experimental/uni_type.h @@ -6,6 +6,13 @@ public: static constexpr size_t Size = Size_; + //*********************************** + template + uni_type(const uni_type& other) + { + memcpy(buffer, other.buffer, Size_); + } + //*********************************** template T& get() @@ -20,12 +27,22 @@ public: return *reinterpret_cast(buffer); } + //*********************************** template operator T() { return *reinterpret_cast(buffer); } + //*********************************** + template + uni_type& operator =(const uni_type& rhs) + { + memcpy(buffer, rhs.buffer, Size_); + + return *this; + } + //*********************************** constexpr size_t size() const { @@ -37,8 +54,6 @@ private: char buffer[Size] }; - - template class uni_type_ptr { @@ -46,6 +61,18 @@ public: static constexpr size_t Size = Size_; + //*********************************** + uni_type_ptr() + : pbuffer(ETL_NULLPTR) + { + } + + //*********************************** + uni_type_ptr(void* pbuffer_) + : pbuffer(reinterpret_cast(pbuffer)) + { + } + //*********************************** template T& get() @@ -75,4 +102,4 @@ public: private: char* pbuffer; -}; \ No newline at end of file +}; From ab7fcbee645a90cd99f774cac726ceb13a469b49 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 25 May 2021 23:06:15 +0100 Subject: [PATCH 09/81] Added experimental uni_type --- .../experimental/{uni_type.h => mem_type.h} | 62 +++++++++++++++---- test/vs2019/etl.vcxproj | 2 +- test/vs2019/etl.vcxproj.filters | 2 +- 3 files changed, 52 insertions(+), 14 deletions(-) rename include/etl/experimental/{uni_type.h => mem_type.h} (52%) diff --git a/include/etl/experimental/uni_type.h b/include/etl/experimental/mem_type.h similarity index 52% rename from include/etl/experimental/uni_type.h rename to include/etl/experimental/mem_type.h index 1aec8899..0b9532de 100644 --- a/include/etl/experimental/uni_type.h +++ b/include/etl/experimental/mem_type.h @@ -1,15 +1,17 @@ #pragma once template -class uni_type +class mem_type { public: static constexpr size_t Size = Size_; - //*********************************** - template - uni_type(const uni_type& other) + //*********************************** + template + mem_type(const mem_type= Other_Size, "Other size is too large"); + memcpy(buffer, other.buffer, Size_); } @@ -29,15 +31,17 @@ public: //*********************************** template - operator T() + operator T() const { return *reinterpret_cast(buffer); } //*********************************** - template - uni_type& operator =(const uni_type& rhs) + template + mem_type& operator =(const mem_type& rhs) { + ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); + memcpy(buffer, rhs.buffer, Size_); return *this; @@ -49,30 +53,46 @@ public: return Size; } + //*********************************** + constexpr char* data() const + { + return buffer; + } + private: char buffer[Size] }; template -class uni_type_ptr +class mem_type_ptr { public: static constexpr size_t Size = Size_; //*********************************** - uni_type_ptr() + mem_type_ptr() : pbuffer(ETL_NULLPTR) { } //*********************************** - uni_type_ptr(void* pbuffer_) - : pbuffer(reinterpret_cast(pbuffer)) + mem_type_ptr(char* pbuffer_) + : pbuffer(pbuffer_) { } + //*********************************** + template + mem_type_ptr(const mem_type_ptr= Other_Size, "Other size is too large"); + + memcpy(buffer, other.buffer, Size_); + } + //*********************************** template T& get() @@ -87,18 +107,36 @@ public: return *reinterpret_cast(pbuffer); } + //*********************************** template - operator T() + operator T() const { return *reinterpret_cast(pbuffer); } + //*********************************** + template + mem_type_ptr& operator =(const mem_type_ptr& rhs) + { + ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); + + memcpy(pbuffer, rhs.pbuffer, Size_); + + return *this; + } + //*********************************** constexpr size_t size() const { return Size; } + //*********************************** + constexpr char* data() const + { + return pbuffer; + } + private: char* pbuffer; diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index d6802bf2..592ece07 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1309,7 +1309,7 @@ - + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 1efda090..6d6ac599 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1110,7 +1110,7 @@ ETL\Private - + ETL\Experimental From d8777dc2f6b7334103e5d9b9131143501fb2d4b9 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 26 May 2021 11:09:02 +0100 Subject: [PATCH 10/81] Further updates to mem_type --- include/etl/experimental/mem_type.h | 91 +++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 24 deletions(-) diff --git a/include/etl/experimental/mem_type.h b/include/etl/experimental/mem_type.h index 0b9532de..68a8c7b5 100644 --- a/include/etl/experimental/mem_type.h +++ b/include/etl/experimental/mem_type.h @@ -1,46 +1,68 @@ #pragma once -template + +#include + +#include "../platform.h" +#include "../memory.h" +#include "../static_assert.h" + +//***************************************************************************** +/// mem_type +//***************************************************************************** +template class mem_type { public: - static constexpr size_t Size = Size_; + static constexpr size_t Size = Size_; + static constexpr size_t Alignment = Alignment_; //*********************************** - template - mem_type(const mem_type + constexpr mem_type(const mem_type& other) { - ETL_STATIC_ASSERT(Size >= Other_Size, "Other size is too large"); + ETL_STATIC_ASSERT(Size >= Other_Size, "Other size is too large"); + ETL_STATIC_ASSERT(Alignment >= Other_Alignment, "Other alignment incompatible"); memcpy(buffer, other.buffer, Size_); } //*********************************** template - T& get() + constexpr T& get() { + ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); + ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); + return *reinterpret_cast(buffer); } //*********************************** template - const T& get() const + constexpr const T& get() const { + ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); + ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); + return *reinterpret_cast(buffer); } //*********************************** template - operator T() const + constexpr operator T() const { + ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); + ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); + return *reinterpret_cast(buffer); } //*********************************** - template - mem_type& operator =(const mem_type& rhs) + template + constexpr mem_type& operator =(const mem_type& rhs) { ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); + ETL_STATIC_ASSERT(Alignment >= Other_Alignment, "RHS alignment incompatible"); memcpy(buffer, rhs.buffer, Size_); @@ -53,17 +75,26 @@ public: return Size; } + //*********************************** + constexpr size_t alignment() const + { + return Alignment; + } + //*********************************** constexpr char* data() const { - return buffer; + return buffer; } private: - char buffer[Size] + etl::aligned_storage buffer; }; +//***************************************************************************** +/// mem_type_ptr +//***************************************************************************** template class mem_type_ptr { @@ -72,45 +103,57 @@ public: static constexpr size_t Size = Size_; //*********************************** - mem_type_ptr() + constexpr mem_type_ptr() : pbuffer(ETL_NULLPTR) { } //*********************************** - mem_type_ptr(char* pbuffer_) + constexpr mem_type_ptr(char* pbuffer_) : pbuffer(pbuffer_) { } //*********************************** template - mem_type_ptr(const mem_type_ptr= Other_Size, "Other size is too large"); + ETL_STATIC_ASSERT(Size >= Other_Size, "Other size is too large"); - memcpy(buffer, other.buffer, Size_); + memcpy(buffer, other.buffer, Size_); + } + + //*********************************** + void set(char* pbuffer_) + { + pbuffer = pbuffer_; } //*********************************** template - T& get() + constexpr T& get() { + ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); + return *reinterpret_cast(pbuffer); } //*********************************** template - const T& get() const + constexpr const T& get() const { + ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); + return *reinterpret_cast(pbuffer); } //*********************************** template - operator T() const + constexpr operator T() const { + ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); + return *reinterpret_cast(pbuffer); } @@ -118,11 +161,11 @@ public: template mem_type_ptr& operator =(const mem_type_ptr& rhs) { - ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); + ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); - memcpy(pbuffer, rhs.pbuffer, Size_); + memcpy(pbuffer, rhs.pbuffer, Size_); - return *this; + return *this; } //*********************************** @@ -134,7 +177,7 @@ public: //*********************************** constexpr char* data() const { - return pbuffer; + return pbuffer; } private: From 380fc59b2be2236d07e3e1e30fcd412d4ee8a3ef Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 26 May 2021 22:04:34 +0100 Subject: [PATCH 11/81] Further updates to mem_type --- include/etl/experimental/mem_type.h | 349 ++++++++++++++++------------ test/test_mem_type.cpp | 88 +++++++ test/vs2019/etl.vcxproj | 1 + test/vs2019/etl.vcxproj.filters | 3 + 4 files changed, 287 insertions(+), 154 deletions(-) create mode 100644 test/test_mem_type.cpp diff --git a/include/etl/experimental/mem_type.h b/include/etl/experimental/mem_type.h index 68a8c7b5..60cc43f1 100644 --- a/include/etl/experimental/mem_type.h +++ b/include/etl/experimental/mem_type.h @@ -1,4 +1,35 @@ -#pragma once +///\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_MEM_TYPE_INCLUDED +#define ETL_MEM_TYPE_INCLUDED #include @@ -6,181 +37,191 @@ #include "../memory.h" #include "../static_assert.h" -//***************************************************************************** -/// mem_type -//***************************************************************************** -template -class mem_type +namespace etl { -public: - - static constexpr size_t Size = Size_; - static constexpr size_t Alignment = Alignment_; - - //*********************************** - template - constexpr mem_type(const mem_type& other) + //***************************************************************************** + /// mem_type + //***************************************************************************** + template + class mem_type { - ETL_STATIC_ASSERT(Size >= Other_Size, "Other size is too large"); - ETL_STATIC_ASSERT(Alignment >= Other_Alignment, "Other alignment incompatible"); + public: - memcpy(buffer, other.buffer, Size_); - } + static ETL_CONSTANT size_t Size = Size_; + static ETL_CONSTANT size_t Alignment = Alignment_; - //*********************************** - template - constexpr T& get() + //*********************************** + ETL_CONSTEXPR mem_type() + { + } + + //*********************************** + template + ETL_CONSTEXPR mem_type(const mem_type& other) + { + ETL_STATIC_ASSERT(Size >= Other_Size, "Other size is too large"); + ETL_STATIC_ASSERT(Alignment >= Other_Alignment, "Other alignment incompatible"); + + memcpy(buffer, other.buffer, Size_); + } + + //*********************************** + template + ETL_CONSTEXPR T& get() + { + ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); + ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); + + return *reinterpret_cast(buffer); + } + + //*********************************** + template + ETL_CONSTEXPR const T& get() const + { + ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); + ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); + + return *reinterpret_cast(buffer); + } + + //*********************************** + template + ETL_CONSTEXPR operator T() const + { + ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); + ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); + + return *reinterpret_cast(buffer); + } + + //*********************************** + template + ETL_CONSTEXPR mem_type& operator =(const mem_type& rhs) + { + ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); + ETL_STATIC_ASSERT(Alignment >= Other_Alignment, "RHS alignment incompatible"); + + memcpy(buffer, rhs.buffer, Size_); + + return *this; + } + + //*********************************** + ETL_CONSTEXPR size_t size() const + { + return Size; + } + + //*********************************** + ETL_CONSTEXPR size_t alignment() const + { + return Alignment; + } + + //*********************************** + ETL_CONSTEXPR char* data() const + { + return buffer; + } + + private: + + etl::aligned_storage buffer; + }; + + //***************************************************************************** + /// mem_type_ptr + //***************************************************************************** + template + class mem_type_ptr { - ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); - ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); + public: - return *reinterpret_cast(buffer); - } + static ETL_CONSTANT size_t Size = Size_; - //*********************************** - template - constexpr const T& get() const - { - ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); - ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); + //*********************************** + ETL_CONSTEXPR mem_type_ptr() + : pbuffer(ETL_NULLPTR) + { + } - return *reinterpret_cast(buffer); - } + //*********************************** + ETL_CONSTEXPR mem_type_ptr(char* pbuffer_) + : pbuffer(pbuffer_) + { + } - //*********************************** - template - constexpr operator T() const - { - ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); - ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); + //*********************************** + template + ETL_CONSTEXPR mem_type_ptr(const mem_type_ptr& other, char* pbuffer_) + : pbuffer(pbuffer_) + { + ETL_STATIC_ASSERT(Size >= Other_Size, "Other size is too large"); - return *reinterpret_cast(buffer); - } + memcpy(buffer, other.buffer, Size_); + } - //*********************************** - template - constexpr mem_type& operator =(const mem_type& rhs) - { - ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); - ETL_STATIC_ASSERT(Alignment >= Other_Alignment, "RHS alignment incompatible"); + //*********************************** + void set(char* pbuffer_) + { + pbuffer = pbuffer_; + } - memcpy(buffer, rhs.buffer, Size_); + //*********************************** + template + ETL_CONSTEXPR T& get() + { + ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); - return *this; - } + return *reinterpret_cast(pbuffer); + } - //*********************************** - constexpr size_t size() const - { - return Size; - } + //*********************************** + template + ETL_CONSTEXPR const T& get() const + { + ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); - //*********************************** - constexpr size_t alignment() const - { - return Alignment; - } + return *reinterpret_cast(pbuffer); + } - //*********************************** - constexpr char* data() const - { - return buffer; - } + //*********************************** + template + ETL_CONSTEXPR operator T() const + { + ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); -private: + return *reinterpret_cast(pbuffer); + } - etl::aligned_storage buffer; -}; + //*********************************** + template + mem_type_ptr& operator =(const mem_type_ptr& rhs) + { + ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); -//***************************************************************************** -/// mem_type_ptr -//***************************************************************************** -template -class mem_type_ptr -{ -public: + memcpy(pbuffer, rhs.pbuffer, Size_); - static constexpr size_t Size = Size_; + return *this; + } - //*********************************** - constexpr mem_type_ptr() - : pbuffer(ETL_NULLPTR) - { - } + //*********************************** + ETL_CONSTEXPR size_t size() const + { + return Size; + } - //*********************************** - constexpr mem_type_ptr(char* pbuffer_) - : pbuffer(pbuffer_) - { - } + //*********************************** + ETL_CONSTEXPR char* data() const + { + return pbuffer; + } - //*********************************** - template - constexpr mem_type_ptr(const mem_type_ptr= Other_Size, "Other size is too large"); + private: - memcpy(buffer, other.buffer, Size_); - } + char* pbuffer; + }; +} - //*********************************** - void set(char* pbuffer_) - { - pbuffer = pbuffer_; - } - - //*********************************** - template - constexpr T& get() - { - ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); - - return *reinterpret_cast(pbuffer); - } - - //*********************************** - template - constexpr const T& get() const - { - ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); - - return *reinterpret_cast(pbuffer); - } - - //*********************************** - template - constexpr operator T() const - { - ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); - - return *reinterpret_cast(pbuffer); - } - - //*********************************** - template - mem_type_ptr& operator =(const mem_type_ptr& rhs) - { - ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); - - memcpy(pbuffer, rhs.pbuffer, Size_); - - return *this; - } - - //*********************************** - constexpr size_t size() const - { - return Size; - } - - //*********************************** - constexpr char* data() const - { - return pbuffer; - } - -private: - - char* pbuffer; -}; +#endif 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/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 592ece07..f794c3bb 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -4495,6 +4495,7 @@ + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 6d6ac599..820f36d5 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2534,6 +2534,9 @@ Source Files + + Source Files + From a5f6d9f0330d756ebf57a009c229451c0d3164ff Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 27 May 2021 10:41:20 +0100 Subject: [PATCH 12/81] Further updates to mem_type --- include/etl/experimental/mem_type.h | 12 ++++++++++ test/test_mem_type.cpp | 37 +++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/include/etl/experimental/mem_type.h b/include/etl/experimental/mem_type.h index 60cc43f1..886d5b39 100644 --- a/include/etl/experimental/mem_type.h +++ b/include/etl/experimental/mem_type.h @@ -36,6 +36,7 @@ SOFTWARE. #include "../platform.h" #include "../memory.h" #include "../static_assert.h" +#include "../largest.h" namespace etl { @@ -222,6 +223,17 @@ namespace etl char* pbuffer; }; + +#if ETL_CPP11_SUPPORTED + //***************************************************************************** + /// mem_type_var + //***************************************************************************** + template + class mem_type_var : public etl::mem_type::size, + etl::largest::alignment> + { + }; +#endif } #endif diff --git a/test/test_mem_type.cpp b/test/test_mem_type.cpp index b0d1db30..318a8822 100644 --- a/test/test_mem_type.cpp +++ b/test/test_mem_type.cpp @@ -45,15 +45,19 @@ namespace std::array a; }; + constexpr size_t Size = etl::largest::size; + constexpr size_t Alignment = etl::largest::alignment; + // Test variant types. - using MemType = etl::mem_type::size, - etl::largest::alignment>; + using MemType = etl::mem_type; + using MemTypeVar = etl::mem_type_var; SUITE(test_mem_type) { TEST(test_alignment) { - MemType memType; + MemType memType; + MemTypeVar memTypeVar; CHECK(alignof(char) <= MemType::Alignment); CHECK(alignof(short) <= MemType::Alignment); @@ -66,11 +70,24 @@ namespace CHECK(alignof(char) <= memType.alignment()); CHECK(alignof(short) <= memType.alignment()); CHECK(alignof(Data) <= memType.alignment()); + + CHECK(alignof(char) <= MemTypeVar::Alignment); + CHECK(alignof(short) <= MemTypeVar::Alignment); + CHECK(alignof(Data) <= MemTypeVar::Alignment); + + CHECK(alignof(char) <= memTypeVar.Alignment); + CHECK(alignof(short) <= memTypeVar.Alignment); + CHECK(alignof(Data) <= memTypeVar.Alignment); + + CHECK(alignof(char) <= memTypeVar.alignment()); + CHECK(alignof(short) <= memTypeVar.alignment()); + CHECK(alignof(Data) <= memTypeVar.alignment()); } TEST(test_size) { - MemType memType; + MemTypeVar memType; + MemTypeVar memTypeVar; CHECK(sizeof(char) <= MemType::Size); CHECK(sizeof(short) <= MemType::Size); @@ -83,6 +100,18 @@ namespace CHECK(sizeof(char) <= memType.size()); CHECK(sizeof(short) <= memType.size()); CHECK(sizeof(Data) <= memType.size()); + + CHECK(sizeof(char) <= MemTypeVar::Size); + CHECK(sizeof(short) <= MemTypeVar::Size); + CHECK(sizeof(Data) <= MemTypeVar::Size); + + CHECK(sizeof(char) <= memTypeVar.Size); + CHECK(sizeof(short) <= memTypeVar.Size); + CHECK(sizeof(Data) <= memTypeVar.Size); + + CHECK(sizeof(char) <= memTypeVar.size()); + CHECK(sizeof(short) <= memTypeVar.size()); + CHECK(sizeof(Data) <= memTypeVar.size()); } }; } From abf8d7bb14e6a1922510605fb958caed82acee04 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 27 May 2021 13:23:15 +0100 Subject: [PATCH 13/81] Renamed mem_type to mem_cast --- .../experimental/{mem_type.h => mem_cast.h} | 48 +++--- include/etl/generators/largest_generator.h | 8 + test/test_mem_cast.cpp | 141 ++++++++++++++++++ test/test_mem_type.cpp | 117 --------------- test/vs2019/etl.vcxproj | 4 +- test/vs2019/etl.vcxproj.filters | 4 +- 6 files changed, 180 insertions(+), 142 deletions(-) rename include/etl/experimental/{mem_type.h => mem_cast.h} (85%) create mode 100644 test/test_mem_cast.cpp delete mode 100644 test/test_mem_type.cpp diff --git a/include/etl/experimental/mem_type.h b/include/etl/experimental/mem_cast.h similarity index 85% rename from include/etl/experimental/mem_type.h rename to include/etl/experimental/mem_cast.h index 886d5b39..395899fc 100644 --- a/include/etl/experimental/mem_type.h +++ b/include/etl/experimental/mem_cast.h @@ -28,8 +28,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#ifndef ETL_MEM_TYPE_INCLUDED -#define ETL_MEM_TYPE_INCLUDED +#ifndef ETL_MEM_CAST_INCLUDED +#define ETL_MEM_CAST_INCLUDED #include @@ -41,10 +41,10 @@ SOFTWARE. namespace etl { //***************************************************************************** - /// mem_type + /// mem_cast //***************************************************************************** template - class mem_type + class mem_cast { public: @@ -52,13 +52,13 @@ namespace etl static ETL_CONSTANT size_t Alignment = Alignment_; //*********************************** - ETL_CONSTEXPR mem_type() + ETL_CONSTEXPR mem_cast() { } //*********************************** template - ETL_CONSTEXPR mem_type(const mem_type& other) + ETL_CONSTEXPR mem_cast(const mem_cast& other) { ETL_STATIC_ASSERT(Size >= Other_Size, "Other size is too large"); ETL_STATIC_ASSERT(Alignment >= Other_Alignment, "Other alignment incompatible"); @@ -73,7 +73,7 @@ namespace etl ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); - return *reinterpret_cast(buffer); + return *static_cast(buffer); } //*********************************** @@ -83,7 +83,7 @@ namespace etl ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); - return *reinterpret_cast(buffer); + return *static_cast(buffer); } //*********************************** @@ -93,12 +93,12 @@ namespace etl ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); - return *reinterpret_cast(buffer); + return *static_cast(buffer); } //*********************************** template - ETL_CONSTEXPR mem_type& operator =(const mem_type& rhs) + ETL_CONSTEXPR mem_cast& operator =(const mem_cast& rhs) { ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); ETL_STATIC_ASSERT(Alignment >= Other_Alignment, "RHS alignment incompatible"); @@ -121,41 +121,47 @@ namespace etl } //*********************************** - ETL_CONSTEXPR char* data() const + ETL_CONSTEXPR char* data() + { + return buffer; + } + + //*********************************** + ETL_CONSTEXPR const char* data() const { return buffer; } private: - etl::aligned_storage buffer; + etl::uninitialized_buffer buffer; }; //***************************************************************************** - /// mem_type_ptr + /// mem_cast_ptr //***************************************************************************** template - class mem_type_ptr + class mem_cast_ptr { public: static ETL_CONSTANT size_t Size = Size_; //*********************************** - ETL_CONSTEXPR mem_type_ptr() + ETL_CONSTEXPR mem_cast_ptr() : pbuffer(ETL_NULLPTR) { } //*********************************** - ETL_CONSTEXPR mem_type_ptr(char* pbuffer_) + ETL_CONSTEXPR mem_cast_ptr(char* pbuffer_) : pbuffer(pbuffer_) { } //*********************************** template - ETL_CONSTEXPR mem_type_ptr(const mem_type_ptr& other, char* pbuffer_) + ETL_CONSTEXPR mem_cast_ptr(const mem_cast_ptr& other, char* pbuffer_) : pbuffer(pbuffer_) { ETL_STATIC_ASSERT(Size >= Other_Size, "Other size is too large"); @@ -198,7 +204,7 @@ namespace etl //*********************************** template - mem_type_ptr& operator =(const mem_type_ptr& rhs) + mem_cast_ptr& operator =(const mem_cast_ptr& rhs) { ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); @@ -226,11 +232,11 @@ namespace etl #if ETL_CPP11_SUPPORTED //***************************************************************************** - /// mem_type_var + /// mem_cast_var //***************************************************************************** template - class mem_type_var : public etl::mem_type::size, - etl::largest::alignment> + class mem_cast_types : public etl::mem_cast::size, + etl::largest::alignment> { }; #endif 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/test/test_mem_cast.cpp b/test/test_mem_cast.cpp new file mode 100644 index 00000000..56c95841 --- /dev/null +++ b/test/test_mem_cast.cpp @@ -0,0 +1,141 @@ +/****************************************************************************** +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_cast.h" +#include "etl/largest.h" + +#include +#include +#include +#include + +namespace +{ + struct Data + { + char c; + double d; + std::array a; + }; + + constexpr size_t Size = etl::largest::size; + constexpr size_t Alignment = etl::largest::alignment; + + // Test variant types. + using MemCast = etl::mem_cast; + using MemCastTypes = etl::mem_cast_types; + + char c; + double d; + Data data; + + SUITE(test_mem_cast) + { + //************************************************************************* + TEST(test_size) + { + MemCast memCast; + MemCastTypes memCastTypes; + + CHECK(sizeof(char) <= MemCast::Size); + CHECK(sizeof(short) <= MemCast::Size); + CHECK(sizeof(Data) <= MemCast::Size); + + CHECK(sizeof(char) <= memCast.Size); + CHECK(sizeof(short) <= memCast.Size); + CHECK(sizeof(Data) <= memCast.Size); + + CHECK(sizeof(char) <= memCast.size()); + CHECK(sizeof(short) <= memCast.size()); + CHECK(sizeof(Data) <= memCast.size()); + + CHECK(sizeof(char) <= MemCastTypes::Size); + CHECK(sizeof(short) <= MemCastTypes::Size); + CHECK(sizeof(Data) <= MemCastTypes::Size); + + CHECK(sizeof(char) <= memCastTypes.Size); + CHECK(sizeof(short) <= memCastTypes.Size); + CHECK(sizeof(Data) <= memCastTypes.Size); + + CHECK(sizeof(char) <= memCastTypes.size()); + CHECK(sizeof(short) <= memCastTypes.size()); + CHECK(sizeof(Data) <= memCastTypes.size()); + } + + //************************************************************************* + TEST(test_alignment) + { + MemCast memCast; + MemCastTypes memCastTypes; + + CHECK(alignof(char) <= MemCast::Alignment); + CHECK(alignof(short) <= MemCast::Alignment); + CHECK(alignof(Data) <= MemCast::Alignment); + + CHECK(alignof(char) <= memCast.Alignment); + CHECK(alignof(short) <= memCast.Alignment); + CHECK(alignof(Data) <= memCast.Alignment); + + CHECK(alignof(char) <= memCast.alignment()); + CHECK(alignof(short) <= memCast.alignment()); + CHECK(alignof(Data) <= memCast.alignment()); + + CHECK(alignof(char) <= MemCastTypes::Alignment); + CHECK(alignof(short) <= MemCastTypes::Alignment); + CHECK(alignof(Data) <= MemCastTypes::Alignment); + + CHECK(alignof(char) <= memCastTypes.Alignment); + CHECK(alignof(short) <= memCastTypes.Alignment); + CHECK(alignof(Data) <= memCastTypes.Alignment); + + CHECK(alignof(char) <= memCastTypes.alignment()); + CHECK(alignof(short) <= memCastTypes.alignment()); + CHECK(alignof(Data) <= memCastTypes.alignment()); + } + + //************************************************************************* + TEST(test_mem_cast_to_type) + { + MemCast memCast; + + char* pbuffer = memCast.data(); + *pbuffer = 123; + CHECK_EQUAL(123, memCast.get()); + + *reinterpret_cast(pbuffer) = 1.23; + CHECK_EQUAL(1.23, memCast.get()); + + *reinterpret_cast(pbuffer) = { 123, 1.23, { 1, 2, 3 } }; + CHECK(123 == memCast.get().c); + CHECK(1.23 == memCast.get().d); + CHECK((std::array { 1, 2, 3 }) == memCast.get().a); + } + }; +} diff --git a/test/test_mem_type.cpp b/test/test_mem_type.cpp deleted file mode 100644 index 318a8822..00000000 --- a/test/test_mem_type.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/****************************************************************************** -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; - }; - - constexpr size_t Size = etl::largest::size; - constexpr size_t Alignment = etl::largest::alignment; - - // Test variant types. - using MemType = etl::mem_type; - using MemTypeVar = etl::mem_type_var; - - SUITE(test_mem_type) - { - TEST(test_alignment) - { - MemType memType; - MemTypeVar memTypeVar; - - 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()); - - CHECK(alignof(char) <= MemTypeVar::Alignment); - CHECK(alignof(short) <= MemTypeVar::Alignment); - CHECK(alignof(Data) <= MemTypeVar::Alignment); - - CHECK(alignof(char) <= memTypeVar.Alignment); - CHECK(alignof(short) <= memTypeVar.Alignment); - CHECK(alignof(Data) <= memTypeVar.Alignment); - - CHECK(alignof(char) <= memTypeVar.alignment()); - CHECK(alignof(short) <= memTypeVar.alignment()); - CHECK(alignof(Data) <= memTypeVar.alignment()); - } - - TEST(test_size) - { - MemTypeVar memType; - MemTypeVar memTypeVar; - - 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()); - - CHECK(sizeof(char) <= MemTypeVar::Size); - CHECK(sizeof(short) <= MemTypeVar::Size); - CHECK(sizeof(Data) <= MemTypeVar::Size); - - CHECK(sizeof(char) <= memTypeVar.Size); - CHECK(sizeof(short) <= memTypeVar.Size); - CHECK(sizeof(Data) <= memTypeVar.Size); - - CHECK(sizeof(char) <= memTypeVar.size()); - CHECK(sizeof(short) <= memTypeVar.size()); - CHECK(sizeof(Data) <= memTypeVar.size()); - } - }; -} diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index f794c3bb..81b374c5 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1309,7 +1309,7 @@ - + @@ -4495,7 +4495,7 @@ - + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 820f36d5..3c1d4a64 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1110,7 +1110,7 @@ ETL\Private - + ETL\Experimental @@ -2534,7 +2534,7 @@ Source Files - + Source Files From 8af219c0b38ee5f2cf24c73ec4698dada12b4ac1 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 30 May 2021 12:08:03 +0100 Subject: [PATCH 14/81] Updates to mem_cast --- include/etl/experimental/mem_cast.h | 161 ++++++++++++++++++------ include/etl/file_error_numbers.h | 1 + test/test_mem_cast.cpp | 80 +++++++++++- test/test_mem_cast_ptr.cpp | 189 ++++++++++++++++++++++++++++ test/vs2019/etl.vcxproj | 1 + test/vs2019/etl.vcxproj.filters | 3 + 6 files changed, 394 insertions(+), 41 deletions(-) create mode 100644 test/test_mem_cast_ptr.cpp diff --git a/include/etl/experimental/mem_cast.h b/include/etl/experimental/mem_cast.h index 395899fc..539beeaf 100644 --- a/include/etl/experimental/mem_cast.h +++ b/include/etl/experimental/mem_cast.h @@ -32,14 +32,59 @@ SOFTWARE. #define ETL_MEM_CAST_INCLUDED #include +#include #include "../platform.h" #include "../memory.h" #include "../static_assert.h" #include "../largest.h" +#include "../utility.h" +#include "../placement_new.h" +#include "../exception.h" +#include "../error_handler.h" +#include "../file_error_numbers.h" namespace etl { + //*************************************************************************** + /// The base class for array_wrapper exceptions. + //*************************************************************************** + class mem_cast_exception : public exception + { + public: + + mem_cast_exception(string_type reason_, string_type file_name_, numeric_type line_number_) + : exception(reason_, file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// The exception thrown when the buffer pointer alignment is not compatible. + //*************************************************************************** + class mem_cast_alignment_exception : public mem_cast_exception + { + public: + + mem_cast_alignment_exception(string_type file_name_, numeric_type line_number_) + : mem_cast_exception(ETL_ERROR_TEXT("mem_cast:alignment", ETL_MEM_CAST_FILE_ID"A"), file_name_, line_number_) + { + } + }; + + //*************************************************************************** + /// The exception thrown when the pointer is null. + //*************************************************************************** + class mem_cast_nullptr_exception : public mem_cast_exception + { + public: + + mem_cast_nullptr_exception(string_type file_name_, numeric_type line_number_) + : mem_cast_exception(ETL_ERROR_TEXT("mem_cast:null pointer", ETL_MEM_CAST_FILE_ID"B"), file_name_, line_number_) + { + } + }; + //***************************************************************************** /// mem_cast //***************************************************************************** @@ -51,14 +96,20 @@ namespace etl static ETL_CONSTANT size_t Size = Size_; static ETL_CONSTANT size_t Alignment = Alignment_; + //*********************************** + /// Default constructor //*********************************** ETL_CONSTEXPR mem_cast() + : buffer() { } + //*********************************** + /// Copy constructor //*********************************** template ETL_CONSTEXPR mem_cast(const mem_cast& other) + : type_size(other.type_size) { ETL_STATIC_ASSERT(Size >= Other_Size, "Other size is too large"); ETL_STATIC_ASSERT(Alignment >= Other_Alignment, "Other alignment incompatible"); @@ -66,9 +117,22 @@ namespace etl memcpy(buffer, other.buffer, Size_); } +#if ETL_CPP11_SUPPORTED + //*********************************** + /// Emplace from parameters + //*********************************** + template + void emplace(TArgs... args) + { + ::new (static_cast(buffer)) T(etl::forward(args)...); + } +#endif + + //*********************************** + /// Get a reference to T //*********************************** template - ETL_CONSTEXPR T& get() + ETL_CONSTEXPR T& ref() { ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); @@ -76,26 +140,20 @@ namespace etl return *static_cast(buffer); } + //*********************************** + /// Get a const reference to T //*********************************** template - ETL_CONSTEXPR const T& get() const + ETL_CONSTEXPR const T& ref() const { ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); - return *static_cast(buffer); + return *static_cast(buffer); } //*********************************** - template - ETL_CONSTEXPR operator T() const - { - ETL_STATIC_ASSERT(sizeof(T) <= Size, "Size of T is too large"); - ETL_STATIC_ASSERT(Alignment >= etl::alignment_of::value, "Alignment of T is incompatible"); - - return *static_cast(buffer); - } - + /// Assignment operator //*********************************** template ETL_CONSTEXPR mem_cast& operator =(const mem_cast& rhs) @@ -108,24 +166,32 @@ namespace etl return *this; } + //*********************************** + /// Get the size of the buffer //*********************************** ETL_CONSTEXPR size_t size() const { return Size; } + //*********************************** + /// Get the alignment of the buffer //*********************************** ETL_CONSTEXPR size_t alignment() const { return Alignment; } + //*********************************** + /// Get a pointer to the internal buffer //*********************************** ETL_CONSTEXPR char* data() { return buffer; } + //*********************************** + /// Get a const pointer to the internal buffer //*********************************** ETL_CONSTEXPR const char* data() const { @@ -134,6 +200,7 @@ namespace etl private: + /// The internal buffer etl::uninitialized_buffer buffer; }; @@ -147,65 +214,78 @@ namespace etl static ETL_CONSTANT size_t Size = Size_; + //*********************************** + /// Default constructor //*********************************** ETL_CONSTEXPR mem_cast_ptr() : pbuffer(ETL_NULLPTR) { } + //*********************************** + /// Construct with pointer to buffer //*********************************** ETL_CONSTEXPR mem_cast_ptr(char* pbuffer_) : pbuffer(pbuffer_) { } + //*********************************** + /// Copy construct with pointer to buffer //*********************************** template ETL_CONSTEXPR mem_cast_ptr(const mem_cast_ptr& other, char* pbuffer_) : pbuffer(pbuffer_) { + ETL_ASSERT((pbuffer != ETL_NULLPTR), ETL_ERROR(etl::mem_cast_nullptr_exception)); ETL_STATIC_ASSERT(Size >= Other_Size, "Other size is too large"); - memcpy(buffer, other.buffer, Size_); + memcpy(pbuffer, other.pbuffer, Size_); } +#if ETL_CPP11_SUPPORTED + //*********************************** + /// Emplace from parameters + //*********************************** + template + void emplace(TArgs... args) + { + ETL_ASSERT((pbuffer != ETL_NULLPTR), ETL_ERROR(etl::mem_cast_nullptr_exception)); + ETL_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, ETL_ERROR(etl::mem_cast_alignment_exception)); + + ::new (pbuffer) T(etl::forward(args)...); + } +#endif + //*********************************** - void set(char* pbuffer_) - { - pbuffer = pbuffer_; - } - + /// Get a reference to T //*********************************** template - ETL_CONSTEXPR T& get() + ETL_CONSTEXPR T& ref() { - ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); + ETL_ASSERT((pbuffer != ETL_NULLPTR), ETL_ERROR(etl::mem_cast_nullptr_exception)); + ETL_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, ETL_ERROR(etl::mem_cast_alignment_exception)); return *reinterpret_cast(pbuffer); } //*********************************** - template - ETL_CONSTEXPR const T& get() const - { - ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); - - return *reinterpret_cast(pbuffer); - } - + /// Get a const reference to T //*********************************** template - ETL_CONSTEXPR operator T() const + ETL_CONSTEXPR const T& ref() const { - ETL_STATIC_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, "Alignment of T is incompatible"); + ETL_ASSERT((pbuffer != ETL_NULLPTR), ETL_ERROR(etl::mem_cast_nullptr_exception)); + ETL_ASSERT((uintptr_t(pbuffer) % etl::alignment_of::value) == 0, ETL_ERROR(etl::mem_cast_alignment_exception)); - return *reinterpret_cast(pbuffer); + return *reinterpret_cast(pbuffer); } //*********************************** template mem_cast_ptr& operator =(const mem_cast_ptr& rhs) { + ETL_ASSERT((pbuffer != ETL_NULLPTR), ETL_ERROR(etl::mem_cast_nullptr_exception)); ETL_STATIC_ASSERT(Size >= Other_Size, "RHS size is too large"); memcpy(pbuffer, rhs.pbuffer, Size_); @@ -213,12 +293,24 @@ namespace etl return *this; } + //*********************************** + /// Assignment operator //*********************************** ETL_CONSTEXPR size_t size() const { return Size; } + //*********************************** + /// Get a pointer to the internal buffer + //*********************************** + void data(char* pbuffer_) + { + pbuffer = pbuffer_; + } + + //*********************************** + /// Get a const pointer to the internal buffer //*********************************** ETL_CONSTEXPR char* data() const { @@ -227,18 +319,17 @@ namespace etl private: + /// Pointer to the buffer char* pbuffer; }; #if ETL_CPP11_SUPPORTED //***************************************************************************** /// mem_cast_var + /// mem_cast from a variadic list of types //***************************************************************************** template - class mem_cast_types : public etl::mem_cast::size, - etl::largest::alignment> - { - }; + using mem_cast_types = etl::mem_cast::size, etl::largest::alignment>; #endif } diff --git a/include/etl/file_error_numbers.h b/include/etl/file_error_numbers.h index a72f34de..86a31fbb 100644 --- a/include/etl/file_error_numbers.h +++ b/include/etl/file_error_numbers.h @@ -92,5 +92,6 @@ SOFTWARE. #define ETL_QUEUE_SPSC_LOCKABLE_FILE_ID "59" #define ETL_MESSAGE_ROUTER_REGISTRY_FILE_ID "60" #define ETL_ARRAY_WRAPPER_FILE_ID "61" +#define ETL_MEM_CAST_FILE_ID "62" #endif diff --git a/test/test_mem_cast.cpp b/test/test_mem_cast.cpp index 56c95841..11d10af4 100644 --- a/test/test_mem_cast.cpp +++ b/test/test_mem_cast.cpp @@ -40,6 +40,20 @@ namespace { struct Data { + Data() + : c(0) + , d(0) + , a() + { + } + + Data(char c_, double d_, std::array a_) + : c(c_) + , d(d_) + , a(a_) + { + } + char c; double d; std::array a; @@ -120,22 +134,76 @@ namespace CHECK(alignof(Data) <= memCastTypes.alignment()); } + //************************************************************************* + TEST(test_mem_cast_emplace_type) + { + MemCast memCast; + + memCast.emplace(123); + CHECK_EQUAL(123, memCast.ref()); + + memCast.emplace(1.23); + CHECK_EQUAL(1.23, memCast.ref()); + + memCast.emplace(123, 1.23, std::array{ 1, 2, 3 }); + CHECK(123 == memCast.ref().c); + CHECK(1.23 == memCast.ref().d); + CHECK((std::array { 1, 2, 3 }) == memCast.ref().a); + } + //************************************************************************* TEST(test_mem_cast_to_type) { - MemCast memCast; + MemCast memCast; char* pbuffer = memCast.data(); *pbuffer = 123; - CHECK_EQUAL(123, memCast.get()); + CHECK_EQUAL(123, memCast.ref()); *reinterpret_cast(pbuffer) = 1.23; - CHECK_EQUAL(1.23, memCast.get()); + CHECK_EQUAL(1.23, memCast.ref()); *reinterpret_cast(pbuffer) = { 123, 1.23, { 1, 2, 3 } }; - CHECK(123 == memCast.get().c); - CHECK(1.23 == memCast.get().d); - CHECK((std::array { 1, 2, 3 }) == memCast.get().a); + CHECK(123 == memCast.ref().c); + CHECK(1.23 == memCast.ref().d); + CHECK((std::array { 1, 2, 3 }) == memCast.ref().a); + } + + //************************************************************************* + TEST(test_const_mem_cast_to_type) + { + MemCast memCast; + const MemCast& memCastRef = memCast; + + char* pbuffer = memCast.data(); + *pbuffer = 123; + CHECK_EQUAL(123, memCastRef.ref()); + + *reinterpret_cast(pbuffer) = 1.23; + CHECK_EQUAL(1.23, memCastRef.ref()); + + *reinterpret_cast(pbuffer) = { 123, 1.23, { 1, 2, 3 } }; + CHECK(123 == memCastRef.ref().c); + CHECK(1.23 == memCastRef.ref().d); + CHECK((std::array { 1, 2, 3 }) == memCastRef.ref().a); + } + + //************************************************************************* + TEST(test_mem_cast_types_to_type) + { + MemCastTypes memCastTypes; + + char* pbuffer = memCastTypes.data(); + *pbuffer = 123; + CHECK_EQUAL(123, memCastTypes.ref()); + + *reinterpret_cast(pbuffer) = 1.23; + CHECK_EQUAL(1.23, memCastTypes.ref()); + + *reinterpret_cast(pbuffer) = { 123, 1.23, { 1, 2, 3 } }; + CHECK(123 == memCastTypes.ref().c); + CHECK(1.23 == memCastTypes.ref().d); + CHECK((std::array { 1, 2, 3 }) == memCastTypes.ref().a); } }; } diff --git a/test/test_mem_cast_ptr.cpp b/test/test_mem_cast_ptr.cpp new file mode 100644 index 00000000..08f8cebc --- /dev/null +++ b/test/test_mem_cast_ptr.cpp @@ -0,0 +1,189 @@ +/****************************************************************************** +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_cast.h" +#include "etl/largest.h" + +#include +#include +#include +#include + +namespace +{ + struct Data + { + Data() + : c(0) + , d(0) + , a() + { + } + + Data(char c_, double d_, std::array a_) + : c(c_) + , d(d_) + , a(a_) + { + } + + char c; + double d; + std::array a; + }; + + constexpr size_t Size = etl::largest::size; + constexpr size_t Alignment = etl::largest::alignment; + + // Test variant types. + using MemCast = etl::mem_cast_ptr; + + char c; + double d; + Data data; + + std::aligned_storage_t buffer; + + SUITE(test_mem_cast) + { + //************************************************************************* + TEST(test_size) + { + MemCast memCast; + + CHECK(sizeof(char) <= MemCast::Size); + CHECK(sizeof(short) <= MemCast::Size); + CHECK(sizeof(Data) <= MemCast::Size); + + CHECK(sizeof(char) <= memCast.Size); + CHECK(sizeof(short) <= memCast.Size); + CHECK(sizeof(Data) <= memCast.Size); + + CHECK(sizeof(char) <= memCast.size()); + CHECK(sizeof(short) <= memCast.size()); + CHECK(sizeof(Data) <= memCast.size()); + } + + //************************************************************************* + TEST(test_mem_cast_emplace_type) + { + char* pbuffer = reinterpret_cast(&buffer); + + MemCast memCast(pbuffer); + + memCast.emplace(123); + CHECK_EQUAL(123, memCast.ref()); + + memCast.emplace(1.23); + CHECK_EQUAL(1.23, memCast.ref()); + + memCast.emplace(123, 1.23, std::array{ 1, 2, 3 }); + CHECK(123 == memCast.ref().c); + CHECK(1.23 == memCast.ref().d); + CHECK((std::array { 1, 2, 3 }) == memCast.ref().a); + } + + //************************************************************************* + TEST(test_mem_cast_to_type) + { + char* pbuffer = reinterpret_cast(&buffer); + + MemCast memCast(pbuffer); + + pbuffer = memCast.data(); + *pbuffer = 123; + CHECK_EQUAL(123, memCast.ref()); + + *reinterpret_cast(pbuffer) = 1.23; + CHECK_EQUAL(1.23, memCast.ref()); + + *reinterpret_cast(pbuffer) = { 123, 1.23, { 1, 2, 3 } }; + CHECK(123 == memCast.ref().c); + CHECK(1.23 == memCast.ref().d); + CHECK((std::array { 1, 2, 3 }) == memCast.ref().a); + } + + //************************************************************************* + TEST(test_const_mem_cast_to_type) + { + char* pbuffer = reinterpret_cast(&buffer); + + const MemCast memCast(pbuffer); + + pbuffer = memCast.data(); + *pbuffer = 123; + CHECK_EQUAL(123, memCast.ref()); + + *reinterpret_cast(pbuffer) = 1.23; + CHECK_EQUAL(1.23, memCast.ref()); + + *reinterpret_cast(pbuffer) = { 123, 1.23, { 1, 2, 3 } }; + CHECK(123 == memCast.ref().c); + CHECK(1.23 == memCast.ref().d); + CHECK((std::array { 1, 2, 3 }) == memCast.ref().a); + } + + //************************************************************************* + TEST(test_mem_cast_to_type_no_buffer) + { + MemCast memCast; + + CHECK_THROW(memCast.ref(), etl::mem_cast_nullptr_exception); + } + + //************************************************************************* + TEST(test_const_mem_cast_to_type_no_buffer) + { + const MemCast memCast; + + CHECK_THROW(memCast.ref(), etl::mem_cast_nullptr_exception); + } + + //************************************************************************* + TEST(test_mem_cast_to_type_misaligned_buffer) + { + double d; + char* pbuffer = reinterpret_cast(&d); + MemCast memCast(pbuffer + 1); + + CHECK_THROW(memCast.ref(), etl::mem_cast_alignment_exception); + } + + //************************************************************************* + TEST(test_const_mem_cast_to_type_misaligned_buffer) + { + double d; + char* pbuffer = reinterpret_cast(&d); + const MemCast memCast(pbuffer + 1); + + CHECK_THROW(memCast.ref(), etl::mem_cast_alignment_exception); + } + }; +} diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 81b374c5..37c264bc 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -4496,6 +4496,7 @@ + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 3c1d4a64..b66174cf 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2537,6 +2537,9 @@ Source Files + + Source Files + From b19471dc8a1802da371fb9ff984e2d0e2bb552f1 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 31 May 2021 10:00:01 +0100 Subject: [PATCH 15/81] Updates to mem_cast --- include/etl/{experimental => }/mem_cast.h | 24 +++++++++---------- test/sanity-check/c++03/CMakeLists.txt | 1 + test/sanity-check/c++11/CMakeLists.txt | 1 + test/sanity-check/c++14/CMakeLists.txt | 1 + test/sanity-check/c++17/CMakeLists.txt | 1 + test/sanity-check/mem_cast.h.t.cpp | 29 +++++++++++++++++++++++ test/test_mem_cast.cpp | 2 +- test/test_mem_cast_ptr.cpp | 2 +- test/vs2019/etl.vcxproj | 8 +++++++ test/vs2019/etl.vcxproj.filters | 5 +++- 10 files changed, 59 insertions(+), 15 deletions(-) rename include/etl/{experimental => }/mem_cast.h (96%) create mode 100644 test/sanity-check/mem_cast.h.t.cpp diff --git a/include/etl/experimental/mem_cast.h b/include/etl/mem_cast.h similarity index 96% rename from include/etl/experimental/mem_cast.h rename to include/etl/mem_cast.h index 539beeaf..cc73cd66 100644 --- a/include/etl/experimental/mem_cast.h +++ b/include/etl/mem_cast.h @@ -34,22 +34,22 @@ SOFTWARE. #include #include -#include "../platform.h" -#include "../memory.h" -#include "../static_assert.h" -#include "../largest.h" -#include "../utility.h" -#include "../placement_new.h" -#include "../exception.h" -#include "../error_handler.h" -#include "../file_error_numbers.h" +#include "platform.h" +#include "memory.h" +#include "static_assert.h" +#include "largest.h" +#include "utility.h" +#include "placement_new.h" +#include "exception.h" +#include "error_handler.h" +#include "file_error_numbers.h" namespace etl { //*************************************************************************** /// The base class for array_wrapper exceptions. //*************************************************************************** - class mem_cast_exception : public exception + class mem_cast_exception : public etl::exception { public: @@ -62,7 +62,7 @@ namespace etl //*************************************************************************** /// The exception thrown when the buffer pointer alignment is not compatible. //*************************************************************************** - class mem_cast_alignment_exception : public mem_cast_exception + class mem_cast_alignment_exception : public etl::mem_cast_exception { public: @@ -75,7 +75,7 @@ namespace etl //*************************************************************************** /// The exception thrown when the pointer is null. //*************************************************************************** - class mem_cast_nullptr_exception : public mem_cast_exception + class mem_cast_nullptr_exception : public etl::mem_cast_exception { public: diff --git a/test/sanity-check/c++03/CMakeLists.txt b/test/sanity-check/c++03/CMakeLists.txt index 9c029fda..dea14a49 100644 --- a/test/sanity-check/c++03/CMakeLists.txt +++ b/test/sanity-check/c++03/CMakeLists.txt @@ -151,6 +151,7 @@ target_sources(t98 PRIVATE etl_profile.h ../map.h.t.cpp ../math_constants.h.t.cpp ../mean.h.t.cpp + ../mem_cast.h.t.cpp ../memory.h.t.cpp ../memory_model.h.t.cpp ../message.h.t.cpp diff --git a/test/sanity-check/c++11/CMakeLists.txt b/test/sanity-check/c++11/CMakeLists.txt index c34ccaea..09193372 100644 --- a/test/sanity-check/c++11/CMakeLists.txt +++ b/test/sanity-check/c++11/CMakeLists.txt @@ -151,6 +151,7 @@ target_sources(t11 PRIVATE etl_profile.h ../map.h.t.cpp ../math_constants.h.t.cpp ../mean.h.t.cpp + ../mem_cast.h.t.cpp ../memory.h.t.cpp ../memory_model.h.t.cpp ../message.h.t.cpp diff --git a/test/sanity-check/c++14/CMakeLists.txt b/test/sanity-check/c++14/CMakeLists.txt index 02fc1823..e514d386 100644 --- a/test/sanity-check/c++14/CMakeLists.txt +++ b/test/sanity-check/c++14/CMakeLists.txt @@ -151,6 +151,7 @@ target_sources(t14 PRIVATE etl_profile.h ../map.h.t.cpp ../math_constants.h.t.cpp ../mean.h.t.cpp + ../mem_cast.h.t.cpp ../memory.h.t.cpp ../memory_model.h.t.cpp ../message.h.t.cpp diff --git a/test/sanity-check/c++17/CMakeLists.txt b/test/sanity-check/c++17/CMakeLists.txt index 91193e63..dd6b754a 100644 --- a/test/sanity-check/c++17/CMakeLists.txt +++ b/test/sanity-check/c++17/CMakeLists.txt @@ -151,6 +151,7 @@ target_sources(t17 PRIVATE etl_profile.h ../map.h.t.cpp ../math_constants.h.t.cpp ../mean.h.t.cpp + ../mem_cast.h.t.cpp ../memory.h.t.cpp ../memory_model.h.t.cpp ../message.h.t.cpp diff --git a/test/sanity-check/mem_cast.h.t.cpp b/test/sanity-check/mem_cast.h.t.cpp new file mode 100644 index 00000000..d62b8b27 --- /dev/null +++ b/test/sanity-check/mem_cast.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_mem_cast.cpp b/test/test_mem_cast.cpp index 11d10af4..cb9105ee 100644 --- a/test/test_mem_cast.cpp +++ b/test/test_mem_cast.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "unit_test_framework.h" -#include "etl/experimental/mem_cast.h" +#include "etl/mem_cast.h" #include "etl/largest.h" #include diff --git a/test/test_mem_cast_ptr.cpp b/test/test_mem_cast_ptr.cpp index 08f8cebc..4bbebfac 100644 --- a/test/test_mem_cast_ptr.cpp +++ b/test/test_mem_cast_ptr.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "unit_test_framework.h" -#include "etl/experimental/mem_cast.h" +#include "etl/mem_cast.h" #include "etl/largest.h" #include diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 37c264bc..430c64ab 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -3231,6 +3231,14 @@ true true + + true + true + true + true + true + true + true true diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index b66174cf..2a763f13 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1111,7 +1111,7 @@ ETL\Private - ETL\Experimental + ETL\Utilities @@ -2540,6 +2540,9 @@ Source Files + + Source Files\Sanity Checks + From 32d80e91e75a68ef0c5b1ac705c3eaa6c4956fd9 Mon Sep 17 00:00:00 2001 From: T <3098462+part22@users.noreply.github.com> Date: Fri, 18 Jun 2021 07:52:34 -0400 Subject: [PATCH 16/81] Add support to cross-compile with clang (#389) Clang does not define __WCHAR_MIN__ however, limits.h relies on it. By using the __AVR__ macro we can define __WCHAR_MIN__ only when cross-compiling with clang. --- include/etl/limits.h | 5 +++++ include/etl/profiles/determine_compiler.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/include/etl/limits.h b/include/etl/limits.h index 9fa86fff..47b10a22 100644 --- a/include/etl/limits.h +++ b/include/etl/limits.h @@ -332,6 +332,11 @@ namespace etl static ETL_CONSTANT bool is_signed = etl::is_signed::value; static ETL_CONSTANT bool is_modulo = etl::is_unsigned::value; +#if defined(ETL_COMPILER_CLANG) && defined(CROSS_COMPILING_TO_AVR) +#undef WCHAR_MIN +#define WCHAR_MIN (-WCHAR_MAX - 1) +#endif + static ETL_CONSTEXPR wchar_t min() { return WCHAR_MIN; } static ETL_CONSTEXPR wchar_t max() { return WCHAR_MAX; } static ETL_CONSTEXPR wchar_t lowest() { return WCHAR_MIN; } diff --git a/include/etl/profiles/determine_compiler.h b/include/etl/profiles/determine_compiler.h index b1078588..60f33c61 100644 --- a/include/etl/profiles/determine_compiler.h +++ b/include/etl/profiles/determine_compiler.h @@ -75,6 +75,9 @@ SOFTWARE. #if defined(__clang__) || defined(__llvm__) #define ETL_COMPILER_CLANG #define ETL_COMPILER_TYPE_DETECTED + #if __AVR__ == 1 + #define CROSS_COMPILING_TO_AVR + #endif #endif #endif From 5dd5bc3aacb814772e93ea7f7637422eda464b56 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 18 Jun 2021 14:15:44 +0100 Subject: [PATCH 17/81] Define missing macro when cross compiling with clang --- include/etl/limits.h | 5 ++--- include/etl/profiles/determine_compiler.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/etl/limits.h b/include/etl/limits.h index 47b10a22..52023d2a 100644 --- a/include/etl/limits.h +++ b/include/etl/limits.h @@ -332,9 +332,8 @@ namespace etl static ETL_CONSTANT bool is_signed = etl::is_signed::value; static ETL_CONSTANT bool is_modulo = etl::is_unsigned::value; -#if defined(ETL_COMPILER_CLANG) && defined(CROSS_COMPILING_TO_AVR) -#undef WCHAR_MIN -#define WCHAR_MIN (-WCHAR_MAX - 1) +#if defined(ETL_COMPILER_CLANG) && defined(ETL_CROSS_COMPILING_TO_AVR) && !defined(WCHAR_MIN) + #define WCHAR_MIN (-WCHAR_MAX - 1) #endif static ETL_CONSTEXPR wchar_t min() { return WCHAR_MIN; } diff --git a/include/etl/profiles/determine_compiler.h b/include/etl/profiles/determine_compiler.h index 60f33c61..1c2f699d 100644 --- a/include/etl/profiles/determine_compiler.h +++ b/include/etl/profiles/determine_compiler.h @@ -76,7 +76,7 @@ SOFTWARE. #define ETL_COMPILER_CLANG #define ETL_COMPILER_TYPE_DETECTED #if __AVR__ == 1 - #define CROSS_COMPILING_TO_AVR + #define ETL_CROSS_COMPILING_TO_AVR #endif #endif #endif From f0f0500c94267fc3f5975f73481bb7fc6490ffb9 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 18 Jun 2021 14:38:12 +0100 Subject: [PATCH 18/81] Define missing macro when cross compiling with clang --- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- meson.build | 2 +- support/Release notes.txt | 4 ++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 1939f2b5..4fff58f9 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 20 #define ETL_VERSION_MINOR 11 -#define ETL_VERSION_PATCH 2 +#define ETL_VERSION_PATCH 3 #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 200b4de9..fbb62211 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.11.2", + "version": "20.11.3", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 0780c918..735cec9a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.11.2 +version=20.11.3 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index 8355fa88..cdd8ac7d 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.11.2' + version: '20.11.3' ) ###################### diff --git a/support/Release notes.txt b/support/Release notes.txt index 6cab183b..3100f572 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +20.11.3 +Define missing macro when cross compiling with clang for AVR + =============================================================================== 20.11.2 etl::basic_string::copy is now const and does not affect truncation flags. From 622eaa443451bf3c47653a22c5615d9647e7cd8a Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 22 Jun 2021 11:00:42 +0100 Subject: [PATCH 19/81] Fixed copy and move assignment bug --- include/etl/circular_buffer.h | 11 +++++-- test/test_circular_buffer.cpp | 31 +++++++++++++++++-- test/test_circular_buffer_external_buffer.cpp | 31 +++++++++++++++++-- 3 files changed, 67 insertions(+), 6 deletions(-) diff --git a/include/etl/circular_buffer.h b/include/etl/circular_buffer.h index d2470d83..ebd3a634 100644 --- a/include/etl/circular_buffer.h +++ b/include/etl/circular_buffer.h @@ -1088,6 +1088,7 @@ namespace etl { if (this != &other) { + this->clear(); this->push(other.begin(), other.end()); } @@ -1119,8 +1120,10 @@ namespace etl { if (this != &other) { + this->clear(); + for (typename etl::icircular_buffer::const_iterator itr = other.begin(); itr != other.end(); ++itr) - { + { this->push(etl::move(*itr)); } } @@ -1203,8 +1206,10 @@ namespace etl //************************************************************************* circular_buffer_ext& operator =(const circular_buffer_ext& other) { + if (this != &other) { + this->clear(); this->push(other.begin(), other.end()); } @@ -1236,8 +1241,10 @@ namespace etl { if (this != &other) { + this->clear(); + for (typename etl::icircular_buffer::iterator itr = other.begin(); itr != other.end(); ++itr) - { + { this->push(etl::move(*itr)); } } diff --git a/test/test_circular_buffer.cpp b/test/test_circular_buffer.cpp index 30ee06ff..536dfe78 100644 --- a/test/test_circular_buffer.cpp +++ b/test/test_circular_buffer.cpp @@ -746,13 +746,14 @@ namespace //************************************************************************* TEST(test_assignment) { - Compare input1{ Ndc("0"), Ndc("1"), Ndc("2"), Ndc("3"), Ndc("4"), Ndc("5"), Ndc("6"), Ndc("7"), Ndc("8"), Ndc("9") }; - Compare input2{ Ndc("9"), Ndc("8"), Ndc("7"), Ndc("6"), Ndc("5"), Ndc("4"), Ndc("3"), Ndc("2"), Ndc("1"), Ndc("0") }; + Compare input1{ Ndc("0"), Ndc("1"), Ndc("2"), Ndc("3"), Ndc("4"), Ndc("5"), Ndc("6"), Ndc("7"), Ndc("8") }; + Compare input2{ Ndc("8"), Ndc("7"), Ndc("6"), Ndc("5"), Ndc("4"), Ndc("3"), Ndc("2"), Ndc("1"), Ndc("0") }; Data data1; data1.push(input1.begin(), input1.end()); // Copy construct from data1 Data data2; + data2.push(Ndc("0")); data2 = data1; @@ -768,6 +769,32 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST(test_move_assignment) + { + Compare input1{ Ndc("0"), Ndc("1"), Ndc("2"), Ndc("3"), Ndc("4"), Ndc("5"), Ndc("6"), Ndc("7"), Ndc("8") }; + Compare input2{ Ndc("8"), Ndc("7"), Ndc("6"), Ndc("5"), Ndc("4"), Ndc("3"), Ndc("2"), Ndc("1"), Ndc("0") }; + Data data1; + data1.push(input1.begin(), input1.end()); + + // Copy construct from data1 + Data data2; + data2.push(Ndc("0")); + + data2 = etl::move(data1); + + // Now change data1 + data1.clear(); + data1.push(input2.begin(), input2.end()); + + CHECK(data2.begin() != data2.end()); + CHECK(data2.cbegin() != data2.cend()); + CHECK_EQUAL(input1.size(), data2.size()); + + bool isEqual = std::equal(input1.begin(), input1.end(), data2.begin()); + CHECK(isEqual); + } + //************************************************************************* TEST(test_swap_iterator) { diff --git a/test/test_circular_buffer_external_buffer.cpp b/test/test_circular_buffer_external_buffer.cpp index eb9cc43e..44fb267c 100644 --- a/test/test_circular_buffer_external_buffer.cpp +++ b/test/test_circular_buffer_external_buffer.cpp @@ -755,13 +755,14 @@ namespace //************************************************************************* TEST(test_assignment) { - Compare input1{ Ndc("0"), Ndc("1"), Ndc("2"), Ndc("3"), Ndc("4"), Ndc("5"), Ndc("6"), Ndc("7"), Ndc("8"), Ndc("9") }; - Compare input2{ Ndc("9"), Ndc("8"), Ndc("7"), Ndc("6"), Ndc("5"), Ndc("4"), Ndc("3"), Ndc("2"), Ndc("1"), Ndc("0") }; + Compare input1{ Ndc("0"), Ndc("1"), Ndc("2"), Ndc("3"), Ndc("4"), Ndc("5"), Ndc("6"), Ndc("7"), Ndc("8") }; + Compare input2{ Ndc("8"), Ndc("7"), Ndc("6"), Ndc("5"), Ndc("4"), Ndc("3"), Ndc("2"), Ndc("1"), Ndc("0") }; Data data1(buffer1.raw, SIZE); data1.push(input1.begin(), input1.end()); // Copy construct from data1 Data data2(buffer2.raw, SIZE); + data2.push(Ndc("0")); data2 = data1; @@ -777,6 +778,32 @@ namespace CHECK(isEqual); } + //************************************************************************* + TEST(test_move_assignment) + { + Compare input1{ Ndc("0"), Ndc("1"), Ndc("2"), Ndc("3"), Ndc("4"), Ndc("5"), Ndc("6"), Ndc("7"), Ndc("8") }; + Compare input2{ Ndc("8"), Ndc("7"), Ndc("6"), Ndc("5"), Ndc("4"), Ndc("3"), Ndc("2"), Ndc("1"), Ndc("0") }; + Data data1(buffer1.raw, SIZE); + data1.push(input1.begin(), input1.end()); + + // Copy construct from data1 + Data data2(buffer2.raw, SIZE); + data2.push(Ndc("0")); + + data2 = etl::move(data1); + + // Now change data1 + data1.clear(); + data1.push(input2.begin(), input2.end()); + + CHECK(data2.begin() != data2.end()); + CHECK(data2.cbegin() != data2.cend()); + CHECK_EQUAL(input1.size(), data2.size()); + + bool isEqual = std::equal(input1.begin(), input1.end(), data2.begin()); + CHECK(isEqual); + } + //************************************************************************* TEST(test_swap_iterator) { From 36db54dd672eeb1b3a4d5d3673335784249b1633 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 22 Jun 2021 12:04:28 +0100 Subject: [PATCH 20/81] Updated version numbers --- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- meson.build | 2 +- support/Release notes.txt | 5 +++++ test/runtests.sh | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 4fff58f9..87f3d950 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 20 #define ETL_VERSION_MINOR 11 -#define ETL_VERSION_PATCH 3 +#define ETL_VERSION_PATCH 4 #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 fbb62211..384fcb94 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.11.3", + "version": "20.11.4", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 735cec9a..71536f16 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.11.3 +version=20.11.4 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index cdd8ac7d..5e308141 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.11.3' + version: '20.11.4' ) ###################### diff --git a/support/Release notes.txt b/support/Release notes.txt index 3100f572..02121a4a 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,8 @@ +=============================================================================== +20.11.4 +Fixed etl::circular_buffer copy and move assignment bug where the destination +buffer was not cleared before assignment. + =============================================================================== 20.11.3 Define missing macro when cross compiling with clang for AVR diff --git a/test/runtests.sh b/test/runtests.sh index 2bfee270..ae2114a6 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -1,5 +1,5 @@ #!/bin/sh -sudo ntpdate ntp.ubuntu.com +#sudo ntpdate ntp.ubuntu.com cd build || exit 1 echo "ETL Tests" > etl_test_log.txt echo "" From 2ef35caa773d78739378ebd6755a528adf7c248f Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 25 May 2021 11:02:24 +0100 Subject: [PATCH 21/81] Added experimental uni_type --- include/etl/experimental/uni_type.h | 78 +++++++++++++++++++++++++++++ test/vs2019/etl.vcxproj.filters | 3 ++ 2 files changed, 81 insertions(+) create mode 100644 include/etl/experimental/uni_type.h diff --git a/include/etl/experimental/uni_type.h b/include/etl/experimental/uni_type.h new file mode 100644 index 00000000..d5840321 --- /dev/null +++ b/include/etl/experimental/uni_type.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/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 747b9512..14e74a75 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1113,6 +1113,9 @@ ETL\Utilities + + ETL\Experimental + From c5fba8fd45fb6a2fd975aa109cad3dcdcc4e5e9b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 25 May 2021 23:06:15 +0100 Subject: [PATCH 22/81] Added experimental uni_type --- include/etl/experimental/{uni_type.h => mem_type.h} | 0 test/vs2019/etl.vcxproj.filters | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename include/etl/experimental/{uni_type.h => mem_type.h} (100%) diff --git a/include/etl/experimental/uni_type.h b/include/etl/experimental/mem_type.h similarity index 100% rename from include/etl/experimental/uni_type.h rename to include/etl/experimental/mem_type.h diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 14e74a75..2fc66ec2 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1113,7 +1113,7 @@ ETL\Utilities - + ETL\Experimental From fc6e391cb4d31b7fdf3db6a2fa71f2daf9bf5043 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 26 May 2021 22:04:34 +0100 Subject: [PATCH 23/81] Further updates to mem_type --- test/test_mem_type.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 test/test_mem_type.cpp 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()); + } + }; +} From 4a9f70cd0c6fd5debd5e24bcae8819c05f2aada5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 27 May 2021 13:23:15 +0100 Subject: [PATCH 24/81] Renamed mem_type to mem_cast --- include/etl/experimental/{mem_type.h => mem_cast.h} | 0 test/vs2019/etl.vcxproj.filters | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename include/etl/experimental/{mem_type.h => mem_cast.h} (100%) diff --git a/include/etl/experimental/mem_type.h b/include/etl/experimental/mem_cast.h similarity index 100% rename from include/etl/experimental/mem_type.h rename to include/etl/experimental/mem_cast.h diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 2fc66ec2..2c28ca23 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1113,7 +1113,7 @@ ETL\Utilities - + ETL\Experimental From c992d93bd658260b2cf3922f3ba5203735f0f8d5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 31 May 2021 10:00:01 +0100 Subject: [PATCH 25/81] Updates to mem_cast --- test/vs2019/etl.vcxproj.filters | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 2c28ca23..5eb838e5 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1114,7 +1114,7 @@ ETL\Utilities - ETL\Experimental + ETL\Utilities From b9ec916b32e0c959d2dae4e97ffdc3629acd7f30 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 21 May 2021 18:05:02 +0100 Subject: [PATCH 26/81] Initial commit --- test/vs2019/etl.vcxproj.filters | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 5eb838e5..7e479e93 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1112,6 +1112,11 @@ ETL\Utilities + + ETL\Private + + + ETL\Private ETL\Utilities From 16afbd88aba57a0ee5ded5bd3575df4390d74a6b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 22 May 2021 17:11:48 +0100 Subject: [PATCH 27/81] Interim commit --- test/vs2019/etl.vcxproj.filters | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 7e479e93..e8c7bbde 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2551,6 +2551,9 @@ Source Files\Sanity Checks + + Source Files + From 812f95e0c50952a673aa8d64fa77c0d56661b25d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 26 May 2021 22:04:34 +0100 Subject: [PATCH 28/81] Further updates to mem_type --- test/vs2019/etl.vcxproj.filters | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index e8c7bbde..a222862c 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2554,6 +2554,9 @@ Source Files + + Source Files + From 3d8302985f1516c8b75899830595471c6a157fa6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 27 May 2021 13:23:15 +0100 Subject: [PATCH 29/81] Renamed mem_type to mem_cast --- test/test_mem_type.cpp | 88 --------------------------------- test/vs2019/etl.vcxproj.filters | 2 +- 2 files changed, 1 insertion(+), 89 deletions(-) delete mode 100644 test/test_mem_type.cpp diff --git a/test/test_mem_type.cpp b/test/test_mem_type.cpp deleted file mode 100644 index b0d1db30..00000000 --- a/test/test_mem_type.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/****************************************************************************** -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/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index a222862c..5f76757d 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2554,7 +2554,7 @@ Source Files - + Source Files From ccc078cc6ded322adfd12661ac29c1f8688d41a4 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 30 May 2021 12:08:03 +0100 Subject: [PATCH 30/81] Updates to mem_cast --- test/vs2019/etl.vcxproj.filters | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 5f76757d..deef183f 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2557,6 +2557,9 @@ Source Files + + Source Files + From dddeb3471f6da7658957c37aa7722ff3e2e98c7e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 31 May 2021 10:00:01 +0100 Subject: [PATCH 31/81] Updates to mem_cast --- test/vs2019/etl.vcxproj.filters | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index deef183f..f617841b 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2560,6 +2560,9 @@ Source Files + + Source Files\Sanity Checks + From 2025e6ff9bc17f75ead76e2671085c1d16281741 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 22 Jun 2021 10:43:39 +0100 Subject: [PATCH 32/81] Latest updates --- include/etl/overload.h | 85 +++++++++++++++++++++++++++++++ include/etl/private/variant_new.h | 84 +++++++++++++++++++++--------- test/etl_profile.h | 2 + test/test_variant_new.cpp | 72 ++++++++++++++++++++++++-- test/vs2019/etl.vcxproj | 3 +- test/vs2019/etl.vcxproj.filters | 11 ++-- 6 files changed, 223 insertions(+), 34 deletions(-) create mode 100644 include/etl/overload.h diff --git a/include/etl/overload.h b/include/etl/overload.h new file mode 100644 index 00000000..2fc7640b --- /dev/null +++ b/include/etl/overload.h @@ -0,0 +1,85 @@ +///\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" + +namespace etl +{ +#if ETL_CPP11_SUPPORTED + #if ETL_CPP17_SUPPORTED && !defined(ETL_OVERLOAD_FORCE_CPP11) + //************************************************************************* + /// Variadic template definition of overload. + //************************************************************************* + template + struct overload : Ts... + { + using Ts::operator()...; + }; + + //************************************************************************* + /// Template deduction guide. + //************************************************************************* + template overload(Ts...)->overload; + +#else + //************************************************************************* + /// Variadic template definition of overload. + //************************************************************************* + template + struct overload : T, overload + { + using T::operator(); + using overload::operator(); + }; + + //************************************************************************* + /// Template specialisation of overload for one type. + //************************************************************************* + template struct overload : T + { + using T::operator(); + }; +#endif + + //************************************************************************* + /// Make an overload. + //************************************************************************* + template + constexpr auto make_overload(T&&... t) + { + return overload{ etl::forward(t)... }; + } +} + +#endif +#endif diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 487cd945..e11a6e32 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -42,6 +42,7 @@ SOFTWARE. #include "../error_handler.h" #include "../parameter_pack.h" #include "../placement_new.h" +#include "../visitor.h" #include @@ -205,7 +206,7 @@ namespace etl constexpr variant() : data() { - using type = typename etl::parameter_pack::type_from_index<0>::type; + using type = typename etl::parameter_pack::template type_from_index<0>::type; type temp; @@ -221,7 +222,7 @@ namespace etl constexpr variant(const T& value) : data() , operation(do_operation) - , type_id(etl::parameter_pack::index_of_type::value) + , type_id(etl::parameter_pack::template index_of_type::value) { static_assert(etl::is_one_of::value, "Unsupported type"); @@ -266,7 +267,7 @@ namespace etl T temp(etl::forward(args)...); operation(action_type::Construct, data, &temp); - type_id = etl::parameter_pack::index_of_type::value; + type_id = etl::parameter_pack::template index_of_type::value; return *static_cast(data); } @@ -285,7 +286,7 @@ namespace etl operation = do_operation; operation(action_type::Construct, data, &value); - type_id = etl::parameter_pack::index_of_type::value; + type_id = etl::parameter_pack::template index_of_type::value; return *this; } @@ -365,12 +366,21 @@ namespace etl } //*************************************************************************** - /// Do an operation determined by type. + /// Accept an etl::visitor. + //*************************************************************************** + template + void accept(etl::visitor& v) + { + do_accept(v, std::make_index_sequence{}); + } + + //*************************************************************************** + /// Accept a generic visitor. //*************************************************************************** template - void accept(TVisitor& visitor) + void operator()(TVisitor& v) { - do_accept(visitor, std::make_index_sequence{}); + do_operator(v, std::make_index_sequence{}); } private: @@ -430,6 +440,32 @@ namespace etl } } + //*************************************************************************** + /// Loop through the types until a match is found. + //*************************************************************************** + template + void do_operator(TVisitor& visitor, std::index_sequence) + { + (attempt_operator(visitor) || ...); + } + + //*************************************************************************** + /// Attempt to call a visitor. + //*************************************************************************** + template + bool attempt_operator(TVisitor& visitor) + { + if (Index == index()) + { + visitor(etl::get(*this)); + return true; + } + else + { + return false; + } + } + //*************************************************************************** /// Default operation. //*************************************************************************** @@ -455,7 +491,7 @@ namespace etl template constexpr bool holds_alternative(const etl::variant& v) noexcept { - constexpr size_t Index = etl::parameter_pack::index_of_type::value; + constexpr size_t Index = etl::parameter_pack::template index_of_type::value; return (Index == variant_npos) ? false : (v.index() == Index); } @@ -538,7 +574,7 @@ namespace etl template constexpr T& get(etl::variant& v) { - constexpr size_t Index = etl::parameter_pack::index_of_type::value; + constexpr size_t Index = etl::parameter_pack::template index_of_type::value; return get(v); } @@ -547,7 +583,7 @@ namespace etl template constexpr T&& get(etl::variant&& v) { - constexpr size_t Index = etl::parameter_pack::index_of_type::value; + constexpr size_t Index = etl::parameter_pack::template index_of_type::value; return get(v); } @@ -556,7 +592,7 @@ namespace etl template constexpr const T& get(const etl::variant& v) { - constexpr size_t Index = etl::parameter_pack::index_of_type::value; + constexpr size_t Index = etl::parameter_pack::template index_of_type::value; return get(v); } @@ -565,7 +601,7 @@ namespace etl template constexpr const T&& get(const etl::variant&& v) { - constexpr size_t Index = etl::parameter_pack::index_of_type::value; + constexpr size_t Index = etl::parameter_pack::template index_of_type::value; return get(v); } @@ -573,9 +609,9 @@ namespace etl //*************************************************************************** /// get_if //*************************************************************************** - template < size_t Index, class... Types > - constexpr etl::add_pointer_t>> - get_if(etl::variant* pv) noexcept + template < size_t Index, typename... TTypes > + constexpr etl::add_pointer_t>> + get_if(etl::variant* pv) noexcept { if ((pv != nullptr) && (pv->index() == Index)) { @@ -588,9 +624,9 @@ namespace etl } //*********************************** - template< size_t Index, class... Types > - constexpr etl::add_pointer_t>> - get_if(const etl::variant* pv) noexcept + template< size_t Index, typename... TTypes > + constexpr etl::add_pointer_t>> + get_if(const etl::variant* pv) noexcept { if ((pv != nullptr) && (pv->index() == Index)) { @@ -603,19 +639,19 @@ namespace etl } //*********************************** - template< class T, class... Types > - constexpr etl::add_pointer_t get_if(etl::variant* pv) noexcept + template< class T, typename... TTypes > + constexpr etl::add_pointer_t get_if(etl::variant* pv) noexcept { - constexpr size_t Index = etl::parameter_pack::index_of_type::value; + constexpr size_t Index = etl::parameter_pack::template index_of_type::value; return etl::get_if(pv); } //*********************************** - template< class T, class... Types > - constexpr etl::add_pointer_t get_if(const etl::variant* pv) noexcept + template< class T, typename... TTypes > + constexpr etl::add_pointer_t get_if(const etl::variant* pv) noexcept { - constexpr size_t Index = etl::parameter_pack::index_of_type::value; + constexpr size_t Index = etl::parameter_pack::template index_of_type::value; return etl::get_if(pv); } diff --git a/test/etl_profile.h b/test/etl_profile.h index c1652ae3..bbb0926b 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -98,6 +98,8 @@ SOFTWARE. #define ETL_MEM_CAST_FORCE_CPP03 #endif +#define ETL_OVERLOAD_FORCE_CPP11 + #if defined(ETL_NO_STL) #define ETL_TIMER_SEMAPHORE_TYPE uint32_t #endif diff --git a/test/test_variant_new.cpp b/test/test_variant_new.cpp index 700780f8..e19a74bc 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -35,6 +35,7 @@ SOFTWARE. #include #include #include +#include namespace { @@ -399,23 +400,34 @@ namespace //************************************************************************* TEST(test_variant_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; @@ -424,12 +436,64 @@ namespace variant = char(1); variant.accept(visitor); + CHECK_EQUAL(1, visitor.result_c); variant = int(2); variant.accept(visitor); + CHECK_EQUAL(2, visitor.result_i); variant = std::string("3"); variant.accept(visitor); + CHECK_EQUAL("3", visitor.result_s); + } + + //************************************************************************* + TEST(test_variant_operator_visit) + { + 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()(std::string& s) + { + result_s = s; + } + + char result_c; + int result_i; + std::string result_s; + }; + + Visitor visitor; + + test_variant_3 variant; + + variant = char(1); + variant(visitor); + CHECK_EQUAL(1, visitor.result_c); + + variant = int(2); + variant(visitor); + CHECK_EQUAL(2, visitor.result_i); + + variant = std::string("3"); + variant(visitor); + CHECK_EQUAL("3", visitor.result_s); } }; } diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 3b3a491b..6eb9aa6f 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1348,6 +1348,7 @@ + @@ -5033,4 +5034,4 @@ - + \ No newline at end of file diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index f617841b..db5c98e6 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1112,11 +1112,12 @@ ETL\Utilities - - ETL\Private - - ETL\Private + + Header Files + + + ETL\Patterns ETL\Utilities @@ -2701,4 +2702,4 @@ Resource Files - + \ No newline at end of file From 0d7405de0d630c3664ea52d53cd16f841da7a173 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 22 Jun 2021 20:32:57 +0100 Subject: [PATCH 33/81] Fixed swapped HUGE_VAL & HUGE_VALF definitions --- include/etl/limits.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/etl/limits.h b/include/etl/limits.h index 52023d2a..56b5292e 100644 --- a/include/etl/limits.h +++ b/include/etl/limits.h @@ -73,8 +73,8 @@ SOFTWARE. #if !defined(HUGE_VAL) // Looks like we don't have these macros defined. // They're compiler implementation dependent, so we'll make them the same as the max values. - #define HUGE_VAL FLT_MAX - #define HUGE_VALF DBL_MAX + #define HUGE_VALF FLT_MAX + #define HUGE_VAL DBL_MAX #define HUGE_VALL LDBL_MAX #endif From dee32492bdb6349658d56d6a11d12bef3b7f2744 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 24 Jun 2021 18:14:25 +0100 Subject: [PATCH 34/81] Deleted experimental files --- include/etl/experimental/crc16.h | 82 ---- include/etl/experimental/crc16_ccitt.h | 82 ---- include/etl/experimental/crc16_genibus.h | 82 ---- include/etl/experimental/crc16_kermit.h | 82 ---- include/etl/experimental/crc16_modbus.h | 82 ---- include/etl/experimental/crc16_usb.h | 82 ---- include/etl/experimental/crc16_x25.h | 82 ---- include/etl/experimental/crc16_xmodem.h | 82 ---- include/etl/experimental/crc32.h | 82 ---- include/etl/experimental/crc32_bzip2.h | 82 ---- include/etl/experimental/crc32_c.h | 82 ---- include/etl/experimental/crc32_mpeg2.h | 82 ---- include/etl/experimental/crc32_posix.h | 82 ---- include/etl/experimental/crc64_ecma.h | 82 ---- include/etl/experimental/crc8_ccitt.h | 80 ---- include/etl/experimental/crc8_rohc.h | 83 ---- include/etl/experimental/variant_new.h | 509 ----------------------- 17 files changed, 1820 deletions(-) delete mode 100644 include/etl/experimental/crc16.h delete mode 100644 include/etl/experimental/crc16_ccitt.h delete mode 100644 include/etl/experimental/crc16_genibus.h delete mode 100644 include/etl/experimental/crc16_kermit.h delete mode 100644 include/etl/experimental/crc16_modbus.h delete mode 100644 include/etl/experimental/crc16_usb.h delete mode 100644 include/etl/experimental/crc16_x25.h delete mode 100644 include/etl/experimental/crc16_xmodem.h delete mode 100644 include/etl/experimental/crc32.h delete mode 100644 include/etl/experimental/crc32_bzip2.h delete mode 100644 include/etl/experimental/crc32_c.h delete mode 100644 include/etl/experimental/crc32_mpeg2.h delete mode 100644 include/etl/experimental/crc32_posix.h delete mode 100644 include/etl/experimental/crc64_ecma.h delete mode 100644 include/etl/experimental/crc8_ccitt.h delete mode 100644 include/etl/experimental/crc8_rohc.h delete mode 100644 include/etl/experimental/variant_new.h diff --git a/include/etl/experimental/crc16.h b/include/etl/experimental/crc16.h deleted file mode 100644 index 07b0c39d..00000000 --- a/include/etl/experimental/crc16.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC16_EX_INCLUDED -#define ETL_CRC16_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc16 16 bit CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 - template - using crc16_t = etl::crc_type; -#else - template - class crc16_t : public etl::private_crc::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc16_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc16_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc16_t<256U> crc16_t256; - typedef etl::crc::crc16_t<16U> crc16_t16; - typedef etl::crc::crc16_t<4U> crc16_t4; - typedef crc16_t256 crc16; - } -} -#endif diff --git a/include/etl/experimental/crc16_ccitt.h b/include/etl/experimental/crc16_ccitt.h deleted file mode 100644 index be148a56..00000000 --- a/include/etl/experimental/crc16_ccitt.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC16_CCITT_EX_INCLUDED -#define ETL_CRC16_CCITT_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc16_ccitt 16 bit CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 - template - using crc16_ccitt_t = etl::crc_type; -#else - template - class crc16_ccitt_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc16_ccitt_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc16_ccitt_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc16_ccitt_t<256U> crc16_ccitt_t256; - typedef etl::crc::crc16_ccitt_t<16U> crc16_ccitt_t16; - typedef etl::crc::crc16_ccitt_t<4U> crc16_ccitt_t4; - typedef crc16_ccitt_t256 crc16_ccitt; - } -} -#endif diff --git a/include/etl/experimental/crc16_genibus.h b/include/etl/experimental/crc16_genibus.h deleted file mode 100644 index f901ab8f..00000000 --- a/include/etl/experimental/crc16_genibus.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC16_GENIBUS_EX_INCLUDED -#define ETL_CRC16_GENIBUS_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc16_genibus 16 bit CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 - template - using crc16_genibus_t = etl::crc_type; -#else - template - class crc16_genibus_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc16_genibus_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc16_genibus_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc16_genibus_t<256U> crc16_genibus_t256; - typedef etl::crc::crc16_genibus_t<16U> crc16_genibus_t16; - typedef etl::crc::crc16_genibus_t<4U> crc16_genibus_t4; - typedef crc16_genibus_t256 crc16_genibus; - } -} -#endif diff --git a/include/etl/experimental/crc16_kermit.h b/include/etl/experimental/crc16_kermit.h deleted file mode 100644 index eb9cc987..00000000 --- a/include/etl/experimental/crc16_kermit.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC16_KERMIT_EX_INCLUDED -#define ETL_CRC16_KERMIT_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc16_kermit 16 bit CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 - template - using crc16_kermit_t = etl::crc_type; -#else - template - class crc16_kermit_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc16_kermit_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc16_kermit_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc16_kermit_t<256U> crc16_kermit_t256; - typedef etl::crc::crc16_kermit_t<16U> crc16_kermit_t16; - typedef etl::crc::crc16_kermit_t<4U> crc16_kermit_t4; - typedef crc16_kermit_t256 crc16_kermit; - } -} -#endif diff --git a/include/etl/experimental/crc16_modbus.h b/include/etl/experimental/crc16_modbus.h deleted file mode 100644 index aca95d3b..00000000 --- a/include/etl/experimental/crc16_modbus.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC16_MODBUS_EX_INCLUDED -#define ETL_CRC16_MODBUS_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -//\defgroup crc16_modbus 16 bit CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 - template - using crc16_modbus_t = etl::crc_type; -#else - template - class crc16_modbus_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc16_modbus_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc16_modbus_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc16_modbus_t<256U> crc16_modbus_t256; - typedef etl::crc::crc16_modbus_t<16U> crc16_modbus_t16; - typedef etl::crc::crc16_modbus_t<4U> crc16_modbus_t4; - typedef crc16_modbus_t256 crc16_modbus; - } -} -#endif diff --git a/include/etl/experimental/crc16_usb.h b/include/etl/experimental/crc16_usb.h deleted file mode 100644 index 2510d78b..00000000 --- a/include/etl/experimental/crc16_usb.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC16_USB_EX_INCLUDED -#define ETL_CRC16_USB_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc16_usb 16 bit CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 - template - using crc16_usb_t = etl::crc_type; -#else - template - class crc16_usb_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc16_usb_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc16_usb_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc16_usb_t<256U> crc16_usb_t256; - typedef etl::crc::crc16_usb_t<16U> crc16_usb_t16; - typedef etl::crc::crc16_usb_t<4U> crc16_usb_t4; - typedef crc16_usb_t256 crc16_usb; - } -} -#endif diff --git a/include/etl/experimental/crc16_x25.h b/include/etl/experimental/crc16_x25.h deleted file mode 100644 index 916c15a7..00000000 --- a/include/etl/experimental/crc16_x25.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC16_X25_EX_INCLUDED -#define ETL_CRC16_X25_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc16_x25 16 bit CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 - template - using crc16_x25_t = etl::crc_type; -#else - template - class crc16_x25_t : public etl::private_crc::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc16_x25_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc16_x25_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc16_x25_t<256U> crc16_x25_t256; - typedef etl::crc::crc16_x25_t<16U> crc16_x25_t16; - typedef etl::crc::crc16_x25_t<4U> crc16_x25_t4; - typedef crc16_x25_t256 crc16_x25; - } -} -#endif diff --git a/include/etl/experimental/crc16_xmodem.h b/include/etl/experimental/crc16_xmodem.h deleted file mode 100644 index 19c520af..00000000 --- a/include/etl/experimental/crc16_xmodem.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC16_XMODEM_EX_INCLUDED -#define ETL_CRC16_XMODEM_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc16_xmodem 16 bit CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED - template - using crc16_xmodem_t = etl::crc_type; -#else - template - class crc16_xmodem_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc16_xmodem_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc16_xmodem_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc16_xmodem_t<256U> crc16_xmodem_t256; - typedef etl::crc::crc16_xmodem_t<16U> crc16_xmodem_t16; - typedef etl::crc::crc16_xmodem_t<4U> crc16_xmodem_t4; - typedef crc16_xmodem_t256 crc16_xmodem; - } -} -#endif diff --git a/include/etl/experimental/crc32.h b/include/etl/experimental/crc32.h deleted file mode 100644 index 37767d2f..00000000 --- a/include/etl/experimental/crc32.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC32_EX_INCLUDED -#define ETL_CRC32_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc32 32 bit CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED - template - using crc32_t = etl::crc_type; -#else - template - class crc32_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc32_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc32_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc32_t<256U> crc32_t256; - typedef etl::crc::crc32_t<16U> crc32_t16; - typedef etl::crc::crc32_t<4U> crc32_t4; - typedef crc32_t256 crc32; - } -} -#endif diff --git a/include/etl/experimental/crc32_bzip2.h b/include/etl/experimental/crc32_bzip2.h deleted file mode 100644 index 5d632d76..00000000 --- a/include/etl/experimental/crc32_bzip2.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC32_BZIP2_EX_INCLUDED -#define ETL_CRC32_BZIP2_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc32_bzip2 32 bit CRC BZIP2 calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED - template - using crc32_bzip2_t = etl::crc_type; -#else - template - class crc32_bzip2_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc32_bzip2_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc32_bzip2_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc32_bzip2_t<256U> crc32_bzip2_t256; - typedef etl::crc::crc32_bzip2_t<16U> crc32_bzip2_t16; - typedef etl::crc::crc32_bzip2_t<4U> crc32_bzip2_t4; - typedef crc32_bzip2_t256 crc32_bzip2; - } -} -#endif diff --git a/include/etl/experimental/crc32_c.h b/include/etl/experimental/crc32_c.h deleted file mode 100644 index 84d84167..00000000 --- a/include/etl/experimental/crc32_c.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC32_C_EX_INCLUDED -#define ETL_CRC32_C_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc32_c 32 bit CRC_C calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED - template - using crc32_c_t = etl::crc_type; -#else - template - class crc32_c_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc32_c_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc32_c_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc32_c_t<256U> crc32_c_t256; - typedef etl::crc::crc32_c_t<16U> crc32_c_t16; - typedef etl::crc::crc32_c_t<4U> crc32_c_t4; - typedef crc32_c_t256 crc32_c; - } -} -#endif diff --git a/include/etl/experimental/crc32_mpeg2.h b/include/etl/experimental/crc32_mpeg2.h deleted file mode 100644 index e23657a4..00000000 --- a/include/etl/experimental/crc32_mpeg2.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC32_MPEG2_EX_INCLUDED -#define ETL_CRC32_MPEG2_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc32_mpeg2 32 bit CRC MPEG2 calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED - template - using crc32_mpeg2_t = etl::crc_type; -#else - template - class crc32_mpeg2_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc32_mpeg2_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc32_mpeg2_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc32_mpeg2_t<256U> crc32_mpeg2_t256; - typedef etl::crc::crc32_mpeg2_t<16U> crc32_mpeg2_t16; - typedef etl::crc::crc32_mpeg2_t<4U> crc32_mpeg2_t4; - typedef crc32_mpeg2_t256 crc32_mpeg2; - } -} -#endif diff --git a/include/etl/experimental/crc32_posix.h b/include/etl/experimental/crc32_posix.h deleted file mode 100644 index 5f3cb701..00000000 --- a/include/etl/experimental/crc32_posix.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC32_POSIX_EX_INCLUDED -#define ETL_CRC32_POSIX_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc32_posix 32 bit CRC POSIX calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED - template - using crc32_posix_t = etl::crc_type; -#else - template - class crc32_posix_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc32_posix_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc32_posix_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc32_posix_t<256U> crc32_posix_t256; - typedef etl::crc::crc32_posix_t<16U> crc32_posix_t16; - typedef etl::crc::crc32_posix_t<4U> crc32_posix_t4; - typedef crc32_posix_t256 crc32_posix; - } -} -#endif diff --git a/include/etl/experimental/crc64_ecma.h b/include/etl/experimental/crc64_ecma.h deleted file mode 100644 index 407c0f4a..00000000 --- a/include/etl/experimental/crc64_ecma.h +++ /dev/null @@ -1,82 +0,0 @@ -///\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_CRC64_ECMA_EX_INCLUDED -#define ETL_CRC64_ECMA_EX_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup crc64_ecma 64 bit ECMA CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED - template - using crc64_ecma_t = etl::crc_type; -#else - template - class crc64_ecma_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc64_ecma_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc64_ecma_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc64_ecma_t<256U> crc64_ecma_t256; - typedef etl::crc::crc64_ecma_t<16U> crc64_ecma_t16; - typedef etl::crc::crc64_ecma_t<4U> crc64_ecma_t4; - typedef crc64_ecma_t256 crc64_ecma; - } -} -#endif diff --git a/include/etl/experimental/crc8_ccitt.h b/include/etl/experimental/crc8_ccitt.h deleted file mode 100644 index 66683b68..00000000 --- a/include/etl/experimental/crc8_ccitt.h +++ /dev/null @@ -1,80 +0,0 @@ -///\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_CRC8_CCITT_EXP_INCLUDED -#define ETL_CRC8_CCITT_EXP_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 - template - using crc8_ccitt_t = etl::crc_type; -#else - template - class crc8_ccitt_t : public etl::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc8_ccitt_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc8_ccitt_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef crc8_ccitt_t<256U> crc8_ccitt_t256; - typedef crc8_ccitt_t<16U> crc8_ccitt_t16; - typedef crc8_ccitt_t<4U> crc8_ccitt_t4; - typedef crc8_ccitt_t256 crc8_ccitt; - } -} - -#endif diff --git a/include/etl/experimental/crc8_rohc.h b/include/etl/experimental/crc8_rohc.h deleted file mode 100644 index 60ab5b23..00000000 --- a/include/etl/experimental/crc8_rohc.h +++ /dev/null @@ -1,83 +0,0 @@ -///\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_CRC8_ROHC_EXP_INCLUDED -#define ETL_CRC8_ROHC_EXP_INCLUDED - -#include "../platform.h" -#include "crc_implementation.h" -#include "crc_parameters.h" - -///\defgroup rohc 8 bit CRC calculation -///\ingroup crc - -namespace etl -{ - namespace crc - { -#if ETL_CPP11_SUPPORTED && !ETL_CRC_FORCE_CPP03 - template - using crc8_rohc_t = etl::crc_type; -#else - template - class crc8_rohc_t : public etl::private_crc::crc_type - { - public: - - //************************************************************************* - /// Default constructor. - //************************************************************************* - crc8_rohc_t() - { - this->reset(); - } - - //************************************************************************* - /// Constructor from range. - /// \param begin Start of the range. - /// \param end End of the range. - //************************************************************************* - template - crc8_rohc_t(TIterator begin, const TIterator end) - { - this->reset(); - this->add(begin, end); - } - }; -#endif - - typedef etl::crc::crc8_rohc_t<256U> crc8_rohc_t256; - typedef etl::crc::crc8_rohc_t<16U> crc8_rohc_t16; - typedef etl::crc::crc8_rohc_t<4U> crc8_rohc_t4; - typedef crc8_rohc_t256 crc8_rohc; - } -} - -#endif diff --git a/include/etl/experimental/variant_new.h b/include/etl/experimental/variant_new.h deleted file mode 100644 index 160969ac..00000000 --- a/include/etl/experimental/variant_new.h +++ /dev/null @@ -1,509 +0,0 @@ -///\file - -/****************************************************************************** -The MIT License(MIT) - -Embedded Template Library. -https://github.com/ETLCPP/etl -https://www.etlcpp.com - -Copyright(c) 2020 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_VARIANT_NEW_INCLUDED -#define ETL_VARIANT_NEW_INCLUDED - -#include - -#include "private/new.h" - -#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" - -#if defined(ETL_COMPILER_KEIL) - #pragma diag_suppress 940 - #pragma diag_suppress 111 -#endif - -#undef ETL_FILE -#define ETL_FILE "24" - -#if ETL_CPP11_SUPPORTED - -//***************************************************************************** -///\defgroup variant variant -/// A class that can contain one a several specified types in a type safe manner. -///\ingroup containers -//***************************************************************************** - -namespace etl -{ - //*************************************************************************** - /// 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_FILE"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 id a unsupported types. - //*************************************************************************** - static ETL_CONST_OR_CONSTEXPR size_t npos = -1; - - 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; - - public: - - //*************************************************************************** - /// Destructor. - //*************************************************************************** - ~variant() - { - destruct_current(); - } - - //*************************************************************************** - /// 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(etl::index_of::value != etl::index_of::npos, "Unsupported type"); - - ::new (static_cast(data)) T(value); - type_id = etl::index_of::value; - } - - //*************************************************************************** - /// 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; - } - - constexpr size_t NUMBER_OF_VARIANTS = sizeof...(TVariants); - - //*************************************************************************** - /// 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 - -#undef ETL_FILE - -#endif From 6f3caa6ede4b1bd301273ecb3a946bc8959eed71 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 24 Jun 2021 20:38:57 +0100 Subject: [PATCH 35/81] C++20 compatibility for deprecated std::is_pod --- .../etl/generators/type_traits_generator.h | 30 +++++++++++++++---- include/etl/type_traits.h | 30 +++++++++++++++---- include/etl/vector.h | 4 --- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 776d991b..b2d405fe 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -1148,51 +1148,71 @@ namespace etl //*************************************************************************** /// 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 = std::is_pod_v; + 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 = std::is_pod_v; + 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 = std::is_pod_v; + 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 = std::is_pod_v; + 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 = std::is_pod_v; + inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; #endif #endif diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index e51a839e..281b94bf 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -1136,51 +1136,71 @@ namespace etl //*************************************************************************** /// 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 = std::is_pod_v; + 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 = std::is_pod_v; + 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 = std::is_pod_v; + 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 = std::is_pod_v; + 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 = std::is_pod_v; + inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; #endif #endif diff --git a/include/etl/vector.h b/include/etl/vector.h index b1ee244c..81ce56e3 100644 --- a/include/etl/vector.h +++ b/include/etl/vector.h @@ -1297,9 +1297,7 @@ namespace etl ETL_OVERRIDE #endif { - #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_ASSERT(etl::is_trivially_copyable::value, ETL_ERROR(etl::vector_incompatible_type)); - #endif etl::ivector::repair_buffer(buffer); } @@ -1468,9 +1466,7 @@ namespace etl ETL_OVERRIDE #endif { -#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED ETL_ASSERT(etl::is_trivially_copyable::value, ETL_ERROR(etl::vector_incompatible_type)); -#endif etl::ivector::repair_buffer(this->p_buffer); } From 8638593b615f04c46bf196e9df4f92894f418088 Mon Sep 17 00:00:00 2001 From: JR Date: Sun, 27 Jun 2021 18:14:30 +0200 Subject: [PATCH 36/81] add a couple of arduino examples (#397) * Add information about Arduino library and repo * Add arduino library example --- README.md | 4 ++ arduino/create_arduino_library.py | 18 +++++++++ .../Example_0_import_etl.ino | 10 +++++ .../Example_Vector_1_simple_use.ino | 37 +++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 arduino_examples/Example_0_import_etl/Example_0_import_etl.ino create mode 100644 arduino_examples/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino diff --git a/README.md b/README.md index 4baa523d..2ca62bd4 100644 --- a/README.md +++ b/README.md @@ -56,3 +56,7 @@ Any help porting the library to work under different platforms and compilers wou I am especially interested in people who are using Keil, IAR, Green Hills, TI Code Composer etc, bare metal or RTOS, and DSPs. See (https://www.etlcpp.com) for up-to-date information. + +**Arduino library:** + +The content of this repo is available as a library in the Arduino IDE (search for the "Embedded Template Library" in the IDE library manager). The Arduino library repository is available at ```https://github.com/ETLCPP/etl-arduino```, see there for more details. diff --git a/arduino/create_arduino_library.py b/arduino/create_arduino_library.py index b74549e1..97924e7f 100644 --- a/arduino/create_arduino_library.py +++ b/arduino/create_arduino_library.py @@ -27,6 +27,10 @@ print('etl_dir = ', etl_dir) include_dir = os.path.join(etl_dir, 'include') print('include_dir = ', include_dir) +# Get the ETL arduino_examples folder +arduino_examples_dir = os.path.join(etl_dir, 'arduino_examples') +print('examples_dir = ', arduino_examples_dir) + # Get the root folder of both repositories common_dir = os.path.dirname(etl_dir) print('common_dir = ', common_dir) @@ -39,6 +43,10 @@ print('etl_arduino_dir = ', etl_arduino_dir) etl_arduino_src_dir = os.path.join(etl_arduino_dir, 'src') print('etl_arduino_src_dir = ', etl_arduino_src_dir) +# Get the ETL Arduino examples repository folder +etl_arduino_examples_dir = os.path.join(etl_arduino_dir, 'examples') +print('etl_arduino_examples_dir = ', etl_arduino_examples_dir) + print('') # Copy the library properties @@ -70,3 +78,13 @@ print('Copy the ETL headers') print(' From :', source) print(' To :', destination) shutil.copytree(source, destination, dirs_exist_ok = True) + +print('') + +# Copy the ETL arduino_examples +source = arduino_examples_dir +destination = etl_arduino_examples_dir +print('Copy the ETL examples_arduino') +print(' From :', source) +print(' To :', destination) +shutil.copytree(source, destination, dirs_exist_ok = True) diff --git a/arduino_examples/Example_0_import_etl/Example_0_import_etl.ino b/arduino_examples/Example_0_import_etl/Example_0_import_etl.ino new file mode 100644 index 00000000..d208c463 --- /dev/null +++ b/arduino_examples/Example_0_import_etl/Example_0_import_etl.ino @@ -0,0 +1,10 @@ +#include "Embedded_Template_Library.h" // this is required for any more etl import when using Arduino IDE + +void setup(){ + +} + + +void loop(){ + +} diff --git a/arduino_examples/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino b/arduino_examples/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino new file mode 100644 index 00000000..a0c92fc1 --- /dev/null +++ b/arduino_examples/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino @@ -0,0 +1,37 @@ +#include "Embedded_Template_Library.h" +#include "etl/vector.h" + +template +void print_vector(etl::ivector const & vec_in){ + Serial.print(F("print vector content | size ")); Serial.print(vec_in.size()); Serial.print(F(" | capacity ")); Serial.println(vec_in.capacity()); + Serial.print(F("content | ")); + for (T const & elem : vec_in) { + Serial.print(elem); + Serial.print(F(" | ")); + } + Serial.println(); +} + +void setup(){ + Serial.begin(115200); + delay(100); + Serial.println(F("booted")); + + etl::vector vec_int; + + Serial.println(F("initialized vec_int")); + print_vector(vec_int); + + vec_int.push_back(1); + vec_int.push_back(2); + Serial.println(F("pushed to vec_int")); + print_vector(vec_int); + + vec_int.pop_back(); + Serial.println(F("pop from vec_int; returns no value")); + print_vector(vec_int); +} + +void loop(){ + +} From 7874a93d037bdd1ff19437f7d844666c6518055c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 29 Jun 2021 09:55:12 +0100 Subject: [PATCH 37/81] Updated Arduino examples --- .gitignore | 3 +++ arduino/create_arduino_library.py | 4 ++-- .../Example_0_import_etl.ino | 12 ++++++++++++ .../Example_Vector_1_simple_use.ino | 14 ++++++++++---- .../Example_0_import_etl.ino | 10 ---------- test/vs2019/etl.vcxproj | 2 ++ test/vs2019/etl.vcxproj.filters | 19 ++++++++++++++++++- 7 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 arduino/examples/Example_0_import_etl/Example_0_import_etl.ino rename {arduino_examples => arduino/examples}/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino (86%) delete mode 100644 arduino_examples/Example_0_import_etl/Example_0_import_etl.ino diff --git a/.gitignore b/.gitignore index 98dcbb02..cb627492 100644 --- a/.gitignore +++ b/.gitignore @@ -312,3 +312,6 @@ test/sanity-check/c++17/cmake_install.cmake test/sanity-check/c++17/CMakeCache.txt test/sanity-check/c++17/libt17.a test/sanity-check/c++17/Makefile +test/vs2019/Debug LLVM +test/vs2019/DebugLLVMNoSTL +test/vs2019/DebugNoSTL diff --git a/arduino/create_arduino_library.py b/arduino/create_arduino_library.py index 97924e7f..f7c7c7e9 100644 --- a/arduino/create_arduino_library.py +++ b/arduino/create_arduino_library.py @@ -28,7 +28,7 @@ include_dir = os.path.join(etl_dir, 'include') print('include_dir = ', include_dir) # Get the ETL arduino_examples folder -arduino_examples_dir = os.path.join(etl_dir, 'arduino_examples') +arduino_examples_dir = os.path.join(arduino_dir, 'examples') print('examples_dir = ', arduino_examples_dir) # Get the root folder of both repositories @@ -84,7 +84,7 @@ print('') # Copy the ETL arduino_examples source = arduino_examples_dir destination = etl_arduino_examples_dir -print('Copy the ETL examples_arduino') +print('Copy the ETL Arduino examples') print(' From :', source) print(' To :', destination) shutil.copytree(source, destination, dirs_exist_ok = True) diff --git a/arduino/examples/Example_0_import_etl/Example_0_import_etl.ino b/arduino/examples/Example_0_import_etl/Example_0_import_etl.ino new file mode 100644 index 00000000..24fa24a4 --- /dev/null +++ b/arduino/examples/Example_0_import_etl/Example_0_import_etl.ino @@ -0,0 +1,12 @@ +#include "Embedded_Template_Library.h" // This is required for any more etl import when using Arduino IDE + +void setup() +{ + +} + + +void loop() +{ + +} diff --git a/arduino_examples/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino b/arduino/examples/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino similarity index 86% rename from arduino_examples/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino rename to arduino/examples/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino index a0c92fc1..a707ce89 100644 --- a/arduino_examples/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino +++ b/arduino/examples/Vector_Examples/Example_Vector_1_simple_use/Example_Vector_1_simple_use.ino @@ -2,17 +2,22 @@ #include "etl/vector.h" template -void print_vector(etl::ivector const & vec_in){ +void print_vector(etl::ivector const & vec_in) +{ Serial.print(F("print vector content | size ")); Serial.print(vec_in.size()); Serial.print(F(" | capacity ")); Serial.println(vec_in.capacity()); Serial.print(F("content | ")); - for (T const & elem : vec_in) { + + for (T const & elem : vec_in) + { Serial.print(elem); Serial.print(F(" | ")); } + Serial.println(); } -void setup(){ +void setup() +{ Serial.begin(115200); delay(100); Serial.println(F("booted")); @@ -32,6 +37,7 @@ void setup(){ print_vector(vec_int); } -void loop(){ +void loop() +{ } diff --git a/arduino_examples/Example_0_import_etl/Example_0_import_etl.ino b/arduino_examples/Example_0_import_etl/Example_0_import_etl.ino deleted file mode 100644 index d208c463..00000000 --- a/arduino_examples/Example_0_import_etl/Example_0_import_etl.ino +++ /dev/null @@ -1,10 +0,0 @@ -#include "Embedded_Template_Library.h" // this is required for any more etl import when using Arduino IDE - -void setup(){ - -} - - -void loop(){ - -} diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 6eb9aa6f..809344d5 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -4987,6 +4987,8 @@ + + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index db5c98e6..b4fce916 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -106,6 +106,17 @@ {562466b5-677d-4448-9e9e-f70805cd71ad} + + {1d6ea286-57ad-4960-9343-9d2376087b24} + + + {5eace791-3e53-4205-a04d-2aba3bac6b47} + + + {2b770849-325e-4ec5-a7f3-9a192cd40dca} + + + {0e4d2126-b9b7-4eef-b5ca-18363b1e01ce} {79c578f6-5400-4b4d-b2a4-9a8c589f7c81} @@ -2647,6 +2658,12 @@ Source Files\Scripts + + ETL\Arduino\Examples\Example_0_import_etl + + + ETL\Arduino\Examples\Vector_Examples\Example_Vector_1_simple_use + @@ -2702,4 +2719,4 @@ Resource Files - \ No newline at end of file + From a8a4d9cc58cdbcd2e881004a36c072e56d6f79b2 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 29 Jun 2021 11:49:57 +0100 Subject: [PATCH 38/81] Updated Arduino examples --- library.json | 2 +- library.properties | 2 +- meson.build | 2 +- support/Release notes.txt | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index 384fcb94..7091254c 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.11.4", + "version": "20.11.5", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 71536f16..a0b702f4 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.11.4 +version=20.11.5 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index 5e308141..2de4988c 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.11.4' + version: '20.11.5' ) ###################### diff --git a/support/Release notes.txt b/support/Release notes.txt index 02121a4a..7ad972a8 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +20.11.5 +Added Arduino examples. + =============================================================================== 20.11.4 Fixed etl::circular_buffer copy and move assignment bug where the destination From f0358764c88203b7970ac44a1e4e3991e254a312 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 29 Jun 2021 19:15:07 +0100 Subject: [PATCH 39/81] Updated Arduino examples --- include/etl/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/etl/version.h b/include/etl/version.h index 87f3d950..b520b1be 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 20 #define ETL_VERSION_MINOR 11 -#define ETL_VERSION_PATCH 4 +#define ETL_VERSION_PATCH 5 #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) From 08f16f99f20cb70709fd51c6cfa257d46387aed0 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 21 May 2021 18:05:02 +0100 Subject: [PATCH 40/81] Initial commit --- test/vs2019/etl.vcxproj.filters | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index b4fce916..a8f40b35 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1123,6 +1123,11 @@ ETL\Utilities + + ETL\Private + + + ETL\Private Header Files From 67b17b263555769bc88ea9a7475965fb276b774f Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 25 May 2021 11:02:24 +0100 Subject: [PATCH 41/81] Added experimental uni_type --- include/etl/experimental/uni_type.h | 78 +++++++++++++++++++++++++++++ test/vs2019/etl.vcxproj | 2 +- 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 include/etl/experimental/uni_type.h diff --git a/include/etl/experimental/uni_type.h b/include/etl/experimental/uni_type.h new file mode 100644 index 00000000..d5840321 --- /dev/null +++ b/include/etl/experimental/uni_type.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/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 809344d5..0a802dd7 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -5036,4 +5036,4 @@ - \ No newline at end of file + From 3afe64dab173d7ae98bf20ac65a8d97031583e48 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 26 May 2021 22:04:34 +0100 Subject: [PATCH 42/81] Further updates to mem_type --- test/test_mem_type.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 test/test_mem_type.cpp 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()); + } + }; +} From f956cc19b491b41bd0fa2a93a8b0b1eea7511f69 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 27 May 2021 13:23:15 +0100 Subject: [PATCH 43/81] Renamed mem_type to mem_cast --- include/etl/experimental/mem_cast.h | 78 ----------------------------- 1 file changed, 78 deletions(-) delete mode 100644 include/etl/experimental/mem_cast.h diff --git a/include/etl/experimental/mem_cast.h b/include/etl/experimental/mem_cast.h deleted file mode 100644 index d5840321..00000000 --- a/include/etl/experimental/mem_cast.h +++ /dev/null @@ -1,78 +0,0 @@ -#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 From 8683b51dd33c860157300493a797421fddb5c14c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 25 May 2021 11:02:24 +0100 Subject: [PATCH 44/81] Added experimental uni_type --- test/vs2019/etl.vcxproj.filters | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index a8f40b35..2dbe421c 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1138,6 +1138,9 @@ ETL\Utilities + + ETL\Experimental + From eb6d5637d436da3dc416887832fefe452aed9d75 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 25 May 2021 23:06:15 +0100 Subject: [PATCH 45/81] Added experimental uni_type --- include/etl/experimental/{uni_type.h => mem_type.h} | 0 test/vs2019/etl.vcxproj.filters | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename include/etl/experimental/{uni_type.h => mem_type.h} (100%) diff --git a/include/etl/experimental/uni_type.h b/include/etl/experimental/mem_type.h similarity index 100% rename from include/etl/experimental/uni_type.h rename to include/etl/experimental/mem_type.h diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 2dbe421c..55dbdd27 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1138,7 +1138,7 @@ ETL\Utilities - + ETL\Experimental From e8a6e12ca11a8b0b47f4d0682f570a22b370dbd2 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 27 May 2021 13:23:15 +0100 Subject: [PATCH 46/81] Renamed mem_type to mem_cast --- include/etl/experimental/{mem_type.h => mem_cast.h} | 0 test/vs2019/etl.vcxproj.filters | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename include/etl/experimental/{mem_type.h => mem_cast.h} (100%) diff --git a/include/etl/experimental/mem_type.h b/include/etl/experimental/mem_cast.h similarity index 100% rename from include/etl/experimental/mem_type.h rename to include/etl/experimental/mem_cast.h diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 55dbdd27..35a95619 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1138,7 +1138,7 @@ ETL\Utilities - + ETL\Experimental From 45e32003262917a0bddaf5713967e7888fad8309 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 21 May 2021 18:05:02 +0100 Subject: [PATCH 47/81] Initial commit --- test/vs2019/etl.vcxproj.filters | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 35a95619..385d9f6e 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1134,6 +1134,12 @@ ETL\Patterns + ETL\Utilities + + ETL\Private + + + ETL\Private ETL\Utilities From d566f1ea1a6dd3c96677b691e56bedbc50ae7a2d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 22 Jun 2021 10:43:39 +0100 Subject: [PATCH 48/81] Latest updates --- test/vs2019/etl.vcxproj | 2 +- test/vs2019/etl.vcxproj.filters | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 0a802dd7..809344d5 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -5036,4 +5036,4 @@ - + \ No newline at end of file diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 385d9f6e..3953ee0e 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1135,11 +1135,12 @@ ETL\Patterns ETL\Utilities - - ETL\Private - - ETL\Private + + Header Files + + + ETL\Patterns ETL\Utilities @@ -2733,4 +2734,4 @@ Resource Files - + \ No newline at end of file From 7e9ca31fb1bf292d3cd00464fca2ab72accfac69 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 24 Jun 2021 21:02:32 +0100 Subject: [PATCH 49/81] Updated overloads --- include/etl/overload.h | 27 ++++++++++++++------------- test/etl_profile.h | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/etl/overload.h b/include/etl/overload.h index 2fc7640b..fb9dd080 100644 --- a/include/etl/overload.h +++ b/include/etl/overload.h @@ -40,44 +40,45 @@ namespace etl //************************************************************************* /// Variadic template definition of overload. //************************************************************************* - template - struct overload : Ts... + template + struct overload : TOverloads... { - using Ts::operator()...; + using TOverloads::operator()...; }; //************************************************************************* /// Template deduction guide. //************************************************************************* - template overload(Ts...)->overload; + template overload(TOverloads...)->overload; #else //************************************************************************* /// Variadic template definition of overload. //************************************************************************* - template - struct overload : T, overload + template + struct overload : TOverload, overload { - using T::operator(); - using overload::operator(); + using TOverload::operator(); + using overload::operator(); }; //************************************************************************* /// Template specialisation of overload for one type. //************************************************************************* - template struct overload : T + template + struct overload : TOverload { - using T::operator(); + using TOverload::operator(); }; #endif //************************************************************************* /// Make an overload. //************************************************************************* - template - constexpr auto make_overload(T&&... t) + template + constexpr auto make_overload(TOverloads&&... overloads) { - return overload{ etl::forward(t)... }; + return overload{ etl::forward(overloads)... }; } } diff --git a/test/etl_profile.h b/test/etl_profile.h index bbb0926b..3212f83b 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -98,7 +98,7 @@ SOFTWARE. #define ETL_MEM_CAST_FORCE_CPP03 #endif -#define ETL_OVERLOAD_FORCE_CPP11 +//#define ETL_OVERLOAD_FORCE_CPP11 #if defined(ETL_NO_STL) #define ETL_TIMER_SEMAPHORE_TYPE uint32_t From 0b321d21e8095d357499ccee016d6e21bc712be9 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 29 Jun 2021 20:25:36 +0100 Subject: [PATCH 50/81] Rebase on master --- test/vs2019/etl.vcxproj.filters | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 3953ee0e..7355962b 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -117,6 +117,7 @@ {0e4d2126-b9b7-4eef-b5ca-18363b1e01ce} + {79c578f6-5400-4b4d-b2a4-9a8c589f7c81} @@ -1123,30 +1124,18 @@ ETL\Utilities + ETL\Private ETL\Private - - Header Files - - - ETL\Patterns - ETL\Utilities - - - Header Files - ETL\Patterns - - ETL\Utilities - - - ETL\Experimental + + ETL\Patterns @@ -2575,9 +2564,6 @@ Source Files - - Source Files\Sanity Checks - Source Files From 7f98b3dfc0b87976b6eabcff96a01ae57f4d0b7d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 1 Jul 2021 15:06:43 +0100 Subject: [PATCH 51/81] Changed script log file name. --- test/runtests.sh | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/test/runtests.sh b/test/runtests.sh index e50b6006..09221812 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -2,40 +2,40 @@ #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 +./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 +./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 " 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 +./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 +./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 " Tests Completed" >> log.txt +echo "-----------------------------------------------" >> log.txt From c54bf63a761dee0d56934158f7080f5a5944a7d6 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 11 Jul 2021 20:36:01 +0100 Subject: [PATCH 52/81] Resolved issues with universal references in construction and assignment. Added 'in_place' structures. Added etl::overload. Updated sanity check cmake files. Added alignment for const void. --- include/etl/functional.h | 1 - .../etl/generators/type_traits_generator.h | 1 + include/etl/overload.h | 107 ++- include/etl/private/variant_new.h | 719 ++++++++++++++---- include/etl/type_traits.h | 1 + include/etl/utility.h | 79 +- include/etl/variant.h | 2 +- test/etl_profile.h | 4 +- test/sanity-check/c++03/CMakeLists.txt | 4 +- test/sanity-check/c++11/CMakeLists.txt | 4 +- test/sanity-check/c++14/CMakeLists.txt | 4 +- test/sanity-check/c++17/CMakeLists.txt | 4 +- test/sanity-check/overload.h.t.cpp | 29 + test/sanity-check/variant_legacy.h.t.cpp | 29 + test/sanity-check/variant_new.h.t.cpp | 29 + test/sanity-check/variant_old.h.t.cpp | 29 + test/test_overload.cpp | 164 ++++ test/test_variant_new.cpp | 437 ++++++++--- test/vs2019/etl.vcxproj | 52 ++ test/vs2019/etl.vcxproj.filters | 15 + 20 files changed, 1411 insertions(+), 303 deletions(-) create mode 100644 test/sanity-check/overload.h.t.cpp create mode 100644 test/sanity-check/variant_legacy.h.t.cpp create mode 100644 test/sanity-check/variant_new.h.t.cpp create mode 100644 test/sanity-check/variant_old.h.t.cpp create mode 100644 test/test_overload.cpp 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/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index b2d405fe..3fad300b 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -781,6 +781,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 diff --git a/include/etl/overload.h b/include/etl/overload.h index fb9dd080..52a41fcd 100644 --- a/include/etl/overload.h +++ b/include/etl/overload.h @@ -32,46 +32,23 @@ SOFTWARE. #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_CPP11) +#if ETL_CPP14_SUPPORTED +#if ETL_CPP17_SUPPORTED && !defined(ETL_OVERLOAD_FORCE_CPP14) + //************************************************************************* - /// Variadic template definition of overload. + /// Variadic template definition of overload for C++17 and above. //************************************************************************* - template + template struct overload : TOverloads... { using TOverloads::operator()...; }; - //************************************************************************* - /// Template deduction guide. - //************************************************************************* - template overload(TOverloads...)->overload; - -#else - //************************************************************************* - /// Variadic template definition of overload. - //************************************************************************* - template - struct overload : TOverload, overload - { - using TOverload::operator(); - using overload::operator(); - }; - - //************************************************************************* - /// Template specialisation of overload for one type. - //************************************************************************* - template - struct overload : TOverload - { - using TOverload::operator(); - }; -#endif - //************************************************************************* /// Make an overload. //************************************************************************* @@ -80,7 +57,75 @@ namespace etl { return overload{ etl::forward(overloads)... }; } -} + + //************************************************************************* + /// Template deduction guide. + //************************************************************************* + template overload(TOverloads...)->overload; + +#else + + //************************************************************************* + /// Variadic template definition of overload for C++14. + //************************************************************************* + //namespace private_overload + //{ + // //*********************************** + // // Overload helper templates. + // //*********************************** + // template + // struct overload_helper; + + // template <> + // struct overload_helper<> + // { + // }; + + // template + // struct overload_helper : TFirst, overload_helper + // { + // using TFirst::operator(); + + // template + // overload_helper(UFirst&& u, UOthers&&... others) + // : TFirst{ etl::forward(u) }, overload_helper{ etl::forward(others)... } + // { + // } + // }; + //} + + ////*********************************** + ///// Make an overload. + ////*********************************** + //template + //constexpr auto make_overload(TOverloads&&... overloads) + //{ + // return private_overload::overload_helper{ etl::forward(overloads)... }; + //} + + template + struct overload : TFirst, overload + { + using TFirst::operator(); + using overload::operator(); + }; + + template struct overload : TFirst + { + using TFirst::operator(); + }; + + //************************************************************************* + /// Make an overload. + //************************************************************************* + template + constexpr auto make_overload(TOthers&&... overloads) + { + return overload{ etl::forward(overloads)... }; + } #endif #endif +} + +#endif diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index e11a6e32..41c2570b 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -43,57 +43,19 @@ SOFTWARE. #include "../parameter_pack.h" #include "../placement_new.h" #include "../visitor.h" - -#include +#include "../memory.h" #if defined(ETL_COMPILER_KEIL) #pragma diag_suppress 940 #pragma diag_suppress 111 #endif -namespace etl -{ - //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, integer_sequence> - // { - // typedef integer_sequence type; - // }; - //} - - //template - //using make_index_sequence = typename private_integer_sequence::make_index_sequence>::type; - - //template - //using index_sequence = integer_sequence; -} - +#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. @@ -102,10 +64,95 @@ namespace etl namespace etl { - static_assert(ETL_CPP11_SUPPORTED, "Only supported for C++11 or above"); + 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_v, "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; + }; + } + + /// Definition of variant_npos. constexpr size_t variant_npos = etl::integral_limits::max; + // Forward declarations. + template + class variant; + + template + ETL_CONSTEXPR14 bool holds_alternative(const etl::variant& v) noexcept; + //*************************************************************************** /// Monostate for variants. ///\ingroup variant @@ -142,7 +189,7 @@ namespace etl { 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_) + : variant_exception(ETL_ERROR_TEXT("variant:unsupported type", ETL_VARIANT_FILE_ID"A"), file_name_, line_number_) { } }; @@ -167,9 +214,8 @@ namespace etl // The type of actions we can perform. enum class action_type : char { - Construct, - Destruct, - Move + Create, + Destroy }; // All types of variant are friends. @@ -197,48 +243,113 @@ namespace etl /// The internal storage. /// Aligned on a suitable boundary, which should be good for all types. //*************************************************************************** - typename etl::aligned_storage::type data; + etl::uninitialized_buffer data; //*************************************************************************** /// Default constructor. /// Sets the state of the instance to containing no valid data. //*************************************************************************** - constexpr variant() + ETL_CONSTEXPR14 variant() : data() { - using type = typename etl::parameter_pack::template type_from_index<0>::type; + using type = typename etl::private_variant::parameter_pack::template type_from_index<0>::type; - type temp; - - operation = do_operation; - operation(action_type::Construct, data, &temp); + operation = do_operation_default_construct; + operation(action_type::Create, data, nullptr); type_id = 0; } //*************************************************************************** - /// Constructor for lvalues + /// Constructor from a value. //*************************************************************************** - template - constexpr variant(const T& value) + template , variant>::value, int> = 0> + ETL_CONSTEXPR14 variant(T&& value) : data() - , operation(do_operation) - , type_id(etl::parameter_pack::template index_of_type::value) + , operation(operation_type::value>::do_operation) + , type_id(etl::private_variant::parameter_pack::template index_of_type>::value) { - static_assert(etl::is_one_of::value, "Unsupported type"); + static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); - operation(action_type::Construct, data, &const_cast(value)); + operation(action_type::Create, data, &value); + } + + //*************************************************************************** + /// Construct from arguments. + //*************************************************************************** + template + ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t, TArgs&&... args) + : data() + , type_id(etl::private_variant::parameter_pack::template index_of_type>::value) + { + T temp(std::forward(args)...); + + operation = operation_type::value>::do_operation; + operation(action_type::Create, data, &temp); + } + + //*************************************************************************** + /// Construct from arguments. + //*************************************************************************** + template + ETL_CONSTEXPR14 explicit variant(etl::in_place_index_t, TArgs&&... args) + : data() + { + using type = private_variant::parameter_pack::type_from_index_t; + + type temp(std::forward(args)...); + + operation = operation_type::value>::do_operation; + operation(action_type::Create, data, &temp); + + type_id = Index; } //*************************************************************************** /// Copy constructor. ///\param other The other variant object to copy. //*************************************************************************** - constexpr variant(const variant& other) + ETL_CONSTEXPR14 variant(const variant& other) : data() , operation(other.operation) , type_id(other.type_id) { - operation(action_type::Construct, data, other.data); + if (this != &other) + { + if (other.index() == variant_npos) + { + type_id = variant_npos; + } + else + { + operation(action_type::Create, 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(action_type::Create, data, other.data); + } + } + else + { + type_id = variant_npos; + } } //*************************************************************************** @@ -246,9 +357,12 @@ namespace etl //*************************************************************************** ~variant() { - operation(action_type::Destruct, data, nullptr); - operation = null_operation; + if (index() != variant_npos) + { + operation(action_type::Destroy, data, nullptr); + } + operation = null_operation; type_id = variant_npos; } @@ -260,33 +374,32 @@ namespace etl { static_assert(etl::is_one_of::value, "Unsupported type"); - operation(action_type::Destruct, data, nullptr); - - operation = do_operation; - + operation(action_type::Destroy, data, nullptr); + T temp(etl::forward(args)...); - operation(action_type::Construct, data, &temp); + operation = operation_type::value>::do_operation; + operation(action_type::Create, data, &temp); - type_id = etl::parameter_pack::template index_of_type::value; + type_id = etl::private_variant::parameter_pack::template index_of_type::value; return *static_cast(data); } //*************************************************************************** - /// Assignment operator for type. + /// Move assignment operator for type. ///\param value The value to assign. //*************************************************************************** - template - variant& operator =(const T& value) + template , variant>, int> = 0> + variant& operator =(T&& value) { - static_assert(etl::is_one_of::value, "Unsupported type"); + static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); - operation(action_type::Destruct, data, nullptr); + operation(action_type::Destroy, data, nullptr); - operation = do_operation; - operation(action_type::Construct, data, &value); + operation = operation_type::value>::do_operation; + operation(action_type::Create, data, &value); - type_id = etl::parameter_pack::template index_of_type::value; + type_id = etl::private_variant::parameter_pack::template index_of_type::value; return *this; } @@ -299,12 +412,45 @@ namespace etl { if (this != &other) { - operation(action_type::Destruct, data, nullptr); + if (other.index() == variant_npos) + { + type_id = variant_npos; + } + else + { + operation(action_type::Destroy, data, nullptr); - operation = other.operation; - operation(action_type::Construct, data, other.data); + operation = other.operation; + operation(action_type::Create, data, other.data); - type_id = other.type_id; + 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(action_type::Destroy, data, nullptr); + + operation = other.operation; + operation(action_type::Create, data, other.data); + + type_id = other.type_id; + } } return *this; @@ -316,7 +462,7 @@ namespace etl //*************************************************************************** constexpr bool valueless_by_exception() const noexcept { - return type_id != variant_npos; + return type_id == variant_npos; } //*************************************************************************** @@ -337,41 +483,17 @@ namespace etl rhs = temp; } - //*************************************************************************** - /// 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() - { - static_assert(etl::is_one_of::value, "Unsupported type"); - ETL_ASSERT(etl::holds_alternative(*this), 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 - { - static_assert(etl::is_one_of::value, "Unsupported type"); - ETL_ASSERT(is_type(), ETL_ERROR(variant_incorrect_type_exception)); - - return static_cast(data); - } - //*************************************************************************** /// Accept an etl::visitor. //*************************************************************************** template void accept(etl::visitor& v) { - do_accept(v, std::make_index_sequence{}); +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) + do_accept(v, etl::make_index_sequence{}); +#else + do_accept(v); +#endif } //*************************************************************************** @@ -380,48 +502,168 @@ namespace etl template void operator()(TVisitor& v) { - do_operator(v, std::make_index_sequence{}); +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) + do_operator(v, etl::make_index_sequence{}); +#else + do_operator(v); +#endif } private: - using operation_type = void(*)(action_type, void*, const void*); + using operation_function = void(*)(action_type, void*, const void*); //*************************************************************************** /// Do an operation determined by type. //*************************************************************************** - template - static void do_operation(action_type action, void* pstorage, const void* pvalue) + template + static void do_operation_default_construct(action_type action, void* pstorage, const void* pvalue) { switch (action) { - case action_type::Construct: - { - ::new (pstorage) T(*reinterpret_cast(pvalue)); - break; - } + case action_type::Create: + { + ::new (pstorage) T(); + break; + } - case action_type::Destruct: - { - reinterpret_cast(pstorage)->~T(); - break; - } + case action_type::Destroy: + { + reinterpret_cast(pstorage)->~T(); + break; + } - default: - { - break; - } + default: + { + break; + } } } + // Declaration. + template + struct operation_type; + + // Specialisation for lvalue rreferences + template + struct operation_type + { + static void do_operation(variant::action_type action, void* pstorage, const void* pvalue) + { + using type = etl::remove_reference_t; + + switch (action) + { + case variant::action_type::Create: + { + ::new (pstorage) type(*reinterpret_cast(pvalue)); + break; + } + + case variant::action_type::Destroy: + { + reinterpret_cast(pstorage)->~type(); + break; + } + + default: + { + break; + } + } + } + }; + + // Specialisation for rvalue rreferences + template + struct operation_type + { + static void do_operation(variant::action_type action, void* pstorage, const void* pvalue) + { + using type = etl::remove_reference_t; + + switch (action) + { + case variant::action_type::Create: + { + ::new (pstorage) type(etl::move(*reinterpret_cast(const_cast(pvalue)))); + break; + } + + case variant::action_type::Destroy: + { + reinterpret_cast(pstorage)->~type(); + break; + } + + default: + { + break; + } + } + } + }; + +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) //*************************************************************************** - /// Loop through the types until a match is found. + /// Call the relevent visitor by attemptng each one. //*************************************************************************** template - void do_accept(TVisitor& visitor, std::index_sequence) + void do_accept(TVisitor& visitor, etl::index_sequence) { (attempt_visitor(visitor) || ...); } +#else + //*************************************************************************** + /// /// Call the relevent visitor. + //*************************************************************************** + template + void do_accept(TVisitor& 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. @@ -440,14 +682,78 @@ namespace etl } } +#if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) //*************************************************************************** - /// Loop through the types until a match is found. + /// Call the relevent visitor by attemptng each one. //*************************************************************************** template - void do_operator(TVisitor& visitor, std::index_sequence) + 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, "???"); +#endif + +#if defined(ETL_VARIANT_CPP11_MAX_16_TYPES) + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 16U, "???"); +#endif + +#if defined(ETL_VARIANT_CPP11_MAX_24_TYPES) + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 24U, "???"); +#endif + + 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. @@ -477,7 +783,7 @@ namespace etl //*************************************************************************** /// The operation function. //*************************************************************************** - operation_type operation; + operation_function operation; //*************************************************************************** /// The id of the current stored type. @@ -489,9 +795,9 @@ namespace etl /// Checks if the variant v holds the alternative T. //*************************************************************************** template - constexpr bool holds_alternative(const etl::variant& v) noexcept + ETL_CONSTEXPR14 bool holds_alternative(const etl::variant& v) noexcept { - constexpr size_t Index = etl::parameter_pack::template index_of_type::value; + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; return (Index == variant_npos) ? false : (v.index() == Index); } @@ -505,7 +811,7 @@ namespace etl template struct variant_alternative> { - using type = typename etl::parameter_pack::template type_from_index::type; + using type = typename etl::private_variant::parameter_pack::template type_from_index::type; }; template @@ -521,10 +827,13 @@ namespace etl /// get //*************************************************************************** template - constexpr etl::variant_alternative_t>& + ETL_CONSTEXPR14 etl::variant_alternative_t>& get(etl::variant& v) { - //static_assert(Index < sizeof...(TTypes), "Index out of range"); +#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>; @@ -534,10 +843,12 @@ namespace etl //*********************************** template - constexpr etl::variant_alternative_t>&& + 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>; @@ -546,10 +857,13 @@ namespace etl //*********************************** template - constexpr const etl::variant_alternative_t>& + 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>; @@ -559,10 +873,13 @@ namespace etl //*********************************** template - constexpr const etl::variant_alternative_t>&& + 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>; @@ -572,45 +889,45 @@ namespace etl //*********************************** template - constexpr T& get(etl::variant& v) + ETL_CONSTEXPR14 T& get(etl::variant& v) { - constexpr size_t Index = etl::parameter_pack::template index_of_type::value; + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; return get(v); } //*********************************** template - constexpr T&& get(etl::variant&& v) + ETL_CONSTEXPR14 T&& get(etl::variant&& v) { - constexpr size_t Index = etl::parameter_pack::template index_of_type::value; + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; return get(v); } //*********************************** template - constexpr const T& get(const etl::variant& v) + ETL_CONSTEXPR14 const T& get(const etl::variant& v) { - constexpr size_t Index = etl::parameter_pack::template index_of_type::value; + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; return get(v); } //*********************************** template - constexpr const T&& get(const etl::variant&& v) + ETL_CONSTEXPR14 const T&& get(const etl::variant&& v) { - constexpr size_t Index = etl::parameter_pack::template index_of_type::value; + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; return get(v); } //*************************************************************************** - /// get_if + /// get_if (pointer parameter) //*************************************************************************** template < size_t Index, typename... TTypes > - constexpr etl::add_pointer_t>> + ETL_CONSTEXPR14 etl::add_pointer_t>> get_if(etl::variant* pv) noexcept { if ((pv != nullptr) && (pv->index() == Index)) @@ -625,7 +942,7 @@ namespace etl //*********************************** template< size_t Index, typename... TTypes > - constexpr etl::add_pointer_t>> + ETL_CONSTEXPR14 etl::add_pointer_t>> get_if(const etl::variant* pv) noexcept { if ((pv != nullptr) && (pv->index() == Index)) @@ -640,22 +957,96 @@ namespace etl //*********************************** template< class T, typename... TTypes > - constexpr etl::add_pointer_t get_if(etl::variant* pv) noexcept + ETL_CONSTEXPR14 etl::add_pointer_t get_if(etl::variant* pv) noexcept { - constexpr size_t Index = etl::parameter_pack::template index_of_type::value; + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; return etl::get_if(pv); } //*********************************** template< class T, typename... TTypes > - constexpr etl::add_pointer_t get_if(const etl::variant* pv) noexcept + ETL_CONSTEXPR14 etl::add_pointer_t get_if(const etl::variant* pv) noexcept { - constexpr size_t Index = etl::parameter_pack::template index_of_type::value; + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; return etl::get_if(pv); } + //*************************************************************************** + /// get_if (reference parameter) + //*************************************************************************** + template < size_t Index, typename... TTypes > + ETL_CONSTEXPR14 etl::add_pointer_t>> + get_if(etl::variant& v) noexcept + { + if (v.index() == Index) + { + return &etl::get(v); + } + else + { + return nullptr; + } + } + + //*********************************** + template< size_t Index, typename... TTypes > + ETL_CONSTEXPR14 etl::add_pointer_t>> + get_if(const etl::variant& v) noexcept + { + if (v.index() == Index) + { + return &etl::get(v); + } + else + { + return nullptr; + } + } + + //*********************************** + template< size_t Index, typename... TTypes > + ETL_CONSTEXPR14 etl::add_pointer_t>> + get_if(etl::variant&& v) noexcept + { + if (v.index() == Index) + { + return &etl::get(v); + } + else + { + return nullptr; + } + } + + //*********************************** + template< class T, typename... TTypes > + ETL_CONSTEXPR14 etl::add_pointer_t get_if(etl::variant& v) noexcept + { + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; + + return etl::get_if(v); + } + + //*********************************** + template< class T, typename... TTypes > + ETL_CONSTEXPR14 etl::add_pointer_t get_if(const etl::variant& v) noexcept + { + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; + + return etl::get_if(v); + } + + //*********************************** + template< class T, typename... TTypes > + ETL_CONSTEXPR14 etl::add_pointer_t get_if(etl::variant&& v) noexcept + { + constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; + + return etl::get_if(v); + } + //*************************************************************************** /// swap //*************************************************************************** @@ -682,4 +1073,10 @@ namespace etl : 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..b12d08e2 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -769,6 +769,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 diff --git a/include/etl/utility.h b/include/etl/utility.h index 62d4237d..a8af74f9 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,36 @@ namespace etl T x; T y; }; + + //*************************************************************************** + /// in_place disambiguation tags. + //*************************************************************************** + + //************************* + struct in_place_t + { + explicit ETL_CONSTEXPR in_place_t() {} + }; + + inline ETL_CONSTEXPR in_place_t in_place{}; + + //************************* + template struct in_place_type_t + { + explicit ETL_CONSTEXPR in_place_type_t(){}; + }; + + template + inline ETL_CONSTEXPR in_place_type_t in_place_type{}; + + //************************* + template struct in_place_index_t + { + explicit ETL_CONSTEXPR in_place_index_t() {} + }; + + template + inline ETL_CONSTEXPR in_place_index_t in_place_index{}; } #endif diff --git a/include/etl/variant.h b/include/etl/variant.h index 8702eeed..7e4a20e6 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -31,7 +31,7 @@ SOFTWARE. #ifndef ETL_VARIANT_INCLUDED #define ETL_VARIANT_INCLUDED -#if 1 //ETL_USE_LEGACY_VARIANT +#if ETL_USE_LEGACY_VARIANT #include "private/variant_legacy.h" #else #include "private/variant_new.h" diff --git a/test/etl_profile.h b/test/etl_profile.h index 3212f83b..b3b01bf7 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -98,7 +98,9 @@ SOFTWARE. #define ETL_MEM_CAST_FORCE_CPP03 #endif -//#define ETL_OVERLOAD_FORCE_CPP11 +#define ETL_OVERLOAD_FORCE_CPP14 +#define ETL_VARIANT_FORCE_CPP11 +#define ETL_VARIANT_CPP11_MAX_16_TYPES #if defined(ETL_NO_STL) #define ETL_TIMER_SEMAPHORE_TYPE uint32_t diff --git a/test/sanity-check/c++03/CMakeLists.txt b/test/sanity-check/c++03/CMakeLists.txt index dea14a49..9361a7c5 100644 --- a/test/sanity-check/c++03/CMakeLists.txt +++ b/test/sanity-check/c++03/CMakeLists.txt @@ -173,6 +173,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 @@ -242,7 +243,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_new.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 09193372..89342ec0 100644 --- a/test/sanity-check/c++11/CMakeLists.txt +++ b/test/sanity-check/c++11/CMakeLists.txt @@ -173,6 +173,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 @@ -242,7 +243,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_new.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 e514d386..65dcab43 100644 --- a/test/sanity-check/c++14/CMakeLists.txt +++ b/test/sanity-check/c++14/CMakeLists.txt @@ -173,6 +173,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 @@ -242,7 +243,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_new.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 dd6b754a..4e691395 100644 --- a/test/sanity-check/c++17/CMakeLists.txt +++ b/test/sanity-check/c++17/CMakeLists.txt @@ -173,6 +173,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 @@ -242,7 +243,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_new.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_new.h.t.cpp b/test/sanity-check/variant_new.h.t.cpp new file mode 100644 index 00000000..62b5bea7 --- /dev/null +++ b/test/sanity-check/variant_new.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/test_overload.cpp b/test/test_overload.cpp new file mode 100644 index 00000000..31d8389f --- /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_variant_new.cpp b/test/test_variant_new.cpp index e19a74bc..db279ece 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -36,11 +36,13 @@ SOFTWARE. #include #include #include +#include namespace { - // Test variant types. - typedef etl::variant test_variant_3; + // Test variant_etl types. + using test_variant_etl_3 = etl::variant; + using test_variant_std_3 = std::variant; struct D1 { @@ -162,6 +164,67 @@ namespace typedef etl::variant test_variant_emplace; + //********************************************* + struct Copyable + { + Copyable() + : copied_from(false) + , copied_to(false) + { + } + + Copyable(const Copyable& other) noexcept + { + copied_to = true; + copied_from = false; + } + + Copyable& operator =(const Copyable& rhs) noexcept + { + copied_to = true; + copied_from = false; + + return *this; + } + + bool copied_from; + bool copied_to; + }; + + //********************************************* + struct Moveable + { + Moveable() + : moved_from(false) + , moved_to(false) + { + } + + Moveable(Moveable&& other) noexcept + { + moved_to = true; + moved_from = false; + other.moved_to = false; + other.moved_from = true; + } + + Moveable& operator =(Moveable&& rhs) noexcept + { + moved_to = true; + moved_from = false; + rhs.moved_to = false; + rhs.moved_from = true; + + return *this; + } + + Moveable(const Moveable& other) = delete; + Moveable& operator =(const Moveable& rhs) = delete; + + bool moved_from; + bool moved_to; + }; + SUITE(test_variant) { TEST(test_alignment) @@ -176,20 +239,20 @@ namespace static test_variant_c c(3); static test_variant_d d(4.5); - CHECK((uintptr_t(&a.get()) % uintptr_t(etl::alignment_of::value)) == 0); - CHECK((uintptr_t(&b.get()) % uintptr_t(etl::alignment_of::value)) == 0); - CHECK((uintptr_t(&c.get()) % uintptr_t(etl::alignment_of::value)) == 0); - CHECK((uintptr_t(&d.get()) % uintptr_t(etl::alignment_of::value)) == 0); + 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_3 variant); + CHECK_NO_THROW(test_variant_etl_3 variant_etl); - test_variant_3 variant; + test_variant_etl_3 variant_etl; - CHECK(etl::holds_alternative(variant)); + CHECK(etl::holds_alternative(variant_etl)); } //************************************************************************* @@ -197,24 +260,24 @@ namespace { // Char. char c = 'a'; - test_variant_3 variant_char(c); - - CHECK(etl::holds_alternative(variant_char)); - CHECK_EQUAL(c, etl::get(variant_char)); + 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_3 variant_int(i); - - CHECK(etl::holds_alternative(variant_int)); - CHECK_EQUAL(i, etl::get(variant_int)); + 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_3 variant_text(text); - - CHECK(etl::holds_alternative(variant_text)); - CHECK_EQUAL(text, etl::get(variant_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)); } //************************************************************************* @@ -222,72 +285,122 @@ namespace { // Char. char c = 'a'; - test_variant_3 variant_char(etl::move(c)); - - CHECK(etl::holds_alternative(variant_char)); - CHECK_EQUAL(c, etl::get(variant_char)); + 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_3 variant_int(etl::move(i)); - - CHECK(etl::holds_alternative(variant_int)); - CHECK_EQUAL(i, etl::get(variant_int)); + 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_3 variant_text(etl::move(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)); + } - CHECK(etl::holds_alternative(variant_text)); - CHECK_EQUAL(text, etl::get(variant_text)); + //************************************************************************* + 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_3 variant_1(text); + test_variant_etl_3 variant_1_etl(text); - test_variant_3 variant_2(variant_1); + test_variant_etl_3 variant_2_etl(variant_1_etl); - CHECK_EQUAL(variant_1.index(), variant_2.index()); - CHECK_EQUAL(variant_1.get(), variant_2.get()); + 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) + { + std::string text("Some Text"); + 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_3 variant_1(text); + test_variant_etl_3 variant_1_etl(text); - test_variant_3 variant_2(etl::move(variant_1)); + test_variant_etl_3 variant_2_etl(etl::move(variant_1_etl)); - CHECK_EQUAL(variant_1.index(), variant_2.index()); - CHECK_EQUAL(variant_1.get(), variant_2.get()); + CHECK_EQUAL(variant_1_etl.index(), variant_2_etl.index()); + CHECK_EQUAL(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_3 variant; + test_variant_etl_3 variant_etl; - variant = text; + variant_etl = text; - CHECK_EQUAL(text, variant.get()); + CHECK_EQUAL(text, etl::get(variant_etl)); } //************************************************************************* TEST(test_assign_from_variant) { std::string text("Some Text"); - test_variant_3 variant_1; - test_variant_3 variant_2; + test_variant_etl_3 variant_1_etl; + test_variant_etl_3 variant_2_etl; - variant_1 = text; - variant_2 = variant_1; + variant_1_etl = text; + variant_2_etl = variant_1_etl; - CHECK_EQUAL(text, variant_2.get()); + CHECK_EQUAL(text, etl::get(variant_2_etl)); } //************************************************************************* @@ -295,36 +408,36 @@ namespace { std::string text("Some Text"); int integer(99); - test_variant_3 variant_1; - test_variant_3 variant_2; + test_variant_etl_3 variant_1_etl; + test_variant_etl_3 variant_2_etl; - variant_1 = text; - variant_2 = integer; - variant_2 = variant_1; + variant_1_etl = text; + variant_2_etl = integer; + variant_2_etl = variant_1_etl; - CHECK_EQUAL(text, variant_2.get()); + CHECK_EQUAL(text, etl::get(variant_2_etl)); } //************************************************************************* TEST(test_assignment_incorrect_type_exception) { std::string text("Some Text"); - test_variant_3 variant(text); + test_variant_etl_3 variant_etl(text); int i; - CHECK_THROW(etl::get(variant), etl::variant_incorrect_type_exception); + CHECK_THROW(etl::get(variant_etl), etl::variant_incorrect_type_exception); (void)i; } //************************************************************************* TEST(test_self_assignment) { - test_variant_3 variant; + test_variant_etl_3 variant_etl; - variant = 1; - variant = variant; + variant_etl = 1; + variant_etl = variant_etl; - CHECK_EQUAL(1, etl::get(variant)); + CHECK_EQUAL(1, etl::get(variant_etl)); } //************************************************************************* @@ -332,16 +445,16 @@ namespace { std::string text("Some Text"); int integer(99); - test_variant_3 variant_1(text); - test_variant_3 variant_2(integer); + test_variant_etl_3 variant_1_etl(text); + test_variant_etl_3 variant_2_etl(integer); - variant_1.swap(variant_2); + variant_1_etl.swap(variant_2_etl); - CHECK(etl::holds_alternative(variant_1)); - CHECK_EQUAL(integer, etl::get(variant_1)); + CHECK(etl::holds_alternative(variant_1_etl)); + CHECK_EQUAL(integer, etl::get(variant_1_etl)); - CHECK(etl::holds_alternative(variant_2)); - CHECK_EQUAL(text, etl::get(variant_2)); + CHECK(etl::holds_alternative(variant_2_etl)); + CHECK_EQUAL(text, etl::get(variant_2_etl)); } //************************************************************************* @@ -349,38 +462,38 @@ namespace { std::string text("Some Text"); int integer(99); - test_variant_3 variant_1(text); - test_variant_3 variant_2(integer); + test_variant_etl_3 variant_1_etl(text); + test_variant_etl_3 variant_2_etl(integer); - etl::swap(variant_1, variant_2); + etl::swap(variant_1_etl, variant_2_etl); - CHECK(etl::holds_alternative(variant_1)); - CHECK_EQUAL(integer, etl::get(variant_1)); + CHECK(etl::holds_alternative(variant_1_etl)); + CHECK_EQUAL(integer, etl::get(variant_1_etl)); - CHECK(etl::holds_alternative(variant_2)); - CHECK_EQUAL(text, etl::get(variant_2)); + CHECK(etl::holds_alternative(variant_2_etl)); + CHECK_EQUAL(text, etl::get(variant_2_etl)); } //************************************************************************* TEST(test_emplace) { - test_variant_emplace variant; + test_variant_emplace variant_etl; - variant.emplace("1"); - CHECK(etl::holds_alternative(variant)); - CHECK_EQUAL(D1("1"), etl::get(variant)); + variant_etl.emplace("1"); + CHECK(etl::holds_alternative(variant_etl)); + CHECK_EQUAL(D1("1"), etl::get(variant_etl)); - variant.emplace("1", "2"); - CHECK(etl::holds_alternative(variant)); - CHECK_EQUAL(D2("1", "2"), etl::get(variant)); + variant_etl.emplace("1", "2"); + CHECK(etl::holds_alternative(variant_etl)); + CHECK_EQUAL(D2("1", "2"), etl::get(variant_etl)); - variant.emplace("1", "2", "3"); - CHECK(etl::holds_alternative(variant)); - CHECK_EQUAL(D3("1", "2", "3"), etl::get(variant)); + variant_etl.emplace("1", "2", "3"); + CHECK(etl::holds_alternative(variant_etl)); + CHECK_EQUAL(D3("1", "2", "3"), etl::get(variant_etl)); - variant.emplace("1", "2", "3", "4"); - CHECK(etl::holds_alternative(variant)); - CHECK_EQUAL(D4("1", "2", "3", "4"), etl::get(variant)); + variant_etl.emplace("1", "2", "3", "4"); + CHECK(etl::holds_alternative(variant_etl)); + CHECK_EQUAL(D4("1", "2", "3", "4"), etl::get(variant_etl)); } //************************************************************************* @@ -393,9 +506,9 @@ namespace { D1 da("1"); - test_variant_emplace variant(etl::move(getD1())); + test_variant_emplace variant_etl(etl::move(getD1())); - D1 db = etl::move(etl::get(variant)); + D1 db = etl::move(etl::get(variant_etl)); } //************************************************************************* @@ -432,18 +545,18 @@ namespace Visitor visitor; - test_variant_3 variant; + test_variant_etl_3 variant_etl; - variant = char(1); - variant.accept(visitor); + variant_etl = char(1); + variant_etl.accept(visitor); CHECK_EQUAL(1, visitor.result_c); - variant = int(2); - variant.accept(visitor); + variant_etl = int(2); + variant_etl.accept(visitor); CHECK_EQUAL(2, visitor.result_i); - variant = std::string("3"); - variant.accept(visitor); + variant_etl = std::string("3"); + variant_etl.accept(visitor); CHECK_EQUAL("3", visitor.result_s); } @@ -481,19 +594,137 @@ namespace Visitor visitor; - test_variant_3 variant; + test_variant_etl_3 variant_etl; - variant = char(1); - variant(visitor); + variant_etl = char(1); + variant_etl(visitor); CHECK_EQUAL(1, visitor.result_c); - variant = int(2); - variant(visitor); + variant_etl = int(2); + variant_etl(visitor); CHECK_EQUAL(2, visitor.result_i); - variant = std::string("3"); - variant(visitor); + variant_etl = std::string("3"); + variant_etl(visitor); CHECK_EQUAL("3", visitor.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<0>(variant_etl) != nullptr); + CHECK(etl::get_if<1>(&variant_etl) == nullptr); + CHECK(etl::get_if<1>(variant_etl) == nullptr); + CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); + CHECK(etl::get_if<1>(&variant_etl) != nullptr); + CHECK(etl::get_if<1>(variant_etl) != nullptr); + CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); + CHECK(etl::get_if<1>(&variant_etl) == nullptr); + CHECK(etl::get_if<1>(variant_etl) == nullptr); + CHECK(etl::get_if<2>(&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); + 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); + 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); + 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; + std::variant variant_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); + + 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); + } + + //************************************************************************* + 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.copied_from, from_etl.copied_from); + 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.copied_from, to_etl.copied_from); + CHECK_EQUAL(to_std.copied_to, to_etl.copied_to); + } }; } diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 809344d5..dd638032 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -3477,6 +3477,23 @@ true true + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true true @@ -4353,6 +4370,40 @@ true true + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true true @@ -4887,6 +4938,7 @@ false + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 7355962b..d5ee5e95 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1137,6 +1137,9 @@ ETL\Patterns + + Header Files + @@ -2576,6 +2579,18 @@ Source Files\Sanity Checks + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files + From 197f65c5da3ab54baa4b1e0387ee7feff72d1918 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 12 Jul 2021 00:51:53 +0100 Subject: [PATCH 53/81] Compiler compatibility updates --- include/etl/private/variant_new.h | 6 +++--- include/etl/utility.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 41c2570b..88fed728 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -103,7 +103,7 @@ namespace etl public: - static_assert(etl::is_one_of_v, "T is not in parameter pack"); + 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; @@ -294,7 +294,7 @@ namespace etl ETL_CONSTEXPR14 explicit variant(etl::in_place_index_t, TArgs&&... args) : data() { - using type = private_variant::parameter_pack::type_from_index_t; + using type = typename private_variant::parameter_pack:: template type_from_index_t; type temp(std::forward(args)...); @@ -389,7 +389,7 @@ namespace etl /// Move assignment operator for type. ///\param value The value to assign. //*************************************************************************** - template , variant>, int> = 0> + template , variant>::value, int> = 0> variant& operator =(T&& value) { static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); diff --git a/include/etl/utility.h b/include/etl/utility.h index a8af74f9..adee90d8 100644 --- a/include/etl/utility.h +++ b/include/etl/utility.h @@ -420,7 +420,7 @@ namespace etl explicit ETL_CONSTEXPR in_place_t() {} }; - inline ETL_CONSTEXPR in_place_t in_place{}; + inline ETL_CONSTANT in_place_t in_place; //************************* template struct in_place_type_t @@ -429,7 +429,7 @@ namespace etl }; template - inline ETL_CONSTEXPR in_place_type_t in_place_type{}; + inline ETL_CONSTANT in_place_type_t in_place_type; //************************* template struct in_place_index_t @@ -438,7 +438,7 @@ namespace etl }; template - inline ETL_CONSTEXPR in_place_index_t in_place_index{}; + inline ETL_CONSTANT in_place_index_t in_place_index; } #endif From 590b26e5137d0bfa2be3f7a9d41672ba304c64ff Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 12 Jul 2021 16:26:50 +0100 Subject: [PATCH 54/81] Added conjunction and disjunction --- include/etl/type_traits.h | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index b12d08e2..a213149c 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -492,6 +492,11 @@ namespace etl 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; }; @@ -1211,6 +1216,11 @@ namespace etl 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 @@ -1356,6 +1366,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 @@ -1612,6 +1623,53 @@ namespace etl 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 } #endif // ETL_TYPE_TRAITS_INCLUDED From 109997b8d6c09131bd721268c361ddeaa4ecc4b9 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 13 Jul 2021 17:15:25 +0100 Subject: [PATCH 55/81] Work in progress --- include/etl/circular_buffer.h | 4 + include/etl/delegate.h | 6 +- include/etl/parameter_pack.h | 8 + include/etl/private/variant_new.h | 366 +++++++--- test/CMakeLists.txt | 3 +- test/runsanitychecks.sh | 32 +- test/test_parameter_pack.cpp | 16 +- test/test_variant_new.cpp | 1098 ++++++++++++++++------------- 8 files changed, 951 insertions(+), 582 deletions(-) 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/parameter_pack.h b/include/etl/parameter_pack.h index 577f95c3..43942a9b 100644 --- a/include/etl/parameter_pack.h +++ b/include/etl/parameter_pack.h @@ -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_new.h b/include/etl/private/variant_new.h index 88fed728..bb6c873b 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -50,6 +50,9 @@ SOFTWARE. #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) @@ -141,6 +144,88 @@ namespace etl template using type_from_index_t = typename type_from_index::type; }; + + + + struct operation_type + { + virtual void move(int action, char* pstorage, const char* pvalue) = 0; + virtual void copy(int action, char* pstorage, const char* pvalue) = 0; + }; + + template + struct operations; + + template + struct operations : public operation_type + { + using type = etl::remove_reference_t; + + void move(int action, char* pstorage, const char* pvalue) override + { + switch (action) + { + case 1: + { + reinterpret_cast(pstorage)->~type(); + break; + } + + default: + { + break; + } + } + } + }; + template + typename etl::enable_if_t>::value, void> + + { + using type = etl::remove_reference_t; + + switch (action) + { + case variant::action_type::Create: + { + ::new (pstorage) type(etl::move(*reinterpret_cast(const_cast(pvalue)))); + break; + } + + case variant::action_type::Destroy: + { + reinterpret_cast(pstorage)->~type(); + break; + } + + default: + { + break; + } + } + } + + template + typename etl::enable_if_t>::value, void> + move(variant::action_type action, char* pstorage, const char* pvalue) + { + using type = etl::remove_reference_t; + + switch (action) + { + case variant::action_type::Destroy: + { + reinterpret_cast(pstorage)->~type(); + break; + } + + default: + { + break; + } + } + } + }; } /// Definition of variant_npos. @@ -212,7 +297,7 @@ namespace etl private: // The type of actions we can perform. - enum class action_type : char + enum class action_type { Create, Destroy @@ -252,11 +337,12 @@ namespace etl ETL_CONSTEXPR14 variant() : data() { - using type = typename etl::private_variant::parameter_pack::template type_from_index<0>::type; + using type = typename etl::private_variant::parameter_pack::template type_from_index<0U>::type; - operation = do_operation_default_construct; - operation(action_type::Create, data, nullptr); - type_id = 0; + default_construct_in_place(data); + operation_move = operation_type_move::value>::do_operation; + operation_copy = operation_type_copy::value>::do_operation; + type_id = 0U; } //*************************************************************************** @@ -265,12 +351,20 @@ namespace etl template , variant>::value, int> = 0> ETL_CONSTEXPR14 variant(T&& value) : data() - , operation(operation_type::value>::do_operation) + , operation_move(operation_type_move>::value>::do_operation) + , operation_copy(operation_type_copy>::value>::do_operation) , type_id(etl::private_variant::parameter_pack::template index_of_type>::value) { + bool bc = etl::is_copy_constructible>::value; + bool bm = etl::is_move_constructible>::value; + + etl::remove_reference_t t; + + size_t s = sizeof(operation_move); + static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); - operation(action_type::Create, data, &value); + construct_in_place>(data, std::forward(value)); } //*************************************************************************** @@ -281,10 +375,10 @@ namespace etl : data() , type_id(etl::private_variant::parameter_pack::template index_of_type>::value) { - T temp(std::forward(args)...); + construct_in_place>(data, std::forward(args)...); - operation = operation_type::value>::do_operation; - operation(action_type::Create, data, &temp); + operation_move = operation_type_move>::value>::do_operation; + operation_copy = operation_type_copy>::value>::do_operation; } //*************************************************************************** @@ -293,24 +387,59 @@ namespace etl 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; - type temp(std::forward(args)...); + construct_in_place>(data, std::forward(args)...); - operation = operation_type::value>::do_operation; - operation(action_type::Create, data, &temp); - - type_id = Index; + operation_move = operation_type_move>::value>::do_operation; + operation_copy = operation_type_copy>::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() + , type_id(private_variant::parameter_pack:: template index_of_type>::value) + { + construct_in_place>(data, std::forward(args)...); + + operation_move = operation_type_move>::value>::do_operation; + operation_copy = operation_type_copy>::value>::do_operation; + operation(action_type::Create, data, reinterpret_cast(&temp)); + } + + //*************************************************************************** + /// 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; + + construct_in_place>(data, std::forward(args)...); + + type temp(args...); + + operation_move = operation_type_move>::value>::do_operation; + operation_copy = operation_type_copy>::value>::do_operation; + } +#endif + //*************************************************************************** /// Copy constructor. ///\param other The other variant object to copy. //*************************************************************************** ETL_CONSTEXPR14 variant(const variant& other) : data() - , operation(other.operation) + , operation_move(other.operation_move) + , operation_copy(other.operation_copy) , type_id(other.type_id) { if (this != &other) @@ -321,7 +450,7 @@ namespace etl } else { - operation(action_type::Create, data, other.data); + operation_copy(action_type::Create, data, other.data); } } } @@ -332,7 +461,8 @@ namespace etl //*************************************************************************** ETL_CONSTEXPR14 variant(variant&& other) : data() - , operation(other.operation) + , operation_move(other.operation_move) + , operation_copy(other.operation_copy) , type_id(other.type_id) { if (this != &other) @@ -343,7 +473,7 @@ namespace etl } else { - operation(action_type::Create, data, other.data); + operation_move(action_type::Create, data, other.data); } } else @@ -359,10 +489,11 @@ namespace etl { if (index() != variant_npos) { - operation(action_type::Destroy, data, nullptr); + operation_move(action_type::Destroy, data, nullptr); } - operation = null_operation; + operation_move = null_operation; + operation_copy = null_operation; type_id = variant_npos; } @@ -372,15 +503,16 @@ namespace etl template T& emplace(TArgs&&... args) { - static_assert(etl::is_one_of::value, "Unsupported type"); + //static_assert(etl::is_one_of::value, "Unsupported type"); - operation(action_type::Destroy, data, nullptr); + //operation_move(action_type::Destroy, data, nullptr); - T temp(etl::forward(args)...); - operation = operation_type::value>::do_operation; - operation(action_type::Create, data, &temp); + //construct_in_place>(data, std::forward(args)...); - type_id = etl::private_variant::parameter_pack::template index_of_type::value; + //operation_move = operation_type_move>::value>::do_operation; + //operation_copy = operation_type_copy>::value>::do_operation; + // + //type_id = etl::private_variant::parameter_pack::template index_of_type::value; return *static_cast(data); } @@ -394,10 +526,12 @@ namespace etl { static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); - operation(action_type::Destroy, data, nullptr); + operation_move(action_type::Destroy, data, nullptr); - operation = operation_type::value>::do_operation; - operation(action_type::Create, data, &value); + construct_in_place>(data, std::forward(value)); + + operation_move = operation_type_move>::value>::do_operation; + operation_copy = operation_type_copy>::value>::do_operation; type_id = etl::private_variant::parameter_pack::template index_of_type::value; @@ -418,10 +552,11 @@ namespace etl } else { - operation(action_type::Destroy, data, nullptr); + operation_copy(action_type::Destroy, data, nullptr); - operation = other.operation; - operation(action_type::Create, data, other.data); + operation_move = other.operation_move; + operation_copy = other.operation_copy; + operation_copy(action_type::Create, data, other.data); type_id = other.type_id; } @@ -444,10 +579,11 @@ namespace etl } else { - operation(action_type::Destroy, data, nullptr); + operation_move(action_type::Destroy, data, nullptr); - operation = other.operation; - operation(action_type::Create, data, other.data); + operation_move = other.operation_move; + operation_copy = other.operation_copy; + operation_move(action_type::Create, data, other.data); type_id = other.type_id; } @@ -486,8 +622,7 @@ namespace etl //*************************************************************************** /// Accept an etl::visitor. //*************************************************************************** - template - void accept(etl::visitor& v) + void accept_visitor(etl::visitor& v) { #if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) do_accept(v, etl::make_index_sequence{}); @@ -497,10 +632,10 @@ namespace etl } //*************************************************************************** - /// Accept a generic visitor. + /// Accept a generic functor. //*************************************************************************** template - void operator()(TVisitor& v) + void accept_functor(TVisitor& v) { #if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) do_operator(v, etl::make_index_sequence{}); @@ -511,44 +646,104 @@ namespace etl private: - using operation_function = void(*)(action_type, void*, const void*); + using operation_function = void(*)(action_type, char*, const char*); + + //*************************************************************************** + /// Construct the type in-place. + //*************************************************************************** + template + static void construct_in_place(char* pstorage, const T& value) + { + using type = etl::remove_reference_t; + + ::new (pstorage) type(value); + } + + template + static void construct_in_place(char* pstorage, T&& value) + { + using type = etl::remove_reference_t; + + ::new (pstorage) type(etl::forward(value)); + } //*************************************************************************** /// Do an operation determined by type. //*************************************************************************** template - static void do_operation_default_construct(action_type action, void* pstorage, const void* pvalue) + static void default_construct_in_place(char* pstorage) { - switch (action) - { - case action_type::Create: - { - ::new (pstorage) T(); - break; - } - - case action_type::Destroy: - { - reinterpret_cast(pstorage)->~T(); - break; - } - - default: - { - break; - } - } + ::new (pstorage) T(); } + //******************************************* // Declaration. - template - struct operation_type; + template + struct operation_type_move; - // Specialisation for lvalue rreferences - template - struct operation_type + template + struct operation_type_copy; + + //******************************************* + // Specialisation for rvalue references + template + struct operation_type_move { - static void do_operation(variant::action_type action, void* pstorage, const void* pvalue) + static void do_operation(variant::action_type action, char* pstorage, const char* pvalue) + { + using type = etl::remove_reference_t; + + switch (action) + { + case variant::action_type::Create: + { + ::new (pstorage) type(etl::move(*reinterpret_cast(const_cast(pvalue)))); + break; + } + + case variant::action_type::Destroy: + { + reinterpret_cast(pstorage)->~type(); + break; + } + + default: + { + break; + } + } + } + }; + + template + struct operation_type_move + { + static void do_operation(variant::action_type action, char* pstorage, const char* pvalue) + { + using type = etl::remove_reference_t; + + switch (action) + { + case variant::action_type::Destroy: + { + reinterpret_cast(pstorage)->~type(); + break; + } + + default: + { + break; + } + } + } + }; + + //******************************************* + // Specialisation for lvalue references + template + struct operation_type_copy + { + static void do_operation(variant::action_type action, char* pstorage, const char* pvalue) { using type = etl::remove_reference_t; @@ -574,22 +769,15 @@ namespace etl } }; - // Specialisation for rvalue rreferences template - struct operation_type + struct operation_type_copy { - static void do_operation(variant::action_type action, void* pstorage, const void* pvalue) + static void do_operation(variant::action_type action, char* pstorage, const char* pvalue) { using type = etl::remove_reference_t; switch (action) { - case variant::action_type::Create: - { - ::new (pstorage) type(etl::move(*reinterpret_cast(const_cast(pvalue)))); - break; - } - case variant::action_type::Destroy: { reinterpret_cast(pstorage)->~type(); @@ -608,8 +796,8 @@ namespace etl //*************************************************************************** /// Call the relevent visitor by attemptng each one. //*************************************************************************** - template - void do_accept(TVisitor& visitor, etl::index_sequence) + template + void do_accept(etl::visitor& visitor, etl::index_sequence) { (attempt_visitor(visitor) || ...); } @@ -617,8 +805,7 @@ namespace etl //*************************************************************************** /// /// Call the relevent visitor. //*************************************************************************** - template - void do_accept(TVisitor& visitor) + void do_accept(etl::visitor& visitor) { switch (index()) { @@ -668,8 +855,8 @@ namespace etl //*************************************************************************** /// Attempt to call a visitor. //*************************************************************************** - template - bool attempt_visitor(TVisitor& visitor) + template + bool attempt_visitor(etl::visitor& visitor) { if (Index == index()) { @@ -699,17 +886,19 @@ namespace etl void do_operator(TVisitor& visitor) { #if defined(ETL_VARIANT_CPP11_MAX_8_TYPES) - ETL_STATIC_ASSERT(sizeof...(TTypes) <= 8U, "???"); + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 8U, "There are more than 8 types in this variant"); #endif #if defined(ETL_VARIANT_CPP11_MAX_16_TYPES) - ETL_STATIC_ASSERT(sizeof...(TTypes) <= 16U, "???"); + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 16U, "There are more than 16 types in this variant"); #endif #if defined(ETL_VARIANT_CPP11_MAX_24_TYPES) - ETL_STATIC_ASSERT(sizeof...(TTypes) <= 24U, "???"); + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 24U, "There are more than 24 types in this variant"); #endif + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 32U, "There are more than 32 types in this variant"); + switch (index()) { case 0: visitor(etl::get<0>(*this)); break; @@ -776,14 +965,17 @@ namespace etl /// Default operation. //*************************************************************************** template - static void null_operation(action_type action, void* pstorage, TArgs... args) + static void null_operation(action_type action, char* pstorage, TArgs... args) { } //*************************************************************************** /// The operation function. //*************************************************************************** - operation_function operation; + operation_function operation_move; + operation_function operation_copy; + + operation_type operations; //*************************************************************************** /// The id of the current stored type. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8664063e..d31af34c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -236,7 +236,8 @@ set(TEST_SOURCE_FILES test_user_type.cpp test_utility.cpp test_variance.cpp - test_variant.cpp + test_variant_legacy.cpp + test_variant_new.cpp test_variant_pool.cpp test_vector.cpp test_vector_external_buffer.cpp diff --git a/test/runsanitychecks.sh b/test/runsanitychecks.sh index 37b8f47a..9a8a42fc 100755 --- a/test/runsanitychecks.sh +++ b/test/runsanitychecks.sh @@ -13,22 +13,22 @@ 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 "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 ############################################################################### cd ../c++11 || exit 1 @@ -41,22 +41,22 @@ 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 "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 ############################################################################### cd ../c++14 || exit 1 @@ -69,22 +69,22 @@ 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 "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 ############################################################################### cd ../c++17 || exit 1 @@ -97,22 +97,22 @@ 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 "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 "-----------------------------------------------" 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_variant_new.cpp b/test/test_variant_new.cpp index db279ece..f4dd0895 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -168,26 +168,30 @@ namespace struct Copyable { Copyable() - : copied_from(false) + : moved_from(false) + , moved_to(false) , copied_to(false) { } Copyable(const Copyable& other) noexcept { + moved_from = false; + moved_to = false; copied_to = true; - copied_from = false; } Copyable& operator =(const Copyable& rhs) noexcept { + moved_from = false; + moved_to = false; copied_to = true; - copied_from = false; return *this; } - bool copied_from; + bool moved_from; + bool moved_to; bool copied_to; }; @@ -197,23 +201,28 @@ namespace Moveable() : moved_from(false) , moved_to(false) + , copied_to(false) { } Moveable(Moveable&& other) noexcept { - moved_to = true; moved_from = false; - other.moved_to = 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_to = true; moved_from = false; - rhs.moved_to = false; + moved_to = true; + copied_to = false; rhs.moved_from = true; + rhs.moved_to = false; + rhs.copied_to = false; return *this; } @@ -223,483 +232,558 @@ namespace 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; + }; +} + +//namespace etl +//{ +// template <> +// struct is_copy_constructible : public etl::bool_constant +// { +// }; +// +// template <> +// struct is_copy_constructible : public etl::bool_constant +// { +// }; +// +// template <> +// struct is_copy_constructible : public etl::bool_constant +// { +// }; +//} + +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)); - } - - //************************************************************************* - 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_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) - { - std::string text("Some Text"); - 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_EQUAL(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) - { - 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)); - } - - //************************************************************************* - D1 getD1() - { - return D1("1"); - } - - TEST(test_move) - { - D1 da("1"); - - test_variant_emplace variant_etl(etl::move(getD1())); - - D1 db = etl::move(etl::get(variant_etl)); - } - - //************************************************************************* - TEST(test_variant_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); - CHECK_EQUAL(1, visitor.result_c); - - variant_etl = int(2); - variant_etl.accept(visitor); - CHECK_EQUAL(2, visitor.result_i); - - variant_etl = std::string("3"); - variant_etl.accept(visitor); - CHECK_EQUAL("3", visitor.result_s); - } - - //************************************************************************* - TEST(test_variant_operator_visit) - { - 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()(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(visitor); - CHECK_EQUAL(1, visitor.result_c); - - variant_etl = int(2); - variant_etl(visitor); - CHECK_EQUAL(2, visitor.result_i); - - variant_etl = std::string("3"); - variant_etl(visitor); - CHECK_EQUAL("3", visitor.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<0>(variant_etl) != nullptr); - CHECK(etl::get_if<1>(&variant_etl) == nullptr); - CHECK(etl::get_if<1>(variant_etl) == nullptr); - CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); - CHECK(etl::get_if<1>(&variant_etl) != nullptr); - CHECK(etl::get_if<1>(variant_etl) != nullptr); - CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); - CHECK(etl::get_if<1>(&variant_etl) == nullptr); - CHECK(etl::get_if<1>(variant_etl) == nullptr); - CHECK(etl::get_if<2>(&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); - 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); - 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); - 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_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)); + //} + + ////************************************************************************* + //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_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) + //{ + // std::string text("Some Text"); + // 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_EQUAL(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) + //{ + // 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)); + //} + + ////************************************************************************* + //D1 getD1() + //{ + // return D1("1"); + //} + + //TEST(test_move) + //{ + // D1 da("1"); + // + // test_variant_emplace variant_etl(etl::move(getD1())); + + // D1 db = etl::move(etl::get(variant_etl)); + //} + + ////************************************************************************* + //TEST(test_variant_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_operator_visit) + //{ + // 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()(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_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<0>(variant_etl) != nullptr); + // CHECK(etl::get_if<1>(&variant_etl) == nullptr); + // CHECK(etl::get_if<1>(variant_etl) == nullptr); + // CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); + // CHECK(etl::get_if<1>(&variant_etl) != nullptr); + // CHECK(etl::get_if<1>(variant_etl) != nullptr); + // CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); + // CHECK(etl::get_if<1>(&variant_etl) == nullptr); + // CHECK(etl::get_if<1>(variant_etl) == nullptr); + // CHECK(etl::get_if<2>(&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); + // 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); + // 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); + // 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_etl; + ////Moveable to_etl; - Moveable from_std; - Moveable to_std; + //Moveable from_std; + ////Moveable to_std; - etl::variant variant_etl; - std::variant variant_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); + //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.moved_from, from_etl.moved_from); + //CHECK_EQUAL(from_std.moved_to, from_etl.moved_to); - to_etl = etl::move(etl::get<0>(variant_etl)); - to_std = etl::move(std::get<0>(variant_std)); + //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.moved_from, to_etl.moved_from); + //CHECK_EQUAL(to_std.moved_to, to_etl.moved_to); } //************************************************************************* @@ -717,14 +801,82 @@ namespace variant_etl = from_etl; variant_std = from_std; - CHECK_EQUAL(from_std.copied_from, from_etl.copied_from); 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.copied_from, to_etl.copied_from); CHECK_EQUAL(to_std.copied_to, to_etl.copied_to); } + + //************************************************************************* + TEST(test_copyable_vs_moveable_types_etl) + { + Copyable copyable_from; + Copyable copyable_to; + + Moveable moveable_from; + Moveable moveable_to; + + MoveableCopyable movecopyable_from1; + MoveableCopyable movecopyable_from2; + MoveableCopyable movecopyable_to1; + MoveableCopyable movecopyable_to2; + + etl::variant variant_c(copyable_from); + copyable_to = etl::get<0>(variant_c); + + etl::variant variant_m(etl::move(moveable_from)); + moveable_to = etl::move(etl::get<0>(variant_m)); + + etl::variant variant_mc1(movecopyable_from1); + movecopyable_to1 = etl::get<0>(variant_mc1); + + etl::variant variant_mc2(etl::move(movecopyable_from2)); + movecopyable_to2 = etl::move(etl::get<0>(variant_mc2)); + + etl::variant variant_mc3(variant_mc1); + + etl::variant variant_mc4(etl::move(variant_mc1)); + + etl::variant variant_mc5(variant_mc2); + + etl::variant variant_mc6(etl::move(variant_mc2)); + } + + //************************************************************************* + TEST(test_copyable_vs_moveable_types_std) + { + Copyable copyable_from; + Copyable copyable_to; + + Moveable moveable_from; + Moveable moveable_to; + + MoveableCopyable movecopyable_from1; + MoveableCopyable movecopyable_from2; + MoveableCopyable movecopyable_to1; + MoveableCopyable movecopyable_to2; + + std::variant variant_c(copyable_from); + copyable_to = std::get<0>(variant_c); + + //std::variant variant_m(etl::move(moveable_from)); + //moveable_to = std::move(std::get<0>(variant_m)); + + std::variant variant_mc1(movecopyable_from1); + movecopyable_to1 = std::get<0>(variant_mc1); + +// std::variant variant_mc2(std::move(movecopyable_from2)); +// movecopyable_to2 = std::move(std::get<0>(variant_mc2)); + +// std::variant variant_mc3(variant_mc1); + +// std::variant variant_mc4(std::move(variant_mc1)); + +// std::variant variant_mc5(variant_mc2); + +// std::variant variant_mc6(std::move(variant_mc2)); + } }; } From 56c75a3ae5508f616f81579382042ac2eba983ec Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 13 Jul 2021 19:57:24 +0100 Subject: [PATCH 56/81] Refactored operation functions into one. --- include/etl/private/variant_new.h | 356 +++++++++++++----------------- 1 file changed, 153 insertions(+), 203 deletions(-) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index bb6c873b..eaeb2698 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -144,88 +144,6 @@ namespace etl template using type_from_index_t = typename type_from_index::type; }; - - - - struct operation_type - { - virtual void move(int action, char* pstorage, const char* pvalue) = 0; - virtual void copy(int action, char* pstorage, const char* pvalue) = 0; - }; - - template - struct operations; - - template - struct operations : public operation_type - { - using type = etl::remove_reference_t; - - void move(int action, char* pstorage, const char* pvalue) override - { - switch (action) - { - case 1: - { - reinterpret_cast(pstorage)->~type(); - break; - } - - default: - { - break; - } - } - } - }; - template - typename etl::enable_if_t>::value, void> - - { - using type = etl::remove_reference_t; - - switch (action) - { - case variant::action_type::Create: - { - ::new (pstorage) type(etl::move(*reinterpret_cast(const_cast(pvalue)))); - break; - } - - case variant::action_type::Destroy: - { - reinterpret_cast(pstorage)->~type(); - break; - } - - default: - { - break; - } - } - } - - template - typename etl::enable_if_t>::value, void> - move(variant::action_type action, char* pstorage, const char* pvalue) - { - using type = etl::remove_reference_t; - - switch (action) - { - case variant::action_type::Destroy: - { - reinterpret_cast(pstorage)->~type(); - break; - } - - default: - { - break; - } - } - } - }; } /// Definition of variant_npos. @@ -296,10 +214,11 @@ namespace etl private: - // The type of actions we can perform. - enum class action_type + // The type of operations we can perform. + enum class command { - Create, + Copy, + Move, Destroy }; @@ -340,8 +259,7 @@ namespace etl using type = typename etl::private_variant::parameter_pack::template type_from_index<0U>::type; default_construct_in_place(data); - operation_move = operation_type_move::value>::do_operation; - operation_copy = operation_type_copy::value>::do_operation; + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; type_id = 0U; } @@ -351,20 +269,22 @@ namespace etl template , variant>::value, int> = 0> ETL_CONSTEXPR14 variant(T&& value) : data() - , operation_move(operation_type_move>::value>::do_operation) - , operation_copy(operation_type_copy>::value>::do_operation) - , type_id(etl::private_variant::parameter_pack::template index_of_type>::value) { - bool bc = etl::is_copy_constructible>::value; - bool bm = etl::is_move_constructible>::value; + using type = etl::remove_reference_t; - etl::remove_reference_t t; + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + type_id = etl::private_variant::parameter_pack::template index_of_type::value; - size_t s = sizeof(operation_move); + bool bc = etl::is_copy_constructible::value; + bool bm = etl::is_move_constructible::value; - static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); + type t; - construct_in_place>(data, std::forward(value)); + size_t s = sizeof(operation); + + static_assert(etl::is_one_of::value, "Unsupported type"); + + construct_in_place(data, std::forward(value)); } //*************************************************************************** @@ -373,12 +293,13 @@ namespace etl template ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t, TArgs&&... args) : data() - , type_id(etl::private_variant::parameter_pack::template index_of_type>::value) { - construct_in_place>(data, std::forward(args)...); + using type = etl::remove_reference_t; - operation_move = operation_type_move>::value>::do_operation; - operation_copy = operation_type_copy>::value>::do_operation; + construct_in_place(data, std::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; } //*************************************************************************** @@ -391,10 +312,9 @@ namespace etl { using type = typename private_variant::parameter_pack:: template type_from_index_t; - construct_in_place>(data, std::forward(args)...); + construct_in_place(data, std::forward(args)...); - operation_move = operation_type_move>::value>::do_operation; - operation_copy = operation_type_copy>::value>::do_operation; + operation_type = operation_type::value, etl::is_move_constructible::value>::do_operation; } #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL @@ -404,13 +324,15 @@ namespace etl template ETL_CONSTEXPR14 explicit variant(etl::in_place_type_t, std::initializer_list init, TArgs&&... args) : data() - , type_id(private_variant::parameter_pack:: template index_of_type>::value) { - construct_in_place>(data, std::forward(args)...); + using type = etl::remove_reference_t; - operation_move = operation_type_move>::value>::do_operation; - operation_copy = operation_type_copy>::value>::do_operation; - operation(action_type::Create, data, reinterpret_cast(&temp)); + construct_in_place(data, std::forward(args)...); + + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + operation(command::Move, data, reinterpret_cast(&temp)); + + type_id = private_variant::parameter_pack:: template index_of_type::value; } //*************************************************************************** @@ -423,12 +345,9 @@ namespace etl { using type = typename private_variant::parameter_pack:: template type_from_index_t; - construct_in_place>(data, std::forward(args)...); + construct_in_place(data, std::forward(args)...); - type temp(args...); - - operation_move = operation_type_move>::value>::do_operation; - operation_copy = operation_type_copy>::value>::do_operation; + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } #endif @@ -438,8 +357,7 @@ namespace etl //*************************************************************************** ETL_CONSTEXPR14 variant(const variant& other) : data() - , operation_move(other.operation_move) - , operation_copy(other.operation_copy) + , operation(other.operation) , type_id(other.type_id) { if (this != &other) @@ -450,7 +368,7 @@ namespace etl } else { - operation_copy(action_type::Create, data, other.data); + operation(command::Copy, data, other.data); } } } @@ -461,8 +379,7 @@ namespace etl //*************************************************************************** ETL_CONSTEXPR14 variant(variant&& other) : data() - , operation_move(other.operation_move) - , operation_copy(other.operation_copy) + , operation(other.operation) , type_id(other.type_id) { if (this != &other) @@ -473,7 +390,7 @@ namespace etl } else { - operation_move(action_type::Create, data, other.data); + operation(command::Move, data, other.data); } } else @@ -489,11 +406,10 @@ namespace etl { if (index() != variant_npos) { - operation_move(action_type::Destroy, data, nullptr); + operation(command::Destroy, data, nullptr); } - operation_move = null_operation; - operation_copy = null_operation; + operation = operation_type::do_operation; // Null operation. type_id = variant_npos; } @@ -503,16 +419,17 @@ namespace etl template T& emplace(TArgs&&... args) { - //static_assert(etl::is_one_of::value, "Unsupported type"); + static_assert(etl::is_one_of::value, "Unsupported type"); - //operation_move(action_type::Destroy, data, nullptr); + using type = etl::remove_reference_t; + + operation(command::Destroy, data, nullptr); - //construct_in_place>(data, std::forward(args)...); + construct_in_place(data, std::forward(args)...); - //operation_move = operation_type_move>::value>::do_operation; - //operation_copy = operation_type_copy>::value>::do_operation; - // - //type_id = etl::private_variant::parameter_pack::template index_of_type::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 *static_cast(data); } @@ -524,16 +441,16 @@ namespace etl template , variant>::value, int> = 0> variant& operator =(T&& value) { - static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); + using type = etl::remove_reference_t; - operation_move(action_type::Destroy, data, nullptr); + static_assert(etl::is_one_of::value, "Unsupported type"); - construct_in_place>(data, std::forward(value)); + operation(command::Destroy, data, nullptr); - operation_move = operation_type_move>::value>::do_operation; - operation_copy = operation_type_copy>::value>::do_operation; + construct_in_place(data, std::forward(value)); - type_id = etl::private_variant::parameter_pack::template index_of_type::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; } @@ -552,11 +469,10 @@ namespace etl } else { - operation_copy(action_type::Destroy, data, nullptr); + operation(command::Destroy, data, nullptr); - operation_move = other.operation_move; - operation_copy = other.operation_copy; - operation_copy(action_type::Create, data, other.data); + operation = other.operation; + operation(command::Copy, data, other.data); type_id = other.type_id; } @@ -579,11 +495,10 @@ namespace etl } else { - operation_move(action_type::Destroy, data, nullptr); + operation(command::Destroy, data, nullptr); - operation_move = other.operation_move; - operation_copy = other.operation_copy; - operation_move(action_type::Create, data, other.data); + operation = other.operation; + operation(command::Move, data, other.data); type_id = other.type_id; } @@ -646,10 +561,11 @@ namespace etl private: - using operation_function = void(*)(action_type, char*, const char*); + /// The operation function type. + using operation_function = void(*)(command, char*, const char*); //*************************************************************************** - /// Construct the type in-place. + /// Construct the type in-place. lvalue reference. //*************************************************************************** template static void construct_in_place(char* pstorage, const T& value) @@ -659,6 +575,9 @@ namespace etl ::new (pstorage) type(value); } + //*************************************************************************** + /// Construct the type in-place. rvalue reference. + //*************************************************************************** template static void construct_in_place(char* pstorage, T&& value) { @@ -668,7 +587,18 @@ namespace etl } //*************************************************************************** - /// Do an operation determined by type. + /// Construct the type in-place. Variadic args. + //*************************************************************************** + template + static void construct_in_place(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) @@ -678,53 +608,66 @@ namespace etl //******************************************* // Declaration. - template - struct operation_type_move; - - template - struct operation_type_copy; + template + struct operation_type; //******************************************* - // Specialisation for rvalue references - template - struct operation_type_move + // Specialisation for null operation. + template <> + struct operation_type { - static void do_operation(variant::action_type action, char* pstorage, const char* pvalue) + static void do_operation(variant::command operation, char* pstorage, const char* pvalue) + { + // This should never occur. + assert(false); + } + }; + + //******************************************* + // Specialisation for no-copyable & non-moveable + template + struct operation_type + { + static void do_operation(variant::command operation, char* pstorage, const char* pvalue) { using type = etl::remove_reference_t; - switch (action) + switch (operation) { - case variant::action_type::Create: + case variant::command::Destroy: + { + reinterpret_cast(pstorage)->~type(); + break; + } + + default: + { + // This should never occur. + assert(false); + break; + } + } + } + }; + + //******************************************* + // Specialisation for no-copyable & moveable + template + struct operation_type + { + static void do_operation(variant::command operation, char* pstorage, const char* pvalue) + { + using type = etl::remove_reference_t; + + switch (operation) + { + case variant::command::Move: { ::new (pstorage) type(etl::move(*reinterpret_cast(const_cast(pvalue)))); break; } - case variant::action_type::Destroy: - { - reinterpret_cast(pstorage)->~type(); - break; - } - - default: - { - break; - } - } - } - }; - - template - struct operation_type_move - { - static void do_operation(variant::action_type action, char* pstorage, const char* pvalue) - { - using type = etl::remove_reference_t; - - switch (action) - { - case variant::action_type::Destroy: + case variant::command::Destroy: { reinterpret_cast(pstorage)->~type(); break; @@ -732,6 +675,8 @@ namespace etl default: { + // This should never occur. + assert(false); break; } } @@ -739,23 +684,23 @@ namespace etl }; //******************************************* - // Specialisation for lvalue references + // Specialisation for copyable & non-moveable template - struct operation_type_copy + struct operation_type { - static void do_operation(variant::action_type action, char* pstorage, const char* pvalue) + static void do_operation(variant::command operation, char* pstorage, const char* pvalue) { using type = etl::remove_reference_t; - switch (action) + switch (operation) { - case variant::action_type::Create: + case variant::command::Copy: { ::new (pstorage) type(*reinterpret_cast(pvalue)); break; } - case variant::action_type::Destroy: + case variant::command::Destroy: { reinterpret_cast(pstorage)->~type(); break; @@ -763,22 +708,38 @@ namespace etl default: { + // This should never occur. + assert(false); break; } } } }; + //******************************************* + // Specialisation for copyable & moveable template - struct operation_type_copy + struct operation_type { - static void do_operation(variant::action_type action, char* pstorage, const char* pvalue) + static void do_operation(variant::command command, char* pstorage, const char* pvalue) { using type = etl::remove_reference_t; - switch (action) + switch (command) { - case variant::action_type::Destroy: + case variant::command::Copy: + { + ::new (pstorage) type(*reinterpret_cast(pvalue)); + break; + } + + case variant::command::Move: + { + ::new (pstorage) type(etl::move(*reinterpret_cast(const_cast(pvalue)))); + break; + } + + case variant::command::Destroy: { reinterpret_cast(pstorage)->~type(); break; @@ -961,21 +922,10 @@ namespace etl } } - //*************************************************************************** - /// Default operation. - //*************************************************************************** - template - static void null_operation(action_type action, char* pstorage, TArgs... args) - { - } - //*************************************************************************** /// The operation function. //*************************************************************************** - operation_function operation_move; - operation_function operation_copy; - - operation_type operations; + operation_function operation; //*************************************************************************** /// The id of the current stored type. From 0bdd5943da134260cd3c80af9667adfffbb01e90 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 13 Jul 2021 21:24:12 +0100 Subject: [PATCH 57/81] Work in progress --- include/etl/private/variant_new.h | 40 +++++++++++++------------------ 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index eaeb2698..7c8cf7a5 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -272,19 +272,12 @@ namespace etl { using type = etl::remove_reference_t; - operation = operation_type::value, etl::is_move_constructible::value>::do_operation; - type_id = etl::private_variant::parameter_pack::template index_of_type::value; - - bool bc = etl::is_copy_constructible::value; - bool bm = etl::is_move_constructible::value; - - type t; - - size_t s = sizeof(operation); - static_assert(etl::is_one_of::value, "Unsupported type"); construct_in_place(data, std::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; } //*************************************************************************** @@ -296,7 +289,7 @@ namespace etl { using type = etl::remove_reference_t; - construct_in_place(data, std::forward(args)...); + construct_in_place_args(data, std::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; @@ -312,9 +305,9 @@ namespace etl { using type = typename private_variant::parameter_pack:: template type_from_index_t; - construct_in_place(data, std::forward(args)...); + construct_in_place_args(data, std::forward(args)...); - operation_type = operation_type::value, etl::is_move_constructible::value>::do_operation; + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL @@ -327,12 +320,10 @@ namespace etl { using type = etl::remove_reference_t; - construct_in_place(data, std::forward(args)...); + construct_in_place_args(data, std::forward(args)...); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; - operation(command::Move, data, reinterpret_cast(&temp)); - - type_id = private_variant::parameter_pack:: template index_of_type::value; + type_id = private_variant::parameter_pack:: template index_of_type::value; } //*************************************************************************** @@ -345,7 +336,7 @@ namespace etl { using type = typename private_variant::parameter_pack:: template type_from_index_t; - construct_in_place(data, std::forward(args)...); + construct_in_place_args(data, std::forward(args)...); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } @@ -425,7 +416,7 @@ namespace etl operation(command::Destroy, data, nullptr); - construct_in_place(data, std::forward(args)...); + construct_in_place_args(data, std::forward(args)...); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; @@ -447,7 +438,7 @@ namespace etl operation(command::Destroy, data, nullptr); - construct_in_place(data, std::forward(value)); + 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; @@ -583,18 +574,20 @@ namespace etl { using type = etl::remove_reference_t; - ::new (pstorage) type(etl::forward(value)); + ::new (pstorage) type(etl::move(value)); } //*************************************************************************** /// Construct the type in-place. Variadic args. //*************************************************************************** template - static void construct_in_place(char* pstorage, TArgs&&... args) + static void construct_in_place_args(char* pstorage, TArgs&&... args) { using type = etl::remove_reference_t; - ::new (pstorage) type(etl::forward(args)...); + type t; + + ::new (pstorage) type(etl::forward(args)...); } //*************************************************************************** @@ -747,6 +740,7 @@ namespace etl default: { + assert(false); break; } } From de1a19775ed54b08c6131ddee85fd6dc82711189 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 14 Jul 2021 12:37:24 +0100 Subject: [PATCH 58/81] Re-enabled all variant unit tests --- .../etl/generators/type_traits_generator.h | 193 +++ include/etl/private/variant_new.h | 114 +- include/etl/type_traits.h | 137 ++ test/etl_profile.h | 2 + test/test_variant_new.cpp | 1112 +++++++++-------- 5 files changed, 982 insertions(+), 576 deletions(-) diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 3fad300b..0f2d2970 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 @@ -504,6 +507,11 @@ namespace etl 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; }; @@ -1223,6 +1231,11 @@ namespace etl 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 @@ -1618,6 +1631,186 @@ 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(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)) + + //********************************************* + // Use the STL's definitions. + //********************************************* + template + struct is_assignable : public std::is_assignable + { + }; + + template + struct is_lvalue_assignable : public etl::is_assignable::type, + typename etl::add_lvalue_reference::type>::type> + { + }; + + template + struct is_constructible : public std::is_constructible + { + }; + + template + struct is_copy_constructible : public std::is_copy_constructible + { + }; + + template + struct is_move_constructible : public std::is_move_constructible + { + }; + + //#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED + // template + // struct is_trivially_constructible : public std::is_trivially_constructible + // { + // }; + //#endif + +#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) + + //********************************************* + // Use the compiler's builtins. + //********************************************* + template + struct is_assignable : public bool_constant<__is_assignable(T1, T2)> + { + }; + + template + struct is_lvalue_assignable : public etl::is_assignable::type, + typename etl::add_lvalue_reference::type>::type> + { + }; + + template + struct is_constructible : public bool_constant<__is_constructible(T, TArgs...)> + { + }; + + template + struct is_copy_constructible : public etl::is_constructible> + { + }; + + template + struct is_move_constructible : public etl::is_constructible + { + }; + + //template + //struct is_trivially_constructible : public bool_constant::value&& __is_trivially_constructible(T, TArgs...)> + //{ + //}; + +#else + + //********************************************* + // Force the user to provide specialisations. + //********************************************* + template + struct is_assignable : public etl::bool_constant + { + }; + + template + struct is_lvalue_assignable : public etl::bool_constant + { + }; + + template + struct is_constructible : public etl::bool_constant + { + }; + + template + struct is_copy_constructible : public etl::bool_constant::value> + { + }; + + template + struct is_move_constructible : public etl::bool_constant::value> + { + }; + + //template + //struct is_trivially_constructible : public etl::bool_constant::value> + //{ + //}; + +#endif + +#if ETL_CPP17_SUPPORTED + template + inline constexpr size_t is_assignable_v = etl::is_assignable::value; + + template + inline constexpr size_t is_lvalue_assignable_v = etl::is_lvalue_assignable::value; + + template + inline constexpr size_t is_constructible_v = etl::is_constructible::value; + + template + inline constexpr size_t is_copy_constructible_v = etl::is_copy_constructible::value; + + template + inline constexpr size_t is_move_constructible_v = etl::is_move_constructible::value; + + //template + //inline constexpr size_t is_trivially_constructible_v = etl::is_trivially_constructible::value; + #endif } diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 7c8cf7a5..2e4d379f 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -32,7 +32,6 @@ SOFTWARE. #include "../platform.h" #include "../utility.h" -#include "../array.h" #include "../largest.h" #include "../exception.h" #include "../type_traits.h" @@ -260,7 +259,7 @@ namespace etl default_construct_in_place(data); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; - type_id = 0U; + type_id = 0U; } //*************************************************************************** @@ -269,15 +268,12 @@ namespace etl 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) { - using type = etl::remove_reference_t; + static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); - static_assert(etl::is_one_of::value, "Unsupported type"); - - construct_in_place(data, std::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; + construct_in_place>(data, std::forward(value)); } //*************************************************************************** @@ -286,13 +282,12 @@ namespace etl 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) { - using type = etl::remove_reference_t; + static_assert(etl::is_one_of>, TTypes...>::value, "Unsupported type"); - construct_in_place_args(data, std::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; + construct_in_place_args>(data, std::forward(args)...); } //*************************************************************************** @@ -304,10 +299,11 @@ namespace etl , type_id(Index) { using type = typename private_variant::parameter_pack:: template type_from_index_t; + static_assert(etl::is_one_of, TTypes... > ::value, "Unsupported type"); construct_in_place_args(data, std::forward(args)...); - operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } #if ETL_CPP11_SUPPORTED && ETL_NOT_USING_STLPORT && ETL_USING_STL @@ -317,13 +313,12 @@ namespace etl 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::etl::remove_reference_t>::do_operation) + , type_id(private_variant::parameter_pack:: template index_of_type>::value) { - using type = etl::remove_reference_t; + static_assert(etl::is_one_of>, TTypes... > ::value, "Unsupported type"); - construct_in_place_args(data, std::forward(args)...); - - operation = operation_type::value, etl::is_move_constructible::value>::do_operation; - type_id = private_variant::parameter_pack:: template index_of_type::value; + construct_in_place_args>(data, std::forward(args)...); } //*************************************************************************** @@ -335,10 +330,11 @@ namespace etl , type_id(Index) { using type = typename private_variant::parameter_pack:: template type_from_index_t; + static_assert(etl::is_one_of, TTypes... > ::value, "Unsupported type"); construct_in_place_args(data, std::forward(args)...); - operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } #endif @@ -418,7 +414,7 @@ namespace etl construct_in_place_args(data, std::forward(args)...); - operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + operation = operation_type::value, etl::is_move_constructible::value>::do_operation; type_id = etl::private_variant::parameter_pack::template index_of_type::value; @@ -440,7 +436,7 @@ namespace etl construct_in_place(data, etl::forward(value)); - operation = operation_type::value, etl::is_move_constructible::value>::do_operation; + 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; @@ -520,9 +516,9 @@ namespace etl //*************************************************************************** void swap(variant& rhs) noexcept { - variant temp(*this); - *this = rhs; - rhs = temp; + variant temp(etl::move(*this)); + *this = etl::move(rhs); + rhs = etl::move(temp); } //*************************************************************************** @@ -585,9 +581,7 @@ namespace etl { using type = etl::remove_reference_t; - type t; - - ::new (pstorage) type(etl::forward(args)...); + ::new (pstorage) type(etl::forward(args)...); } //*************************************************************************** @@ -596,7 +590,9 @@ namespace etl template static void default_construct_in_place(char* pstorage) { - ::new (pstorage) T(); + using type = etl::remove_reference_t; + + ::new (pstorage) type(); } //******************************************* @@ -612,31 +608,33 @@ namespace etl static void do_operation(variant::command 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 + // Specialisation for no-copyable & non-moveable types. template struct operation_type { static void do_operation(variant::command operation, char* pstorage, const char* pvalue) { - using type = etl::remove_reference_t; - switch (operation) { case variant::command::Destroy: { - reinterpret_cast(pstorage)->~type(); + reinterpret_cast(pstorage)->~T(); break; } default: { // This should never occur. +#if defined(ETL_IN_UNIT_TEST) assert(false); +#endif break; } } @@ -644,32 +642,32 @@ namespace etl }; //******************************************* - // Specialisation for no-copyable & moveable + // Specialisation for no-copyable & moveable types. template struct operation_type { static void do_operation(variant::command operation, char* pstorage, const char* pvalue) { - using type = etl::remove_reference_t; - switch (operation) { case variant::command::Move: { - ::new (pstorage) type(etl::move(*reinterpret_cast(const_cast(pvalue)))); + ::new (pstorage) T(etl::move(*reinterpret_cast(const_cast(pvalue)))); break; } case variant::command::Destroy: { - reinterpret_cast(pstorage)->~type(); + reinterpret_cast(pstorage)->~T(); break; } default: { // This should never occur. +#if defined(ETL_IN_UNIT_TEST) assert(false); +#endif break; } } @@ -677,32 +675,32 @@ namespace etl }; //******************************************* - // Specialisation for copyable & non-moveable + // Specialisation for copyable & non-moveable types. template struct operation_type { static void do_operation(variant::command operation, char* pstorage, const char* pvalue) { - using type = etl::remove_reference_t; - switch (operation) { case variant::command::Copy: { - ::new (pstorage) type(*reinterpret_cast(pvalue)); + ::new (pstorage) T(*reinterpret_cast(pvalue)); break; } case variant::command::Destroy: { - reinterpret_cast(pstorage)->~type(); + reinterpret_cast(pstorage)->~T(); break; } default: { // This should never occur. +#if defined(ETL_IN_UNIT_TEST) assert(false); +#endif break; } } @@ -710,31 +708,29 @@ namespace etl }; //******************************************* - // Specialisation for copyable & moveable + // Specialisation for copyable & moveable types. template struct operation_type { static void do_operation(variant::command command, char* pstorage, const char* pvalue) { - using type = etl::remove_reference_t; - switch (command) { case variant::command::Copy: { - ::new (pstorage) type(*reinterpret_cast(pvalue)); + ::new (pstorage) T(*reinterpret_cast(pvalue)); break; } case variant::command::Move: { - ::new (pstorage) type(etl::move(*reinterpret_cast(const_cast(pvalue)))); + ::new (pstorage) T(etl::move(*reinterpret_cast(const_cast(pvalue)))); break; } case variant::command::Destroy: { - reinterpret_cast(pstorage)->~type(); + reinterpret_cast(pstorage)->~T(); break; } @@ -938,6 +934,24 @@ namespace etl 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()); + } + //*************************************************************************** /// variant_alternative //*************************************************************************** diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index a213149c..35cc59bd 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 @@ -1669,6 +1672,140 @@ namespace etl #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(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)) + + //********************************************* + // Use the STL's definitions. + //********************************************* + template + struct is_assignable : public std::is_assignable + { + }; + + template + struct is_lvalue_assignable : public etl::is_assignable::type, + typename etl::add_lvalue_reference::type>::type> + { + }; + + template + struct is_constructible : public std::is_constructible + { + }; + + template + struct is_copy_constructible : public std::is_copy_constructible + { + }; + + template + struct is_move_constructible : public std::is_move_constructible + { + }; + +//#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED +// template +// struct is_trivially_constructible : public std::is_trivially_constructible +// { +// }; +//#endif + +#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) + + //********************************************* + // Use the compiler's builtins. + //********************************************* + template + struct is_assignable : public bool_constant<__is_assignable(T1, T2)> + { + }; + + template + struct is_lvalue_assignable : public etl::is_assignable::type, + typename etl::add_lvalue_reference::type>::type> + { + }; + + template + struct is_constructible : public bool_constant<__is_constructible(T, TArgs...)> + { + }; + + template + struct is_copy_constructible : public etl::is_constructible> + { + }; + + template + struct is_move_constructible : public etl::is_constructible + { + }; + + //template + //struct is_trivially_constructible : public bool_constant::value&& __is_trivially_constructible(T, TArgs...)> + //{ + //}; + +#else + + //********************************************* + // Force the user to provide specialisations. + //********************************************* + template + struct is_assignable : public etl::bool_constant + { + }; + + template + struct is_lvalue_assignable : public etl::bool_constant + { + }; + + template + struct is_constructible : public etl::bool_constant + { + }; + + template + struct is_copy_constructible : public etl::bool_constant::value> + { + }; + + template + struct is_move_constructible : public etl::bool_constant::value> + { + }; + + //template + //struct is_trivially_constructible : public etl::bool_constant::value> + //{ + //}; + +#endif + +#if ETL_CPP17_SUPPORTED + + template + inline constexpr size_t is_assignable_v = etl::is_assignable::value; + + template + inline constexpr size_t is_lvalue_assignable_v = etl::is_lvalue_assignable::value; + + template + inline constexpr size_t is_constructible_v = etl::is_constructible::value; + + template + inline constexpr size_t is_copy_constructible_v = etl::is_copy_constructible::value; + + template + inline constexpr size_t is_move_constructible_v = etl::is_move_constructible::value; + +//template +//inline constexpr size_t is_trivially_constructible_v = etl::is_trivially_constructible::value; + #endif } diff --git a/test/etl_profile.h b/test/etl_profile.h index b3b01bf7..ec26e76c 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -80,6 +80,8 @@ SOFTWARE. //#define ETL_NO_STL +#define ETL_USE_TYPE_TRAITS_BUILTINS + #if defined(ETL_FORCE_TEST_CPP03) #define ETL_FUNCTION_FORCE_CPP03 #define ETL_PRIORITY_QUEUE_FORCE_CPP03 diff --git a/test/test_variant_new.cpp b/test/test_variant_new.cpp index f4dd0895..ae0cfc81 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -289,501 +289,516 @@ namespace }; } -//namespace etl -//{ -// template <> -// struct is_copy_constructible : public etl::bool_constant -// { -// }; -// -// template <> -// struct is_copy_constructible : public etl::bool_constant -// { -// }; -// -// template <> -// struct is_copy_constructible : public etl::bool_constant -// { -// }; -//} +// Definitions for when the STL and compiler built-ins are not avalable. +#if ETL_NOT_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) +namespace etl +{ + template <> + struct is_copy_constructible : public etl::bool_constant + { + }; + + template <> + struct is_copy_constructible : public etl::bool_constant + { + }; + + template <> + struct is_copy_constructible : public etl::bool_constant + { + }; + + template <> + struct is_move_constructible : public etl::bool_constant + { + }; + + template <> + struct is_move_constructible : public etl::bool_constant + { + }; + + template <> + struct is_move_constructible : public etl::bool_constant + { + }; +} +#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)); - //} - - ////************************************************************************* - //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_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) - //{ - // std::string text("Some Text"); - // 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_EQUAL(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) - //{ - // 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)); - //} - - ////************************************************************************* - //D1 getD1() - //{ - // return D1("1"); - //} - - //TEST(test_move) - //{ - // D1 da("1"); - // - // test_variant_emplace variant_etl(etl::move(getD1())); - - // D1 db = etl::move(etl::get(variant_etl)); - //} - - ////************************************************************************* - //TEST(test_variant_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_operator_visit) - //{ - // 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()(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_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<0>(variant_etl) != nullptr); - // CHECK(etl::get_if<1>(&variant_etl) == nullptr); - // CHECK(etl::get_if<1>(variant_etl) == nullptr); - // CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); - // CHECK(etl::get_if<1>(&variant_etl) != nullptr); - // CHECK(etl::get_if<1>(variant_etl) != nullptr); - // CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); - // CHECK(etl::get_if<1>(&variant_etl) == nullptr); - // CHECK(etl::get_if<1>(variant_etl) == nullptr); - // CHECK(etl::get_if<2>(&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); - // 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); - // 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); - // 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_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_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_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_operator_visit) + { + 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()(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_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<0>(variant_etl) != nullptr); + CHECK(etl::get_if<1>(&variant_etl) == nullptr); + CHECK(etl::get_if<1>(variant_etl) == nullptr); + CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); + CHECK(etl::get_if<1>(&variant_etl) != nullptr); + CHECK(etl::get_if<1>(variant_etl) != nullptr); + CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); + CHECK(etl::get_if<1>(&variant_etl) == nullptr); + CHECK(etl::get_if<1>(variant_etl) == nullptr); + CHECK(etl::get_if<2>(&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); + 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); + 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); + 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_etl; + Moveable to_etl; - //Moveable from_std; - ////Moveable to_std; + Moveable from_std; + Moveable to_std; - //etl::variant variant_etl(etl::move(from_etl)); - //std::variant variant_std(etl::move(from_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); + 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.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)); + 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.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); } //************************************************************************* @@ -801,82 +816,127 @@ namespace variant_etl = from_etl; variant_std = from_std; - CHECK_EQUAL(from_std.copied_to, from_etl.copied_to); + 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.copied_to, to_etl.copied_to); + 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_copyable_vs_moveable_types_etl) + TEST(test_compare_etl_and_stl_variant_with_moveable_copyable_type) { - Copyable copyable_from; - Copyable copyable_to; + MoveableCopyable from_etl; + MoveableCopyable to_etl; - Moveable moveable_from; - Moveable moveable_to; + MoveableCopyable from_std; + MoveableCopyable to_std; - MoveableCopyable movecopyable_from1; - MoveableCopyable movecopyable_from2; - MoveableCopyable movecopyable_to1; - MoveableCopyable movecopyable_to2; + etl::variant variant_etl; + std::variant variant_std; - etl::variant variant_c(copyable_from); - copyable_to = etl::get<0>(variant_c); + variant_etl = from_etl; + variant_std = from_std; - etl::variant variant_m(etl::move(moveable_from)); - moveable_to = etl::move(etl::get<0>(variant_m)); + 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); - etl::variant variant_mc1(movecopyable_from1); - movecopyable_to1 = etl::get<0>(variant_mc1); + variant_etl = etl::move(from_etl); + variant_std = etl::move(from_std); - etl::variant variant_mc2(etl::move(movecopyable_from2)); - movecopyable_to2 = etl::move(etl::get<0>(variant_mc2)); + 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); - etl::variant variant_mc3(variant_mc1); + to_etl = etl::get<0>(variant_etl); + to_std = std::get<0>(variant_std); - etl::variant variant_mc4(etl::move(variant_mc1)); + 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); - etl::variant variant_mc5(variant_mc2); + to_etl = etl::move(etl::get<0>(variant_etl)); + to_std = etl::move(std::get<0>(variant_std)); - etl::variant variant_mc6(etl::move(variant_mc2)); + 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_copyable_vs_moveable_types_std) - { - Copyable copyable_from; - Copyable copyable_to; + //TEST(test_copyable_vs_moveable_types_etl) + //{ + // Copyable copyable_from; + // Copyable copyable_to; - Moveable moveable_from; - Moveable moveable_to; + // Moveable moveable_from; + // Moveable moveable_to; - MoveableCopyable movecopyable_from1; - MoveableCopyable movecopyable_from2; - MoveableCopyable movecopyable_to1; - MoveableCopyable movecopyable_to2; + // MoveableCopyable movecopyable_from1; + // MoveableCopyable movecopyable_from2; + // MoveableCopyable movecopyable_to1; + // MoveableCopyable movecopyable_to2; - std::variant variant_c(copyable_from); - copyable_to = std::get<0>(variant_c); + // etl::variant variant_c(copyable_from); + // copyable_to = etl::get<0>(variant_c); - //std::variant variant_m(etl::move(moveable_from)); - //moveable_to = std::move(std::get<0>(variant_m)); + // etl::variant variant_m(etl::move(moveable_from)); + // moveable_to = etl::move(etl::get<0>(variant_m)); - std::variant variant_mc1(movecopyable_from1); - movecopyable_to1 = std::get<0>(variant_mc1); + // etl::variant variant_mc1(movecopyable_from1); + // movecopyable_to1 = etl::get<0>(variant_mc1); -// std::variant variant_mc2(std::move(movecopyable_from2)); -// movecopyable_to2 = std::move(std::get<0>(variant_mc2)); + // etl::variant variant_mc2(etl::move(movecopyable_from2)); + // movecopyable_to2 = etl::move(etl::get<0>(variant_mc2)); -// std::variant variant_mc3(variant_mc1); + // etl::variant variant_mc3(variant_mc1); -// std::variant variant_mc4(std::move(variant_mc1)); + // etl::variant variant_mc4(etl::move(variant_mc1)); -// std::variant variant_mc5(variant_mc2); + // etl::variant variant_mc5(variant_mc2); -// std::variant variant_mc6(std::move(variant_mc2)); - } + // etl::variant variant_mc6(etl::move(variant_mc2)); + //} + + //************************************************************************* +// TEST(test_copyable_vs_moveable_types_std) +// { +// Copyable copyable_from; +// Copyable copyable_to; +// +// Moveable moveable_from; +// Moveable moveable_to; +// +// MoveableCopyable movecopyable_from1; +// MoveableCopyable movecopyable_from2; +// MoveableCopyable movecopyable_to1; +// MoveableCopyable movecopyable_to2; +// +// std::variant variant_c(copyable_from); +// copyable_to = std::get<0>(variant_c); +// +// //std::variant variant_m(etl::move(moveable_from)); +// //moveable_to = std::move(std::get<0>(variant_m)); +// +// std::variant variant_mc1(movecopyable_from1); +// movecopyable_to1 = std::get<0>(variant_mc1); +// +//// std::variant variant_mc2(std::move(movecopyable_from2)); +//// movecopyable_to2 = std::move(std::get<0>(variant_mc2)); +// +//// std::variant variant_mc3(variant_mc1); +// +//// std::variant variant_mc4(std::move(variant_mc1)); +// +//// std::variant variant_mc5(variant_mc2); +// +//// std::variant variant_mc6(std::move(variant_mc2)); +// } }; } From 9c68847c5c1851e96f55d7696b3e830731c2b2af Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 15 Jul 2021 12:57:46 +0100 Subject: [PATCH 59/81] Compiler compatibility changes --- include/etl/private/variant_new.h | 613 ++++++++++++++++++++---------- include/etl/utility.h | 12 +- test/etl_profile.h | 2 +- test/test_variant_new.cpp | 64 ++++ 4 files changed, 487 insertions(+), 204 deletions(-) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 2e4d379f..2fe4865c 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -143,15 +143,206 @@ namespace etl 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; - // Forward declarations. + //*********************************** + // 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; @@ -213,14 +404,6 @@ namespace etl private: - // The type of operations we can perform. - enum class command - { - Copy, - Move, - Destroy - }; - // All types of variant are friends. template friend class variant; @@ -240,13 +423,20 @@ namespace etl //*************************************************************************** static const size_t Alignment = etl::largest_alignment::value; - public: + //*************************************************************************** + /// The operation templates. + //*************************************************************************** + template + using operation_type = private_variant::operation_type; - //*************************************************************************** - /// The internal storage. - /// Aligned on a suitable boundary, which should be good for all types. - //*************************************************************************** - etl::uninitialized_buffer data; + //******************************************* + // 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. @@ -285,7 +475,7 @@ namespace etl , 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"); + static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); construct_in_place_args>(data, std::forward(args)...); } @@ -299,7 +489,7 @@ namespace etl , type_id(Index) { using type = typename private_variant::parameter_pack:: template type_from_index_t; - static_assert(etl::is_one_of, TTypes... > ::value, "Unsupported type"); + static_assert(etl::is_one_of ::value, "Unsupported type"); construct_in_place_args(data, std::forward(args)...); @@ -313,12 +503,12 @@ namespace etl 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::etl::remove_reference_t>::do_operation) + , 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"); + static_assert(etl::is_one_of, TTypes...> ::value, "Unsupported type"); - construct_in_place_args>(data, std::forward(args)...); + construct_in_place_args>(data, init, std::forward(args)...); } //*************************************************************************** @@ -330,9 +520,9 @@ namespace etl , type_id(Index) { using type = typename private_variant::parameter_pack:: template type_from_index_t; - static_assert(etl::is_one_of, TTypes... > ::value, "Unsupported type"); + static_assert(etl::is_one_of ::value, "Unsupported type"); - construct_in_place_args(data, std::forward(args)...); + construct_in_place_args(data, init, std::forward(args)...); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } @@ -355,7 +545,7 @@ namespace etl } else { - operation(command::Copy, data, other.data); + operation(private_variant::Copy, data, other.data); } } } @@ -377,7 +567,7 @@ namespace etl } else { - operation(command::Move, data, other.data); + operation(private_variant::Move, data, other.data); } } else @@ -393,7 +583,7 @@ namespace etl { if (index() != variant_npos) { - operation(command::Destroy, data, nullptr); + operation(private_variant::Destroy, data, nullptr); } operation = operation_type::do_operation; // Null operation. @@ -410,7 +600,7 @@ namespace etl using type = etl::remove_reference_t; - operation(command::Destroy, data, nullptr); + operation(private_variant::Destroy, data, nullptr); construct_in_place_args(data, std::forward(args)...); @@ -432,7 +622,7 @@ namespace etl static_assert(etl::is_one_of::value, "Unsupported type"); - operation(command::Destroy, data, nullptr); + operation(private_variant::Destroy, data, nullptr); construct_in_place(data, etl::forward(value)); @@ -456,10 +646,10 @@ namespace etl } else { - operation(command::Destroy, data, nullptr); + operation(Destroy, data, nullptr); operation = other.operation; - operation(command::Copy, data, other.data); + operation(Copy, data, other.data); type_id = other.type_id; } @@ -482,10 +672,10 @@ namespace etl } else { - operation(command::Destroy, data, nullptr); + operation(Destroy, data, nullptr); operation = other.operation; - operation(command::Move, data, other.data); + operation(Move, data, other.data); type_id = other.type_id; } @@ -546,10 +736,41 @@ namespace etl #endif } + //*************************************************************************** + /// 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: /// The operation function type. - using operation_function = void(*)(command, char*, const char*); + using operation_function = void(*)(int, char*, const char*); //*************************************************************************** /// Construct the type in-place. lvalue reference. @@ -595,153 +816,160 @@ namespace etl ::new (pstorage) type(); } - //******************************************* - // Declaration. - template - struct operation_type; - - //******************************************* - // Specialisation for null operation. - template <> - struct operation_type - { - static void do_operation(variant::command 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(variant::command operation, char* pstorage, const char* pvalue) - { - switch (operation) - { - case variant::command::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(variant::command operation, char* pstorage, const char* pvalue) - { - switch (operation) - { - case variant::command::Move: - { - ::new (pstorage) T(etl::move(*reinterpret_cast(const_cast(pvalue)))); - break; - } - - case variant::command::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(variant::command operation, char* pstorage, const char* pvalue) - { - switch (operation) - { - case variant::command::Copy: - { - ::new (pstorage) T(*reinterpret_cast(pvalue)); - break; - } - - case variant::command::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(variant::command command, char* pstorage, const char* pvalue) - { - switch (command) - { - case variant::command::Copy: - { - ::new (pstorage) T(*reinterpret_cast(pvalue)); - break; - } - - case variant::command::Move: - { - ::new (pstorage) T(etl::move(*reinterpret_cast(const_cast(pvalue)))); - break; - } - - case variant::command::Destroy: - { - reinterpret_cast(pstorage)->~T(); - break; - } - - default: - { - assert(false); - break; - } - } - } - }; +// //******************************************* +// // 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; +// +// //******************************************* +// // Declaration. +// template +// struct operation_type; +// +// //******************************************* +// // Specialisation for null operation. +// template <> +// struct operation_type +// { +// static void do_operation(variant::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(variant::int operation, char* pstorage, const char* pvalue) +// { +// switch (operation) +// { +// case variant::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(variant::int operation, char* pstorage, const char* pvalue) +// { +// switch (operation) +// { +// case variant::Move: +// { +// ::new (pstorage) T(etl::move(*reinterpret_cast(const_cast(pvalue)))); +// break; +// } +// +// case variant::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(variant::int operation, char* pstorage, const char* pvalue) +// { +// switch (operation) +// { +// case variant::Copy: +// { +// ::new (pstorage) T(*reinterpret_cast(pvalue)); +// break; +// } +// +// case variant::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(variant::int int, char* pstorage, const char* pvalue) +// { +// switch (int) +// { +// case variant::Copy: +// { +// ::new (pstorage) T(*reinterpret_cast(pvalue)); +// break; +// } +// +// case variant::Move: +// { +// ::new (pstorage) T(etl::move(*reinterpret_cast(const_cast(pvalue)))); +// break; +// } +// +// case variant::Destroy: +// { +// reinterpret_cast(pstorage)->~T(); +// break; +// } +// +// default: +// { +// assert(false); +// break; +// } +// } +// } +// }; #if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) //*************************************************************************** @@ -912,6 +1140,12 @@ namespace etl } } + //*************************************************************************** + /// The internal storage. + /// Aligned on a suitable boundary, which should be good for all types. + //*************************************************************************** + etl::uninitialized_buffer data; + //*************************************************************************** /// The operation function. //*************************************************************************** @@ -952,27 +1186,6 @@ namespace etl return (index == v.index()); } - //*************************************************************************** - /// 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; - //*************************************************************************** /// get //*************************************************************************** diff --git a/include/etl/utility.h b/include/etl/utility.h index adee90d8..df3f86e0 100644 --- a/include/etl/utility.h +++ b/include/etl/utility.h @@ -420,7 +420,9 @@ namespace etl explicit ETL_CONSTEXPR in_place_t() {} }; - inline ETL_CONSTANT in_place_t in_place; +#if ETL_CPP17_SUPPORTED + inline constexpr in_place_t in_place; +#endif //************************* template struct in_place_type_t @@ -428,8 +430,10 @@ namespace etl explicit ETL_CONSTEXPR in_place_type_t(){}; }; +#if ETL_CPP17_SUPPORTED template - inline ETL_CONSTANT in_place_type_t in_place_type; + inline constexpr in_place_type_t in_place_type; +#endif //************************* template struct in_place_index_t @@ -437,8 +441,10 @@ namespace etl explicit ETL_CONSTEXPR in_place_index_t() {} }; +#if ETL_CPP17_SUPPORTED template - inline ETL_CONSTANT in_place_index_t in_place_index; + inline constexpr in_place_index_t in_place_index; +#endif } #endif diff --git a/test/etl_profile.h b/test/etl_profile.h index ec26e76c..8b455130 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -101,7 +101,7 @@ SOFTWARE. #endif #define ETL_OVERLOAD_FORCE_CPP14 -#define ETL_VARIANT_FORCE_CPP11 +//#define ETL_VARIANT_FORCE_CPP11 #define ETL_VARIANT_CPP11_MAX_16_TYPES #if defined(ETL_NO_STL) diff --git a/test/test_variant_new.cpp b/test/test_variant_new.cpp index ae0cfc81..87079ab0 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -415,6 +415,70 @@ namespace 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)); + } + + //************************************************************************* + 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()); + } + //************************************************************************* TEST(test_emplace_value) { From 7b63b567b665bb277876c2bab9f98156137ab16c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 16 Jul 2021 22:21:42 +0100 Subject: [PATCH 60/81] Fixes for cross compiler cmpatibility Added tests for all get<>() functions --- include/etl/private/variant_new.h | 255 ++++++++---------------------- test/test_variant_new.cpp | 28 ++++ 2 files changed, 93 insertions(+), 190 deletions(-) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 2fe4865c..3e8adc76 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -346,6 +346,36 @@ namespace etl 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 @@ -402,6 +432,37 @@ namespace etl //*************************************************************************** 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. @@ -736,37 +797,6 @@ namespace etl #endif } - //*************************************************************************** - /// 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: /// The operation function type. @@ -816,161 +846,6 @@ namespace etl ::new (pstorage) 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; -// -// //******************************************* -// // Declaration. -// template -// struct operation_type; -// -// //******************************************* -// // Specialisation for null operation. -// template <> -// struct operation_type -// { -// static void do_operation(variant::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(variant::int operation, char* pstorage, const char* pvalue) -// { -// switch (operation) -// { -// case variant::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(variant::int operation, char* pstorage, const char* pvalue) -// { -// switch (operation) -// { -// case variant::Move: -// { -// ::new (pstorage) T(etl::move(*reinterpret_cast(const_cast(pvalue)))); -// break; -// } -// -// case variant::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(variant::int operation, char* pstorage, const char* pvalue) -// { -// switch (operation) -// { -// case variant::Copy: -// { -// ::new (pstorage) T(*reinterpret_cast(pvalue)); -// break; -// } -// -// case variant::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(variant::int int, char* pstorage, const char* pvalue) -// { -// switch (int) -// { -// case variant::Copy: -// { -// ::new (pstorage) T(*reinterpret_cast(pvalue)); -// break; -// } -// -// case variant::Move: -// { -// ::new (pstorage) T(etl::move(*reinterpret_cast(const_cast(pvalue)))); -// break; -// } -// -// case variant::Destroy: -// { -// reinterpret_cast(pstorage)->~T(); -// break; -// } -// -// default: -// { -// assert(false); -// break; -// } -// } -// } -// }; - #if ETL_CPP17_SUPPORTED && !defined(ETL_VARIANT_FORCE_CPP11) //*************************************************************************** /// Call the relevent visitor by attemptng each one. @@ -1231,7 +1106,7 @@ namespace etl using type = etl::variant_alternative_t>; - return *static_cast(v.data); + return *static_cast(v.data); } //*********************************** @@ -1247,7 +1122,7 @@ namespace etl using type = etl::variant_alternative_t>; - return etl::move(*static_cast(v.data)); + return etl::move(*static_cast(v.data)); } //*********************************** @@ -1265,7 +1140,7 @@ namespace etl { constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; - return get(v); + return get(etl::move(v)); } //*********************************** @@ -1283,7 +1158,7 @@ namespace etl { constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; - return get(v); + return get(etl::move(v)); } //*************************************************************************** diff --git a/test/test_variant_new.cpp b/test/test_variant_new.cpp index 87079ab0..c264c0eb 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -455,6 +455,7 @@ namespace CHECK_EQUAL(D4("1", "2", "3", "4"), etl::get(variant_etl4)); } +#if ETL_USING_STL //************************************************************************* TEST(test_construct_with_initializer_list_by_type) { @@ -478,6 +479,7 @@ namespace CHECK_EQUAL(expected.size(), result.size()); CHECK_ARRAY_EQUAL(expected.data(), result.data(), expected.size()); } +#endif //************************************************************************* TEST(test_emplace_value) @@ -933,6 +935,32 @@ namespace CHECK_EQUAL(to_std.copied_to, to_etl.copied_to); } + //************************************************************************* + TEST(test_get_by_type) + { + MoveableCopyable movecopyable; + + etl::variant v(movecopyable); + + const etl::variant cv(movecopyable); + + etl::variant& rv(v); + + const etl::variant& crv(v); + + // From variant reference + MoveableCopyable movecopyable_vr = etl::get(rv); + + // From variant rvalue reference + MoveableCopyable&& movecopyable_vrr = etl::get(etl::move(v)); + + // From variant const reference + const MoveableCopyable& movecopyable_vcr = etl::get(crv); + + // From variant const rvalue reference + const MoveableCopyable&& movecopyable_vcrr = etl::get(etl::move(cv)); + } + //************************************************************************* //TEST(test_copyable_vs_moveable_types_etl) //{ From aa98a608226071eb1b50405f8c79d158a77c1ec7 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 17 Jul 2021 23:45:28 +0100 Subject: [PATCH 61/81] etl::variant release candidate --- include/etl/overload.h | 41 +---- include/etl/private/variant_new.h | 94 ++--------- include/etl/variant.h | 2 +- test/etl_profile.h | 2 +- test/test_mem_cast.cpp | 4 +- test/test_mem_cast_ptr.cpp | 4 - test/test_variant_new.cpp | 270 +++++++++++++++++++----------- 7 files changed, 197 insertions(+), 220 deletions(-) diff --git a/include/etl/overload.h b/include/etl/overload.h index 52a41fcd..b2ab3333 100644 --- a/include/etl/overload.h +++ b/include/etl/overload.h @@ -65,44 +65,6 @@ namespace etl #else - //************************************************************************* - /// Variadic template definition of overload for C++14. - //************************************************************************* - //namespace private_overload - //{ - // //*********************************** - // // Overload helper templates. - // //*********************************** - // template - // struct overload_helper; - - // template <> - // struct overload_helper<> - // { - // }; - - // template - // struct overload_helper : TFirst, overload_helper - // { - // using TFirst::operator(); - - // template - // overload_helper(UFirst&& u, UOthers&&... others) - // : TFirst{ etl::forward(u) }, overload_helper{ etl::forward(others)... } - // { - // } - // }; - //} - - ////*********************************** - ///// Make an overload. - ////*********************************** - //template - //constexpr auto make_overload(TOverloads&&... overloads) - //{ - // return private_overload::overload_helper{ etl::forward(overloads)... }; - //} - template struct overload : TFirst, overload { @@ -110,7 +72,8 @@ namespace etl using overload::operator(); }; - template struct overload : TFirst + template + struct overload : TFirst { using TFirst::operator(); }; diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 3e8adc76..139c0552 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -940,18 +940,18 @@ namespace etl void do_operator(TVisitor& visitor) { #if defined(ETL_VARIANT_CPP11_MAX_8_TYPES) - ETL_STATIC_ASSERT(sizeof...(TTypes) <= 8U, "There are more than 8 types in this variant"); + 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, "There are more than 16 types in this variant"); + 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, "There are more than 24 types in this variant"); + 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, "There are more than 32 types in this variant"); + ETL_STATIC_ASSERT(sizeof...(TTypes) <= 32U, "A maximum of 32 types are allowed in this variant"); switch (index()) { @@ -1162,9 +1162,9 @@ namespace etl } //*************************************************************************** - /// get_if (pointer parameter) - //*************************************************************************** - template < size_t Index, typename... TTypes > + /// get_if + //*************************************************************************** + template< size_t Index, typename... TTypes > ETL_CONSTEXPR14 etl::add_pointer_t>> get_if(etl::variant* pv) noexcept { @@ -1199,7 +1199,14 @@ namespace etl { constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; - return etl::get_if(pv); + if ((pv != nullptr) && (pv->index() == Index)) + { + return &etl::get(*pv); + } + else + { + return nullptr; + } } //*********************************** @@ -1208,19 +1215,9 @@ namespace etl { constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; - return etl::get_if(pv); - } - - //*************************************************************************** - /// get_if (reference parameter) - //*************************************************************************** - template < size_t Index, typename... TTypes > - ETL_CONSTEXPR14 etl::add_pointer_t>> - get_if(etl::variant& v) noexcept - { - if (v.index() == Index) + if ((pv != nullptr) && (pv->index() == Index)) { - return &etl::get(v); + return &etl::get(*pv); } else { @@ -1228,63 +1225,6 @@ namespace etl } } - //*********************************** - template< size_t Index, typename... TTypes > - ETL_CONSTEXPR14 etl::add_pointer_t>> - get_if(const etl::variant& v) noexcept - { - if (v.index() == Index) - { - return &etl::get(v); - } - else - { - return nullptr; - } - } - - //*********************************** - template< size_t Index, typename... TTypes > - ETL_CONSTEXPR14 etl::add_pointer_t>> - get_if(etl::variant&& v) noexcept - { - if (v.index() == Index) - { - return &etl::get(v); - } - else - { - return nullptr; - } - } - - //*********************************** - template< class T, typename... TTypes > - ETL_CONSTEXPR14 etl::add_pointer_t get_if(etl::variant& v) noexcept - { - constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; - - return etl::get_if(v); - } - - //*********************************** - template< class T, typename... TTypes > - ETL_CONSTEXPR14 etl::add_pointer_t get_if(const etl::variant& v) noexcept - { - constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; - - return etl::get_if(v); - } - - //*********************************** - template< class T, typename... TTypes > - ETL_CONSTEXPR14 etl::add_pointer_t get_if(etl::variant&& v) noexcept - { - constexpr size_t Index = etl::private_variant::parameter_pack::template index_of_type::value; - - return etl::get_if(v); - } - //*************************************************************************** /// swap //*************************************************************************** diff --git a/include/etl/variant.h b/include/etl/variant.h index 7e4a20e6..7f6b4546 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -31,7 +31,7 @@ SOFTWARE. #ifndef ETL_VARIANT_INCLUDED #define ETL_VARIANT_INCLUDED -#if ETL_USE_LEGACY_VARIANT +#if !ETL_CPP11_SUPPORTED || ETL_USE_LEGACY_VARIANT #include "private/variant_legacy.h" #else #include "private/variant_new.h" diff --git a/test/etl_profile.h b/test/etl_profile.h index 8b455130..710bb5a9 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -100,7 +100,7 @@ SOFTWARE. #define ETL_MEM_CAST_FORCE_CPP03 #endif -#define ETL_OVERLOAD_FORCE_CPP14 +//#define ETL_OVERLOAD_FORCE_CPP14 //#define ETL_VARIANT_FORCE_CPP11 #define ETL_VARIANT_CPP11_MAX_16_TYPES 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_variant_new.cpp b/test/test_variant_new.cpp index c264c0eb..5ce23d0a 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -30,6 +30,7 @@ SOFTWARE. #include "etl/private/variant_new.h" #include "etl/visitor.h" +#include "etl/overload.h" #include #include @@ -675,7 +676,7 @@ namespace } //************************************************************************* - TEST(test_variant_visitor) + TEST(test_variant_accept_visitor) { struct Visitor : public etl::visitor { @@ -724,7 +725,7 @@ namespace } //************************************************************************* - TEST(test_variant_operator_visit) + TEST(test_variant_accept_functor_with_functor_class) { struct Visitor { @@ -745,7 +746,7 @@ namespace result_i = i; } - void operator()(std::string& s) + void operator()(const std::string& s) { result_s = s; } @@ -772,6 +773,35 @@ namespace 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::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) { @@ -779,27 +809,18 @@ namespace variant_etl = char(1); CHECK(etl::get_if<0>(&variant_etl) != nullptr); - CHECK(etl::get_if<0>(variant_etl) != nullptr); CHECK(etl::get_if<1>(&variant_etl) == nullptr); - CHECK(etl::get_if<1>(variant_etl) == nullptr); CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); CHECK(etl::get_if<1>(&variant_etl) != nullptr); - CHECK(etl::get_if<1>(variant_etl) != nullptr); CHECK(etl::get_if<2>(&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<0>(variant_etl) == nullptr); CHECK(etl::get_if<1>(&variant_etl) == nullptr); - CHECK(etl::get_if<1>(variant_etl) == nullptr); CHECK(etl::get_if<2>(&variant_etl) != nullptr); - CHECK(etl::get_if<2>(variant_etl) != nullptr); } //************************************************************************* @@ -809,27 +830,18 @@ namespace 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); - 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); - 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); - CHECK(etl::get_if(variant_etl) == nullptr); CHECK(etl::get_if(&variant_etl) != nullptr); - CHECK(etl::get_if(variant_etl) != nullptr); } //************************************************************************* @@ -938,97 +950,165 @@ namespace //************************************************************************* TEST(test_get_by_type) { - MoveableCopyable movecopyable; + MoveableCopyable value1; + MoveableCopyable value2; + MoveableCopyable value3; - etl::variant v(movecopyable); + etl::variant v_etl(value1); + const etl::variant cv_etl(value2); + etl::variant& rv_etl(v_etl); + const etl::variant& crv_etl(value3); - const etl::variant cv(movecopyable); - - etl::variant& rv(v); - - const etl::variant& crv(v); + 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 movecopyable_vr = etl::get(rv); - - // From variant rvalue reference - MoveableCopyable&& movecopyable_vrr = etl::get(etl::move(v)); + 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& movecopyable_vcr = etl::get(crv); - + 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&& movecopyable_vcrr = etl::get(etl::move(cv)); + 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_copyable_vs_moveable_types_etl) - //{ - // Copyable copyable_from; - // Copyable copyable_to; + TEST(test_get_by_index) + { + MoveableCopyable value1; + MoveableCopyable value2; + MoveableCopyable value3; - // Moveable moveable_from; - // Moveable moveable_to; + etl::variant v_etl(value1); + const etl::variant cv_etl(value2); + etl::variant& rv_etl(v_etl); + const etl::variant& crv_etl(value3); - // MoveableCopyable movecopyable_from1; - // MoveableCopyable movecopyable_from2; - // MoveableCopyable movecopyable_to1; - // MoveableCopyable movecopyable_to2; + std::variant v_std(value1); + const std::variant cv_std(value2); + std::variant& rv_std(v_std); + const std::variant& crv_std(value3); - // etl::variant variant_c(copyable_from); - // copyable_to = etl::get<0>(variant_c); + // 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); - // etl::variant variant_m(etl::move(moveable_from)); - // moveable_to = etl::move(etl::get<0>(variant_m)); + // 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); - // etl::variant variant_mc1(movecopyable_from1); - // movecopyable_to1 = etl::get<0>(variant_mc1); + // 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); - // etl::variant variant_mc2(etl::move(movecopyable_from2)); - // movecopyable_to2 = etl::move(etl::get<0>(variant_mc2)); - - // etl::variant variant_mc3(variant_mc1); - - // etl::variant variant_mc4(etl::move(variant_mc1)); - - // etl::variant variant_mc5(variant_mc2); - - // etl::variant variant_mc6(etl::move(variant_mc2)); - //} + // 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_copyable_vs_moveable_types_std) -// { -// Copyable copyable_from; -// Copyable copyable_to; -// -// Moveable moveable_from; -// Moveable moveable_to; -// -// MoveableCopyable movecopyable_from1; -// MoveableCopyable movecopyable_from2; -// MoveableCopyable movecopyable_to1; -// MoveableCopyable movecopyable_to2; -// -// std::variant variant_c(copyable_from); -// copyable_to = std::get<0>(variant_c); -// -// //std::variant variant_m(etl::move(moveable_from)); -// //moveable_to = std::move(std::get<0>(variant_m)); -// -// std::variant variant_mc1(movecopyable_from1); -// movecopyable_to1 = std::get<0>(variant_mc1); -// -//// std::variant variant_mc2(std::move(movecopyable_from2)); -//// movecopyable_to2 = std::move(std::get<0>(variant_mc2)); -// -//// std::variant variant_mc3(variant_mc1); -// -//// std::variant variant_mc4(std::move(variant_mc1)); -// -//// std::variant variant_mc5(variant_mc2); -// -//// std::variant variant_mc6(std::move(variant_mc2)); -// } + 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); + } }; } From 42db0ac1994d888feea9ab4dfea516a340cb120b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 17 Jul 2021 23:46:24 +0100 Subject: [PATCH 62/81] VS2022 Preview Solution --- test/vs2022/.gitignore | 7 + test/vs2022/.leu | 1 + test/vs2022/NatvisFile.natvis | 3 + test/vs2022/cpp.hint | 40 + test/vs2022/etl.sln | 103 + test/vs2022/etl.vcxproj | 5091 +++++++++++++++++++++++++++++++ test/vs2022/etl.vcxproj.filters | 2738 +++++++++++++++++ 7 files changed, 7983 insertions(+) create mode 100644 test/vs2022/.gitignore create mode 100644 test/vs2022/.leu create mode 100644 test/vs2022/NatvisFile.natvis create mode 100644 test/vs2022/cpp.hint create mode 100644 test/vs2022/etl.sln create mode 100644 test/vs2022/etl.vcxproj create mode 100644 test/vs2022/etl.vcxproj.filters diff --git a/test/vs2022/.gitignore b/test/vs2022/.gitignore new file mode 100644 index 00000000..e3cb4a54 --- /dev/null +++ b/test/vs2022/.gitignore @@ -0,0 +1,7 @@ +/random_clcg.csv +/random_lcg.csv +/random_lsfr.csv +/random_mwc.csv +/random_xorshift.csv +/random_pcg.csv +/random_hash.csv diff --git a/test/vs2022/.leu b/test/vs2022/.leu new file mode 100644 index 00000000..65f61979 --- /dev/null +++ b/test/vs2022/.leu @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/vs2022/NatvisFile.natvis b/test/vs2022/NatvisFile.natvis new file mode 100644 index 00000000..e78c2e3b --- /dev/null +++ b/test/vs2022/NatvisFile.natvis @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/test/vs2022/cpp.hint b/test/vs2022/cpp.hint new file mode 100644 index 00000000..3c9d8d88 --- /dev/null +++ b/test/vs2022/cpp.hint @@ -0,0 +1,40 @@ +// Hint files help the Visual Studio IDE interpret Visual C++ identifiers +// such as names of functions and macros. +// For more information see https://go.microsoft.com/fwlink/?linkid=865984 +#define ETL_CONSTEXPR +#define ETL_CONSTEXPR14 +#define ETL_CONSTEXPR17 +#define ETL_IF_CONSTEXPR +#define ETL_DELETE +#define ETL_NOEXCEPT +#define ETL_NOEXCEPT_EXPR +#define ETL_NODISCARD +#define ETL_OVERRIDE +#define ETL_FINAL +#define ETL_DEPRECATED +#define ETL_ERROR_TEXT +#define ETL_ASSERT +#define ETL_ERROR +#define ETL_VERBOSE_ERRORS +#define ETL_FILE +#define ETL_NULLPTR +#define ETL_CPP11_SUPPORTED +#define ETL_CPP14_SUPPORTED +#define ETL_CPP17_SUPPORTED + +#define TEST +#define CHECK +#define CHECK_EQUAL +#define CHECK_THROW +// Hint files help the Visual Studio IDE interpret Visual C++ identifiers +// such as names of functions and macros. +// For more information see https://go.microsoft.com/fwlink/?linkid=865984 +#define ETL_ASSERT(b, e) +#define ETL_ASSERT(b, e) {if (!(b)) {etl::error_handler::error((e)); throw((e));}} +#define ETL_ASSERT(b, e) {if (!(b)) {throw((e));}} +#define ETL_ASSERT(b, e) {if(!(b)) {etl::error_handler::error((e));}} +#define ETL_ASSERT(b, e) assert((b)) +// Hint files help the Visual Studio IDE interpret Visual C++ identifiers +// such as names of functions and macros. +// For more information see https://go.microsoft.com/fwlink/?linkid=865984 +#define ETL_NULLPTR diff --git a/test/vs2022/etl.sln b/test/vs2022/etl.sln new file mode 100644 index 00000000..ce177c05 --- /dev/null +++ b/test/vs2022/etl.sln @@ -0,0 +1,103 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29926.136 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "etl", "etl.vcxproj", "{C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug LLVM - No STL|Win32 = Debug LLVM - No STL|Win32 + 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 - 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 + Debug MSVC - No STL|x64 = Debug MSVC - No STL|x64 + Debug MSVC - No Unit Tests|Win32 = Debug MSVC - No Unit Tests|Win32 + Debug MSVC - No Unit Tests|x64 = Debug MSVC - No Unit Tests|x64 + Debug MSVC - Small Strings|Win32 = Debug MSVC - Small Strings|Win32 + Debug MSVC - Small Strings|x64 = Debug MSVC - Small Strings|x64 + Debug MSVC - String Truncation Is Error|Win32 = Debug MSVC - String Truncation Is Error|Win32 + Debug MSVC - String Truncation Is Error|x64 = Debug MSVC - String Truncation Is Error|x64 + Debug MSVC 64|Win32 = Debug MSVC 64|Win32 + Debug MSVC 64|x64 = Debug MSVC 64|x64 + Debug MSVC No Checks|Win32 = Debug MSVC No Checks|Win32 + Debug MSVC No Checks|x64 = Debug MSVC No Checks|x64 + Debug MSVC|Win32 = Debug MSVC|Win32 + Debug MSVC|x64 = Debug MSVC|x64 + LLVM New|Win32 = LLVM New|Win32 + LLVM New|x64 = LLVM New|x64 + MSVCDebugAppveyor|Win32 = MSVCDebugAppveyor|Win32 + MSVCDebugAppveyor|x64 = MSVCDebugAppveyor|x64 + MSVCDebugNoSTLAppveyor|Win32 = MSVCDebugNoSTLAppveyor|Win32 + MSVCDebugNoSTLAppveyor|x64 = MSVCDebugNoSTLAppveyor|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|Win32.ActiveCfg = DebugLLVMNoSTL|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|Win32.Build.0 = DebugLLVMNoSTL|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|x64.ActiveCfg = DebugLLVMNoSTL|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM - No STL|x64.Build.0 = DebugLLVMNoSTL|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug LLVM|Win32.ActiveCfg = Debug LLVM|Win32 + {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 - 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 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL - Force No Advanced|x64.Build.0 = DebugNoSTLForceNoAdvanced|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL|Win32.ActiveCfg = DebugNoSTL|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL|Win32.Build.0 = DebugNoSTL|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL|x64.ActiveCfg = DebugNoSTL|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No STL|x64.Build.0 = DebugNoSTL|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No Unit Tests|Win32.ActiveCfg = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No Unit Tests|Win32.Build.0 = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No Unit Tests|x64.ActiveCfg = Debug No Unit Tests|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - No Unit Tests|x64.Build.0 = Debug No Unit Tests|x64 + {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 - 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 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC - String Truncation Is Error|x64.Build.0 = DebugStringTruncationIsError|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|Win32.ActiveCfg = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|Win32.Build.0 = Debug No Unit Tests|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|x64.ActiveCfg = Debug64|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC 64|x64.Build.0 = Debug64|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC No Checks|Win32.ActiveCfg = Debug MSVC No Checks|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC No Checks|Win32.Build.0 = Debug MSVC No Checks|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC No Checks|x64.ActiveCfg = Debug MSVC No Checks|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC No Checks|x64.Build.0 = Debug MSVC No Checks|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Debug MSVC|Win32.ActiveCfg = Debug|Win32 + {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}.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 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.LLVM New|x64.Build.0 = LLVM New|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVCDebugAppveyor|Win32.ActiveCfg = MSVCDebugAppveyor|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVCDebugAppveyor|Win32.Build.0 = MSVCDebugAppveyor|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVCDebugAppveyor|x64.ActiveCfg = MSVCDebugAppveyor|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVCDebugAppveyor|x64.Build.0 = MSVCDebugAppveyor|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVCDebugNoSTLAppveyor|Win32.ActiveCfg = MSVCDebugNoSTLAppveyor|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVCDebugNoSTLAppveyor|Win32.Build.0 = MSVCDebugNoSTLAppveyor|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVCDebugNoSTLAppveyor|x64.ActiveCfg = MSVCDebugNoSTLAppveyor|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.MSVCDebugNoSTLAppveyor|x64.Build.0 = MSVCDebugNoSTLAppveyor|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|Win32.ActiveCfg = Release|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|Win32.Build.0 = Release|Win32 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|x64.ActiveCfg = Release|x64 + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0E35F961-E9EF-40C4-8E3E-2EC79B1D44B8} + EndGlobalSection +EndGlobal diff --git a/test/vs2022/etl.vcxproj b/test/vs2022/etl.vcxproj new file mode 100644 index 00000000..f591bed1 --- /dev/null +++ b/test/vs2022/etl.vcxproj @@ -0,0 +1,5091 @@ + + + + + Debug Clang + Win32 + + + Debug Clang + x64 + + + Debug LLVM + Win32 + + + Debug LLVM + x64 + + + DebugMSVCSmallStrings + Win32 + + + DebugMSVCSmallStrings + x64 + + + Debug MSVC No Checks + Win32 + + + Debug MSVC No Checks + x64 + + + Debug64 + Win32 + + + Debug64 + x64 + + + Debug No Unit Tests + Win32 + + + Debug No Unit Tests + x64 + + + DebugLLVMNoSTL + Win32 + + + DebugLLVMNoSTL + x64 + + + DebugNoSTLForceNoAdvanced + Win32 + + + DebugNoSTLForceNoAdvanced + x64 + + + DebugNoSTL + Win32 + + + DebugNoSTL + x64 + + + DebugStringTruncationIsError + Win32 + + + DebugStringTruncationIsError + x64 + + + Debug + Win32 + + + Debug + x64 + + + LLVM New + Win32 + + + LLVM New + x64 + + + MSVCDebugAppveyor + Win32 + + + MSVCDebugAppveyor + x64 + + + MSVCDebugNoSTLAppveyor + Win32 + + + MSVCDebugNoSTLAppveyor + x64 + + + Release + Win32 + + + Release + x64 + + + + {C21DF78C-D8E0-46AB-9D6F-D38A3C1CB0FB} + Win32Proj + unittest + etl + 10.0 + + + + Application + true + v143 + Unicode + false + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + false + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + ClangCL + Unicode + + + Application + true + ClangCL + Unicode + + + Application + true + ClangCL + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + \$(IntDir) + + + true + true + \$(IntDir) + + + true + true + \$(IntDir) + + + true + true + \$(IntDir) + + + true + false + \$(IntDir) + + + true + true + \$(IntDir) + + + true + true + \$(IntDir) + + + true + true + \$(IntDir) + + + true + true + \$(IntDir) + + + false + true + \$(IntDir) + + + false + true + \$(IntDir) + + + false + true + \$(IntDir) + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + + + true + true + \$(IntDir) + + + true + true + + + true + true + + + true + true + + + false + true + + + false + true + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + true + stdcpp17 + EditAndContinue + + + Console + true + + + $(OutDir)\etl.exe + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_DISABLE_STRING_TRUNCATION_CHECKS;ETL_DISABLE_STRING_CLEAR_AFTER_USE;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + + + Console + true + + + $(OutDir)\etl.exe + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_TEMPLATE_DEDUCTION_GUIDE_TESTS_DISABLED;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + + + Console + true + + + $(OutDir)\etl.exe + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + + + Console + true + + + $(OutDir)\etl.exe + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_NO_CHECKS;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + + + Console + true + + + $(OutDir)\etl.exe + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_STRING_TRUNCATION_IS_ERROR;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + + + Console + true + + + $(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;%(PreprocessorDefinitions) + ./;../../../unittest-cpp/;../../include;../../test + + + true + stdcpp17 + ProgramDatabase + + + Console + true + + + $(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_TEMPLATE_DEDUCTION_GUIDE_TESTS_DISABLED;%(PreprocessorDefinitions) + ./;../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + + + Console + true + + + $(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_FORCE_NO_ADVANCED_CPP;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + + + Console + true + + + $(OutDir)\etl.exe + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;__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;__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;%(PreprocessorDefinitions) + ../../../unittest-cpp/UnitTest++/;../../include;../../test + + + false + stdcpp17 + false + FullDebug + Default + + + Console + false + + + "$(OutDir)etl.exe" + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + false + stdcpp17 + false + FullDebug + Default + + + Console + false + + + "$(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 + + + + + + + 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 + + + + + + + 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 + + + + + + + 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 + + + + + + + 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 + + + + + + + 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 + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../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 + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../../unittest-cpp/;../../include;../../test + + + stdcpp17 + + + Console + true + + + + + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../src;../../src/c;../../test + + + + + Console + true + + + + + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/;../../src + false + + + Console + true + true + true + + + $(OutDir)\etl.exe + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ../../unittest-cpp/UnitTest++/;../../src + false + + + Console + true + true + true + + + $(OutDir)\etl.exe + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ../../../unittest-cpp + ../../../unittest-cpp + false + false + + + + + + + + + + + + + + + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + + + + + + true + true + + + true + true + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + + + + + + + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + + + + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + true + true + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + + + + + + + + + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + + + + + + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/vs2022/etl.vcxproj.filters b/test/vs2022/etl.vcxproj.filters new file mode 100644 index 00000000..d5ee5e95 --- /dev/null +++ b/test/vs2022/etl.vcxproj.filters @@ -0,0 +1,2738 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {ecfaf316-dc6d-4dc1-9838-24061047ad63} + + + {53c3a373-0496-4db0-a981-86bf14a1fac9} + + + {107d7e33-580f-4dc5-be11-a4b2076c2c10} + + + {dc39d09c-75c9-453f-8feb-9631a200c0f4} + + + {ab41d19f-82fe-4974-a73b-16aebfa1d03f} + + + {d56ca96b-66e1-46cb-83fd-1cd72c51d962} + + + {1c55dd7d-c04b-428c-810b-dd3a08fc4c65} + + + {7028012c-30c4-4993-b2d9-3b1521a610ae} + + + {6be3bc76-e17c-4be0-8b0b-d1053e1a1761} + + + {c1264f38-22fa-4fcb-8cab-f254b1290eab} + + + {39015d44-a7cb-47f0-a7dd-27714f852363} + + + {1c95b9c1-96c0-4c1e-8e5a-e6680d88276c} + + + {0a77d88b-f9f0-456a-be4b-c0a0ce6b437b} + + + {e4a699ae-e7f3-418e-bf9f-211c21f7f4b2} + + + {7371282e-fddc-4269-891b-e909f74ff8e9} + + + {3353062c-e8dc-4095-b7cf-d11fc952263e} + + + {4d08353c-b393-47c7-a9eb-c9f2f8c25887} + + + {0bcdf7f9-8e2b-4f70-932b-bde56404f421} + + + {da88d71d-e5ea-4c26-9807-94616d31addb} + + + {0eaad66f-3ce3-4952-8ae8-c935e6aa7c1d} + + + {0d5824b1-3ef9-43e0-b2d5-15d6246b843e} + + + {c25471f3-451a-4279-925d-cbdcec912ef8} + + + {586d2c92-e504-4dea-9b1f-42d725a5272c} + + + {74399f00-a7a3-47e3-9b27-d01fb2b5ce87} + + + {afc65d0e-d846-4e30-8723-06c8cefa3a36} + + + {8a3300fa-c2cd-44dd-8582-692f97ec4dc0} + + + {ca522a34-8cf0-4f64-8ca1-33f52f65a9a7} + + + {ba2bf848-6023-4906-a0d4-14a4c8fba0e5} + + + {527f4d9a-8968-4352-8cdf-f6ccc391dcf9} + + + {57b110fa-b3d8-4cc4-9619-ca510a29c213} + + + {562466b5-677d-4448-9e9e-f70805cd71ad} + + + {1d6ea286-57ad-4960-9343-9d2376087b24} + + + {5eace791-3e53-4205-a04d-2aba3bac6b47} + + + {2b770849-325e-4ec5-a7f3-9a192cd40dca} + + + {0e4d2126-b9b7-4eef-b5ca-18363b1e01ce} + + + {79c578f6-5400-4b4d-b2a4-9a8c589f7c81} + + + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Patterns + + + ETL\Patterns + + + ETL\Utilities + + + ETL\Containers + + + ETL\Containers + + + ETL\Maths + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Containers + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Containers + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Containers + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Containers + + + ETL\Maths + + + ETL\Containers + + + ETL\Containers + + + ETL\Utilities + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Maths + + + ETL\Maths + + + Source Files + + + ETL\Maths + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Utilities + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Private + + + ETL\Utilities + + + ETL\Containers + + + ETL\Utilities + + + ETL\Containers + + + ETL\Containers + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Frameworks + + + ETL\Frameworks + + + ETL\Containers + + + ETL\Frameworks + + + ETL\Frameworks + + + ETL\Frameworks + + + ETL\Frameworks + + + ETL\Frameworks + + + ETL\Maths + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Maths + + + ETL\Utilities + + + ETL\Utilities + + + ETL\Frameworks + + + ETL\Frameworks + + + ETL\Frameworks + + + ETL\Utilities + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + Source Files + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Utilities\Atomic + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Utilities + + + ETL\Utilities\Atomic + + + ETL\Utilities\Atomic + + + ETL\Containers + + + ETL\Containers + + + ETL\Containers + + + ETL\Utilities\Mutex + + + ETL\Utilities\Mutex + + + ETL\Utilities\Mutex + + + ETL\Utilities + + + ETL\Maths + + + ETL\Maths + + + ETL\Utilities + + + ETL\Utilities + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + ETL\Maths + + + ETL\Profiles + + + ETL\Private + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Maths + + + ETL\Utilities + + + ETL\Private + + + ETL\Private + + + ETL\Private + + + ETL\Frameworks + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + Source Files + + + ETL\Frameworks + + + ETL\Maths + + + ETL\Containers + + + ETL\Utilities + + + ETL\Private + + + ETL\Containers + + + ETL\Utilities + + + ETL\Frameworks + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Utilities + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Containers + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Private + + + ETL\Utilities + + + Source Files + + + ETL\Utilities\Mutex + + + ETL\Frameworks + + + ETL\Utilities + + + ETL\Containers + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Profiles + + + ETL\Utilities\Generators + + + ETL\Utilities\Generators + + + ETL\Utilities\Generators + + + ETL\Utilities\Generators + + + ETL\Utilities\Generators + + + ETL\Frameworks\Generators + + + ETL\Frameworks\Generators + + + ETL\Frameworks\Generators + + + ETL\Containers\Generators + + + ETL\Utilities + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Strings + + + ETL\Pseudo Containers + + + ETL\Strings + + + ETL\Containers + + + ETL\Utilities + + + ETL\Utilities\Atomic + + + ETL\Containers + + + ETL\Utilities + + + ETL\Utilities\Mutex + + + ETL\Arduino + + + ETL\Utilities + + + Header Files + + + ETL\Frameworks + + + ETL\Frameworks + + + ETL\Frameworks + + + ETL\Containers + + + ETL\Containers + + + ETL\Utilities + + + ETL\Frameworks + + + ETL\Utilities + + + ETL\Containers + + + ETL\Containers + + + ETL\Patterns + + + ETL\Containers + + + ETL\Frameworks + + + Source Files + + + Source Files\Sanity Checks\C++03 + + + Source Files\Sanity Checks\C++11 + + + Source Files\Sanity Checks\C++14 + + + Source Files\Sanity Checks\C++17 + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Private + + + ETL\Private + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Maths + + + ETL\Frameworks + + + ETL\Private + + + ETL\Private + + + ETL\Utilities + + + ETL\Private + + + ETL\Private + + + ETL\Patterns + + + ETL\Patterns + + + Header 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 + + + 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 + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++ + + + UnitTest++\Win32 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\Sanity Checks + + + Source Files + + + Source Files + + + Source Files + + + 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 + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files\Sanity Checks + + + Source Files + + + + + Resource Files + + + Resource Files\Images + + + Resource Files\Images + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files\Generators + + + Resource Files\Generators + + + Resource Files\Generators + + + Resource Files\Generators + + + Resource Files\Generators + + + Resource Files\Generators + + + Resource Files\Generators + + + Resource Files\Generators + + + Resource Files\Generators + + + Resource Files\Generators + + + Resource Files\CI\CircleCI + + + Resource Files\Make + + + Resource Files\CI\Appveyor + + + Resource Files\CI\Github + + + Resource Files\CI\Github + + + Resource Files\CI\Github + + + Resource Files + + + Resource Files + + + ETL\Arduino + + + Source Files\Scripts + + + Source Files\Scripts + + + ETL\Arduino\Examples\Example_0_import_etl + + + ETL\Arduino\Examples\Vector_Examples\Example_Vector_1_simple_use + + + + + Resource Files + + + Source Files + + + Resource Files + + + Resource Files\Make + + + Source Files\Sanity Checks\C++03 + + + Source Files\Sanity Checks\C++11 + + + Source Files\Sanity Checks\C++14 + + + Source Files\Sanity Checks\C++17 + + + Source Files\Sanity Checks + + + + + Resource Files\Images + + + Resource Files\Images + + + Resource Files\Images + + + Resource Files\Images + + + Resource Files\Images + + + Resource Files\Images + + + + + Resource Files + + + \ No newline at end of file From e9f6822215762c35cc84bcf7218dd5ac67c6562b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 17 Jul 2021 23:46:24 +0100 Subject: [PATCH 63/81] VS2022 Preview Solution --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cb627492..5effe158 100644 --- a/.gitignore +++ b/.gitignore @@ -315,3 +315,4 @@ test/sanity-check/c++17/Makefile test/vs2019/Debug LLVM test/vs2019/DebugLLVMNoSTL test/vs2019/DebugNoSTL +test/vs2022/Debug LLVM From a7420267a66424e2b6ab960a732a545c51882c81 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 18 Jul 2021 09:53:13 +0100 Subject: [PATCH 64/81] Cross compiler compatibity changes --- include/etl/overload.h | 23 +++++++++-------------- test/etl_profile.h | 4 ++-- test/test_overload.cpp | 2 +- test/test_variant_new.cpp | 10 ++++------ 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/include/etl/overload.h b/include/etl/overload.h index b2ab3333..259aebeb 100644 --- a/include/etl/overload.h +++ b/include/etl/overload.h @@ -37,7 +37,7 @@ SOFTWARE. namespace etl { -#if ETL_CPP14_SUPPORTED +#if ETL_CPP11_SUPPORTED #if ETL_CPP17_SUPPORTED && !defined(ETL_OVERLOAD_FORCE_CPP14) //************************************************************************* @@ -49,15 +49,6 @@ namespace etl using TOverloads::operator()...; }; - //************************************************************************* - /// Make an overload. - //************************************************************************* - template - constexpr auto make_overload(TOverloads&&... overloads) - { - return overload{ etl::forward(overloads)... }; - } - //************************************************************************* /// Template deduction guide. //************************************************************************* @@ -65,6 +56,9 @@ namespace etl #else + //************************************************************************* + /// Variadic template definition of overload for C++14. + //************************************************************************* template struct overload : TFirst, overload { @@ -78,16 +72,17 @@ namespace etl using TFirst::operator(); }; +#endif + //************************************************************************* /// Make an overload. //************************************************************************* - template - constexpr auto make_overload(TOthers&&... overloads) + template + constexpr overload make_overload(TOverloads&&... overloads) { - return overload{ etl::forward(overloads)... }; + return overload{ etl::forward(overloads)... }; } -#endif #endif } diff --git a/test/etl_profile.h b/test/etl_profile.h index 710bb5a9..13ff44c3 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -100,9 +100,9 @@ SOFTWARE. #define ETL_MEM_CAST_FORCE_CPP03 #endif -//#define ETL_OVERLOAD_FORCE_CPP14 +//#define ETL_OVERLOAD_FORCE_CPP11 //#define ETL_VARIANT_FORCE_CPP11 -#define ETL_VARIANT_CPP11_MAX_16_TYPES +//#define ETL_VARIANT_CPP11_MAX_16_TYPES #if defined(ETL_NO_STL) #define ETL_TIMER_SEMAPHORE_TYPE uint32_t diff --git a/test/test_overload.cpp b/test/test_overload.cpp index 31d8389f..a9f50369 100644 --- a/test/test_overload.cpp +++ b/test/test_overload.cpp @@ -65,7 +65,7 @@ namespace }; template - void Function(T value, TOverload& ol) + void Function(T value, TOverload&& ol) { ol(value); } diff --git a/test/test_variant_new.cpp b/test/test_variant_new.cpp index 5ce23d0a..a1b421c7 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -774,18 +774,16 @@ namespace } //************************************************************************* + TEST(test_variant__accept_functor_with_overload) { char result_c; int result_i; std::string result_s; - auto visitor = etl::overload - { - [&result_c](char c) { result_c = 1; }, - [&result_i](int i) { result_i = 2; }, - [&result_s](const std::string& s) { result_s = "3"; } - }; + 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; From 140c69e6eaa862ad8ad392cccd230b520b3bfe4b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 18 Jul 2021 20:22:12 +0100 Subject: [PATCH 65/81] Updated version numbers --- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- meson.build | 2 +- support/Release notes.txt | 11 +++++++++++ test/test_delegate.cpp | 6 +++--- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index a763d4fc..4d30e25f 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,7 +38,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 20 -#define ETL_VERSION_MINOR 12 +#define ETL_VERSION_MINOR 13 #define ETL_VERSION_PATCH 0 #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) diff --git a/library.json b/library.json index 6a2af629..d18c46c6 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.12.0", + "version": "20.13.0", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index aa7cb1c7..37a22174 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.12.0 +version=20.13.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index aa473f82..095f2da6 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.13.0' ) ###################### diff --git a/support/Release notes.txt b/support/Release notes.txt index ab82c5b0..961f775c 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,14 @@ +=============================================================================== +20.13.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. +Added etl::is_assignable, etl::is_lvalue_assignable, etl::is_constructible, etl::is_copy_constructible +and etl::is_move_constructible to 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 +Fixed missing etl::alignment_of specialisation for const void. + =============================================================================== 20.12.0 Added the option to derived etl::message<> from a parent class other than etl::imessage. 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); } //******************************************* From cee880b2e669648f11fbe12fcb528ae39246a60c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 19 Jul 2021 12:51:54 +0100 Subject: [PATCH 66/81] Changed 'class' to 'typename'. --- include/etl/private/variant_new.h | 4 ++-- support/Release notes.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index 139c0552..a6c5608e 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -575,7 +575,7 @@ namespace etl //*************************************************************************** /// Construct from index, initializer_list and arguments. //*************************************************************************** - template + template ETL_CONSTEXPR14 explicit variant(etl::in_place_index_t, std::initializer_list init, TArgs&&... args) : data() , type_id(Index) @@ -1210,7 +1210,7 @@ namespace etl } //*********************************** - template< class T, typename... TTypes > + 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; diff --git a/support/Release notes.txt b/support/Release notes.txt index 961f775c..4354bb29 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -7,6 +7,7 @@ and etl::is_move_constructible to type_traits.h. Uses STL, compiler built-ins or 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. =============================================================================== From 31c183d8edfa670be3a29cd387f40fd521c78d87 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 19 Jul 2021 21:56:26 +0100 Subject: [PATCH 67/81] Added etl::conjunction and etl::disjunction tests --- test/test_type_traits.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index 8230581f..b77bc493 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -871,4 +871,18 @@ 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)); + } } From d49c2d28e0af3bcaef002c3702e34734313280cd Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 23 Jul 2021 10:21:11 +0100 Subject: [PATCH 68/81] Added compile time constexpr initialisation --- include/etl/delegate_service.h | 182 ++++++++++++++------ test/CMakeLists.txt | 1 + test/test_delegate_service.cpp | 14 +- test/test_delegate_service_compile_time.cpp | 144 ++++++++++++++++ test/vs2019/etl.vcxproj | 1 + test/vs2019/etl.vcxproj.filters | 3 + 6 files changed, 283 insertions(+), 62 deletions(-) create mode 100644 test/test_delegate_service_compile_time.cpp diff --git a/include/etl/delegate_service.h b/include/etl/delegate_service.h index 1d02560e..fd653349 100644 --- a/include/etl/delegate_service.h +++ b/include/etl/delegate_service.h @@ -46,55 +46,16 @@ 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. - /// Sets all delegates to the internal default. - //************************************************************************* - delegate_service() - { - etl::delegate default_delegate = etl::delegate::create, &delegate_service::unhandled>(*this); - - lookup.fill(default_delegate); - } - - //************************************************************************* - /// Registers a delegate for the specified id. - /// Compile time assert if the id is out of range. - /// \tparam ID The id of the delegate. - /// \param delegate Reference to the delegate. - //************************************************************************* - 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"); - - lookup[ID - OFFSET] = callback; - } - - //************************************************************************* - /// Registers a delegate for the specified id. - /// No action if the id is out of range. - /// \param id Id of the delegate. - /// \param delegate Reference to the delegate. - //************************************************************************* - void register_delegate(const size_t id, etl::delegate callback) - { - if ((id >= OFFSET) && (id < (OFFSET + RANGE))) - { - lookup[id - OFFSET] = callback; - } - } - //************************************************************************* /// Registers an alternative delegate for unhandled ids. /// \param delegate A reference to the user supplied 'unhandled' delegate. @@ -107,26 +68,26 @@ 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); + Delegates[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); + Delegates[id - Offset](id); } else { @@ -143,7 +104,118 @@ 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()) + { + unhandled_delegate(id); + } + } + + /// The default delegate for unhandled ids. + etl::delegate unhandled_delegate; + }; + + //*************************************************************************** + /// 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); + + lookup.fill(default_delegate); + } + + //************************************************************************* + /// Registers a delegate for the specified id. + /// Compile time assert if the id is out of range. + /// \tparam Id The id of the delegate. + /// \param delegate Reference to the delegate. + //************************************************************************* + 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"); + + lookup[Id - Offset] = callback; + } + + //************************************************************************* + /// Registers a delegate for the specified id. + /// No action if the id is out of range. + /// \param id Id of the delegate. + /// \param delegate Reference to the delegate. + //************************************************************************* + void register_delegate(const size_t id, etl::delegate callback) + { + if ((id >= Offset) && (id < (Offset + Range))) + { + lookup[id - Offset] = callback; + } + } + + //************************************************************************* + /// Registers an alternative delegate for unhandled ids. + /// \param delegate A reference to the user supplied 'unhandled' delegate. + //************************************************************************* + void register_unhandled_delegate(etl::delegate callback) + { + unhandled_delegate = callback; + } + + //************************************************************************* + /// 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"); + + lookup[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))) + { + lookup[id - Offset](id); + } + else + { + if (unhandled_delegate.is_valid()) + { + unhandled_delegate(id); + } + } + } + + private: + + //************************************************************************* + /// The default callback function. + /// Calls the user defined 'unhandled' callback if it exists. + //************************************************************************* + void unhandled(size_t id) const { if (unhandled_delegate.is_valid()) { @@ -155,7 +227,7 @@ namespace etl etl::delegate unhandled_delegate; /// Lookup table of delegates. - etl::array, RANGE> lookup; + etl::array, Range> lookup; }; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8664063e..65a0c6d0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -100,6 +100,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 diff --git a/test/test_delegate_service.cpp b/test/test_delegate_service.cpp index 8e20f10b..385e769d 100644 --- a/test/test_delegate_service.cpp +++ b/test/test_delegate_service.cpp @@ -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; } }; diff --git a/test/test_delegate_service_compile_time.cpp b/test/test_delegate_service_compile_time.cpp new file mode 100644 index 00000000..4fe696cb --- /dev/null +++ b/test/test_delegate_service_compile_time.cpp @@ -0,0 +1,144 @@ +/****************************************************************************** +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 = 3U; + 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 'member2'. + 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(); + + //***************************************************************************** + // 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) + { + static constexpr etl::delegate delegate_list[] + { + global_callback, + member_callback + }; + + etl::delegate_service service; + + service.call(); + CHECK_EQUAL(GLOBAL, called_id); + CHECK(global_called); + CHECK(!member_called); + + global_called = false; + + service.call(); + CHECK_EQUAL(MEMBER, called_id); + CHECK(!global_called); + CHECK(member_called); + } + }; +} diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 6c70ddf5..44fd284e 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -4493,6 +4493,7 @@ + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index cd5ef18a..0e9b7fdd 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2543,6 +2543,9 @@ Source Files\Sanity Checks + + Source Files + From 7a061a43cdafee73e2a73c7d446d2129f0853703 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 23 Jul 2021 12:50:17 +0100 Subject: [PATCH 69/81] Altered 'unhandled' delegate to tbe the last in the array for the constexpr vspecialisation. --- include/etl/delegate_service.h | 31 +----- test/test_delegate_service.cpp | 110 ++++++++++---------- test/test_delegate_service_compile_time.cpp | 53 ++++++---- 3 files changed, 91 insertions(+), 103 deletions(-) diff --git a/include/etl/delegate_service.h b/include/etl/delegate_service.h index fd653349..d6152dfb 100644 --- a/include/etl/delegate_service.h +++ b/include/etl/delegate_service.h @@ -56,15 +56,6 @@ namespace etl { public: - //************************************************************************* - /// Registers an alternative delegate for unhandled ids. - /// \param delegate A reference to the user supplied 'unhandled' delegate. - //************************************************************************* - void register_unhandled_delegate(etl::delegate callback) - { - unhandled_delegate = callback; - } - //************************************************************************* /// Executes the delegate function for the index. /// Compile time assert if the id is out of range. @@ -91,29 +82,9 @@ namespace etl } else { - if (unhandled_delegate.is_valid()) - { - unhandled_delegate(id); - } + Delegates[Range](id); } } - - private: - - //************************************************************************* - /// The default callback function. - /// Calls the user defined 'unhandled' callback if it exists. - //************************************************************************* - void unhandled(size_t id) const - { - if (unhandled_delegate.is_valid()) - { - unhandled_delegate(id); - } - } - - /// The default delegate for unhandled ids. - etl::delegate unhandled_delegate; }; //*************************************************************************** diff --git a/test/test_delegate_service.cpp b/test/test_delegate_service.cpp index 385e769d..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; @@ -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 index 4fe696cb..14b5faf8 100644 --- a/test/test_delegate_service_compile_time.cpp +++ b/test/test_delegate_service_compile_time.cpp @@ -33,10 +33,10 @@ SOFTWARE. namespace { - const size_t SIZE = 3U; - const size_t OFFSET = 5U; + const size_t Size = 2U; + const size_t Offset = 5U; - using Service = etl::delegate_service; + using Service = etl::delegate_service; //***************************************************************************** bool global_called = false; @@ -82,7 +82,7 @@ namespace Test test; - // Callback for 'member2'. + // Callback for 'member'. constexpr etl::delegate member_callback = etl::delegate::create(); // Callback for 'global'. @@ -91,6 +91,13 @@ namespace // 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. //***************************************************************************** @@ -110,9 +117,9 @@ namespace { enum { - GLOBAL = OFFSET, - MEMBER, - OUT_OF_RANGE + Global = Offset, + Member, + Out_Of_Range }; SUITE(test_delegate_service) @@ -120,25 +127,35 @@ namespace //************************************************************************* TEST_FIXTURE(SetupFixture, test_delegate_compile_time_constexpr) { - static constexpr etl::delegate delegate_list[] - { - global_callback, - member_callback - }; + etl::delegate_service service; - etl::delegate_service service; - - service.call(); - CHECK_EQUAL(GLOBAL, called_id); + 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); + 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); } }; } From 23b8ffcd2040b5029a4b339c90c13f2537b6581d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 23 Jul 2021 13:39:24 +0100 Subject: [PATCH 70/81] updated version numbers --- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- meson.build | 2 +- support/Release notes.txt | 4 ++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index a763d4fc..4d30e25f 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,7 +38,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 20 -#define ETL_VERSION_MINOR 12 +#define ETL_VERSION_MINOR 13 #define ETL_VERSION_PATCH 0 #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) diff --git a/library.json b/library.json index 6a2af629..d18c46c6 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.12.0", + "version": "20.13.0", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index aa7cb1c7..37a22174 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.12.0 +version=20.13.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index aa473f82..095f2da6 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.13.0' ) ###################### diff --git a/support/Release notes.txt b/support/Release notes.txt index ab82c5b0..a0b8388c 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +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. From 8f570d81cdcd504a6039920364caf2419b316750 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 26 Jul 2021 09:29:11 +0100 Subject: [PATCH 71/81] Work in progress --- include/etl/delegate_service.h | 16 +- .../etl/generators/type_traits_generator.h | 92 +++--- include/etl/private/variant_new.h | 12 + include/etl/type_traits.h | 266 +++++++++++++++--- test/etl_profile.h | 2 +- test/runtests.sh | 16 ++ test/test_type_traits.cpp | 139 +++++++++ test/test_variant_new.cpp | 111 ++++++-- 8 files changed, 534 insertions(+), 120 deletions(-) diff --git a/include/etl/delegate_service.h b/include/etl/delegate_service.h index d6152dfb..3908d841 100644 --- a/include/etl/delegate_service.h +++ b/include/etl/delegate_service.h @@ -51,7 +51,9 @@ namespace etl /// \tparam Delegates Pointer to an array of delegate pointers. /// The delegate ids must range between Offset and Offset + Range - 1. //*************************************************************************** - template * Delegates = nullptr> + template * Delegates = nullptr> class delegate_service { public: @@ -78,10 +80,12 @@ namespace etl { 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); } } @@ -93,7 +97,8 @@ namespace etl /// \tparam Offset The lowest delegate id value. /// The delegate ids must range between Offset and Offset + Range - 1. //*************************************************************************** - template + template class delegate_service { public: @@ -169,14 +174,13 @@ namespace etl { if ((id >= Offset) && (id < (Offset + Range))) { + // 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); } } diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 0f2d2970..91b3bfef 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -1691,12 +1691,6 @@ namespace etl { }; - template - struct is_lvalue_assignable : public etl::is_assignable::type, - typename etl::add_lvalue_reference::type>::type> - { - }; - template struct is_constructible : public std::is_constructible { @@ -1712,13 +1706,6 @@ namespace etl { }; - //#if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED - // template - // struct is_trivially_constructible : public std::is_trivially_constructible - // { - // }; - //#endif - #elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) //********************************************* @@ -1729,16 +1716,12 @@ namespace etl { }; - template - struct is_lvalue_assignable : public etl::is_assignable::type, - typename etl::add_lvalue_reference::type>::type> - { - }; - +#if ETL_CPP11_SUPPORTED template struct is_constructible : public bool_constant<__is_constructible(T, TArgs...)> { }; +#endif template struct is_copy_constructible : public etl::is_constructible> @@ -1750,54 +1733,74 @@ namespace etl { }; - //template - //struct is_trivially_constructible : public bool_constant::value&& __is_trivially_constructible(T, TArgs...)> - //{ - //}; - #else //********************************************* - // Force the user to provide specialisations. + // Force the user to provide specialisations for + // anything other than arithmetics and pointers. //********************************************* - template - struct is_assignable : public etl::bool_constant + 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_lvalue_assignable : public etl::bool_constant + struct is_assignable; + +#if ETL_CPP11_SUPPORTED + //********************************************* + template + struct is_constructible_helper; + + template + struct is_constructible_helper : public etl::true_type { }; - template - struct is_constructible : public etl::bool_constant + template + struct is_constructible_helper; + + template + struct is_constructible : public is_constructible_helper::value || etl::is_pointer::value, TArgs...> + { + }; +#endif + + //********************************************* + template ::value || etl::is_pointer::value> + struct is_copy_constructible; + + template + struct is_copy_constructible : public etl::true_type { }; template - struct is_copy_constructible : public etl::bool_constant::value> + struct is_copy_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 : public etl::bool_constant::value> - { - }; - - //template - //struct is_trivially_constructible : public etl::bool_constant::value> - //{ - //}; + struct is_move_constructible; #endif #if ETL_CPP17_SUPPORTED - template - inline constexpr size_t is_assignable_v = etl::is_assignable::value; - template - inline constexpr size_t is_lvalue_assignable_v = etl::is_lvalue_assignable::value; + template + inline constexpr size_t is_assignable_v = etl::is_assignable::value; template inline constexpr size_t is_constructible_v = etl::is_constructible::value; @@ -1808,9 +1811,6 @@ namespace etl template inline constexpr size_t is_move_constructible_v = etl::is_move_constructible::value; - //template - //inline constexpr size_t is_trivially_constructible_v = etl::is_trivially_constructible::value; - #endif } diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_new.h index a6c5608e..38e987a5 100644 --- a/include/etl/private/variant_new.h +++ b/include/etl/private/variant_new.h @@ -391,6 +391,18 @@ namespace etl 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 diff --git a/include/etl/type_traits.h b/include/etl/type_traits.h index 35cc59bd..d8622266 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -1680,37 +1680,123 @@ namespace etl //********************************************* // Use the STL's definitions. //********************************************* + + //********************************************* + // is_assignable template struct is_assignable : public std::is_assignable { }; - template - struct is_lvalue_assignable : public etl::is_assignable::type, - typename etl::add_lvalue_reference::type>::type> - { - }; - + //********************************************* + // 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 +// 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) @@ -1723,16 +1809,12 @@ namespace etl { }; - template - struct is_lvalue_assignable : public etl::is_assignable::type, - typename etl::add_lvalue_reference::type>::type> - { - }; - +#if ETL_CPP11_SUPPORTED template struct is_constructible : public bool_constant<__is_constructible(T, TArgs...)> { }; +#endif template struct is_copy_constructible : public etl::is_constructible> @@ -1744,67 +1826,169 @@ namespace etl { }; - //template - //struct is_trivially_constructible : public bool_constant::value&& __is_trivially_constructible(T, TArgs...)> - //{ - //}; - #else //********************************************* - // Force the user to provide specialisations. + // Force the user to provide specialisations for + // anything other than arithmetics and pointers. //********************************************* - template - struct is_assignable : public etl::bool_constant + + //********************************************* + // 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_lvalue_assignable : public etl::bool_constant + 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 : public etl::bool_constant + 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 : public etl::bool_constant::value> + 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 : public etl::bool_constant::value> - { - }; + struct is_move_constructible; - //template - //struct is_trivially_constructible : public etl::bool_constant::value> + ////********************************************* + //// 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; + #endif #if ETL_CPP17_SUPPORTED - template - inline constexpr size_t is_assignable_v = etl::is_assignable::value; - - template - inline constexpr size_t is_lvalue_assignable_v = etl::is_lvalue_assignable::value; + template + inline constexpr bool is_assignable_v = etl::is_assignable::value; template - inline constexpr size_t is_constructible_v = etl::is_constructible::value; + inline constexpr bool is_constructible_v = etl::is_constructible::value; template - inline constexpr size_t is_copy_constructible_v = etl::is_copy_constructible::value; + inline constexpr bool is_copy_constructible_v = etl::is_copy_constructible::value; template - inline constexpr size_t is_move_constructible_v = etl::is_move_constructible::value; + inline constexpr bool is_move_constructible_v = etl::is_move_constructible::value; -//template -//inline constexpr size_t is_trivially_constructible_v = etl::is_trivially_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/test/etl_profile.h b/test/etl_profile.h index 13ff44c3..796182cd 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -80,7 +80,7 @@ SOFTWARE. //#define ETL_NO_STL -#define ETL_USE_TYPE_TRAITS_BUILTINS +//#define ETL_USE_TYPE_TRAITS_BUILTINS #if defined(ETL_FORCE_TEST_CPP03) #define ETL_FUNCTION_FORCE_CPP03 diff --git a/test/runtests.sh b/test/runtests.sh index 09221812..ba924fc9 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -21,6 +21,14 @@ make -j8 ./etl_tests | tee log.txt echo "" 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 +./etl_tests | tee log.txt +echo "" +echo "-----------------------------------------------" >> log.txt echo " Clang" >> log.txt echo "-----------------------------------------------" >> log.txt clang --version | grep clang >> log.txt @@ -37,5 +45,13 @@ make -j8 ./etl_tests | tee log.txt echo "" 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 +./etl_tests | tee log.txt +echo "" +echo "-----------------------------------------------" >> log.txt echo " Tests Completed" >> log.txt echo "-----------------------------------------------" >> log.txt diff --git a/test/test_type_traits.cpp b/test/test_type_traits.cpp index b77bc493..da6f740d 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) { //************************************************************************* @@ -885,4 +992,36 @@ namespace 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_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)); + } } diff --git a/test/test_variant_new.cpp b/test/test_variant_new.cpp index a1b421c7..d4ca78db 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -292,38 +292,97 @@ namespace // Definitions for when the STL and compiler built-ins are not avalable. #if ETL_NOT_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) -namespace etl + +using etl::is_copy_constructible; +using etl::is_move_constructible; + +//************************* +template <> +struct etl::is_copy_constructible : public etl::true_type { - template <> - struct is_copy_constructible : public etl::bool_constant - { - }; +}; - template <> - struct is_copy_constructible : public etl::bool_constant - { - }; +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; - template <> - struct is_copy_constructible : public etl::bool_constant - { - }; +//************************* +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; - template <> - struct is_move_constructible : public etl::bool_constant - { - }; +template <> +struct etl::is_move_constructible : public etl::true_type +{ +}; - template <> - struct is_move_constructible : public etl::bool_constant - { - }; +//************************* +template <> +struct etl::is_copy_constructible : public etl::true_type +{ +}; - template <> - struct is_move_constructible : public etl::bool_constant - { - }; -} +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 From 1702a6e043f01bd61b50f22875bb71412120b580 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 26 Jul 2021 17:17:22 +0100 Subject: [PATCH 72/81] Type traits refactor --- .gitignore | 2 + .../ArmTimerCallbacks.uvoptx | 2 +- .../ArmTimerCallbacks.uvprojx | 24 +- .../etl/generators/type_traits_generator.h | 522 +- include/etl/type_traits.h | 631 ++- test/etl_profile.h | 4 - test/runsanitychecks.sh | 84 +- test/runtests.sh | 12 +- test/test_pool.cpp | 21 + test/test_type_traits.cpp | 160 +- test/test_variant_new.cpp | 2 +- test/vs2019/etl.sln | 14 +- test/vs2019/etl.vcxproj | 4408 ++++++++++++----- test/vs2019/etl.vcxproj.filters | 1402 +++--- 14 files changed, 4818 insertions(+), 2470 deletions(-) diff --git a/.gitignore b/.gitignore index 5effe158..870ab075 100644 --- a/.gitignore +++ b/.gitignore @@ -316,3 +316,5 @@ 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/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 91b3bfef..24653e00 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -452,56 +452,6 @@ 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; }; @@ -653,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: @@ -661,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: @@ -1103,128 +1055,6 @@ 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 @@ -1681,68 +1511,224 @@ namespace etl #endif //*************************************************************************** -#if ETL_CPP11_SUPPORTED && ETL_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) && ((!defined(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)) +#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 bool_constant<__is_assignable(T1, T2)> + struct is_assignable : public etl::bool_constant<__is_assignable(T1, T2)> { }; #if ETL_CPP11_SUPPORTED + //********************************************* + // is_constructible template - struct is_constructible : public bool_constant<__is_constructible(T, TArgs...)> + 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 { }; -#else + //********************************************* + // 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; + typename T2, + bool B = (etl::is_arithmetic::value || etl::is_pointer::value) && (etl::is_arithmetic::value || etl::is_pointer::value)> + struct is_assignable; template struct is_assignable : public etl::true_type @@ -1754,6 +1740,7 @@ namespace etl #if ETL_CPP11_SUPPORTED //********************************************* + // is_constructible template struct is_constructible_helper; @@ -1772,6 +1759,7 @@ namespace etl #endif //********************************************* + // is_copy_constructible template ::value || etl::is_pointer::value> struct is_copy_constructible; @@ -1784,6 +1772,7 @@ namespace etl struct is_copy_constructible; //********************************************* + // is_move_constructible template ::value || etl::is_pointer::value> struct is_move_constructible; @@ -1795,21 +1784,182 @@ namespace etl 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 size_t is_assignable_v = etl::is_assignable::value; + 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 size_t is_constructible_v = etl::is_constructible::value; + inline constexpr bool is_constructible_v = etl::is_constructible::value; template - inline constexpr size_t is_copy_constructible_v = etl::is_copy_constructible::value; + inline constexpr bool is_copy_constructible_v = etl::is_copy_constructible::value; template - inline constexpr size_t is_move_constructible_v = etl::is_move_constructible::value; + 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/type_traits.h b/include/etl/type_traits.h index d8622266..82bf041d 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -440,56 +440,6 @@ 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; }; @@ -509,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; }; @@ -641,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: @@ -649,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: @@ -1091,128 +1043,6 @@ 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 @@ -1675,7 +1505,7 @@ namespace etl #endif //*************************************************************************** -#if ETL_CPP11_SUPPORTED && ETL_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) && ((!defined(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)) +#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. @@ -1709,124 +1539,178 @@ namespace etl { }; -// //********************************************* -// // 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 + //********************************************* + // 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; -#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) + 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 bool_constant<__is_assignable(T1, T2)> + struct is_assignable : public etl::bool_constant<__is_assignable(T1, T2)> { }; #if ETL_CPP11_SUPPORTED + //********************************************* + // is_constructible template - struct is_constructible : public bool_constant<__is_constructible(T, TArgs...)> + 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 { }; -#else + //********************************************* + // 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 @@ -1894,78 +1778,159 @@ namespace etl template struct is_move_constructible; - ////********************************************* - //// is_trivially_constructible - //template ::value || etl::is_pointer::value> - //struct is_trivially_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 : public etl::true_type + { + }; - //template - //struct is_trivially_constructible; + template + struct is_trivially_constructible; - ////*************************************************************************** - //// is_trivially_copy_constructible - //template ::value || etl::is_pointer::value> - //struct is_trivially_copy_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 : public etl::true_type + { + }; - //template - //struct is_trivially_copy_constructible; + template + struct is_trivially_copy_constructible; - ////*************************************************************************** - //// is_trivially_destructible - //template ::value || etl::is_pointer::value> - //struct is_trivially_destructible; + //*************************************************************************** + // 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 : public etl::true_type + { + }; - //template - //struct is_trivially_destructible; + template + struct is_trivially_destructible; - ////*************************************************************************** - //// is_trivially_copy_assignable - //template ::value || etl::is_pointer::value> - //struct is_trivially_copy_assignable; + //*************************************************************************** + // 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 : public etl::true_type + { + }; - //template - //struct is_trivially_copy_assignable; + template + struct is_trivially_copy_assignable; - ////*************************************************************************** - //// is_trivially_copyable - //template ::value || etl::is_pointer::value> - //struct is_trivially_copyable; + //*************************************************************************** + // 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 : public etl::true_type + { + }; - //template - //struct is_trivially_copyable; + 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; @@ -1975,20 +1940,20 @@ namespace etl 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_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_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_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_copy_assignable_v = etl::is_trivially_copy_assignable::value; - //template - //inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; + template + inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; #endif } diff --git a/test/etl_profile.h b/test/etl_profile.h index 796182cd..f4c983ce 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -78,10 +78,6 @@ SOFTWARE. //#define ETL_MESSAGES_ARE_VIRTUAL //#define ETL_POLYMORPHIC_MESSAGES -//#define ETL_NO_STL - -//#define ETL_USE_TYPE_TRAITS_BUILTINS - #if defined(ETL_FORCE_TEST_CPP03) #define ETL_FUNCTION_FORCE_CPP03 #define ETL_PRIORITY_QUEUE_FORCE_CPP03 diff --git a/test/runsanitychecks.sh b/test/runsanitychecks.sh index dd3a1c32..42f7adbb 100755 --- a/test/runsanitychecks.sh +++ b/test/runsanitychecks.sh @@ -23,6 +23,16 @@ 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 "****************\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 .. @@ -33,6 +43,16 @@ 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 "****************\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 cmake -E make_directory bgcc bclang @@ -51,6 +71,16 @@ 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 "****************\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 .. @@ -61,6 +91,16 @@ 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 "****************\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 cmake -E make_directory bgcc bclang @@ -69,7 +109,7 @@ 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 "****************\n**** Failed ****\n****************" >> ../log.txt @@ -79,6 +119,16 @@ 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 "****************\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 .. @@ -89,7 +139,17 @@ 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 "****************\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 "" @@ -107,6 +167,16 @@ 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 "****************\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 .. @@ -117,6 +187,16 @@ 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 "****************\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 "-----------------------------------------------" echo " Completed" diff --git a/test/runtests.sh b/test/runtests.sh index ba924fc9..51feeff5 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -9,7 +9,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt @@ -17,7 +17,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt @@ -25,7 +25,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt @@ -33,7 +33,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt @@ -41,7 +41,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt @@ -49,7 +49,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt 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 da6f740d..b3f8b938 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -98,67 +98,67 @@ using etl::is_copy_constructible; using etl::is_move_constructible; //************************* - template <> - struct etl::is_assignable : 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_constructible : public etl::true_type +{ +}; - template <> - struct etl::is_copy_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_move_constructible : public etl::false_type +{ +}; - //************************* - template <> - struct etl::is_assignable : 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_constructible : public etl::true_type +{ +}; - template <> - struct etl::is_copy_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_move_constructible : public etl::true_type +{ +}; - //************************* - template <> - struct etl::is_assignable : 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_constructible : public etl::true_type +{ +}; - template <> - struct etl::is_copy_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_move_constructible : public etl::true_type +{ +}; #endif namespace @@ -1001,6 +1001,16 @@ namespace 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) { @@ -1024,4 +1034,54 @@ namespace 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_new.cpp b/test/test_variant_new.cpp index d4ca78db..bb70329b 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -375,7 +375,7 @@ struct etl::is_move_constructible : public etl::true_type //************************* template <> -struct etl::is_copy_constructible : public etl::true_type +struct etl::is_copy_constructible : public etl::true_type { }; 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 b29e60e0..50bb65df 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 + + @@ -1570,2923 +1809,4664 @@ - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true + true true true - true - true + true + true true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true + true + true + true + true + true + true + true + true + true + true true true true - true - true - true true - true - true - true - true + true true true true - true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true - true - - + true true true true - true - true - true true - true - true - true - true + true true true true - true + true + true + true + true + true + true + true + true + true + true true true true - true - true - true true - true - true - true - true + true true true true + + + true + true + true + true + true + true + true + true true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true @@ -4601,10 +6581,13 @@ false false false + false false false false false + false + false false false false @@ -4614,10 +6597,13 @@ false false false + false false false false false + false + false false false false @@ -4646,10 +6632,13 @@ false false false + false false false false false + false + false false false false @@ -4659,10 +6648,13 @@ false false false + false false false false false + false + false false false false @@ -4686,10 +6678,13 @@ false false false + false false false false false + false + false false false false @@ -4699,10 +6694,13 @@ false false false + false false false false false + false + false false false false @@ -4716,10 +6714,13 @@ false false false + false false false false false + false + false false false false @@ -4729,10 +6730,13 @@ false false false + false false false false false + false + false false false false @@ -4746,10 +6750,13 @@ false false false + false false false false false + false + false false false false @@ -4759,10 +6766,13 @@ false false false + false false false false false + false + false false false false @@ -4776,10 +6786,13 @@ false false false + false false false false false + false + false false false false @@ -4789,10 +6802,13 @@ false false false + false false false false false + false + false false false false @@ -4806,10 +6822,13 @@ false false false + false false false false false + false + false false false false @@ -4819,10 +6838,13 @@ false false false + false false false false false + false + false false false false @@ -4841,10 +6863,13 @@ false false false + false false false false false + false + false false false false @@ -4854,10 +6879,13 @@ false false false + false false false false false + false + false false false false @@ -4875,10 +6903,13 @@ false false false + false false false false false + false + false false false false @@ -4888,10 +6919,13 @@ false false false + false false false false false + false + false false false false @@ -4915,10 +6949,13 @@ false false false + false false false false false + false + false false false false @@ -4928,10 +6965,13 @@ false false false + false false false false false + false + false false false false diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index a6f1e78e..a69d030f 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} + @@ -1691,567 +1694,6 @@ 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 - - - 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 - - - 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 - - - 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 - - - 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 - - - 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 @@ -2384,87 +1826,6 @@ 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 - - - 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 @@ -2495,9 +1856,6 @@ Source Files - - Source Files\Sanity Checks - Source Files @@ -2510,45 +1868,6 @@ 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 - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - Source Files @@ -2573,24 +1892,711 @@ Source Files - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - Source Files 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + @@ -2707,7 +2713,7 @@ Source Files\Sanity Checks\C++17 - Source Files\Sanity Checks + Source Files\Sanity Checks\Logs @@ -2735,4 +2741,4 @@ Resource Files - + \ No newline at end of file From fd89f5162167a02478b126b867e0b48df0631257 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 26 Jul 2021 17:17:22 +0100 Subject: [PATCH 73/81] Type traits refactor --- .gitignore | 2 + .../ArmTimerCallbacks.uvoptx | 2 +- .../ArmTimerCallbacks.uvprojx | 24 +- .../etl/generators/type_traits_generator.h | 522 +- include/etl/type_traits.h | 631 ++- support/Release notes.txt | 3 +- test/etl_profile.h | 4 - test/runsanitychecks.sh | 84 +- test/runtests.sh | 12 +- test/test_pool.cpp | 21 + test/test_type_traits.cpp | 160 +- test/test_variant_new.cpp | 2 +- test/vs2019/etl.sln | 14 +- test/vs2019/etl.vcxproj | 4408 ++++++++++++----- test/vs2019/etl.vcxproj.filters | 1402 +++--- 15 files changed, 4819 insertions(+), 2472 deletions(-) diff --git a/.gitignore b/.gitignore index 5effe158..870ab075 100644 --- a/.gitignore +++ b/.gitignore @@ -316,3 +316,5 @@ 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/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index 91b3bfef..24653e00 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -452,56 +452,6 @@ 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; }; @@ -653,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: @@ -661,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: @@ -1103,128 +1055,6 @@ 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 @@ -1681,68 +1511,224 @@ namespace etl #endif //*************************************************************************** -#if ETL_CPP11_SUPPORTED && ETL_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) && ((!defined(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)) +#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 bool_constant<__is_assignable(T1, T2)> + struct is_assignable : public etl::bool_constant<__is_assignable(T1, T2)> { }; #if ETL_CPP11_SUPPORTED + //********************************************* + // is_constructible template - struct is_constructible : public bool_constant<__is_constructible(T, TArgs...)> + 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 { }; -#else + //********************************************* + // 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; + typename T2, + bool B = (etl::is_arithmetic::value || etl::is_pointer::value) && (etl::is_arithmetic::value || etl::is_pointer::value)> + struct is_assignable; template struct is_assignable : public etl::true_type @@ -1754,6 +1740,7 @@ namespace etl #if ETL_CPP11_SUPPORTED //********************************************* + // is_constructible template struct is_constructible_helper; @@ -1772,6 +1759,7 @@ namespace etl #endif //********************************************* + // is_copy_constructible template ::value || etl::is_pointer::value> struct is_copy_constructible; @@ -1784,6 +1772,7 @@ namespace etl struct is_copy_constructible; //********************************************* + // is_move_constructible template ::value || etl::is_pointer::value> struct is_move_constructible; @@ -1795,21 +1784,182 @@ namespace etl 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 size_t is_assignable_v = etl::is_assignable::value; + 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 size_t is_constructible_v = etl::is_constructible::value; + inline constexpr bool is_constructible_v = etl::is_constructible::value; template - inline constexpr size_t is_copy_constructible_v = etl::is_copy_constructible::value; + inline constexpr bool is_copy_constructible_v = etl::is_copy_constructible::value; template - inline constexpr size_t is_move_constructible_v = etl::is_move_constructible::value; + 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/type_traits.h b/include/etl/type_traits.h index d8622266..82bf041d 100644 --- a/include/etl/type_traits.h +++ b/include/etl/type_traits.h @@ -440,56 +440,6 @@ 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; }; @@ -509,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; }; @@ -641,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: @@ -649,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: @@ -1091,128 +1043,6 @@ 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 @@ -1675,7 +1505,7 @@ namespace etl #endif //*************************************************************************** -#if ETL_CPP11_SUPPORTED && ETL_USING_STL && !defined(ETL_USE_TYPE_TRAITS_BUILTINS) && ((!defined(ARDUINO) && ETL_NOT_USING_STLPORT) || defined(ETL_GCC_V5_TYPE_TRAITS_SUPPORTED)) +#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. @@ -1709,124 +1539,178 @@ namespace etl { }; -// //********************************************* -// // 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 + //********************************************* + // 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; -#elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) + 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 bool_constant<__is_assignable(T1, T2)> + struct is_assignable : public etl::bool_constant<__is_assignable(T1, T2)> { }; #if ETL_CPP11_SUPPORTED + //********************************************* + // is_constructible template - struct is_constructible : public bool_constant<__is_constructible(T, TArgs...)> + 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 { }; -#else + //********************************************* + // 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 @@ -1894,78 +1778,159 @@ namespace etl template struct is_move_constructible; - ////********************************************* - //// is_trivially_constructible - //template ::value || etl::is_pointer::value> - //struct is_trivially_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 : public etl::true_type + { + }; - //template - //struct is_trivially_constructible; + template + struct is_trivially_constructible; - ////*************************************************************************** - //// is_trivially_copy_constructible - //template ::value || etl::is_pointer::value> - //struct is_trivially_copy_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 : public etl::true_type + { + }; - //template - //struct is_trivially_copy_constructible; + template + struct is_trivially_copy_constructible; - ////*************************************************************************** - //// is_trivially_destructible - //template ::value || etl::is_pointer::value> - //struct is_trivially_destructible; + //*************************************************************************** + // 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 : public etl::true_type + { + }; - //template - //struct is_trivially_destructible; + template + struct is_trivially_destructible; - ////*************************************************************************** - //// is_trivially_copy_assignable - //template ::value || etl::is_pointer::value> - //struct is_trivially_copy_assignable; + //*************************************************************************** + // 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 : public etl::true_type + { + }; - //template - //struct is_trivially_copy_assignable; + template + struct is_trivially_copy_assignable; - ////*************************************************************************** - //// is_trivially_copyable - //template ::value || etl::is_pointer::value> - //struct is_trivially_copyable; + //*************************************************************************** + // 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 : public etl::true_type + { + }; - //template - //struct is_trivially_copyable; + 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; @@ -1975,20 +1940,20 @@ namespace etl 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_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_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_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_copy_assignable_v = etl::is_trivially_copy_assignable::value; - //template - //inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; + template + inline constexpr bool is_trivially_copyable_v = etl::is_trivially_copyable::value; #endif } diff --git a/support/Release notes.txt b/support/Release notes.txt index c22c2eee..463015c7 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -2,8 +2,7 @@ 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. -Added etl::is_assignable, etl::is_lvalue_assignable, etl::is_constructible, etl::is_copy_constructible -and etl::is_move_constructible to type_traits.h. Uses STL, compiler built-ins or user defined specialisations, dependent on settings. +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 diff --git a/test/etl_profile.h b/test/etl_profile.h index 796182cd..f4c983ce 100644 --- a/test/etl_profile.h +++ b/test/etl_profile.h @@ -78,10 +78,6 @@ SOFTWARE. //#define ETL_MESSAGES_ARE_VIRTUAL //#define ETL_POLYMORPHIC_MESSAGES -//#define ETL_NO_STL - -//#define ETL_USE_TYPE_TRAITS_BUILTINS - #if defined(ETL_FORCE_TEST_CPP03) #define ETL_FUNCTION_FORCE_CPP03 #define ETL_PRIORITY_QUEUE_FORCE_CPP03 diff --git a/test/runsanitychecks.sh b/test/runsanitychecks.sh index dd3a1c32..42f7adbb 100755 --- a/test/runsanitychecks.sh +++ b/test/runsanitychecks.sh @@ -23,6 +23,16 @@ 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 "****************\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 .. @@ -33,6 +43,16 @@ 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 "****************\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 cmake -E make_directory bgcc bclang @@ -51,6 +71,16 @@ 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 "****************\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 .. @@ -61,6 +91,16 @@ 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 "****************\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 cmake -E make_directory bgcc bclang @@ -69,7 +109,7 @@ 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 "****************\n**** Failed ****\n****************" >> ../log.txt @@ -79,6 +119,16 @@ 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 "****************\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 .. @@ -89,7 +139,17 @@ 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 "****************\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 "" @@ -107,6 +167,16 @@ 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 "****************\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 .. @@ -117,6 +187,16 @@ 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 "****************\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 "-----------------------------------------------" echo " Completed" diff --git a/test/runtests.sh b/test/runtests.sh index ba924fc9..51feeff5 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -9,7 +9,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt @@ -17,7 +17,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt @@ -25,7 +25,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt @@ -33,7 +33,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt @@ -41,7 +41,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt @@ -49,7 +49,7 @@ 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 +make -j8 || echo "****************\n**** Failed ****\n****************" >> ../log.txt ./etl_tests | tee log.txt echo "" echo "-----------------------------------------------" >> log.txt 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 da6f740d..b3f8b938 100644 --- a/test/test_type_traits.cpp +++ b/test/test_type_traits.cpp @@ -98,67 +98,67 @@ using etl::is_copy_constructible; using etl::is_move_constructible; //************************* - template <> - struct etl::is_assignable : 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_constructible : public etl::true_type +{ +}; - template <> - struct etl::is_copy_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_move_constructible : public etl::false_type +{ +}; - //************************* - template <> - struct etl::is_assignable : 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_constructible : public etl::true_type +{ +}; - template <> - struct etl::is_copy_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_move_constructible : public etl::true_type +{ +}; - //************************* - template <> - struct etl::is_assignable : 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_constructible : public etl::true_type +{ +}; - template <> - struct etl::is_copy_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_move_constructible : public etl::true_type +{ +}; #endif namespace @@ -1001,6 +1001,16 @@ namespace 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) { @@ -1024,4 +1034,54 @@ namespace 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_new.cpp b/test/test_variant_new.cpp index d4ca78db..bb70329b 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_new.cpp @@ -375,7 +375,7 @@ struct etl::is_move_constructible : public etl::true_type //************************* template <> -struct etl::is_copy_constructible : public etl::true_type +struct etl::is_copy_constructible : public etl::true_type { }; 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 b29e60e0..50bb65df 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 + + @@ -1570,2923 +1809,4664 @@ - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true + true true true true - true true true true true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true true true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true + true true + true true true true - true true + true true true - true - true + true + true true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true + true + true + true + true + true + true + true + true + true + true true true true - true - true - true true - true - true - true - true + true true true true - true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true - true - true + true + true + true true true true - true true true + true true - true - true + true + true true + true + true true - true + true + true - true - true + true true - true - true - true + true true + true true + true + true true - true - - + true true true true - true - true - true true - true - true - true - true + true true true true - true + true + true + true + true + true + true + true + true + true + true true true true - true - true - true true - true - true - true - true + true true true true + + + true + true + true + true + true + true + true + true true + true + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true - true - true + true true - true - true - true + true true + true true + true + true true + true + true + true + true + true + true true + true + true @@ -4601,10 +6581,13 @@ false false false + false false false false false + false + false false false false @@ -4614,10 +6597,13 @@ false false false + false false false false false + false + false false false false @@ -4646,10 +6632,13 @@ false false false + false false false false false + false + false false false false @@ -4659,10 +6648,13 @@ false false false + false false false false false + false + false false false false @@ -4686,10 +6678,13 @@ false false false + false false false false false + false + false false false false @@ -4699,10 +6694,13 @@ false false false + false false false false false + false + false false false false @@ -4716,10 +6714,13 @@ false false false + false false false false false + false + false false false false @@ -4729,10 +6730,13 @@ false false false + false false false false false + false + false false false false @@ -4746,10 +6750,13 @@ false false false + false false false false false + false + false false false false @@ -4759,10 +6766,13 @@ false false false + false false false false false + false + false false false false @@ -4776,10 +6786,13 @@ false false false + false false false false false + false + false false false false @@ -4789,10 +6802,13 @@ false false false + false false false false false + false + false false false false @@ -4806,10 +6822,13 @@ false false false + false false false false false + false + false false false false @@ -4819,10 +6838,13 @@ false false false + false false false false false + false + false false false false @@ -4841,10 +6863,13 @@ false false false + false false false false false + false + false false false false @@ -4854,10 +6879,13 @@ false false false + false false false false false + false + false false false false @@ -4875,10 +6903,13 @@ false false false + false false false false false + false + false false false false @@ -4888,10 +6919,13 @@ false false false + false false false false false + false + false false false false @@ -4915,10 +6949,13 @@ false false false + false false false false false + false + false false false false @@ -4928,10 +6965,13 @@ false false false + false false false false false + false + false false false false diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index a6f1e78e..a69d030f 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} + @@ -1691,567 +1694,6 @@ 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 - - - 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 - - - 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 - - - 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 - - - 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 - - - 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 @@ -2384,87 +1826,6 @@ 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 - - - 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 @@ -2495,9 +1856,6 @@ Source Files - - Source Files\Sanity Checks - Source Files @@ -2510,45 +1868,6 @@ 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 - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - Source Files @@ -2573,24 +1892,711 @@ Source Files - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - - - Source Files\Sanity Checks - Source Files 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + + + 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 + @@ -2707,7 +2713,7 @@ Source Files\Sanity Checks\C++17 - Source Files\Sanity Checks + Source Files\Sanity Checks\Logs @@ -2735,4 +2741,4 @@ Resource Files - + \ No newline at end of file From 031b3e7eda9298f15de2614945836f8871d3f7be Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 29 Jul 2021 14:15:49 +0100 Subject: [PATCH 74/81] Changed variant files names --- include/etl/private/{variant_new.h => variant_variadic.h} | 0 include/etl/variant.h | 2 +- test/CMakeLists.txt | 2 +- test/sanity-check/c++03/CMakeLists.txt | 2 +- test/sanity-check/c++11/CMakeLists.txt | 2 +- test/sanity-check/c++14/CMakeLists.txt | 2 +- test/sanity-check/c++17/CMakeLists.txt | 2 +- .../{variant_new.h.t.cpp => variant_variadic.h.t.cpp} | 2 +- test/{test_variant_new.cpp => test_variant_variadic.cpp} | 2 +- test/vs2019/etl.vcxproj | 6 +++--- test/vs2019/etl.vcxproj.filters | 6 +++--- 11 files changed, 14 insertions(+), 14 deletions(-) rename include/etl/private/{variant_new.h => variant_variadic.h} (100%) rename test/sanity-check/{variant_new.h.t.cpp => variant_variadic.h.t.cpp} (96%) rename test/{test_variant_new.cpp => test_variant_variadic.cpp} (99%) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_variadic.h similarity index 100% rename from include/etl/private/variant_new.h rename to include/etl/private/variant_variadic.h diff --git a/include/etl/variant.h b/include/etl/variant.h index 7f6b4546..c8664590 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -34,7 +34,7 @@ SOFTWARE. #if !ETL_CPP11_SUPPORTED || ETL_USE_LEGACY_VARIANT #include "private/variant_legacy.h" #else - #include "private/variant_new.h" + #include "private/variant_variadic.h" #endif #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c0513466..74cf97b1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -238,7 +238,7 @@ set(TEST_SOURCE_FILES test_utility.cpp test_variance.cpp test_variant_legacy.cpp - test_variant_new.cpp + test_variant_variadic.cpp test_variant_pool.cpp test_vector.cpp test_vector_external_buffer.cpp diff --git a/test/sanity-check/c++03/CMakeLists.txt b/test/sanity-check/c++03/CMakeLists.txt index 9361a7c5..5347a376 100644 --- a/test/sanity-check/c++03/CMakeLists.txt +++ b/test/sanity-check/c++03/CMakeLists.txt @@ -244,7 +244,7 @@ target_sources(t98 PRIVATE etl_profile.h ../utility.h.t.cpp ../variance.h.t.cpp ../variant_legacy.h.t.cpp - ../variant_new.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 89342ec0..087c9085 100644 --- a/test/sanity-check/c++11/CMakeLists.txt +++ b/test/sanity-check/c++11/CMakeLists.txt @@ -244,7 +244,7 @@ target_sources(t11 PRIVATE etl_profile.h ../utility.h.t.cpp ../variance.h.t.cpp ../variant_legacy.h.t.cpp - ../variant_new.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 65dcab43..fd9a2e2e 100644 --- a/test/sanity-check/c++14/CMakeLists.txt +++ b/test/sanity-check/c++14/CMakeLists.txt @@ -244,7 +244,7 @@ target_sources(t14 PRIVATE etl_profile.h ../utility.h.t.cpp ../variance.h.t.cpp ../variant_legacy.h.t.cpp - ../variant_new.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 4e691395..63d76bd3 100644 --- a/test/sanity-check/c++17/CMakeLists.txt +++ b/test/sanity-check/c++17/CMakeLists.txt @@ -244,7 +244,7 @@ target_sources(t17 PRIVATE etl_profile.h ../utility.h.t.cpp ../variance.h.t.cpp ../variant_legacy.h.t.cpp - ../variant_new.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/variant_new.h.t.cpp b/test/sanity-check/variant_variadic.h.t.cpp similarity index 96% rename from test/sanity-check/variant_new.h.t.cpp rename to test/sanity-check/variant_variadic.h.t.cpp index 62b5bea7..82835c85 100644 --- a/test/sanity-check/variant_new.h.t.cpp +++ b/test/sanity-check/variant_variadic.h.t.cpp @@ -26,4 +26,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include +#include diff --git a/test/test_variant_new.cpp b/test/test_variant_variadic.cpp similarity index 99% rename from test/test_variant_new.cpp rename to test/test_variant_variadic.cpp index bb70329b..3da00fd2 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_variadic.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "unit_test_framework.h" -#include "etl/private/variant_new.h" +#include "etl/private/variant_variadic.h" #include "etl/visitor.h" #include "etl/overload.h" diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 50bb65df..24cac775 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1596,7 +1596,7 @@ - + @@ -6288,7 +6288,7 @@ true true - + true true true @@ -7061,7 +7061,7 @@ - + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index a69d030f..1fe51913 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1119,7 +1119,7 @@ ETL\Private - + ETL\Private @@ -1874,7 +1874,7 @@ Source Files - + Source Files @@ -2570,7 +2570,7 @@ Source Files\Sanity Checks - + Source Files\Sanity Checks From 2c119563110d9aeb0226fda8b8a7bac65919f24d Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 29 Jul 2021 14:27:41 +0100 Subject: [PATCH 75/81] Updated version numbers --- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- meson.build | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 4d30e25f..12592eba 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,7 +38,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 20 -#define ETL_VERSION_MINOR 13 +#define ETL_VERSION_MINOR 14 #define ETL_VERSION_PATCH 0 #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) diff --git a/library.json b/library.json index d18c46c6..990b2d31 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.13.0", + "version": "20.14.0", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 37a22174..5021b0d1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.13.0 +version=20.14.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index 095f2da6..7d295964 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.13.0' + version: '20.14.0' ) ###################### From da1daf64e22e38b0c9d0d3e5c81d333c90d15b97 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 26 Jul 2021 17:17:22 +0100 Subject: [PATCH 76/81] Type traits refactor --- support/Release notes.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/support/Release notes.txt b/support/Release notes.txt index c22c2eee..463015c7 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -2,8 +2,7 @@ 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. -Added etl::is_assignable, etl::is_lvalue_assignable, etl::is_constructible, etl::is_copy_constructible -and etl::is_move_constructible to type_traits.h. Uses STL, compiler built-ins or user defined specialisations, dependent on settings. +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 From 734f14a8ec20dee1896f13a05a1048128fe55735 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 29 Jul 2021 14:15:49 +0100 Subject: [PATCH 77/81] Changed variant files names --- include/etl/private/{variant_new.h => variant_variadic.h} | 0 include/etl/variant.h | 2 +- test/CMakeLists.txt | 2 +- test/sanity-check/c++03/CMakeLists.txt | 2 +- test/sanity-check/c++11/CMakeLists.txt | 2 +- test/sanity-check/c++14/CMakeLists.txt | 2 +- test/sanity-check/c++17/CMakeLists.txt | 2 +- .../{variant_new.h.t.cpp => variant_variadic.h.t.cpp} | 2 +- test/{test_variant_new.cpp => test_variant_variadic.cpp} | 2 +- test/vs2019/etl.vcxproj | 6 +++--- test/vs2019/etl.vcxproj.filters | 6 +++--- 11 files changed, 14 insertions(+), 14 deletions(-) rename include/etl/private/{variant_new.h => variant_variadic.h} (100%) rename test/sanity-check/{variant_new.h.t.cpp => variant_variadic.h.t.cpp} (96%) rename test/{test_variant_new.cpp => test_variant_variadic.cpp} (99%) diff --git a/include/etl/private/variant_new.h b/include/etl/private/variant_variadic.h similarity index 100% rename from include/etl/private/variant_new.h rename to include/etl/private/variant_variadic.h diff --git a/include/etl/variant.h b/include/etl/variant.h index 7f6b4546..c8664590 100644 --- a/include/etl/variant.h +++ b/include/etl/variant.h @@ -34,7 +34,7 @@ SOFTWARE. #if !ETL_CPP11_SUPPORTED || ETL_USE_LEGACY_VARIANT #include "private/variant_legacy.h" #else - #include "private/variant_new.h" + #include "private/variant_variadic.h" #endif #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c0513466..74cf97b1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -238,7 +238,7 @@ set(TEST_SOURCE_FILES test_utility.cpp test_variance.cpp test_variant_legacy.cpp - test_variant_new.cpp + test_variant_variadic.cpp test_variant_pool.cpp test_vector.cpp test_vector_external_buffer.cpp diff --git a/test/sanity-check/c++03/CMakeLists.txt b/test/sanity-check/c++03/CMakeLists.txt index 9361a7c5..5347a376 100644 --- a/test/sanity-check/c++03/CMakeLists.txt +++ b/test/sanity-check/c++03/CMakeLists.txt @@ -244,7 +244,7 @@ target_sources(t98 PRIVATE etl_profile.h ../utility.h.t.cpp ../variance.h.t.cpp ../variant_legacy.h.t.cpp - ../variant_new.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 89342ec0..087c9085 100644 --- a/test/sanity-check/c++11/CMakeLists.txt +++ b/test/sanity-check/c++11/CMakeLists.txt @@ -244,7 +244,7 @@ target_sources(t11 PRIVATE etl_profile.h ../utility.h.t.cpp ../variance.h.t.cpp ../variant_legacy.h.t.cpp - ../variant_new.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 65dcab43..fd9a2e2e 100644 --- a/test/sanity-check/c++14/CMakeLists.txt +++ b/test/sanity-check/c++14/CMakeLists.txt @@ -244,7 +244,7 @@ target_sources(t14 PRIVATE etl_profile.h ../utility.h.t.cpp ../variance.h.t.cpp ../variant_legacy.h.t.cpp - ../variant_new.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 4e691395..63d76bd3 100644 --- a/test/sanity-check/c++17/CMakeLists.txt +++ b/test/sanity-check/c++17/CMakeLists.txt @@ -244,7 +244,7 @@ target_sources(t17 PRIVATE etl_profile.h ../utility.h.t.cpp ../variance.h.t.cpp ../variant_legacy.h.t.cpp - ../variant_new.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/variant_new.h.t.cpp b/test/sanity-check/variant_variadic.h.t.cpp similarity index 96% rename from test/sanity-check/variant_new.h.t.cpp rename to test/sanity-check/variant_variadic.h.t.cpp index 62b5bea7..82835c85 100644 --- a/test/sanity-check/variant_new.h.t.cpp +++ b/test/sanity-check/variant_variadic.h.t.cpp @@ -26,4 +26,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ -#include +#include diff --git a/test/test_variant_new.cpp b/test/test_variant_variadic.cpp similarity index 99% rename from test/test_variant_new.cpp rename to test/test_variant_variadic.cpp index bb70329b..3da00fd2 100644 --- a/test/test_variant_new.cpp +++ b/test/test_variant_variadic.cpp @@ -28,7 +28,7 @@ SOFTWARE. #include "unit_test_framework.h" -#include "etl/private/variant_new.h" +#include "etl/private/variant_variadic.h" #include "etl/visitor.h" #include "etl/overload.h" diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 50bb65df..24cac775 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1596,7 +1596,7 @@ - + @@ -6288,7 +6288,7 @@ true true - + true true true @@ -7061,7 +7061,7 @@ - + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index a69d030f..1fe51913 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -1119,7 +1119,7 @@ ETL\Private - + ETL\Private @@ -1874,7 +1874,7 @@ Source Files - + Source Files @@ -2570,7 +2570,7 @@ Source Files\Sanity Checks - + Source Files\Sanity Checks From b886ee381b06249989ddf7e5dae986d2f6c7d88b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 29 Jul 2021 14:27:41 +0100 Subject: [PATCH 78/81] Updated version numbers --- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- meson.build | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 4d30e25f..12592eba 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,7 +38,7 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 20 -#define ETL_VERSION_MINOR 13 +#define ETL_VERSION_MINOR 14 #define ETL_VERSION_PATCH 0 #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) diff --git a/library.json b/library.json index d18c46c6..990b2d31 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.13.0", + "version": "20.14.0", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 37a22174..5021b0d1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.13.0 +version=20.14.0 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index 095f2da6..7d295964 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.13.0' + version: '20.14.0' ) ###################### From 9fbb6c80087b3ad6716bfd9e5028d72e8351837c Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 26 Jul 2021 17:17:22 +0100 Subject: [PATCH 79/81] Type traits refactor --- test/vs2019/etl.vcxproj | 2 +- test/vs2019/etl.vcxproj.filters | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 24cac775..5f65af23 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -7129,4 +7129,4 @@ - \ No newline at end of file + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 1fe51913..d1b3f4b4 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -2741,4 +2741,4 @@ Resource Files - \ No newline at end of file + From c1f7edeee63b0bfe74bb1ff834dc1c381e79551e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 1 Aug 2021 19:34:40 +0100 Subject: [PATCH 80/81] Changed std::forward to etl::forward --- include/etl/private/variant_variadic.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/etl/private/variant_variadic.h b/include/etl/private/variant_variadic.h index 38e987a5..06ff1933 100644 --- a/include/etl/private/variant_variadic.h +++ b/include/etl/private/variant_variadic.h @@ -536,7 +536,7 @@ namespace etl { static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); - construct_in_place>(data, std::forward(value)); + construct_in_place>(data, etl::forward(value)); } //*************************************************************************** @@ -550,7 +550,7 @@ namespace etl { static_assert(etl::is_one_of, TTypes...>::value, "Unsupported type"); - construct_in_place_args>(data, std::forward(args)...); + construct_in_place_args>(data, etl::forward(args)...); } //*************************************************************************** @@ -564,7 +564,7 @@ namespace etl 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, std::forward(args)...); + construct_in_place_args(data, etl::forward(args)...); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } @@ -581,7 +581,7 @@ namespace etl { static_assert(etl::is_one_of, TTypes...> ::value, "Unsupported type"); - construct_in_place_args>(data, init, std::forward(args)...); + construct_in_place_args>(data, init, etl::forward(args)...); } //*************************************************************************** @@ -595,7 +595,7 @@ namespace etl 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, std::forward(args)...); + construct_in_place_args(data, init, etl::forward(args)...); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; } @@ -675,7 +675,7 @@ namespace etl operation(private_variant::Destroy, data, nullptr); - construct_in_place_args(data, std::forward(args)...); + construct_in_place_args(data, etl::forward(args)...); operation = operation_type::value, etl::is_move_constructible::value>::do_operation; From 78239ec2ef3e1fbf79e2b318089db3c19f0637b5 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 1 Aug 2021 19:39:14 +0100 Subject: [PATCH 81/81] Updated versions --- include/etl/version.h | 2 +- library.json | 2 +- library.properties | 2 +- meson.build | 2 +- support/Release notes.txt | 4 ++++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/etl/version.h b/include/etl/version.h index 12592eba..3d86d6ee 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 20 #define ETL_VERSION_MINOR 14 -#define ETL_VERSION_PATCH 0 +#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 990b2d31..e6ec5ef2 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ETL Embedded Template Library", - "version": "20.14.0", + "version": "20.14.1", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" diff --git a/library.properties b/library.properties index 5021b0d1..ec1698a8 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library ETL -version=20.14.0 +version=20.14.1 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/meson.build b/meson.build index 7d295964..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.14.0' + version: '20.14.1' ) ###################### diff --git a/support/Release notes.txt b/support/Release notes.txt index 463015c7..f815aadf 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +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.