Skip to content

Commit

Permalink
Added ETL_NODISCARD to make_delegete functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jwellbelove committed Feb 4, 2025
1 parent 37fd5b7 commit dd4d008
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/etl/private/delegate_cpp11.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ namespace etl
//*************************************************************************
/// Checks equality.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14 bool operator == (const delegate& rhs) const
{
return invocation == rhs.invocation;
Expand All @@ -500,6 +501,7 @@ namespace etl
//*************************************************************************
/// Returns <b>true</b> if the delegate is valid.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14 operator bool() const
{
return is_valid();
Expand Down Expand Up @@ -712,6 +714,7 @@ namespace etl
/// Make a delegate from a free function.
//*************************************************************************
template <auto Function>
ETL_NODISCARD
constexpr auto make_delegate() ETL_NOEXCEPT
{
using function_type = typename etl::private_delegate::function_traits<decltype(Function)>::function_type;
Expand All @@ -723,6 +726,7 @@ namespace etl
/// Make a delegate from a functor or lambda function.
//*************************************************************************
template <typename TLambda, typename = etl::enable_if_t<etl::is_class<TLambda>::value, void>>
ETL_NODISCARD
constexpr auto make_delegate(TLambda& instance) ETL_NOEXCEPT
{
using function_type = typename etl::private_delegate::function_traits<decltype(&TLambda::operator())>::function_type;
Expand All @@ -734,6 +738,7 @@ namespace etl
/// Make a delegate from a functor, compile time.
//*************************************************************************
template <typename T, T& Instance>
ETL_NODISCARD
constexpr auto make_delegate() ETL_NOEXCEPT
{
using function_type = typename etl::private_delegate::function_traits<decltype(&T::operator())>::function_type;
Expand All @@ -745,6 +750,7 @@ namespace etl
/// Make a delegate from a member function at compile time.
//*************************************************************************
template <typename T, auto Method, T& Instance, typename = etl::enable_if_t<!private_delegate::function_traits<decltype(Method)>::is_const>>
ETL_NODISCARD
constexpr auto make_delegate() ETL_NOEXCEPT
{
using function_type = typename etl::private_delegate::function_traits<decltype(Method)>::function_type;
Expand All @@ -756,6 +762,7 @@ namespace etl
/// Make a delegate from a const member function at compile time.
//*************************************************************************
template <typename T, auto Method, const T& Instance, typename = etl::enable_if_t<private_delegate::function_traits<decltype(Method)>::is_const>>
ETL_NODISCARD
constexpr auto make_delegate() ETL_NOEXCEPT
{
using function_type = typename etl::private_delegate::function_traits<decltype(Method)>::function_type;
Expand All @@ -767,6 +774,7 @@ namespace etl
/// Make a delegate from a member function at run time.
//*************************************************************************
template <typename T, auto Method>
ETL_NODISCARD
constexpr auto make_delegate(T& instance) ETL_NOEXCEPT
{
using function_type = typename etl::private_delegate::function_traits<decltype(Method)>::function_type;
Expand All @@ -778,6 +786,7 @@ namespace etl
/// Make a delegate from a member function at run time.
//*************************************************************************
template <typename T, auto Method>
ETL_NODISCARD
constexpr auto make_delegate(const T& instance) ETL_NOEXCEPT
{
using function_type = typename etl::private_delegate::function_traits<decltype(Method)>::function_type;
Expand Down

0 comments on commit dd4d008

Please sign in to comment.