Console Library 4.7.0
A header-only library that makes C++ simple
Loading...
Searching...
No Matches
sfinae.h File Reference

提供编译期类型特征检测(SFINAE 工具),用于判断容器、可调用对象、迭代器、下标访问、字符串、可打印类型、字符类型等。 More...

#include <type_traits>
#include <iterator>
#include <random>
#include "outfwd.h"

Go to the source code of this file.

Classes

struct  console::is_container< T, class >
 检测类型是否为容器(支持 std::begin 和 std::end)。 More...
struct  console::is_callable< F, class, Args >
 检测类型是否可作为函数对象以给定参数调用(返回 void 或可转换为 void)。 More...
struct  console::is_iterator< T, class >
 检测类型是否为迭代器(具有 iterator_category)。 More...
struct  console::has_subscript< T, Idx, class >
 检测类型是否支持下标操作符(如 T[Idx])。 More...
struct  console::is_string< T, class >
 检测类型是否为字符串类型(char*、std::string、std::string_view 等)。 More...
struct  console::is_printable< T, class >
 检测类型是否支持输出到 std::ostream(即定义了 operator<<)。 More...
struct  console::is_char< T, class >
 检测类型是否为字符类型(char、wchar_t、char16_t、char32_t 等)。 More...

Namespaces

namespace  console
 本库所有组件所在的顶层命名空间。

Typedefs

template<class T>
using console::enable_if_container
 启用若 T 是容器。
template<class T>
using console::enable_if_not_container
 启用若 T 不是容器。
template<class F, class... Args>
using console::enable_if_callable
 启用若 F 可以 Args... 参数调用。
template<class F, class... Args>
using console::enable_if_not_callable
 启用若 F 不可以 Args... 参数调用。
template<class T>
using console::enable_if_iterator
 启用若 T 是迭代器。
template<class T>
using console::enable_if_not_iterator
 启用若 T 不是迭代器。
template<class T>
using console::enable_if_string
 启用若 T(decay 后)是字符串类型。
template<class T>
using console::enable_if_not_string
 启用若 T(decay 后)不是字符串类型。
template<class T>
using console::enable_if_printable
 启用若 T 可打印。
template<class T>
using console::enable_if_not_printable
 启用若 T 不可打印。
template<class T>
using console::enable_if_char
 启用若 T(decay 后)是字符类型。
template<class T>
using console::enable_if_not_char
 启用若 T(decay 后)不是字符类型。
template<typename T>
using console::uniform_distribution_t = typename uniform_distribution_impl<T>::type
 取得对印类型所对应的均匀分布。

Detailed Description

提供编译期类型特征检测(SFINAE 工具),用于判断容器、可调用对象、迭代器、下标访问、字符串、可打印类型、字符类型等。

Author
MrXie1109
Date
2026