template<class T>using IsIterable = std::
- Traits class for checking whether given type is iterable.
template<class T>using IsStringLike = std::
integral_constant<bool, implementation-specific> new in 2019.10
- Traits class for checking whether given type is string-like.
- #define CORRADE_LONG_DOUBLE_SAME_AS_DOUBLE new in 2020.06
long doublehas the same precision as
- #define CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED new in 2020.06
- Whether the std::
is_trivially_copyable family of type traits is supported by the standard library.
- #define CORRADE_HAS_TYPE(className, ...)
- Macro for creating traits class that checks for type expression validity.
long double has the same precision as
Defined on platforms where the
long double type has a 64-bit precision instead of 80-bit, thus same as
double. It's the case for MSVC (source), 32-bit Android (no reliable source found, sorry) and Emscripten. Emscripten is a bit special because it's
long double is sometimes 80-bit, but its precision differs from the 80-bit representation elsewhere, so it's always treated as 64-bit. Note that even though the type size and precision may be the same, these are still two distinct types, similarly to how
signed int behave the same but are treated as different types.
Whether the std::
std::has_trivial_copy_assign are available, with slightly different semantics (see e.g. https:/
__has_trivial_assign() builtins that don't produce any deprecated warnings and are available until GCC 9 / Clang 10 at least — however note that for SFINAE you need to wrap them in std::
error: use of built-in trait ‘__has_trivial_copy(T)’ in function signature; use library traits instead
This macro is defined if the standard variants are available. Unfortunately, when libstdc++ is used through Clang, there's no way to check for its version until libstdc++ 7, which added the
_GLIBCXX_RELEASE macro. That means, when using Clang with libstdc++ 5 or 6, it will still report those traits as being unavailable. Both libc++ and MSVC STL have these traits in all versions supported by Corrade, so there the macro is defined always.
#define CORRADE_HAS_TYPE(className, ...)
Macro for creating traits class that checks for type expression validity.
|className||Resulting class name|
|...||Type expression to check. Variadic parameter to allow unrestricted usage of template expressions containing commas.|
Defines a traits class checking whether an expression is valid. You can use
T to reference the type which is being checked; the type expression can contain
Usage examples: checking for presence of a
CORRADE_HAS_TYPE(HasKeyType, typename T::key_type); static_assert(HasKeyType<std::map<int, int>>::value, ""); static_assert(!HasKeyType<std::vector<int>>::value, "");
Checking for presence of
size() member function:
CORRADE_HAS_TYPE(HasSize, decltype(std::declval<T>().size())); static_assert(HasSize<std::vector<int>>::value, ""); static_assert(!HasSize<std::tuple<int, int>>::value, "");