Iros
 
Loading...
Searching...
No Matches
di::concepts::ImplicitlyConvertibleTo Concept Reference

Implicit conversion for this test refers to the ability to return a value of function from a type. More...

#include <di/meta/operations.h>

Concept definition

template<typename From, typename To>
(LanguageVoid<From> && LanguageVoid<To>) || requires(void (*function_accepting_to)(To), From&& from) {
static_cast<To (*)()>(nullptr);
{ function_accepting_to(util::forward<From>(from)) };
}
Implicit conversion for this test refers to the ability to return a value of function from a type.
Definition operations.h:89
Definition core.h:128

Detailed Description

Implicit conversion for this test refers to the ability to return a value of function from a type.

In particular, []() -> long { return static_cast<int>(0); }, is valid because 'int' is implicitly convertible to 'long'. In addition, one can pass 'int' to a function expecting a 'long', with no conversion necessary.

This is checked first by determining if a function pointer which returns the type 'To' is valid (arrays with dimensions, like int[42] cannot be returned from functions).

Secondly, it is checked that a value of type 'From' can be passed to a function expecting a value of type 'To'.