Home C&C++函数库 c++ 语法 程序源码 Linux C库

std::

is_placeholder

类模板  <functional>

template <class T> struct is_placeholder;

是否占位符
Trait类,用于标识T是否是绑定占位符。

C++11
它继承自integral_constant<int,I>, 如果T是绑定占位符的类型,则I是占位符的序号(1为_1,2为_2,…) 如果不是则0(0)。

C++14
它被定义为继承自integral_constant<int,I>,如果T是绑定占位符的类型,则I是占位符的序号(1为_1,2为_2,…) 如果不是则0(0)。


bind函数使用此特征来确定其每个参数的类型是否为占位符。对于将被视为占位符的类型,用户可以特化该模板。

☲  成员参数



T
一种类型

☲  成员类型



C++11
从integral_constant继承:
成员类型 定义
value_type int
type 它继承的integral_constant类型。

C++14
成员类型 定义
value_type int
type 它继承的integral_constant类型,或具有相同特征的类型

☲  常量成员



成员常量 定义
value 如果T是占位符的类型:占位符的序号(_1为1,_2为2,…) 否则:0。

☲  成员函数



成员函数 定义
operator int 返回成员常量值

☣  示例



// is_placeholder example
#include <iostream>     // std::cout, std::boolalpha
#include <functional>   // std::is_placeholder, std::placeholders

int main () {
  using namespace std::placeholders;  // introduces _1

  std::cout << std::is_placeholder<decltype(_1)>::value << '\n';
  std::cout << std::is_placeholder<decltype(_2)>::value << '\n';
  std::cout << std::is_placeholder<int>::value << '\n';

  return 0;
}

输出:
1
2
0

🍄  另请参阅



placeholders 绑定参数占位符(命名空间)
is_bind_expression 是否绑定表达式(类模板)

联系我们 免责声明 关于CandCplus 网站地图