Skip to content

Commit f343230

Browse files
authored
Make result of AtScopeExit non-discardable. (#6248)
* Make result of AtScopeExit non-discardable. * Make CallAtExit constructor nodiscard. --------- Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
1 parent 7c49abb commit f343230

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/dali/core/call_at_exit.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ namespace detail {
2525
*/
2626
template <typename Callable>
2727
struct CallAtExit {
28+
[[nodiscard("The callback would be called immediately.")]]
2829
explicit CallAtExit(Callable &&c) : callable(std::move(c)) {}
2930
~CallAtExit() noexcept(false) {
3031
callable();
@@ -35,6 +36,7 @@ struct CallAtExit {
3536
} // namespace detail
3637

3738
template <typename Callable>
39+
[[nodiscard("The callback would be called immediately.")]]
3840
detail::CallAtExit<Callable> AtScopeExit(Callable &&c) {
3941
return detail::CallAtExit<Callable>(std::forward<Callable>(c));
4042
}

0 commit comments

Comments
 (0)