Corrade/Utility/TypeTraits.h file

Macros CORRADE_LONG_DOUBLE_SAME_AS_DOUBLE, CORRADE_NO_STD_IS_TRIVIALLY_TRAITS, CORRADE_SOURCE_LOCATION_BUILTINS_SUPPORTED, CORRADE_HAS_TYPE(), alias Corrade::Utility::IsIterable.

Namespaces

namespace Corrade
Root namespace.
namespace Corrade::Utility
Utilities.

Typedefs

template<class T>
using IsIterable = std::integral_constant<bool, implementation-specific>
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.

Defines

#define CORRADE_SOURCE_LOCATION_BUILTINS_SUPPORTED new in Git master
Whether source location builtins are supported.
#define CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED deprecated in Git master
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.

Define documentation

#define CORRADE_SOURCE_LOCATION_BUILTINS_SUPPORTED new in Git master

Whether source location builtins are supported.

Defined if compiler-specific builtins used to implement the C++20 std::source_location feature are available. Defined on GCC at least since version 4.8, Clang 9+ and MSVC 2019 16.6 and newer; on all three they're present also in the C++11 mode. Used by:

#define CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED

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.

Parameters
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.

Usage examples: checking for presence of a key_type member typedef:

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, "");