diff --git a/.gitignore b/.gitignore index 5c8a2e4c..4f2b0c76 100644 --- a/.gitignore +++ b/.gitignore @@ -379,3 +379,7 @@ test/vs2022/Debug MSVC - No STL - Force Built-ins test/temp test/vs2022/Debug MSVC C++14 test/vs2022/Debug MSVC C++20 - No STL +build-test-Desktop_x86_windows_msvc2019_pe_64bit-Debug +test/vs2022/Debug MSVC C++14 - No STL +test/log.txt +test/etl_error_handler/log.txt diff --git a/include/etl/array.h b/include/etl/array.h index 1435ddbb..1f1195db 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -236,7 +236,7 @@ namespace etl //************************************************************************* iterator end() ETL_NOEXCEPT { - return &_buffer[SIZE]; + return _buffer + SIZE; } //************************************************************************* @@ -244,7 +244,7 @@ namespace etl //************************************************************************* ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT { - return &_buffer[SIZE]; + return _buffer + SIZE; } //************************************************************************* @@ -252,7 +252,7 @@ namespace etl //************************************************************************* ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT { - return &_buffer[SIZE]; + return _buffer + SIZE; } //************************************************************************* diff --git a/include/etl/array_view.h b/include/etl/array_view.h index 84ceeeab..44fbd5a1 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -636,8 +636,8 @@ namespace etl { size_t operator()(const etl::array_view& view) const { - return etl::private_hash::generic_hash(reinterpret_cast(&view[0]), - reinterpret_cast(&view[view.size()])); + return etl::private_hash::generic_hash(reinterpret_cast(view.data()), + reinterpret_cast(view.data() + view.size())); } }; #endif diff --git a/include/etl/array_wrapper.h b/include/etl/array_wrapper.h index ddb4a5fe..45d45f1b 100644 --- a/include/etl/array_wrapper.h +++ b/include/etl/array_wrapper.h @@ -394,8 +394,10 @@ namespace etl { size_t operator()(const etl::array_wrapper& aw) const { - return etl::private_hash::generic_hash(reinterpret_cast(&aw[0]), - reinterpret_cast(&aw[aw.size()])); + const uint8_t* pb = reinterpret_cast(aw.data()); + const uint8_t* pe = pb + (SIZE * sizeof(T)); + + return etl::private_hash::generic_hash(pb, pe); } }; #endif diff --git a/include/etl/basic_string.h b/include/etl/basic_string.h index 66489078..f2a1a1c3 100644 --- a/include/etl/basic_string.h +++ b/include/etl/basic_string.h @@ -136,21 +136,39 @@ namespace etl ///\ingroup string /// The base class for all templated string types. //*************************************************************************** - class string_base + namespace private_basic_string + { + //************************************************************************* + template + class string_base_statics + { + public: + + typedef size_t size_type; + + static ETL_CONSTANT uint_least8_t IS_TRUNCATED = etl::bit<0>::value; + static ETL_CONSTANT uint_least8_t CLEAR_AFTER_USE = etl::bit<1>::value; + + static ETL_CONSTANT size_type npos = etl::integral_limits::max; + }; + + template + ETL_CONSTANT uint_least8_t string_base_statics::IS_TRUNCATED; + + template + ETL_CONSTANT uint_least8_t string_base_statics::CLEAR_AFTER_USE; + + template + ETL_CONSTANT typename string_base_statics::size_type string_base_statics::npos; + } + + //*************************************************************************** + class string_base : public private_basic_string::string_base_statics<> { public: typedef size_t size_type; -#if ETL_USING_CPP11 - static constexpr size_type npos = etl::integral_limits::max; -#else - enum - { - npos = etl::integral_limits::max - }; -#endif - //************************************************************************* /// Gets the current size of the string. ///\return The current size of the string. @@ -290,9 +308,6 @@ namespace etl { } - static ETL_CONSTANT uint_least8_t IS_TRUNCATED = etl::bit<0>::value; - static ETL_CONSTANT uint_least8_t CLEAR_AFTER_USE = etl::bit<1>::value; - size_type current_size; ///< The current number of elements in the string. const size_type CAPACITY; ///< The maximum number of elements in the string. diff --git a/include/etl/binary.h b/include/etl/binary.h index 5d5a6128..ad478015 100644 --- a/include/etl/binary.h +++ b/include/etl/binary.h @@ -96,8 +96,8 @@ namespace etl template <> struct max_value_for_nbits<0> { - typedef etl::smallest_uint_for_bits<0>::type value_type; - static ETL_CONSTANT value_type value = 0; + typedef etl::smallest_uint_for_bits<0>::type value_type; + static ETL_CONSTANT value_type value = 0; }; template @@ -544,6 +544,9 @@ namespace etl static ETL_CONSTANT uint8_t value = uint8_t((value2 >> 4U) | ((value2 & 0x0FU) << 4U)); }; + template + ETL_CONSTANT uint8_t reverse_bits_const::value; + //*********************************** template struct reverse_bits_const @@ -557,6 +560,9 @@ namespace etl static ETL_CONSTANT int8_t value = int8_t((value2 >> 4U) | ((value2 & 0x0FU) << 4U)); }; + + template + ETL_CONSTANT int8_t reverse_bits_const::value; #endif //*************************************************************************** @@ -591,6 +597,9 @@ namespace etl static ETL_CONSTANT uint16_t value = uint16_t((value3 >> 8U) | ((value3 & 0xFFU) << 8U)); }; + template + ETL_CONSTANT uint16_t reverse_bits_const::value; + //*********************************** template struct reverse_bits_const @@ -606,6 +615,9 @@ namespace etl static ETL_CONSTANT int16_t value = int16_t((value3 >> 8U) | ((value3 & 0xFFU) << 8U)); }; + template + ETL_CONSTANT int16_t reverse_bits_const::value; + //*************************************************************************** /// Reverse 32 bits. ///\ingroup binary @@ -640,6 +652,9 @@ namespace etl static ETL_CONSTANT uint32_t value = uint32_t((value4 >> 16U) | ((value4 & 0xFFFFU) << 16U)); }; + template + ETL_CONSTANT uint32_t reverse_bits_const::value; + //*********************************** template struct reverse_bits_const @@ -656,6 +671,9 @@ namespace etl static ETL_CONSTANT int32_t value = int32_t((value4 >> 16U) | ((value4 & 0xFFFFUL) << 16U)); }; + template + ETL_CONSTANT int32_t reverse_bits_const::value; + #if ETL_USING_64BIT_TYPES //*************************************************************************** /// Reverse 64 bits. @@ -693,6 +711,9 @@ namespace etl static ETL_CONSTANT uint64_t value = uint64_t((value5 >> 32U) | ((value5 & 0xFFFFFFFFULL) << 32U)); }; + template + ETL_CONSTANT uint64_t reverse_bits_const::value; + //*********************************** template struct reverse_bits_const @@ -709,6 +730,9 @@ namespace etl static ETL_CONSTANT int64_t value = int64_t((value5 >> 32U) | ((value5 & 0xFFFFFFFFULL) << 32U)); }; + + template + ETL_CONSTANT int64_t reverse_bits_const::value; #endif //*************************************************************************** @@ -2190,6 +2214,9 @@ namespace etl static ETL_CONSTANT T value = static_cast(etl::max_value_for_nbits::value); }; + template + ETL_CONSTANT T lsb_mask::value; + //*********************************** template ETL_CONSTEXPR14 T make_lsb_mask(size_t nbits) @@ -2209,6 +2236,9 @@ namespace etl static ETL_CONSTANT T value = static_cast(etl::reverse_bits_const::value>::value); }; + template + ETL_CONSTANT T msb_mask::value; + //*********************************** template ETL_CONSTEXPR T make_msb_mask(size_t nbits) diff --git a/include/etl/bip_buffer_spsc_atomic.h b/include/etl/bip_buffer_spsc_atomic.h index 6b67ae4b..51d54612 100644 --- a/include/etl/bip_buffer_spsc_atomic.h +++ b/include/etl/bip_buffer_spsc_atomic.h @@ -526,11 +526,14 @@ namespace etl base_t::clear(); } - private: + private: /// The uninitialised buffer of T used in the bip_buffer_spsc. etl::uninitialized_buffer_of buffer; }; + + template + ETL_CONSTANT typename bip_buffer_spsc_atomic::size_type bip_buffer_spsc_atomic::RESERVED_SIZE; } #endif /* ETL_HAS_ATOMIC && ETL_USING_CPP11 */ diff --git a/include/etl/buffer_descriptors.h b/include/etl/buffer_descriptors.h index 1bd98443..b34e223b 100644 --- a/include/etl/buffer_descriptors.h +++ b/include/etl/buffer_descriptors.h @@ -290,6 +290,15 @@ namespace etl etl::array descriptor_items; etl::cyclic_value next; }; + + template + ETL_CONSTANT typename buffer_descriptors::size_type buffer_descriptors::N_BUFFERS; + + template + ETL_CONSTANT typename buffer_descriptors::size_type buffer_descriptors::BUFFER_SIZE; + + template + ETL_CONSTANT typename buffer_descriptors::size_type buffer_descriptors::descriptor::MAX_SIZE; } #endif #endif diff --git a/include/etl/circular_buffer.h b/include/etl/circular_buffer.h index 84126f1b..aa7eff18 100644 --- a/include/etl/circular_buffer.h +++ b/include/etl/circular_buffer.h @@ -1226,6 +1226,9 @@ namespace etl etl::uninitialized_buffer_of buffer; }; + template + ETL_CONSTANT typename icircular_buffer::size_type circular_buffer::MAX_SIZE; + //*************************************************************************** /// A fixed capacity circular buffer. /// External buffer. diff --git a/include/etl/combinations.h b/include/etl/combinations.h index 9fbb8654..dbb5c224 100644 --- a/include/etl/combinations.h +++ b/include/etl/combinations.h @@ -51,6 +51,9 @@ namespace etl static ETL_CONSTANT size_t value = etl::permutations::value / etl::factorial::value; }; + template + ETL_CONSTANT size_t combinations::value; + #if ETL_USING_CPP17 template inline constexpr size_t combinations_v = combinations::value; diff --git a/include/etl/correlation.h b/include/etl/correlation.h index a1408424..47bfec41 100644 --- a/include/etl/correlation.h +++ b/include/etl/correlation.h @@ -73,10 +73,24 @@ namespace etl //*************************************************************************** /// Correlation Type. //*************************************************************************** - struct correlation_type + namespace private_correlation + { + template + struct correlation_type_statics + { + static ETL_CONSTANT bool Sample = false; + static ETL_CONSTANT bool Population = true; + }; + + template + ETL_CONSTANT bool correlation_type_statics::Sample; + + template + ETL_CONSTANT bool correlation_type_statics::Population; + } + + struct correlation_type : public private_correlation::correlation_type_statics<> { - static ETL_CONSTANT bool Sample = false; - static ETL_CONSTANT bool Population = true; }; //*************************************************************************** @@ -270,6 +284,9 @@ namespace etl mutable double correlation_value; mutable bool recalculate; }; + + template + ETL_CONSTANT int correlation::Adjustment; } #endif diff --git a/include/etl/covariance.h b/include/etl/covariance.h index e0ba59ee..8ecd8027 100644 --- a/include/etl/covariance.h +++ b/include/etl/covariance.h @@ -73,10 +73,24 @@ namespace etl //*************************************************************************** /// Covariance Type. //*************************************************************************** - struct covariance_type + namespace private_covariance + { + template + struct covariance_type_statics + { + static ETL_CONSTANT bool Sample = false; + static ETL_CONSTANT bool Population = true; + }; + + template + ETL_CONSTANT bool covariance_type_statics::Sample; + + template + ETL_CONSTANT bool covariance_type_statics::Population; + } + + struct covariance_type : public private_covariance::covariance_type_statics<> { - static ETL_CONSTANT bool Sample = false; - static ETL_CONSTANT bool Population = true; }; //*************************************************************************** @@ -219,6 +233,9 @@ namespace etl mutable double covariance_value; mutable bool recalculate; }; + + template + ETL_CONSTANT int covariance::Adjustment; } #endif diff --git a/include/etl/deque.h b/include/etl/deque.h index aa075ac7..3406ae00 100644 --- a/include/etl/deque.h +++ b/include/etl/deque.h @@ -2469,6 +2469,9 @@ namespace etl etl::uninitialized_buffer_of buffer; }; + template + ETL_CONSTANT size_t deque::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/factorial.h b/include/etl/factorial.h index 43446aa1..cfe421fb 100644 --- a/include/etl/factorial.h +++ b/include/etl/factorial.h @@ -61,6 +61,9 @@ namespace etl static ETL_CONSTANT size_t value = 1; }; + template + ETL_CONSTANT size_t factorial::value; + #if ETL_USING_CPP17 template inline constexpr size_t factorial_v = factorial::value; diff --git a/include/etl/fibonacci.h b/include/etl/fibonacci.h index 9105f8ad..fb4a0d62 100644 --- a/include/etl/fibonacci.h +++ b/include/etl/fibonacci.h @@ -70,6 +70,9 @@ namespace etl static ETL_CONSTANT size_t value = 0UL; }; + template + ETL_CONSTANT size_t fibonacci::value; + #if ETL_USING_CPP17 template inline constexpr size_t fibonacci_v = fibonacci::value; diff --git a/include/etl/fixed_sized_memory_block_allocator.h b/include/etl/fixed_sized_memory_block_allocator.h index e48a278a..ad4fac30 100644 --- a/include/etl/fixed_sized_memory_block_allocator.h +++ b/include/etl/fixed_sized_memory_block_allocator.h @@ -112,6 +112,15 @@ namespace etl /// The generic pool from which allocate memory blocks. etl::generic_pool pool; }; + + template + ETL_CONSTANT size_t fixed_sized_memory_block_allocator::Block_Size; + + template + ETL_CONSTANT size_t fixed_sized_memory_block_allocator::Alignment; + + template + ETL_CONSTANT size_t fixed_sized_memory_block_allocator::Size; } #endif diff --git a/include/etl/flags.h b/include/etl/flags.h index 5bdf2aaa..3b49dc6c 100644 --- a/include/etl/flags.h +++ b/include/etl/flags.h @@ -349,6 +349,15 @@ namespace etl value_type data; }; + template + ETL_CONSTANT typename flags::value_type flags::ALL_SET; + + template + ETL_CONSTANT typename flags::value_type flags::ALL_CLEAR; + + template + ETL_CONSTANT size_t flags::NBITS; + //*************************************************************************** /// operator == //*************************************************************************** diff --git a/include/etl/flat_map.h b/include/etl/flat_map.h index 29bd2cd4..0f8ad3d5 100644 --- a/include/etl/flat_map.h +++ b/include/etl/flat_map.h @@ -1158,6 +1158,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t flat_map::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/flat_multimap.h b/include/etl/flat_multimap.h index cd3686fb..01c55720 100644 --- a/include/etl/flat_multimap.h +++ b/include/etl/flat_multimap.h @@ -206,7 +206,7 @@ namespace etl //********************************************************************* const_reverse_iterator rend() const { - refmap_t::rend(); + return refmap_t::rend(); } //********************************************************************* @@ -1041,6 +1041,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t flat_multimap::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/flat_multiset.h b/include/etl/flat_multiset.h index 7d3fdce2..2f35babe 100644 --- a/include/etl/flat_multiset.h +++ b/include/etl/flat_multiset.h @@ -995,6 +995,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t flat_multiset::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/flat_set.h b/include/etl/flat_set.h index 05505df9..1a71cbb3 100644 --- a/include/etl/flat_set.h +++ b/include/etl/flat_set.h @@ -1082,6 +1082,9 @@ namespace etl etl::vector lookup; }; + template + ETL_CONSTANT size_t flat_set::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/forward_list.h b/include/etl/forward_list.h index 8d1ac9d5..98da9b7e 100644 --- a/include/etl/forward_list.h +++ b/include/etl/forward_list.h @@ -1748,6 +1748,9 @@ namespace etl etl::pool::data_node_t, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t forward_list::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/fsm.h b/include/etl/fsm.h index 5c71795d..0f2eb368 100644 --- a/include/etl/fsm.h +++ b/include/etl/fsm.h @@ -169,19 +169,34 @@ namespace etl } }; + namespace private_fsm + { + template + class ifsm_state_helper + { + public: + + // Pass this whenever no state change is desired. + // The highest unsigned value of fsm_state_id_t. + static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits::max; + // Pass this when this event also needs to be passed to the parent. + static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; + }; + + template + ETL_CONSTANT fsm_state_id_t ifsm_state_helper::No_State_Change; + + template + ETL_CONSTANT fsm_state_id_t ifsm_state_helper::Pass_To_Parent; + } + //*************************************************************************** /// Interface class for FSM states. //*************************************************************************** - class ifsm_state + class ifsm_state : public private_fsm::ifsm_state_helper<> { public: - // Pass this whenever no state change is desired. - // The highest unsigned value of fsm_state_id_t. - static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits::max; - // Pass this when this event also needs to be passed to the parent. - static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; - /// Allows ifsm_state functions to be private. friend class etl::fsm; friend class etl::hfsm; diff --git a/include/etl/functional.h b/include/etl/functional.h index 0a4bde46..e6a72ad8 100644 --- a/include/etl/functional.h +++ b/include/etl/functional.h @@ -57,6 +57,11 @@ namespace etl { } + ETL_CONSTEXPR20 reference_wrapper(const reference_wrapper& rhs) ETL_NOEXCEPT + : t(rhs.t) + { + } + ETL_CONSTEXPR20 reference_wrapper& operator = (const reference_wrapper& rhs) ETL_NOEXCEPT { t = rhs.t; diff --git a/include/etl/generators/fsm_generator.h b/include/etl/generators/fsm_generator.h index c30c8b9c..6d5e945a 100644 --- a/include/etl/generators/fsm_generator.h +++ b/include/etl/generators/fsm_generator.h @@ -188,19 +188,35 @@ namespace etl } }; + namespace private_fsm + { + template + class ifsm_state_helper + { + public: + + // Pass this whenever no state change is desired. + // The highest unsigned value of fsm_state_id_t. + static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits::max; + + // Pass this when this event also needs to be passed to the parent. + static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; + }; + + template + ETL_CONSTANT fsm_state_id_t ifsm_state_helper::No_State_Change; + + template + ETL_CONSTANT fsm_state_id_t ifsm_state_helper::Pass_To_Parent; + } + //*************************************************************************** /// Interface class for FSM states. //*************************************************************************** - class ifsm_state + class ifsm_state : public private_fsm::ifsm_state_helper<> { public: - // Pass this whenever no state change is desired. - // The highest unsigned value of fsm_state_id_t. - static ETL_CONSTANT fsm_state_id_t No_State_Change = etl::integral_limits::max; - // Pass this when this event also needs to be passed to the parent. - static ETL_CONSTANT fsm_state_id_t Pass_To_Parent = No_State_Change - 1U; - /// Allows ifsm_state functions to be private. friend class etl::fsm; friend class etl::hfsm; @@ -325,6 +341,9 @@ namespace etl ifsm_state& operator =(const ifsm_state&); }; + ETL_CONSTANT fsm_state_id_t ifsm_state::No_State_Change; + ETL_CONSTANT fsm_state_id_t ifsm_state::Pass_To_Parent; + //*************************************************************************** /// The FSM class. //*************************************************************************** diff --git a/include/etl/generators/message_packet_generator.h b/include/etl/generators/message_packet_generator.h index 6ada9acd..8a9bf0e0 100644 --- a/include/etl/generators/message_packet_generator.h +++ b/include/etl/generators/message_packet_generator.h @@ -483,7 +483,7 @@ namespace etl for n in range(1, int(Handlers)): cog.out("T%s, " % n) cog.outl("T%s>::value, int>::type>" % int(Handlers)) - cog.outl(" explicit message_packet(TMessage&& msg)") + cog.outl(" explicit message_packet(TMessage&& /*msg*/)") cog.outl(" : valid(true)") cog.outl(" {") generate_static_assert_cpp11(int(Handlers)) @@ -767,7 +767,7 @@ namespace etl for t in range(1, n): cog.out("T%s, " % t) cog.outl("T%s>::value, int>::type>" % n) - cog.outl(" explicit message_packet(TMessage&& msg)") + cog.outl(" explicit message_packet(TMessage&& /*msg*/)") cog.outl(" : valid(true)") cog.outl(" {") generate_static_assert_cpp11(n) diff --git a/include/etl/generators/smallest_generator.h b/include/etl/generators/smallest_generator.h index 10f599e3..771d4111 100644 --- a/include/etl/generators/smallest_generator.h +++ b/include/etl/generators/smallest_generator.h @@ -333,6 +333,9 @@ namespace etl typedef typename private_smallest::best_fit_uint_type::type type; }; + template + ETL_CONSTANT int smallest_uint_for_bits::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_uint_for_bits_t = typename smallest_uint_for_bits::type; @@ -359,6 +362,9 @@ namespace etl typedef typename private_smallest::best_fit_int_type::type type; }; + template + ETL_CONSTANT int smallest_int_for_bits::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_int_for_bits_t = typename smallest_int_for_bits::type; @@ -385,6 +391,9 @@ namespace etl typedef typename private_smallest::best_fit_uint_type::type type; }; + template + ETL_CONSTANT int smallest_uint_for_value::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_uint_for_value_t = typename smallest_uint_for_value::type; @@ -411,6 +420,9 @@ namespace etl typedef typename private_smallest::best_fit_int_type::type type; }; + template + ETL_CONSTANT int smallest_int_for_value::TYPE_INDEX; + #if ETL_USING_CPP11 template using smallest_int_for_value_t = typename smallest_int_for_value::type; diff --git a/include/etl/generators/type_lookup_generator.h b/include/etl/generators/type_lookup_generator.h index 2563729a..bcc10e2d 100644 --- a/include/etl/generators/type_lookup_generator.h +++ b/include/etl/generators/type_lookup_generator.h @@ -137,14 +137,14 @@ namespace etl template struct id_from_type_helper { - static constexpr size_t value = etl::is_same::value ? T1::ID : id_from_type_helper::value; + static constexpr size_t value = etl::is_same::value ? size_t(T1::ID) : id_from_type_helper::value; }; // Specialisation for 1 type pair. template struct id_from_type_helper { - static constexpr size_t value = etl::is_same::value ? T1::ID : UNKNOWN; + static constexpr size_t value = etl::is_same::value ? size_t(T1::ID) : UNKNOWN; }; public: diff --git a/include/etl/generators/type_traits_generator.h b/include/etl/generators/type_traits_generator.h index c692add8..bcaa8e54 100644 --- a/include/etl/generators/type_traits_generator.h +++ b/include/etl/generators/type_traits_generator.h @@ -96,7 +96,7 @@ namespace etl //*************************************************************************** /// integral_constant - template + template struct integral_constant { static const T value = VALUE; @@ -119,7 +119,7 @@ namespace etl #if ETL_USING_CPP17 template - inline constexpr T integral_constant_v = std::integral_constant::value; + inline constexpr T integral_constant_v = etl::integral_constant::value; #endif #if ETL_USING_CPP11 @@ -132,7 +132,7 @@ namespace etl #if ETL_USING_CPP17 template - inline constexpr bool bool_constant_v = std::bool_constant::value; + inline constexpr bool bool_constant_v = bool_constant::value; #endif //*************************************************************************** @@ -825,11 +825,11 @@ namespace etl // Traits are derived from the STL //***************************************************************************** -//*************************************************************************** -/// integral_constant -///\ingroup type_traits -template -struct integral_constant : std::integral_constant {}; + //*************************************************************************** + /// integral_constant + ///\ingroup type_traits + template + struct integral_constant : std::integral_constant {}; /// integral_constant specialisations ///\ingroup type_traits @@ -841,6 +841,11 @@ typedef integral_constant true_type; inline constexpr T integral_constant_v = std::integral_constant::value; #endif +#if ETL_USING_CPP17 + template + inline constexpr T integral_constant_v = std::integral_constant::value; +#endif + #if ETL_USING_CPP17 template using bool_constant = std::bool_constant; @@ -851,7 +856,7 @@ typedef integral_constant true_type; #if ETL_USING_CPP17 template - inline constexpr bool bool_constant_v = std::bool_constant::value; + inline constexpr bool bool_constant_v = bool_constant::value; #endif //*************************************************************************** @@ -1637,99 +1642,71 @@ typedef integral_constant true_type; //********************************************* // is_assignable template - struct is_assignable : public std::is_assignable - { - }; + using is_assignable = std::is_assignable; //********************************************* // is_constructible template - struct is_constructible : public std::is_constructible - { - }; + using is_constructible = std::is_constructible; //********************************************* // is_copy_constructible template - struct is_copy_constructible : public std::is_copy_constructible - { - }; + using is_copy_constructible = std::is_copy_constructible; //********************************************* // is_move_constructible template - struct is_move_constructible : public std::is_move_constructible - { - }; + using is_move_constructible = 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 - { - }; + using is_trivially_constructible = std::is_trivially_constructible; #else template - struct is_trivially_constructible : public etl::bool_constant::value || etl::is_pointer::value> - { - }; + using is_trivially_constructible = etl::bool_constant::value || etl::is_pointer::value>; #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 - { - }; + using is_trivially_copy_constructible = std::is_trivially_copy_constructible; #else template - struct is_trivially_copy_constructible : public etl::bool_constant::value || etl::is_pointer::value> - { - }; + using is_trivially_copy_constructible = etl::bool_constant::value || etl::is_pointer::value>; #endif //********************************************* // is_trivially_destructible #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template - struct is_trivially_destructible : public std::is_trivially_destructible - { - }; + using is_trivially_destructible = std::is_trivially_destructible; #else template - struct is_trivially_destructible : public etl::bool_constant::value || etl::is_pointer::value> - { - }; + using is_trivially_destructible = etl::bool_constant::value || etl::is_pointer::value>; #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 - { - }; + using is_trivially_copy_assignable = std::is_trivially_copy_assignable; #else template - struct is_trivially_copy_assignable : public etl::bool_constant::value || etl::is_pointer::value> - { - }; + using is_trivially_copy_assignable = etl::bool_constant::value || etl::is_pointer::value>; #endif //********************************************* // is_trivially_copyable #if ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED template - struct is_trivially_copyable : public std::is_trivially_copyable - { - }; + using is_trivially_copyable = std::is_trivially_copyable; #else template - struct is_trivially_copyable : public etl::bool_constant::value || etl::is_pointer::value> - { - }; + using is_trivially_copyable = etl::bool_constant::value || etl::is_pointer::value>; #endif #elif defined(ETL_USE_TYPE_TRAITS_BUILTINS) && !defined(ETL_USER_DEFINED_TYPE_TRAITS) diff --git a/include/etl/generic_pool.h b/include/etl/generic_pool.h index 5ef0635d..f464b7b2 100644 --- a/include/etl/generic_pool.h +++ b/include/etl/generic_pool.h @@ -194,6 +194,15 @@ namespace etl generic_pool& operator =(const generic_pool&) ETL_DELETE; }; + template + ETL_CONSTANT size_t generic_pool::SIZE; + + template + ETL_CONSTANT size_t generic_pool::ALIGNMENT; + + template + ETL_CONSTANT size_t generic_pool::TYPE_SIZE; + //************************************************************************* /// A templated abstract pool implementation that uses a fixed size pool. /// The storage for the pool is supplied externally. @@ -338,6 +347,12 @@ namespace etl generic_pool_ext(const generic_pool_ext&) ETL_DELETE; generic_pool_ext& operator=(const generic_pool_ext&) ETL_DELETE; }; + + template + ETL_CONSTANT size_t generic_pool_ext::ALIGNMENT; + + template + ETL_CONSTANT size_t generic_pool_ext::TYPE_SIZE; } #endif diff --git a/include/etl/hfsm.h b/include/etl/hfsm.h index 73eee88b..b49eaa19 100644 --- a/include/etl/hfsm.h +++ b/include/etl/hfsm.h @@ -67,6 +67,14 @@ namespace etl if (call_on_enter_state) { do_enters(ETL_NULLPTR, p_state, true); + + + //etl::fsm_state_id_t next_state = do_enters(ETL_NULLPTR, p_state, true); + + //if (ifsm_state::No_State_Change != next_state) + //{ + // p_state = state_list[next_state]; + //} } } } diff --git a/include/etl/histogram.h b/include/etl/histogram.h index 4cb03175..15d54222 100644 --- a/include/etl/histogram.h +++ b/include/etl/histogram.h @@ -126,6 +126,9 @@ namespace etl etl::array accumulator; }; + + template + ETL_CONSTANT size_t histogram_common::Max_Size; } //*************************************************************************** @@ -592,6 +595,9 @@ namespace etl etl::flat_map accumulator; }; + + template + ETL_CONSTANT size_t sparse_histogram::Max_Size; } #endif diff --git a/include/etl/indirect_vector.h b/include/etl/indirect_vector.h index 78e592bf..7158a4a0 100644 --- a/include/etl/indirect_vector.h +++ b/include/etl/indirect_vector.h @@ -1424,6 +1424,9 @@ namespace etl etl::pool storage_pool; }; + template + ETL_CONSTANT size_t indirect_vector::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/integral_limits.h b/include/etl/integral_limits.h index a93f6c88..f7b7c68c 100644 --- a/include/etl/integral_limits.h +++ b/include/etl/integral_limits.h @@ -45,8 +45,422 @@ SOFTWARE. ///\ingroup utilities //***************************************************************************** +#ifndef LLONG_MAX + #define LLONG_MAX 9223372036854775807LL +#endif + +#ifndef LLONG_MIN + #define LLONG_MIN (-LLONG_MAX - 1LL) +#endif + +#ifndef ULLONG_MAX + #define ULLONG_MAX 18446744073709551615ULL +#endif + namespace etl { + namespace private_integral_limits + { + //***************************************************************************** + /// The technique of using templated base classes to declare and define the statics + /// is to get around the limits of the One Definition Rule (ODR) that occurs when + /// the top level integral_limits classes are specialised. This issue currently seems + /// to only be apparent for GCC/C++14. + /// In C++17 and above this is not necessary, as the inline keyword may be used. + /// At the time of writing, the ETL is generally aimed to be compatible with C++98 and above. + //***************************************************************************** + + //********************************* + // signed char + template + struct statics_signed_char + { + typedef signed char value_type; + + static ETL_CONSTANT signed char min = SCHAR_MIN; + static ETL_CONSTANT signed char max = SCHAR_MAX; + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT signed char statics_signed_char::min; + + template + ETL_CONSTANT signed char statics_signed_char::max; + + template + ETL_CONSTANT int statics_signed_char::bits; + + template + ETL_CONSTANT bool statics_signed_char::is_signed; + + //*********************************** + // unsigned char + template + struct statics_unsigned_char + { + typedef unsigned char value_type; + + static ETL_CONSTANT unsigned char min = 0; + static ETL_CONSTANT unsigned char max = UCHAR_MAX; + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT unsigned char statics_unsigned_char::min; + + template + ETL_CONSTANT unsigned char statics_unsigned_char::max; + + template + ETL_CONSTANT int statics_unsigned_char::bits; + + template + ETL_CONSTANT bool statics_unsigned_char::is_signed; + + //*********************************** + // char + template + struct statics_char + { + typedef char value_type; + + static ETL_CONSTANT char min = (etl::is_signed::value) ? SCHAR_MIN : 0; + static ETL_CONSTANT char max = (etl::is_signed::value) ? SCHAR_MAX : static_cast(UCHAR_MAX); + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT char statics_char::min; + + template + ETL_CONSTANT char statics_char::max; + + template + ETL_CONSTANT int statics_char::bits; + + template + ETL_CONSTANT bool statics_char::is_signed; + + //*********************************** + // wchar_t + template + struct statics_wchar_t + { + typedef wchar_t value_type; + + static ETL_CONSTANT wchar_t min = WCHAR_MIN; + static ETL_CONSTANT wchar_t max = WCHAR_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * sizeof(wchar_t); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT wchar_t statics_wchar_t::min; + + template + ETL_CONSTANT wchar_t statics_wchar_t::max; + + template + ETL_CONSTANT int statics_wchar_t::bits; + + template + ETL_CONSTANT bool statics_wchar_t::is_signed; + + //*********************************** + // short +#if defined(ETL_COMPILER_MICROSOFT) + #pragma warning(push) + #pragma warning(disable : 4309) +#endif + + template + struct statics_short + { + typedef short value_type; + + static ETL_CONSTANT short min = SHRT_MIN; + static ETL_CONSTANT short max = SHRT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(short) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT short statics_short::min; + + template + ETL_CONSTANT short statics_short::max; + + template + ETL_CONSTANT int statics_short::bits; + + template + ETL_CONSTANT bool statics_short::is_signed; + +#if defined(ETL_COMPILER_MICROSOFT) + #pragma warning(pop) +#endif + + //*********************************** + // unsigned short + template + struct statics_unsigned_short + { + typedef unsigned short value_type; + + static ETL_CONSTANT unsigned short min = 0; + static ETL_CONSTANT unsigned short max = USHRT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned short) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT unsigned short statics_unsigned_short::min; + + template + ETL_CONSTANT unsigned short statics_unsigned_short::max; + + template + ETL_CONSTANT int statics_unsigned_short::bits; + + template + ETL_CONSTANT bool statics_unsigned_short::is_signed; + + //*********************************** + // int + template + struct statics_int + { + typedef int value_type; + + static ETL_CONSTANT int min = INT_MIN; + static ETL_CONSTANT int max = INT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(int) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT int statics_int::min; + + template + ETL_CONSTANT int statics_int::max; + + template + ETL_CONSTANT int statics_int::bits; + + template + ETL_CONSTANT bool statics_int::is_signed; + + //*********************************** + // unsigned int + template + struct statics_unsigned_int + { + typedef unsigned int value_type; + + static ETL_CONSTANT unsigned int min = 0; + static ETL_CONSTANT unsigned int max = UINT_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned int) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT unsigned int statics_unsigned_int::min; + + template + ETL_CONSTANT unsigned int statics_unsigned_int::max; + + template + ETL_CONSTANT int statics_unsigned_int::bits; + + template + ETL_CONSTANT bool statics_unsigned_int::is_signed; + + //*********************************** + // long + template + struct statics_long + { + typedef long value_type; + + static ETL_CONSTANT long min = LONG_MIN; + static ETL_CONSTANT long max = LONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT long statics_long::min; + + template + ETL_CONSTANT long statics_long::max; + + template + ETL_CONSTANT int statics_long::bits; + + template + ETL_CONSTANT bool statics_long::is_signed; + + //*********************************** + // unsigned long + template + struct statics_unsigned_long + { + typedef unsigned long value_type; + + static ETL_CONSTANT unsigned long min = 0; + static ETL_CONSTANT unsigned long max = ULONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT unsigned long statics_unsigned_long::min; + + template + ETL_CONSTANT unsigned long statics_unsigned_long::max; + + template + ETL_CONSTANT int statics_unsigned_long::bits; + + template + ETL_CONSTANT bool statics_unsigned_long::is_signed; + + //*********************************** + // long long + template + struct statics_long_long + { + typedef long long value_type; + + static ETL_CONSTANT long long min = LLONG_MIN; + static ETL_CONSTANT long long max = LLONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(long long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT long long statics_long_long::min; + + template + ETL_CONSTANT long long statics_long_long::max; + + template + ETL_CONSTANT int statics_long_long::bits; + + template + ETL_CONSTANT bool statics_long_long::is_signed; + + //*********************************** + // unsigned long long + template + struct statics_unsigned_long_long + { + typedef unsigned long value_type; + + static ETL_CONSTANT unsigned long long min = 0; + static ETL_CONSTANT unsigned long long max = ULLONG_MAX; + static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned long long) / sizeof(char)); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT unsigned long long statics_unsigned_long_long::min; + + template + ETL_CONSTANT unsigned long long statics_unsigned_long_long::max; + + template + ETL_CONSTANT int statics_unsigned_long_long::bits; + + template + ETL_CONSTANT bool statics_unsigned_long_long::is_signed; + +#if ETL_HAS_NATIVE_CHAR8_T + //*********************************** + // char8_t + template + struct statics_char8_t + { + typedef char8_t value_type; + + static ETL_CONSTANT char8_t min = (etl::is_signed::value) ? SCHAR_MIN : 0; + static ETL_CONSTANT char8_t max = (etl::is_signed::value) ? SCHAR_MAX : static_cast(UCHAR_MAX); + static ETL_CONSTANT int bits = CHAR_BIT; + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + template + ETL_CONSTANT char8_t statics_char8_t::min; + + template + ETL_CONSTANT char8_t statics_char8_t::max; + + template + ETL_CONSTANT int statics_char8_t::bits; + + template + ETL_CONSTANT bool statics_char8_t::is_signed; +#endif + +#if ETL_HAS_NATIVE_CHAR16_T + //*********************************** + // char16_t + template + struct statics_char16_t + { + typedef char16_t value_type; + + static ETL_CONSTANT char16_t min = 0; + static ETL_CONSTANT char16_t max = 0xFFFFU; + static ETL_CONSTANT int bits = 16; + static ETL_CONSTANT bool is_signed = false; + }; + + template + ETL_CONSTANT char16_t statics_char16_t::min; + + template + ETL_CONSTANT char16_t statics_char16_t::max; + + template + ETL_CONSTANT int statics_char16_t::bits; + + template + ETL_CONSTANT bool statics_char16_t::is_signed; +#endif + +#if ETL_HAS_NATIVE_CHAR32_T + //*********************************** + // char32_t + template + struct statics_char32_t + { + typedef char32_t value_type; + + static ETL_CONSTANT char32_t min = 0; + static ETL_CONSTANT char32_t max = 0xFFFFFFFFU; + static ETL_CONSTANT int bits = 32; + static ETL_CONSTANT bool is_signed = false; + }; + + template + ETL_CONSTANT char32_t statics_char32_t::min; + + template + ETL_CONSTANT char32_t statics_char32_t::max; + + template + ETL_CONSTANT int statics_char32_t::bits; + + template + ETL_CONSTANT bool statics_char32_t::is_signed; +#endif + } + //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** @@ -57,166 +471,91 @@ namespace etl ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_signed_char<> { - static ETL_CONSTANT int min = 0; - static ETL_CONSTANT int max = 0; - static ETL_CONSTANT int bits = 0; - static ETL_CONSTANT bool is_signed = false; }; //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_unsigned_char<> { - static ETL_CONSTANT signed char min = SCHAR_MIN; - static ETL_CONSTANT signed char max = SCHAR_MAX; - static ETL_CONSTANT int bits = CHAR_BIT; - static ETL_CONSTANT bool is_signed = etl::is_signed::value; + }; + + //*************************************************************************** + ///\ingroup integral_limits + //*************************************************************************** + + template <> + struct integral_limits : public private_integral_limits::statics_char<> + { + typedef char value_type; }; //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_short<> { - static ETL_CONSTANT unsigned char min = 0; - static ETL_CONSTANT unsigned char max = UCHAR_MAX; - static ETL_CONSTANT int bits = CHAR_BIT; - static ETL_CONSTANT bool is_signed = etl::is_signed::value; - }; - - //*************************************************************************** - ///\ingroup integral_limits - //*************************************************************************** -#if defined(ETL_COMPILER_MICROSOFT) - #pragma warning(push) - #pragma warning(disable : 4309) -#endif - template <> - struct integral_limits - { - static ETL_CONSTANT char min = (etl::is_signed::value) ? SCHAR_MIN : 0; - static ETL_CONSTANT char max = (etl::is_signed::value) ? SCHAR_MAX : static_cast(UCHAR_MAX); - static ETL_CONSTANT int bits = CHAR_BIT; - static ETL_CONSTANT bool is_signed = etl::is_signed::value; - }; -#if defined(ETL_COMPILER_MICROSOFT) - #pragma warning(pop) -#endif - - //*************************************************************************** - ///\ingroup integral_limits - //*************************************************************************** - template <> - struct integral_limits - { - static ETL_CONSTANT short min = SHRT_MIN; - static ETL_CONSTANT short max = SHRT_MAX; - static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(short) / sizeof(char)); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_unsigned_short<> { - static ETL_CONSTANT unsigned short min = 0; - static ETL_CONSTANT unsigned short max = USHRT_MAX; - static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned short) / sizeof(char)); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_int<> { - static ETL_CONSTANT int min = INT_MIN; - static ETL_CONSTANT int max = INT_MAX; - static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(int) / sizeof(char)); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_unsigned_int<> { - static ETL_CONSTANT unsigned int min = 0; - static ETL_CONSTANT unsigned int max = UINT_MAX; - static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned int) / sizeof(char)); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_long<> { - static ETL_CONSTANT long min = LONG_MIN; - static ETL_CONSTANT long max = LONG_MAX; - static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(long) / sizeof(char)); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits + struct integral_limits : public private_integral_limits::statics_unsigned_long<> { - static ETL_CONSTANT unsigned long min = 0; - static ETL_CONSTANT unsigned long max = ULONG_MAX; - static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned long) / sizeof(char)); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; - }; - -#ifndef LLONG_MAX -#define LLONG_MAX 9223372036854775807LL -#endif - -#ifndef LLONG_MIN -#define LLONG_MIN (-LLONG_MAX - 1LL) -#endif - -#ifndef ULLONG_MAX -#define ULLONG_MAX 18446744073709551615ULL -#endif - - //*************************************************************************** - ///\ingroup integral_limits - //*************************************************************************** - template <> - struct integral_limits - { - static ETL_CONSTANT long long min = LLONG_MIN; - static ETL_CONSTANT long long max = LLONG_MAX; - static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(long long) / sizeof(char)); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; }; //*************************************************************************** ///\ingroup integral_limits //*************************************************************************** template <> - struct integral_limits - { - static ETL_CONSTANT unsigned long long min = 0; - static ETL_CONSTANT unsigned long long max = ULLONG_MAX; - static ETL_CONSTANT int bits = CHAR_BIT * (sizeof(unsigned long long) / sizeof(char)); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; + struct integral_limits : public private_integral_limits::statics_long_long<> + { }; - static ETL_CONSTANT size_t npos = etl::integral_limits::max; + //*************************************************************************** + ///\ingroup integral_limits + //*************************************************************************** + template <> + struct integral_limits : public private_integral_limits::statics_unsigned_long_long<> + { + }; } #include "private/minmax_pop.h" diff --git a/include/etl/iterator.h b/include/etl/iterator.h index 016eec10..83251179 100644 --- a/include/etl/iterator.h +++ b/include/etl/iterator.h @@ -806,24 +806,36 @@ namespace etl static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::input_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_input_iterator::value; + template struct is_output_iterator { static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::output_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_output_iterator::value; + template struct is_forward_iterator { static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::forward_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_forward_iterator::value; + template struct is_bidirectional_iterator { static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::bidirectional_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_bidirectional_iterator::value; + // Deprecated template struct is_random_iterator @@ -831,12 +843,18 @@ namespace etl static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::random_access_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_random_iterator::value; + template struct is_random_access_iterator { static ETL_CONSTANT bool value = etl::is_same::iterator_category, ETL_OR_STD::random_access_iterator_tag>::value; }; + template + ETL_CONSTANT bool is_random_access_iterator::value; + template struct is_input_iterator_concept { @@ -846,6 +864,9 @@ namespace etl etl::is_random_iterator::value; }; + template + ETL_CONSTANT bool is_input_iterator_concept::value; + template struct is_output_iterator_concept { @@ -855,6 +876,9 @@ namespace etl etl::is_random_iterator::value; }; + template + ETL_CONSTANT bool is_output_iterator_concept::value; + template struct is_forward_iterator_concept { @@ -863,6 +887,9 @@ namespace etl etl::is_random_iterator::value; }; + template + ETL_CONSTANT bool is_forward_iterator_concept::value; + template struct is_bidirectional_iterator_concept { @@ -870,6 +897,9 @@ namespace etl etl::is_random_iterator::value; }; + template + ETL_CONSTANT bool is_bidirectional_iterator_concept::value; + // Deprecated template struct is_random_iterator_concept @@ -877,12 +907,21 @@ namespace etl static ETL_CONSTANT bool value = etl::is_random_iterator::value; }; + // Deprecated + template + ETL_CONSTANT bool is_random_iterator_concept::value; + + // Deprecated template struct is_random_access_iterator_concept { static ETL_CONSTANT bool value = etl::is_random_access_iterator::value; }; + // Deprecated + template + ETL_CONSTANT bool is_random_access_iterator_concept::value; + #if ETL_NOT_USING_STL || ETL_CPP11_NOT_SUPPORTED //***************************************************************************** /// Get the 'begin' iterator. diff --git a/include/etl/limits.h b/include/etl/limits.h index eae016b0..ae54da04 100644 --- a/include/etl/limits.h +++ b/include/etl/limits.h @@ -101,69 +101,658 @@ namespace etl { enum float_round_style { - round_indeterminate = -1, - round_toward_zero = 0, - round_to_nearest = 1, - round_toward_infinity = 2, + round_indeterminate = -1, + round_toward_zero = 0, + round_to_nearest = 1, + round_toward_infinity = 2, round_toward_neg_infinity = 3, }; enum float_denorm_style { denorm_indeterminate = -1, - denorm_absent = 0, - denorm_present = 1 + denorm_absent = 0, + denorm_present = 1 }; - - class etl_integral_limits + namespace private_limits { - public: + //********************************* + // Integral limits common + template + class integral_limits_common + { + public: - static ETL_CONSTANT bool is_specialized = true; - static ETL_CONSTANT bool is_integer = true; - static ETL_CONSTANT bool is_exact = true; - static ETL_CONSTANT int max_digits10 = 0; - static ETL_CONSTANT int radix = 2; - static ETL_CONSTANT int min_exponent = 0; - static ETL_CONSTANT int min_exponent10 = 0; - static ETL_CONSTANT int max_exponent = 0; - static ETL_CONSTANT int max_exponent10 = 0; - static ETL_CONSTANT bool has_infinity = false; - static ETL_CONSTANT bool has_quiet_NaN = false; - static ETL_CONSTANT bool has_signaling_NaN = false; - static ETL_CONSTANT bool has_denorm_loss = false; - static ETL_CONSTANT bool is_iec559 = false; - static ETL_CONSTANT bool is_bounded = true; - static ETL_CONSTANT bool traps = false; - static ETL_CONSTANT bool tinyness_before = false; - static ETL_CONSTANT float_denorm_style has_denorm = denorm_absent; - static ETL_CONSTANT float_round_style round_style = round_toward_zero; - }; + static ETL_CONSTANT bool is_specialized = true; + static ETL_CONSTANT bool is_integer = true; + static ETL_CONSTANT bool is_exact = true; + static ETL_CONSTANT int max_digits10 = 0; + static ETL_CONSTANT int radix = 2; + static ETL_CONSTANT int min_exponent = 0; + static ETL_CONSTANT int min_exponent10 = 0; + static ETL_CONSTANT int max_exponent = 0; + static ETL_CONSTANT int max_exponent10 = 0; + static ETL_CONSTANT bool has_infinity = false; + static ETL_CONSTANT bool has_quiet_NaN = false; + static ETL_CONSTANT bool has_signaling_NaN = false; + static ETL_CONSTANT bool has_denorm_loss = false; + static ETL_CONSTANT bool is_iec559 = false; + static ETL_CONSTANT bool is_bounded = true; + static ETL_CONSTANT bool traps = false; + static ETL_CONSTANT bool tinyness_before = false; + static ETL_CONSTANT float_denorm_style has_denorm = denorm_absent; + static ETL_CONSTANT float_round_style round_style = round_toward_zero; + }; - class etl_floating_point_limits - { - public: + template + ETL_CONSTANT bool integral_limits_common::is_specialized; - static ETL_CONSTANT bool is_specialized = true; - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_integer = false; - static ETL_CONSTANT bool is_exact = false; - static ETL_CONSTANT int radix = 2; - static ETL_CONSTANT bool has_infinity = true; - static ETL_CONSTANT bool has_quiet_NaN = ETL_HAS_NAN; - static ETL_CONSTANT bool has_signaling_NaN = ETL_HAS_NAN; - static ETL_CONSTANT bool has_denorm_loss = false; - static ETL_CONSTANT bool is_iec559 = false; - static ETL_CONSTANT bool is_bounded = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTANT bool traps = false; - static ETL_CONSTANT bool tinyness_before = false; - static ETL_CONSTANT float_denorm_style has_denorm = denorm_indeterminate; - static ETL_CONSTANT float_round_style round_style = round_indeterminate; + template + ETL_CONSTANT bool integral_limits_common::is_integer; - static float round_error() { return float(0.5); } - }; + template + ETL_CONSTANT bool integral_limits_common::is_exact; + + template + ETL_CONSTANT int integral_limits_common::max_digits10; + + template + ETL_CONSTANT int integral_limits_common::radix; + + template + ETL_CONSTANT int integral_limits_common::min_exponent; + + template + ETL_CONSTANT int integral_limits_common::min_exponent10; + + template + ETL_CONSTANT int integral_limits_common::max_exponent; + + template + ETL_CONSTANT int integral_limits_common::max_exponent10; + + template + ETL_CONSTANT bool integral_limits_common::has_infinity; + + template + ETL_CONSTANT bool integral_limits_common::has_quiet_NaN; + + template + ETL_CONSTANT bool integral_limits_common::has_signaling_NaN; + + template + ETL_CONSTANT bool integral_limits_common::has_denorm_loss; + + template + ETL_CONSTANT bool integral_limits_common::is_iec559; + + template + ETL_CONSTANT bool integral_limits_common::is_bounded; + + template + ETL_CONSTANT bool integral_limits_common::traps; + + template + ETL_CONSTANT bool integral_limits_common::tinyness_before; + + template + ETL_CONSTANT float_denorm_style integral_limits_common::has_denorm; + + template + ETL_CONSTANT float_round_style integral_limits_common::round_style; + + //********************************* + // bool + template + struct integral_limits_bool + { + static ETL_CONSTANT int digits = 1; + static ETL_CONSTANT int digits10 = 0; + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_bool::digits; + + template + ETL_CONSTANT int integral_limits_bool::digits10; + + template + ETL_CONSTANT bool integral_limits_bool::is_signed; + + template + ETL_CONSTANT bool integral_limits_bool::is_modulo; + + //********************************* + // char + template + struct integral_limits_char + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed::value ? 1 : 0); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + static ETL_CONSTANT bool is_modulo = etl::is_unsigned::value; + }; + + template + ETL_CONSTANT int integral_limits_char::digits; + + template + ETL_CONSTANT int integral_limits_char::digits10; + + template + ETL_CONSTANT bool integral_limits_char::is_signed; + + template + ETL_CONSTANT bool integral_limits_char::is_modulo; + + //********************************* + // unsigned char + template + struct integral_limits_unsigned_char + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned char)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_unsigned_char::digits; + + template + ETL_CONSTANT int integral_limits_unsigned_char::digits10; + + template + ETL_CONSTANT bool integral_limits_unsigned_char::is_signed; + + template + ETL_CONSTANT bool integral_limits_unsigned_char::is_modulo; + + //********************************* + // signed char + template + struct integral_limits_signed_char + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - 1; + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_signed_char::digits; + + template + ETL_CONSTANT int integral_limits_signed_char::digits10; + + template + ETL_CONSTANT bool integral_limits_signed_char::is_signed; + + template + ETL_CONSTANT bool integral_limits_signed_char::is_modulo; + +#if ETL_HAS_NATIVE_CHAR8_T + //********************************* + // char8_t + template + struct integral_limits_char8_t + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char8_t)) - (etl::is_signed::value ? 1 : 0); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_char8_t::digits; + + template + ETL_CONSTANT int integral_limits_char8_t::digits10; + + template + ETL_CONSTANT bool integral_limits_char8_t::is_signed; + + template + ETL_CONSTANT bool integral_limits_char8_t::is_modulo; +#endif + +#if ETL_HAS_NATIVE_CHAR16_T + //********************************* + // char16_t + template + struct integral_limits_char16_t + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char16_t)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_char16_t::digits; + + template + ETL_CONSTANT int integral_limits_char16_t::digits10; + + template + ETL_CONSTANT bool integral_limits_char16_t::is_signed; + + template + ETL_CONSTANT bool integral_limits_char16_t::is_modulo; +#endif + +#if ETL_HAS_NATIVE_CHAR32_T + //********************************* + // char32_t + template + struct integral_limits_char32_t + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char32_t)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_char32_t::digits; + + template + ETL_CONSTANT int integral_limits_char32_t::digits10; + + template + ETL_CONSTANT bool integral_limits_char32_t::is_signed; + + template + ETL_CONSTANT bool integral_limits_char32_t::is_modulo; +#endif + + //********************************* + // wchar_t + template + struct integral_limits_wchar_t + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(wchar_t)) - (etl::is_signed::value ? 1 : 0); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = etl::is_signed::value; + static ETL_CONSTANT bool is_modulo = etl::is_unsigned::value; + }; + + template + ETL_CONSTANT int integral_limits_wchar_t::digits; + + template + ETL_CONSTANT int integral_limits_wchar_t::digits10; + + template + ETL_CONSTANT bool integral_limits_wchar_t::is_signed; + + template + ETL_CONSTANT bool integral_limits_wchar_t::is_modulo; + + //********************************* + // short + template + struct integral_limits_short + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(short)) - 1; + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_short::digits; + + template + ETL_CONSTANT int integral_limits_short::digits10; + + template + ETL_CONSTANT bool integral_limits_short::is_signed; + + template + ETL_CONSTANT bool integral_limits_short::is_modulo; + + //********************************* + // unsigned short + template + struct integral_limits_unsigned_short + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned short)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_unsigned_short::digits; + + template + ETL_CONSTANT int integral_limits_unsigned_short::digits10; + + template + ETL_CONSTANT bool integral_limits_unsigned_short::is_signed; + + template + ETL_CONSTANT bool integral_limits_unsigned_short::is_modulo; + + //********************************* + // int + template + struct integral_limits_int + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(int)) - 1; + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_int::digits; + + template + ETL_CONSTANT int integral_limits_int::digits10; + + template + ETL_CONSTANT bool integral_limits_int::is_signed; + + template + ETL_CONSTANT bool integral_limits_int::is_modulo; + + //********************************* + // unsigned int + template + struct integral_limits_unsigned_int + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned int)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_unsigned_int::digits; + + template + ETL_CONSTANT int integral_limits_unsigned_int::digits10; + + template + ETL_CONSTANT bool integral_limits_unsigned_int::is_signed; + + template + ETL_CONSTANT bool integral_limits_unsigned_int::is_modulo; + + //********************************* + // long + template + struct integral_limits_long + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long)) - 1; + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_long::digits; + + template + ETL_CONSTANT int integral_limits_long::digits10; + + template + ETL_CONSTANT bool integral_limits_long::is_signed; + + template + ETL_CONSTANT bool integral_limits_long::is_modulo; + + //********************************* + // unsigned long + template + struct integral_limits_unsigned_long + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_unsigned_long::digits; + + template + ETL_CONSTANT int integral_limits_unsigned_long::digits10; + + template + ETL_CONSTANT bool integral_limits_unsigned_long::is_signed; + + template + ETL_CONSTANT bool integral_limits_unsigned_long::is_modulo; + + //********************************* + // long long + template + struct integral_limits_long_long + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long long)) - 1; + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_modulo = false; + }; + + template + ETL_CONSTANT int integral_limits_long_long::digits; + + template + ETL_CONSTANT int integral_limits_long_long::digits10; + + template + ETL_CONSTANT bool integral_limits_long_long::is_signed; + + template + ETL_CONSTANT bool integral_limits_long_long::is_modulo; + + //********************************* + // unsigned long long + template + struct integral_limits_unsigned_long_long + { + static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long long)); + static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); + static ETL_CONSTANT bool is_signed = false; + static ETL_CONSTANT bool is_modulo = true; + }; + + template + ETL_CONSTANT int integral_limits_unsigned_long_long::digits; + + template + ETL_CONSTANT int integral_limits_unsigned_long_long::digits10; + + template + ETL_CONSTANT bool integral_limits_unsigned_long_long::is_signed; + + template + ETL_CONSTANT bool integral_limits_unsigned_long_long::is_modulo; + + //********************************* + // Floating point limits common + template + class floating_point_limits_common + { + public: + + static ETL_CONSTANT bool is_specialized = true; + static ETL_CONSTANT bool is_signed = true; + static ETL_CONSTANT bool is_integer = false; + static ETL_CONSTANT bool is_exact = false; + static ETL_CONSTANT int radix = 2; + static ETL_CONSTANT bool has_infinity = true; + static ETL_CONSTANT bool has_quiet_NaN = ETL_HAS_NAN; + static ETL_CONSTANT bool has_signaling_NaN = ETL_HAS_NAN; + static ETL_CONSTANT bool has_denorm_loss = false; + static ETL_CONSTANT bool is_iec559 = false; + static ETL_CONSTANT bool is_bounded = true; + static ETL_CONSTANT bool is_modulo = false; + static ETL_CONSTANT bool traps = false; + static ETL_CONSTANT bool tinyness_before = false; + static ETL_CONSTANT float_denorm_style has_denorm = denorm_indeterminate; + static ETL_CONSTANT float_round_style round_style = round_indeterminate; + + static float round_error() { return float(0.5); } + }; + + template + ETL_CONSTANT bool floating_point_limits_common::is_specialized; + + template + ETL_CONSTANT bool floating_point_limits_common::is_integer; + + template + ETL_CONSTANT bool floating_point_limits_common::is_exact; + + template + ETL_CONSTANT int floating_point_limits_common::radix; + + template + ETL_CONSTANT bool floating_point_limits_common::has_infinity; + + template + ETL_CONSTANT bool floating_point_limits_common::has_quiet_NaN; + + template + ETL_CONSTANT bool floating_point_limits_common::has_signaling_NaN; + + template + ETL_CONSTANT bool floating_point_limits_common::has_denorm_loss; + + template + ETL_CONSTANT bool floating_point_limits_common::is_iec559; + + template + ETL_CONSTANT bool floating_point_limits_common::is_bounded; + + template + ETL_CONSTANT bool floating_point_limits_common::traps; + + template + ETL_CONSTANT bool floating_point_limits_common::tinyness_before; + + template + ETL_CONSTANT float_denorm_style floating_point_limits_common::has_denorm; + + template + ETL_CONSTANT float_round_style floating_point_limits_common::round_style; + + //********************************* + // float + template + struct floating_point_limits_float + { + static ETL_CONSTANT int digits = FLT_MANT_DIG; + static ETL_CONSTANT int digits10 = FLT_DIG; + static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(FLT_MANT_DIG) + 2; + + static ETL_CONSTANT int min_exponent = FLT_MIN_EXP; + static ETL_CONSTANT int min_exponent10 = FLT_MIN_10_EXP; + static ETL_CONSTANT int max_exponent = FLT_MAX_EXP; + static ETL_CONSTANT int max_exponent10 = FLT_MAX_10_EXP; + }; + + template + ETL_CONSTANT int floating_point_limits_float::digits; + + template + ETL_CONSTANT int floating_point_limits_float::digits10; + + template + ETL_CONSTANT int floating_point_limits_float::max_digits10; + + template + ETL_CONSTANT int floating_point_limits_float::min_exponent; + + template + ETL_CONSTANT int floating_point_limits_float::min_exponent10; + + template + ETL_CONSTANT int floating_point_limits_float::max_exponent; + + template + ETL_CONSTANT int floating_point_limits_float::max_exponent10; + + //********************************* + // double + template + struct floating_point_limits_double + { + static ETL_CONSTANT int digits = DBL_MANT_DIG; + static ETL_CONSTANT int digits10 = DBL_DIG; + static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(DBL_MANT_DIG) + 2; + + static ETL_CONSTANT int min_exponent = DBL_MIN_EXP; + static ETL_CONSTANT int min_exponent10 = DBL_MIN_10_EXP; + static ETL_CONSTANT int max_exponent = DBL_MAX_EXP; + static ETL_CONSTANT int max_exponent10 = DBL_MAX_10_EXP; + }; + + template + ETL_CONSTANT int floating_point_limits_double::digits; + + template + ETL_CONSTANT int floating_point_limits_double::digits10; + + template + ETL_CONSTANT int floating_point_limits_double::max_digits10; + + template + ETL_CONSTANT int floating_point_limits_double::min_exponent; + + template + ETL_CONSTANT int floating_point_limits_double::min_exponent10; + + template + ETL_CONSTANT int floating_point_limits_double::max_exponent; + + template + ETL_CONSTANT int floating_point_limits_double::max_exponent10; + + //********************************* + // long double + template + struct floating_point_limits_long_double + { + static ETL_CONSTANT int digits = LDBL_MANT_DIG; + static ETL_CONSTANT int digits10 = LDBL_DIG; + static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(LDBL_MANT_DIG) + 2; + + static ETL_CONSTANT int min_exponent = LDBL_MIN_EXP; + static ETL_CONSTANT int min_exponent10 = LDBL_MIN_10_EXP; + static ETL_CONSTANT int max_exponent = LDBL_MAX_EXP; + static ETL_CONSTANT int max_exponent10 = LDBL_MAX_10_EXP; + }; + + template + ETL_CONSTANT int floating_point_limits_long_double::digits; + + template + ETL_CONSTANT int floating_point_limits_long_double::digits10; + + template + ETL_CONSTANT int floating_point_limits_long_double::max_digits10; + + template + ETL_CONSTANT int floating_point_limits_long_double::min_exponent; + + template + ETL_CONSTANT int floating_point_limits_long_double::min_exponent10; + + template + ETL_CONSTANT int floating_point_limits_long_double::max_exponent; + + template + ETL_CONSTANT int floating_point_limits_long_double::max_exponent10; + } //*************************************************************************** // Default @@ -179,18 +768,14 @@ namespace etl template class numeric_limits : public numeric_limits { }; - //*************************************************************************** + //*********************************** // bool template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_bool<> { public: - static ETL_CONSTANT int digits = 1; - static ETL_CONSTANT int digits10 = 0; - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR bool min() { return false; } static ETL_CONSTEXPR bool max() { return true; } static ETL_CONSTEXPR bool lowest() { return false; } @@ -205,15 +790,11 @@ namespace etl //*************************************************************************** // char template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_char<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR char min() { return char(CHAR_MIN); } static ETL_CONSTEXPR char max() { return char(CHAR_MAX); } static ETL_CONSTEXPR char lowest() { return char(CHAR_MIN); } @@ -228,15 +809,11 @@ namespace etl //*************************************************************************** // unsigned char template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_unsigned_char<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned char)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR unsigned char min() { return 0U; } static ETL_CONSTEXPR unsigned char max() { return UCHAR_MAX; } static ETL_CONSTEXPR unsigned char lowest() { return 0U; } @@ -251,15 +828,11 @@ namespace etl //*************************************************************************** // signed char template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_signed_char<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR signed char min() { return SCHAR_MIN; } static ETL_CONSTEXPR signed char max() { return SCHAR_MAX; } static ETL_CONSTEXPR signed char lowest() { return SCHAR_MIN; } @@ -275,15 +848,11 @@ namespace etl //*************************************************************************** // char8_t template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_char8_t<> { public: - - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char8_t)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; - static ETL_CONSTANT bool is_modulo = false; - + static ETL_CONSTEXPR char8_t min() { return char8_t(CHAR_MIN); } static ETL_CONSTEXPR char8_t max() { return char8_t(CHAR_MAX); } static ETL_CONSTEXPR char8_t lowest() { return char8_t(CHAR_MIN); } @@ -300,15 +869,11 @@ namespace etl //*************************************************************************** // char16_t template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_char16_t<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char16_t)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR char16_t min() { return 0U; } static ETL_CONSTEXPR char16_t max() { return UINT_LEAST16_MAX; } static ETL_CONSTEXPR char16_t lowest() { return 0U; } @@ -325,15 +890,11 @@ namespace etl //*************************************************************************** // char32_t template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_char32_t<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char32_t)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR char32_t min() { return 0U; } static ETL_CONSTEXPR char32_t max() { return UINT_LEAST32_MAX; } static ETL_CONSTEXPR char32_t lowest() { return 0U; } @@ -349,14 +910,11 @@ namespace etl //*************************************************************************** // wchar_t template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_wchar_t<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(wchar_t)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = etl::is_signed::value; - static ETL_CONSTANT bool is_modulo = etl::is_unsigned::value; 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; } @@ -371,15 +929,11 @@ namespace etl //*************************************************************************** // short template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_short<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(short)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR short min() { return SHRT_MIN; } static ETL_CONSTEXPR short max() { return SHRT_MAX; } static ETL_CONSTEXPR short lowest() { return SHRT_MIN; } @@ -394,15 +948,11 @@ namespace etl //*************************************************************************** // unsigned short template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_unsigned_short<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned short)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR unsigned short min() { return 0U; } static ETL_CONSTEXPR unsigned short max() { return USHRT_MAX; } static ETL_CONSTEXPR unsigned short lowest() { return 0U; } @@ -412,21 +962,16 @@ namespace etl static ETL_CONSTEXPR unsigned short infinity() { return 0U; } static ETL_CONSTEXPR unsigned short quiet_NaN() { return 0U; } static ETL_CONSTEXPR unsigned short signaling_NaN() { return 0U; } - }; //*************************************************************************** // int template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_int<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(int)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR int min() { return INT_MIN; } static ETL_CONSTEXPR int max() { return INT_MAX; } static ETL_CONSTEXPR int lowest() { return INT_MIN; } @@ -441,15 +986,11 @@ namespace etl //*************************************************************************** // unsigned int template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_unsigned_int<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned int)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR unsigned int min() { return 0U; } static ETL_CONSTEXPR unsigned int max() { return UINT_MAX; } static ETL_CONSTEXPR unsigned int lowest() { return 0U; } @@ -464,15 +1005,11 @@ namespace etl //*************************************************************************** // long template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_long<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR long min() { return LONG_MIN; } static ETL_CONSTEXPR long max() { return LONG_MAX; } static ETL_CONSTEXPR long lowest() { return LONG_MIN; } @@ -487,15 +1024,11 @@ namespace etl //*************************************************************************** // unsigned long template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_unsigned_long<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR unsigned long min() { return 0U; } static ETL_CONSTEXPR unsigned long max() { return ULONG_MAX; } static ETL_CONSTEXPR unsigned long lowest() { return 0U; } @@ -510,15 +1043,11 @@ namespace etl //*************************************************************************** // long long template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_long_long<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long long)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = true; - static ETL_CONSTANT bool is_modulo = false; - static ETL_CONSTEXPR long long min() { return LLONG_MIN; } static ETL_CONSTEXPR long long max() { return LLONG_MAX; } static ETL_CONSTEXPR long long lowest() { return LLONG_MIN; } @@ -533,15 +1062,11 @@ namespace etl //*************************************************************************** // unsigned long long template<> - class numeric_limits : public etl_integral_limits + class numeric_limits : public private_limits::integral_limits_common<>, + public private_limits::integral_limits_unsigned_long_long<> { public: - static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long long)) - (etl::is_signed::value ? 1 : 0); - static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits); - static ETL_CONSTANT bool is_signed = false; - static ETL_CONSTANT bool is_modulo = true; - static ETL_CONSTEXPR unsigned long long min() { return 0U; } static ETL_CONSTEXPR unsigned long long max() { return ULLONG_MAX; } static ETL_CONSTEXPR unsigned long long lowest() { return 0U; } @@ -556,7 +1081,8 @@ namespace etl //*************************************************************************** // float template<> - class numeric_limits : public etl_floating_point_limits + class numeric_limits : public private_limits::floating_point_limits_common<>, + public private_limits::floating_point_limits_float<> { public: @@ -568,21 +1094,13 @@ namespace etl static ETL_CONSTEXPR float infinity() { return HUGE_VALF; } static float quiet_NaN() { return ETL_NANF; } static float signaling_NaN() { return ETL_NANF; } - - static ETL_CONSTANT int digits = FLT_MANT_DIG; - static ETL_CONSTANT int digits10 = FLT_DIG; - static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(FLT_MANT_DIG) + 2; - - static ETL_CONSTANT int min_exponent = FLT_MIN_EXP; - static ETL_CONSTANT int min_exponent10 = FLT_MIN_10_EXP; - static ETL_CONSTANT int max_exponent = FLT_MAX_EXP; - static ETL_CONSTANT int max_exponent10 = FLT_MAX_10_EXP; }; //*************************************************************************** // double template<> - class numeric_limits : public etl_floating_point_limits + class numeric_limits : public private_limits::floating_point_limits_common<>, + public private_limits::floating_point_limits_double<> { public: @@ -594,21 +1112,13 @@ namespace etl static ETL_CONSTEXPR double infinity() { return HUGE_VAL; } static double quiet_NaN() { return ETL_NAN; } static double signaling_NaN() { return ETL_NAN; } - - static ETL_CONSTANT int digits = DBL_MANT_DIG; - static ETL_CONSTANT int digits10 = DBL_DIG; - static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(DBL_MANT_DIG) + 2; - - static ETL_CONSTANT int min_exponent = DBL_MIN_EXP; - static ETL_CONSTANT int min_exponent10 = DBL_MIN_10_EXP; - static ETL_CONSTANT int max_exponent = DBL_MAX_EXP; - static ETL_CONSTANT int max_exponent10 = DBL_MAX_10_EXP; }; //*************************************************************************** // long double template<> - class numeric_limits : public etl_floating_point_limits + class numeric_limits : public private_limits::floating_point_limits_common<>, + public private_limits::floating_point_limits_long_double<> { public: @@ -620,15 +1130,6 @@ namespace etl static ETL_CONSTEXPR long double infinity() { return HUGE_VALL; } static long double quiet_NaN() { return ETL_NANL; } static long double signaling_NaN() { return ETL_NANL; } - - static ETL_CONSTANT int digits = LDBL_MANT_DIG; - static ETL_CONSTANT int digits10 = LDBL_DIG; - static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(LDBL_MANT_DIG) + 2; - - static ETL_CONSTANT int min_exponent = LDBL_MIN_EXP; - static ETL_CONSTANT int min_exponent10 = LDBL_MIN_10_EXP; - static ETL_CONSTANT int max_exponent = LDBL_MAX_EXP; - static ETL_CONSTANT int max_exponent10 = LDBL_MAX_10_EXP; }; } @@ -654,10 +1155,15 @@ namespace etl denorm_present = std::denorm_present }; +#if ETL_USING_CPP11 + template + using numeric_limits = std::numeric_limits; +#else template class numeric_limits : public std::numeric_limits { }; +#endif } #endif diff --git a/include/etl/list.h b/include/etl/list.h index c5e78631..43497059 100644 --- a/include/etl/list.h +++ b/include/etl/list.h @@ -689,7 +689,7 @@ namespace etl //************************************************************************* const_iterator end() const { - return const_iterator(static_cast(terminal_node)); + return const_iterator(terminal_node); } //************************************************************************* @@ -705,7 +705,7 @@ namespace etl //************************************************************************* const_iterator cend() const { - return const_iterator(static_cast(terminal_node)); + return const_iterator(terminal_node); } //************************************************************************* @@ -721,7 +721,7 @@ namespace etl //************************************************************************* const_reverse_iterator rbegin() const { - return const_reverse_iterator(static_cast(terminal_node)); + return const_reverse_iterator(terminal_node); } //************************************************************************* @@ -745,7 +745,7 @@ namespace etl //************************************************************************* const_reverse_iterator crbegin() const { - return const_reverse_iterator(static_cast(terminal_node)); + return const_reverse_iterator(terminal_node); } //************************************************************************* @@ -2167,6 +2167,9 @@ namespace etl etl::pool::data_node_t, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t list::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/map.h b/include/etl/map.h index 3c0ba2b5..30773032 100644 --- a/include/etl/map.h +++ b/include/etl/map.h @@ -2718,6 +2718,9 @@ namespace etl etl::pool::Data_Node, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t map::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/math_constants.h b/include/etl/math_constants.h index 7dd33247..dd99f147 100644 --- a/include/etl/math_constants.h +++ b/include/etl/math_constants.h @@ -33,19 +33,57 @@ SOFTWARE. namespace etl { - namespace math + namespace private_math_constants { - ETL_CONSTANT double pi = 3.14159265358979; - ETL_CONSTANT double pi_reciprocal = 0.31830988618379; - ETL_CONSTANT double pi_squared = 9.86960440108936; - ETL_CONSTANT double e = 2.71828182845905; - ETL_CONSTANT double e_reciprocal = 0.36787944117144; - ETL_CONSTANT double e_squared = 7.38905609893065; - ETL_CONSTANT double root2 = 1.41421356237310; - ETL_CONSTANT double root2_reciprocal = 0.70710678118655; - ETL_CONSTANT double euler = 0.57721566490153; - ETL_CONSTANT double golden_ratio = 1.61803398874989; + template + struct math_helper + { + static ETL_CONSTANT double pi = 3.14159265358979; + static ETL_CONSTANT double pi_reciprocal = 0.31830988618379; + static ETL_CONSTANT double pi_squared = 9.86960440108936; + static ETL_CONSTANT double e = 2.71828182845905; + static ETL_CONSTANT double e_reciprocal = 0.36787944117144; + static ETL_CONSTANT double e_squared = 7.38905609893065; + static ETL_CONSTANT double root2 = 1.41421356237310; + static ETL_CONSTANT double root2_reciprocal = 0.70710678118655; + static ETL_CONSTANT double euler = 0.57721566490153; + static ETL_CONSTANT double golden_ratio = 1.61803398874989; + }; + + template + ETL_CONSTANT double math_helper::pi; + + template + ETL_CONSTANT double math_helper::pi_reciprocal; + + template + ETL_CONSTANT double math_helper::pi_squared; + + template + ETL_CONSTANT double math_helper::e; + + template + ETL_CONSTANT double math_helper::e_reciprocal; + + template + ETL_CONSTANT double math_helper::e_squared; + + template + ETL_CONSTANT double math_helper::root2; + + template + ETL_CONSTANT double math_helper::root2_reciprocal; + + template + ETL_CONSTANT double math_helper::euler; + + template + ETL_CONSTANT double math_helper::golden_ratio; } + + struct math : public private_math_constants::math_helper<> + { + }; } #endif diff --git a/include/etl/mem_cast.h b/include/etl/mem_cast.h index d611dab2..33b79021 100644 --- a/include/etl/mem_cast.h +++ b/include/etl/mem_cast.h @@ -315,6 +315,12 @@ namespace etl etl::uninitialized_buffer buffer; }; + template + ETL_CONSTANT size_t mem_cast::Size; + + template + ETL_CONSTANT size_t mem_cast::Alignment; + //***************************************************************************** /// mem_cast_ptr //***************************************************************************** diff --git a/include/etl/memory.h b/include/etl/memory.h index 4e39ca3a..38e9889c 100644 --- a/include/etl/memory.h +++ b/include/etl/memory.h @@ -2146,6 +2146,15 @@ namespace etl #endif }; + template + ETL_CONSTANT size_t uninitialized_buffer::Object_Size; + + template + ETL_CONSTANT size_t uninitialized_buffer::N_Objects; + + template + ETL_CONSTANT size_t uninitialized_buffer::Alignment; + //*************************************************************************** /// Declares an aligned buffer of VN_Objects as if they were type T. ///\ingroup alignment @@ -2235,6 +2244,15 @@ namespace etl #endif }; + template + ETL_CONSTANT size_t uninitialized_buffer_of::Object_Size; + + template + ETL_CONSTANT size_t uninitialized_buffer_of::N_Objects; + + template + ETL_CONSTANT size_t uninitialized_buffer_of::Alignment; + #if ETL_USING_CPP11 template using uninitialized_buffer_of_t = typename uninitialized_buffer_of::buffer; diff --git a/include/etl/message_packet.h b/include/etl/message_packet.h index cf5e4442..d5130974 100644 --- a/include/etl/message_packet.h +++ b/include/etl/message_packet.h @@ -387,7 +387,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -680,7 +680,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -971,7 +971,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -1260,7 +1260,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -1546,7 +1546,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -1827,7 +1827,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -2106,7 +2106,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -2383,7 +2383,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8, T9>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -2657,7 +2657,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7, T8>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -2926,7 +2926,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6, T7>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -3193,7 +3193,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5, T6>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -3458,7 +3458,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4, T5>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -3720,7 +3720,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3, T4>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -3977,7 +3977,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2, T3>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -4232,7 +4232,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1, T2>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. @@ -4485,7 +4485,7 @@ namespace etl template ::type, etl::message_packet >::value && !etl::is_same::type, etl::imessage>::value && !etl::is_one_of::type, T1>::value, int>::type> - explicit message_packet(TMessage&& msg) + explicit message_packet(TMessage&& /*msg*/) : valid(true) { // Not etl::message_packet, not etl::imessage and in typelist. diff --git a/include/etl/multimap.h b/include/etl/multimap.h index cf4639a7..fb14bba1 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -2438,6 +2438,9 @@ namespace etl etl::pool::Data_Node, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t multimap::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 92d33796..5494792c 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -2420,6 +2420,9 @@ namespace etl etl::pool::Data_Node, MAX_SIZE> node_pool; }; + template + ETL_CONSTANT size_t multiset::MAX_SIZE; + //************************************************************************* /// Template deduction guides. //************************************************************************* diff --git a/include/etl/parameter_pack.h b/include/etl/parameter_pack.h index e5760453..7f30a82c 100644 --- a/include/etl/parameter_pack.h +++ b/include/etl/parameter_pack.h @@ -121,9 +121,19 @@ namespace etl using type_from_index_t = typename type_from_index::type; }; + //*********************************** template using parameter_pack_t = typename etl::parameter_pack::template type_from_index_t; + //*********************************** + template + constexpr size_t parameter_pack::size; + + //*********************************** + template + template + constexpr size_t parameter_pack::template index_of_type::value; + #if ETL_USING_CPP17 template inline constexpr size_t parameter_pack_v = etl::parameter_pack::template index_of_type::value; diff --git a/include/etl/permutations.h b/include/etl/permutations.h index 3b5b69c0..12fcbec7 100644 --- a/include/etl/permutations.h +++ b/include/etl/permutations.h @@ -49,6 +49,9 @@ namespace etl static ETL_CONSTANT size_t value = NV * permutations::value; }; + template + ETL_CONSTANT size_t permutations::value; + //*************************************************************************** /// Calculates permutations. /// Specialisation for KV == 0. @@ -59,6 +62,9 @@ namespace etl static ETL_CONSTANT size_t value = 1UL; }; + template + ETL_CONSTANT size_t permutations::value; + #if ETL_USING_CPP17 template inline constexpr size_t permutations_v = permutations::value; diff --git a/include/etl/poly_span.h b/include/etl/poly_span.h index 79d3f32d..1d654529 100644 --- a/include/etl/poly_span.h +++ b/include/etl/poly_span.h @@ -611,6 +611,9 @@ namespace etl size_t element_size; }; + template + ETL_CONSTANT size_t poly_span::extent; + //*************************************************************************** /// Poly Span - Dynamic Extent //*************************************************************************** @@ -984,6 +987,9 @@ protected: size_t span_extent; }; + template + ETL_CONSTANT size_t poly_span::extent; + //************************************************************************* /// Template deduction guides. //************************************************************************* @@ -1028,8 +1034,8 @@ protected: { size_t operator()(const etl::poly_span& view) const { - return etl::private_hash::generic_hash(reinterpret_cast(&view[0]), - reinterpret_cast(&view[view.size()])); + return etl::private_hash::generic_hash(reinterpret_cast(view.data()), + reinterpret_cast(view.data() + view.size())); } }; #endif diff --git a/include/etl/power.h b/include/etl/power.h index 7816dd88..9ca4f0f0 100644 --- a/include/etl/power.h +++ b/include/etl/power.h @@ -63,6 +63,9 @@ namespace etl static ETL_CONSTANT private_power::type value = NV * power::value; }; + template + ETL_CONSTANT private_power::type power::value; + //*************************************************************************** /// Calculates powers. ///\note Only supports positive N. @@ -74,6 +77,9 @@ namespace etl static ETL_CONSTANT private_power::type value = 1; }; + template + ETL_CONSTANT private_power::type power::value; + #if ETL_USING_CPP17 template inline constexpr size_t power_v = power::value; @@ -203,6 +209,9 @@ namespace etl static ETL_CONSTANT bool value = false; }; + template + ETL_CONSTANT bool is_power_of_2::value; + #if ETL_USING_CPP17 template inline constexpr size_t is_power_of_2_v = is_power_of_2::value; diff --git a/include/etl/priority_queue.h b/include/etl/priority_queue.h index 46be2901..d4222090 100644 --- a/include/etl/priority_queue.h +++ b/include/etl/priority_queue.h @@ -526,6 +526,9 @@ namespace etl } #endif }; + + template + ETL_CONSTANT typename priority_queue::size_type priority_queue::MAX_SIZE; } #endif diff --git a/include/etl/private/bitset_legacy.h b/include/etl/private/bitset_legacy.h index 775012b7..e03135ce 100644 --- a/include/etl/private/bitset_legacy.h +++ b/include/etl/private/bitset_legacy.h @@ -183,6 +183,15 @@ namespace etl return p_bitset->test(position); } + //******************************* + /// Copy constructor. + //******************************* + bit_reference(const bit_reference& other) + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Assignment operator. //******************************* @@ -1064,6 +1073,12 @@ namespace etl #endif }; + ETL_CONSTANT ibitset::element_type ibitset::ALL_SET; + + ETL_CONSTANT ibitset::element_type ibitset::ALL_CLEAR; + + ETL_CONSTANT size_t ibitset::Bits_Per_Element; + //************************************************************************* /// The class emulates an array of bool elements, but optimized for space allocation. /// Will accommodate any number of bits. @@ -1429,6 +1444,12 @@ namespace etl element_type data[Array_Size > 0U ? Array_Size : 1U]; }; + template + ETL_CONSTANT size_t bitset::ALLOCATED_BITS; + + template + ETL_CONSTANT size_t bitset::Allocated_Bits; + //*************************************************************************** /// operator & ///\ingroup bitset diff --git a/include/etl/private/bitset_new.h b/include/etl/private/bitset_new.h index d636ce60..2b01ecc3 100644 --- a/include/etl/private/bitset_new.h +++ b/include/etl/private/bitset_new.h @@ -76,11 +76,15 @@ SOFTWARE. namespace etl { + template struct bitset_constants { static ETL_CONSTANT size_t npos = etl::integral_limits::max; }; + template + ETL_CONSTANT size_t bitset_constants::npos; + //*************************************************************************** /// Exception base for bitset ///\ingroup bitset @@ -114,7 +118,7 @@ namespace etl ///\ingroup bitset //************************************************************************* template - class bitset_impl : public bitset_constants + class bitset_impl : public bitset_constants<> { public: @@ -795,9 +799,18 @@ namespace etl } }; + template + ETL_CONSTANT size_t bitset_impl::Bits_Per_Element; + + template + ETL_CONSTANT typename bitset_impl::element_type bitset_impl::All_Set_Element; + + template + ETL_CONSTANT typename bitset_impl::element_type bitset_impl::All_Clear_Element; + //*************************************************************************** template ::bits == Active_Bits> class bitset; @@ -806,7 +819,7 @@ namespace etl /// Just defines 'npos'. //*************************************************************************** template <> - class bitset<0U, void, true> : public bitset_constants + class bitset<0U, char, true> : public bitset_constants<> { }; @@ -814,7 +827,7 @@ namespace etl /// Specialisation for zero bits. //*************************************************************************** template <> - class bitset<0U, void, false> : public bitset_constants + class bitset<0U, char, false> : public bitset_constants<> { }; @@ -823,7 +836,7 @@ namespace etl /// same size as the number of active bits. //*************************************************************************** template - class bitset : public bitset_constants + class bitset : public bitset_constants<> { public: @@ -853,6 +866,15 @@ namespace etl friend class bitset; + //******************************* + /// Copy constructor. + //******************************* + ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Conversion operator. //******************************* @@ -1663,11 +1685,32 @@ namespace etl element_type buffer; }; + template + ETL_CONSTANT size_t bitset::Bits_Per_Element; + + template + ETL_CONSTANT size_t bitset::Number_Of_Elements; + + template + ETL_CONSTANT size_t bitset::Allocated_Bits; + + template + ETL_CONSTANT typename bitset::element_type bitset::All_Set_Element; + + template + ETL_CONSTANT typename bitset::element_type bitset::All_Clear_Element; + + template + ETL_CONSTANT size_t bitset::Top_Mask_Shift; + + template + ETL_CONSTANT typename bitset::element_type bitset::Top_Mask; + //************************************************************************* /// The specialisation that uses an array of the default element type. //************************************************************************* template - class bitset : public bitset_constants + class bitset : public bitset_constants<> { private: @@ -1708,6 +1751,15 @@ namespace etl friend class bitset; + //******************************* + /// Copy constructor. + //******************************* + ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Conversion operator. //******************************* @@ -2312,6 +2364,27 @@ namespace etl element_type buffer[Number_Of_Elements > 0U ? Number_Of_Elements : 1U]; }; + template + ETL_CONSTANT size_t bitset::Bits_Per_Element; + + template + ETL_CONSTANT size_t bitset::Number_Of_Elements; + + template + ETL_CONSTANT size_t bitset::Allocated_Bits; + + template + ETL_CONSTANT typename bitset::element_type bitset::All_Set_Element; + + template + ETL_CONSTANT typename bitset::element_type bitset::All_Clear_Element; + + template + ETL_CONSTANT size_t bitset::Top_Mask_Shift; + + template + ETL_CONSTANT typename bitset::element_type bitset::Top_Mask; + //*************************************************************************** /// operator & ///\ingroup bitset @@ -2375,8 +2448,8 @@ namespace etl { //*************************************************************************** template ::bits == Active_Bits> + typename TElement = char, + bool IsSingleElement = etl::integral_limits::bits == Active_Bits> class bitset_ext; //*************************************************************************** @@ -2384,7 +2457,7 @@ namespace etl /// Just defines 'npos'. //*************************************************************************** template <> - class bitset_ext<0U, void, true> : public bitset_constants + class bitset_ext<0U, char, true> : public bitset_constants<> { }; @@ -2392,7 +2465,7 @@ namespace etl /// Specialisation for zero bits. //*************************************************************************** template <> - class bitset_ext<0U, void, false> : public bitset_constants + class bitset_ext<0U, char, false> : public bitset_constants<> { }; @@ -2401,7 +2474,7 @@ namespace etl /// same size as the number of active bits. //*************************************************************************** template - class bitset_ext : public bitset_constants + class bitset_ext : public bitset_constants<> { public: @@ -2433,6 +2506,15 @@ namespace etl friend class bitset_ext; + //******************************* + /// Copy constructor. + //******************************* + ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Conversion operator. //******************************* @@ -3240,11 +3322,32 @@ namespace etl element_type* pbuffer; }; + template + ETL_CONSTANT size_t bitset_ext::Bits_Per_Element; + + template + ETL_CONSTANT size_t bitset_ext::Number_Of_Elements; + + template + ETL_CONSTANT size_t bitset_ext::Allocated_Bits; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::All_Set_Element; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::All_Clear_Element; + + template + ETL_CONSTANT size_t bitset_ext::Top_Mask_Shift; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::Top_Mask; + //************************************************************************* /// The specialisation that uses an array of the default element type. //************************************************************************* template - class bitset_ext : public bitset_constants + class bitset_ext : public bitset_constants<> { private: @@ -3287,6 +3390,15 @@ namespace etl friend class bitset_ext; + //******************************* + /// Copy constructor + //******************************* + ETL_CONSTEXPR14 bit_reference(const bit_reference& other) ETL_NOEXCEPT + : p_bitset(other.p_bitset) + , position(other.position) + { + } + //******************************* /// Conversion operator. //******************************* @@ -3891,6 +4003,27 @@ namespace etl element_type* pbuffer; }; + template + ETL_CONSTANT size_t bitset_ext::Bits_Per_Element; + + template + ETL_CONSTANT size_t bitset_ext::Number_Of_Elements; + + template + ETL_CONSTANT size_t bitset_ext::Allocated_Bits; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::All_Set_Element; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::All_Clear_Element; + + template + ETL_CONSTANT size_t bitset_ext::Top_Mask_Shift; + + template + ETL_CONSTANT typename bitset_ext::element_type bitset_ext::Top_Mask; + //*************************************************************************** /// operator != ///\ingroup bitset diff --git a/include/etl/private/choose_namespace.h b/include/etl/private/choose_namespace.h index 44b0c440..494d030f 100644 --- a/include/etl/private/choose_namespace.h +++ b/include/etl/private/choose_namespace.h @@ -33,6 +33,7 @@ SOFTWARE. #undef ETL_OR_STD #undef ETL_OR_STD11 +#undef ETL_OR_STD14 #if ETL_NOT_USING_STL && !defined(ETL_IN_UNIT_TEST) // If we're not using the STL and we are not unit testing, then use the ETL's definitions under the etl namespace @@ -58,4 +59,28 @@ SOFTWARE. #define ETL_USING_ETL11_NAMESPACE 0 #endif +#if (ETL_NOT_USING_STL && !defined(ETL_IN_UNIT_TEST)) || ETL_CPP14_NOT_SUPPORTED + // If we're not using the STL and we are not unit testing or C++14 is not supported, then use the ETL's definitions under the etl namespace + #define ETL_OR_STD14 etl + #define ETL_USING_STD14_NAMESPACE 0 + #define ETL_USING_ETL14_NAMESPACE 1 +#else + // We will use the STL's definitions under the std namespace + #define ETL_OR_STD14 std + #define ETL_USING_STD14_NAMESPACE 1 + #define ETL_USING_ETL14_NAMESPACE 0 +#endif + +#if (ETL_NOT_USING_STL && !defined(ETL_IN_UNIT_TEST)) || ETL_CPP17_NOT_SUPPORTED + // If we're not using the STL and we are not unit testing or C++17 is not supported, then use the ETL's definitions under the etl namespace + #define ETL_OR_STD17 etl + #define ETL_USING_STD17_NAMESPACE 0 + #define ETL_USING_ETL17_NAMESPACE 1 +#else + // We will use the STL's definitions under the std namespace + #define ETL_OR_STD17 std + #define ETL_USING_STD17_NAMESPACE 1 + #define ETL_USING_ETL17_NAMESPACE 0 +#endif + #endif diff --git a/include/etl/private/crc_implementation.h b/include/etl/private/crc_implementation.h index 8e450544..d94f0f18 100644 --- a/include/etl/private/crc_implementation.h +++ b/include/etl/private/crc_implementation.h @@ -66,6 +66,9 @@ namespace etl : TAccumulator(Do_Poly ? (Entry << 1U) ^ Polynomial : (Entry << 1U)); }; + template + ETL_CONSTANT TAccumulator crc_partial_table_entry::value; + //***************************************************************************** /// CRC Table Entry //***************************************************************************** @@ -89,6 +92,15 @@ namespace etl crc_partial_table_entry::value>::value; }; + template + ETL_CONSTANT size_t crc_table_entry::Shift_Bits; + + template + ETL_CONSTANT TAccumulator crc_table_entry::Entry; + + template + ETL_CONSTANT TAccumulator crc_table_entry::value; + //********************************* // Chunk bit size of 4. template @@ -105,6 +117,15 @@ namespace etl crc_partial_table_entry::value>::value>::value>::value; }; + template + ETL_CONSTANT size_t crc_table_entry::Shift_Bits; + + template + ETL_CONSTANT TAccumulator crc_table_entry::Entry; + + template + ETL_CONSTANT TAccumulator crc_table_entry::value; + //********************************* // Chunk bit size of 8. template @@ -125,6 +146,15 @@ namespace etl crc_partial_table_entry::value>::value>::value>::value>::value>::value>::value>::value; }; + template + ETL_CONSTANT size_t crc_table_entry::Shift_Bits; + + template + ETL_CONSTANT TAccumulator crc_table_entry::Entry; + + template + ETL_CONSTANT TAccumulator crc_table_entry::value; + //***************************************************************************** /// CRC Update Chunk //***************************************************************************** diff --git a/include/etl/private/crc_parameters.h b/include/etl/private/crc_parameters.h index 8ffb9242..72cd1ef5 100644 --- a/include/etl/private/crc_parameters.h +++ b/include/etl/private/crc_parameters.h @@ -53,6 +53,21 @@ namespace etl static ETL_CONSTANT size_t Accumulator_Bits = etl::integral_limits::bits; }; + template + ETL_CONSTANT TAccumulator crc_parameters::Polynomial; + + template + ETL_CONSTANT TAccumulator crc_parameters::Initial; + + template + ETL_CONSTANT TAccumulator crc_parameters::Xor_Out; + + template + ETL_CONSTANT bool crc_parameters::Reflect; + + template + ETL_CONSTANT size_t crc_parameters::Accumulator_Bits; + // 8 bit. typedef crc_parameters crc8_ccitt_parameters; typedef crc_parameters crc8_rohc_parameters; diff --git a/include/etl/private/variant_variadic.h b/include/etl/private/variant_variadic.h index 5d344b5c..76a90c62 100644 --- a/include/etl/private/variant_variadic.h +++ b/include/etl/private/variant_variadic.h @@ -1352,10 +1352,10 @@ namespace etl /// in which every recursive instantiation of `visit_result_helper` appends /// more elements and give it a pass through `common_type_t`. //*************************************************************************** - template