diff --git a/examples/FunctionInterruptSimulation/FunctionInterruptSimulation.cpp b/examples/FunctionInterruptSimulation/FunctionInterruptSimulation.cpp index d7fffbdf..186f4542 100644 --- a/examples/FunctionInterruptSimulation/FunctionInterruptSimulation.cpp +++ b/examples/FunctionInterruptSimulation/FunctionInterruptSimulation.cpp @@ -66,19 +66,11 @@ class Timer { public: - Timer(int interruptId) - : callback(*this) - { - GetInterruptVectorsInstance().register_callback(interruptId, callback); - } - // Handler for interrupts from the timer. void InterruptHandler(const size_t id) { std::cout << "Timer interrupt (member) : ID " << id << "\n"; } - - etl::function_mp callback; }; //******************************** @@ -121,10 +113,14 @@ void UnhandledInterrupt(const size_t id) } // Declare the driver instances. -Timer timer(TIM1_CC_IRQ_HANDLER); +Timer timer; Uart uart1(0, USART1_IRQ_HANDLER); Uart uart2(1, USART2_IRQ_HANDLER); +// Declare a global callback for the timer. +// Uses the most efficient callback type for a class, as everthing is known at compile time. +etl::function_imp timer_member_callback; + // Declare the callbacks for the free functions. etl::function_fp timer_free_callback; etl::function_fp unhandled_callback; @@ -137,6 +133,7 @@ int main() // Setup the callbacks. InterruptVectors& interruptVectors = GetInterruptVectorsInstance(); + interruptVectors.register_callback(timer_member_callback); interruptVectors.register_callback(timer_free_callback); interruptVectors.register_unhandled_callback(unhandled_callback); diff --git a/include/etl/array_view.h b/include/etl/array_view.h index ec46d96c..659a3a0e 100644 --- a/include/etl/array_view.h +++ b/include/etl/array_view.h @@ -114,7 +114,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - array_view() + ETL_CONSTEXPR array_view() : mbegin(nullptr), mend(nullptr) { @@ -125,7 +125,7 @@ namespace etl /// data() and size() member functions. //************************************************************************* template - explicit array_view(TArray& a) + ETL_CONSTEXPR explicit array_view(TArray& a) : mbegin(a.data()), mend(a.data() + a.size()) { @@ -135,7 +135,7 @@ namespace etl /// Construct from iterators //************************************************************************* template - array_view(TIterator begin_, TIterator end_) + ETL_CONSTEXPR array_view(TIterator begin_, TIterator end_) : mbegin(etl::addressof(*begin_)), mend(etl::addressof(*begin_) + std::distance(begin_, end_)) { @@ -146,7 +146,7 @@ namespace etl //************************************************************************* template - array_view(TIterator begin_, TSize size_) + ETL_CONSTEXPR array_view(TIterator begin_, TSize size_) : mbegin(etl::addressof(*begin_)), mend(etl::addressof(*begin_) + size_) { @@ -156,7 +156,7 @@ namespace etl /// Construct from C array //************************************************************************* template - explicit array_view(T(&begin_)[ARRAY_SIZE]) + ETL_CONSTEXPR explicit array_view(T(&begin_)[ARRAY_SIZE]) : mbegin(begin_), mend(begin_ + ARRAY_SIZE) { @@ -165,7 +165,7 @@ namespace etl //************************************************************************* /// Copy constructor //************************************************************************* - array_view(const array_view& other) + ETL_CONSTEXPR array_view(const array_view& other) : mbegin(other.mbegin), mend(other.mend) { @@ -504,7 +504,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - const_array_view() + ETL_CONSTEXPR const_array_view() : mbegin(nullptr), mend(nullptr) { @@ -515,7 +515,7 @@ namespace etl /// data() and size() member functions. //************************************************************************* template - explicit const_array_view(TArray& a) + ETL_CONSTEXPR explicit const_array_view(TArray& a) : mbegin(a.data()), mend(a.data() + a.size()) { @@ -525,7 +525,7 @@ namespace etl /// Construct from iterators //************************************************************************* template - const_array_view(TIterator begin_, TIterator end_) + ETL_CONSTEXPR const_array_view(TIterator begin_, TIterator end_) : mbegin(etl::addressof(*begin_)), mend(etl::addressof(*begin_) + std::distance(begin_, end_)) { @@ -536,7 +536,7 @@ namespace etl //************************************************************************* template - const_array_view(TIterator begin_, TSize size_) + ETL_CONSTEXPR const_array_view(TIterator begin_, TSize size_) : mbegin(etl::addressof(*begin_)), mend(etl::addressof(*begin_) + size_) { @@ -546,16 +546,16 @@ namespace etl /// Construct from C array //************************************************************************* template - explicit const_array_view(const T(&begin_)[ARRAY_SIZE]) + ETL_CONSTEXPR explicit const_array_view(const T(&begin_)[ARRAY_SIZE]) : mbegin(begin_), mend(begin_ + ARRAY_SIZE) { } - //************************************************************************* + //************0************************************************************* /// Copy constructor //************************************************************************* - const_array_view(const array_view& other) + ETL_CONSTEXPR const_array_view(const array_view& other) : mbegin(other.begin()), mend(other.end()) { @@ -564,9 +564,9 @@ namespace etl //************************************************************************* /// Copy constructor //************************************************************************* - const_array_view(const const_array_view& other) + ETL_CONSTEXPR const_array_view(const const_array_view& other) : mbegin(other.mbegin), - mend(other.mend) + mend(other.mend) { } diff --git a/include/etl/string_view.h b/include/etl/string_view.h index 39ccd7ff..d8247bb1 100644 --- a/include/etl/string_view.h +++ b/include/etl/string_view.h @@ -118,7 +118,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - basic_string_view() + ETL_CONSTEXPR basic_string_view() : mbegin(nullptr), mend(nullptr) { @@ -127,7 +127,7 @@ namespace etl //************************************************************************* /// Construct from T*. //************************************************************************* - basic_string_view(const T* begin_) + ETL_CONSTEXPR basic_string_view(const T* begin_) : mbegin(begin_), mend(begin_ + TTraits::length(begin_)) { @@ -136,7 +136,7 @@ namespace etl //************************************************************************* /// Construct from pointer range. //************************************************************************* - basic_string_view(const T* begin_, const T* end_) + ETL_CONSTEXPR basic_string_view(const T* begin_, const T* end_) : mbegin(begin_), mend(end_) { @@ -146,7 +146,7 @@ namespace etl /// Construct from iterator/size. //************************************************************************* template ::value, void>::type> - basic_string_view(const T* begin_, TSize size_) + ETL_CONSTEXPR basic_string_view(const T* begin_, TSize size_) : mbegin(begin_), mend(begin_ + size_) { @@ -155,7 +155,7 @@ namespace etl //************************************************************************* /// Copy constructor //************************************************************************* - basic_string_view(const basic_string_view& other) + ETL_CONSTEXPR basic_string_view(const basic_string_view& other) : mbegin(other.mbegin), mend(other.mend) { diff --git a/include/etl/version.h b/include/etl/version.h index 8d74618f..97efaef9 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -38,8 +38,8 @@ SOFTWARE. ///\ingroup utilities #define ETL_VERSION_MAJOR 14 -#define ETL_VERSION_MINOR 8 -#define ETL_VERSION_PATCH 2 +#define ETL_VERSION_MINOR 9 +#define ETL_VERSION_PATCH 0 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) ETL_STRINGIFY(ETL_VERSION_MINOR) ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_WIDE_STRING(ETL_CONCAT(ETL_CONCAT(ETL_VERSION_MAJOR, ETL_VERSION_MINOR), ETL_VERSION_PATCH)) diff --git a/support/Release notes.txt b/support/Release notes.txt index c50fdd8b..3db09549 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +14.9.0 +Added constexpr constructors to string_view and array_view. + =============================================================================== 14.8.2 Added missing #include "stl/interator.h" in frame_check_sequence.h