Jamba C++ API 8.0.0
Loading...
Searching...
No Matches
pongasoft::Utils::ConvertibleTo Concept Reference

Allows to detect (at compilation time) whether the call static_cast<To>(from) (where from is of type From) will compile. More...

#include <Metaprogramming.h>

Concept definition

template<typename From, typename To>
concept ConvertibleTo =
requires(From const& f)
{
{ static_cast<To>(f) } -> std::same_as<To>;
}
Allows to detect (at compilation time) whether the call static_cast<To>(from) (where from is of type ...
Definition Metaprogramming.h:84

Detailed Description

Allows to detect (at compilation time) whether the call static_cast<To>(from) (where from is of type From) will compile.

Example:

void f(SomeType &iValue) {
if constexpr(Utils::is_static_cast_defined<SomeType, int>) {
auto i = static_cast<int>(iValue); // this will compile!
...
} else {
// static_cast<int>(iValue) does NOT compile so do something different
}