Files
lix/src/libutil/concepts.hh
T
Qyriadandeldritch horrors ddfca6e81b libexpr: implement actual constructors for nix::Value
Change-Id: Iebc2bb4e4ea5e93045afe47677df756de4ec4d05
2024-07-31 15:38:37 +02:00

23 lines
718 B
C++

#pragma once
/// @file Defines C++ 20 concepts that std doesn't have.
#include <type_traits>
namespace nix
{
/// Like std::invocable<>, but also constrains the return type as well.
///
/// Somehow, there is no std concept to do this, even though there is a type trait
/// for it.
///
/// @tparam CallableT The type you want to constrain to be callable, and to return
/// @p ReturnT when called with @p Args as arguments.
///
/// @tparam ReturnT The type the callable should return when called.
/// @tparam Args The arguments the callable should accept to return @p ReturnT.
template<typename CallableT, typename ReturnT, typename ...Args>
concept InvocableR = std::is_invocable_r_v<ReturnT, CallableT, Args...>;
}