rsl
1.1.0
ROS Support Library
Loading...
Searching...
No Matches
no_discard.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <utility>
4
5
namespace
rsl {
6
14
template
<
typename
Fn>
15
class
NoDiscard
{
16
static_assert
(std::is_invocable_v<Fn()>,
"Fn must be invocable"
);
17
Fn fn_;
18
19
public
:
20
NoDiscard
(Fn
const
& fn) : fn_(fn) {}
21
template
<
typename
... Ts>
22
[[nodiscard]]
constexpr
auto
operator()(Ts&&... args)
const
23
noexcept
(
noexcept
(fn_(std::forward<Ts>(args)...))) {
24
return
fn_(std::forward<Ts>(args)...);
25
}
26
};
27
28
}
// namespace rsl
rsl::NoDiscard
Template for creating lambdas with the nodiscard attribute.
Definition
no_discard.hpp:15
rsl
no_discard.hpp
Generated by
1.9.8