-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simple client calls for usable/settable
- Loading branch information
1 parent
73a0a81
commit 4a087af
Showing
4 changed files
with
45 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,48 @@ | ||
#ifndef PHARE_CORE_DEF_HPP | ||
#define PHARE_CORE_DEF_HPP | ||
|
||
#include <type_traits> | ||
|
||
#define NO_DISCARD [[nodiscard]] | ||
|
||
#if !defined(NDEBUG) || defined(PHARE_FORCE_DEBUG_DO) | ||
#define PHARE_DEBUG_DO(...) __VA_ARGS__ | ||
#else | ||
#define PHARE_DEBUG_DO(...) | ||
#endif | ||
|
||
#define _PHARE_TO_STR(x) #x // convert macro text to string | ||
#define PHARE_TO_STR(x) _PHARE_TO_STR(x) | ||
|
||
#define PHARE_TOKEN_PASTE(x, y) x##y | ||
#define PHARE_STR_CAT(x, y) PHARE_TOKEN_PASTE(x, y) | ||
|
||
|
||
namespace PHARE::core | ||
{ | ||
template<typename... Args> | ||
NO_DISCARD bool isUsable(Args const&... args) | ||
{ | ||
auto check = [](auto const& arg) { | ||
if constexpr (std::is_pointer_v<std::decay_t<decltype(arg)>>) | ||
return arg != nullptr; | ||
else | ||
return arg.isUsable(); | ||
}; | ||
return (check(args) && ...); | ||
} | ||
|
||
template<typename... Args> | ||
NO_DISCARD bool isSettable(Args const&... args) | ||
{ | ||
auto check = [](auto const& arg) { | ||
if constexpr (std::is_pointer_v<std::decay_t<decltype(arg)>>) | ||
return arg == nullptr; | ||
else | ||
return arg.isSettable(); | ||
}; | ||
return (check(args) && ...); | ||
} | ||
} // namespace PHARE::core | ||
|
||
#endif // PHARE_CORE_DEF_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters