tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
enable_if< bool, Type > Struct Template Reference

Define a member typedef only if a boolean constant is true. More...

#include <enable_if.hpp>

Detailed Description

template<bool, typename Type = void>
struct etl::enable_if< bool, Type >

Define a member typedef only if a boolean constant is true.

// SPDX-License-Identifier: BSL-1.0
#include <etl/cstdint.hpp>
namespace {
template <typename T>
auto func(T val) -> etl::enable_if_t<etl::is_integral_v<T>, int>
{
return static_cast<int>(val);
}
auto func(float val) -> float { return val; }
} // namespace
auto main() -> int
{
func(42); // Calls template
func(etl::uint16_t{1}); // Calls template
func(3.0F); // Does not call template
return 0;
}
TETL_BUILTIN_UINT16 uint16_t
Unsigned integer type with width of exactly 16 bits.
Definition uint_t.hpp:14
typename enable_if< B, T >::type enable_if_t
Definition enable_if.hpp:19

The documentation for this struct was generated from the following file: