Added return_type and argument_types to etl::delegate

This commit is contained in:
John Wellbelove 2025-08-13 19:51:31 +01:00
parent 1af74206d2
commit 8c49e67702
3 changed files with 31 additions and 7 deletions

View File

@ -55,6 +55,7 @@ Original publication: https://www.codeproject.com/Articles/1170503/The-Impossibl
#include "../function_traits.h"
#include "../utility.h"
#include "../optional.h"
#include "../type_list.h"
namespace etl
{
@ -119,6 +120,9 @@ namespace etl
{
public:
using return_type = TReturn;
using argument_types = etl::type_list<TParams...>;
//*************************************************************************
/// Default constructor.
//*************************************************************************

View File

@ -3,13 +3,8 @@
Updates:
Added 'emplace' constructor to etl::optional
Added etl::crc8_opensafety
Added etl::crc16_opensafety_a and etl::crc16_opensafety_b
Added etl::crc64_iso
Added etl::type_lists_are_convertible
Made etl::closure constexpr for C++14
Made invocation of delegate consrexpr for C++14
#1132 Request: Make type_def Methods Noexcept
Added etl::delegate_observable
Added return_type and argument_types to etl::delegate
#1054 Using #pragma once
#1159 etl::fsm helper to check states id sequence at compile time
#1160 Feature request: rounded division (similar to scaled rounding)
@ -28,6 +23,18 @@ Pull Requests:
#955 Implements deferred callback timer with optional priority
#1147 Fix compile error in closure.h by using etl::forward
===============================================================================
20.42.2
Updates:
Added etl::crc8_opensafety
Added etl::crc16_opensafety_a and etl::crc16_opensafety_b
Added etl::crc64_iso
Added etl::type_lists_are_convertible
Made etl::closure constexpr for C++14
Made invocation of delegate consrexpr for C++14
#1132 Request: Make type_def Methods Noexcept
===============================================================================
20.42.1

View File

@ -36,6 +36,7 @@ SOFTWARE.
#include <vector>
#include <functional>
#include <algorithm>
#include <type_traits>
namespace
{
@ -287,6 +288,18 @@ namespace
SUITE(test_delegate)
{
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_delegate_types)
{
using Delegate = etl::delegate<int(float, long)>;
// Check the return type.
CHECK_TRUE((std::is_same<Delegate::return_type, int>::value));
// Check the argument types.
CHECK_TRUE((std::is_same<Delegate::argument_types, etl::type_list<float, long>>::value));
}
//*************************************************************************
TEST_FIXTURE(SetupFixture, test_is_valid_false)
{