Skip to content

Commit

Permalink
iox-eclipse-iceoryx#831 Make operator bool() and operator() const
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
  • Loading branch information
mossmaurice committed Jun 27, 2022
1 parent 76f3051 commit 829dbe3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ class storable_function<StorageType, signature<ReturnType, Args...>>
/// Not specifying move or using a default implementation is fine.
/// This is also the case for std::function (for the gcc implementation at least).
///
ReturnType operator()(Args... args);
ReturnType operator()(Args... args) const;


/// @brief indicates whether a function is currently stored
/// @return true if a function is stored, false otherwise
operator bool() noexcept;
operator bool() const noexcept;

/// @brief swap this with another storable function
/// @param f the function to swap this with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ storable_function<S, signature<ReturnType, Args...>>::~storable_function() noexc
}

template <typename S, typename ReturnType, typename... Args>
ReturnType storable_function<S, signature<ReturnType, Args...>>::operator()(Args... args)
ReturnType storable_function<S, signature<ReturnType, Args...>>::operator()(Args... args) const
{
cxx::Expects(!empty());
return m_invoker(m_callable, std::forward<Args>(args)...);
}


template <typename S, typename ReturnType, typename... Args>
storable_function<S, signature<ReturnType, Args...>>::operator bool() noexcept
storable_function<S, signature<ReturnType, Args...>>::operator bool() const noexcept
{
return !empty();
}
Expand Down

0 comments on commit 829dbe3

Please sign in to comment.