Add concept restrictions to coral::closure constructors
This commit is contained in:
parent
02e202cb3b
commit
ff4d60a1b3
@ -286,14 +286,16 @@ export void operator delete[](void * pointer, coral::allocator & allocator) {
|
||||
|
||||
// Wrapper types.
|
||||
export namespace coral {
|
||||
template<typename type, typename... arguments> concept function_pointer = requires (type value, arguments... value_arguments) {
|
||||
{*value};
|
||||
{value(value_arguments...)};
|
||||
};
|
||||
template<typename type, typename... arguments> concept function_pointer =
|
||||
requires (type value, arguments... value_arguments) {
|
||||
{*value};
|
||||
{value(value_arguments...)};
|
||||
};
|
||||
|
||||
template<typename type, typename... arguments> concept functor = requires (type value, arguments... value_arguments) {
|
||||
{value.operator()(value_arguments...)};
|
||||
};
|
||||
template<typename type, typename... arguments> concept functor =
|
||||
requires (type value, arguments... value_arguments) {
|
||||
{value.operator()(value_arguments...)};
|
||||
};
|
||||
|
||||
template<typename> struct closure;
|
||||
|
||||
@ -305,7 +307,7 @@ export namespace coral {
|
||||
* the caller to manage the lifetime of any functor assigned to it.
|
||||
*/
|
||||
template<typename returns, typename... arguments> struct closure<returns(arguments...)> {
|
||||
template<typename callable> closure(callable const & call) requires function_pointer<callable, arguments...> {
|
||||
template<typename callable> closure(callable call) requires function_pointer<callable, arguments...> {
|
||||
this->dispatch = [](void * context, arguments... dispatch_arguments) -> returns {
|
||||
return (*reinterpret_cast<callable *>(context))(dispatch_arguments...);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user