「cpp/utility/functional/is bind expression」の版間の差分
提供: cppreference.com
< cpp | utility | functional
細 (Fix some translations) |
|||
1行: | 1行: | ||
− | |||
{{cpp/title|is_bind_expression}} | {{cpp/title|is_bind_expression}} | ||
{{cpp/utility/functional/navbar}} | {{cpp/utility/functional/navbar}} | ||
10行: | 9行: | ||
{{dcl end}} | {{dcl end}} | ||
− | + | {{tt|T}} {{lc|std::bind}} {{|}} {{lc|std::}} | |
− | {{ | + | {{|{{lc|std::bind}} {{lc|std::}} }} |
− | {{cpp/types/integral_constant/inherit | {{tt|T}} | + | |
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | {{cpp/types/integral_constant/inherit | {{tt|T}} {{lc|std::bind}} }} | ||
===例=== | ===例=== | ||
49行: | 54行: | ||
}} | }} | ||
− | === | + | ====== |
{{dsc begin}} | {{dsc begin}} | ||
{{dsc inc | cpp/utility/functional/dsc bind}} | {{dsc inc | cpp/utility/functional/dsc bind}} | ||
+ | |||
{{dsc end}} | {{dsc end}} | ||
2018年6月9日 (土) 22:18時点における版
ヘッダ <functional> で定義
|
||
template< class T > struct is_bind_expression; |
(C++11以上) | |
T
が std::bind の呼び出しによって生成される型の場合、このテンプレートは std::true_type から派生します。 それ以外のあらゆる型に対しては、このテンプレートは std::false_type から派生します。
このテンプレートは、 T
が bind 部分式の型であるかのように std::bind によって取り扱われるべきであることを示すために std::true_type の BaseCharacteristic を持つ UnaryTypeTrait を実装するために、ユーザ定義型 T
に対して特殊化しても構いません。 bind の生成した関数オブジェクトが呼び出されるとき、この型の束縛引数は関数オブジェクトとして呼び出され、 bind の生成したオブジェクトに渡される未束縛引数がすべて与えられます。
目次 |
ヘルパー変数テンプレート
template< class T > inline constexpr bool is_bind_expression_v = is_bind_expression<T>::value; |
(C++17以上) | |
std::integral_constant から継承
メンバ定数
value [静的] |
T が std::bind によって生成された関数オブジェクトならば true、そうでなければ false (パブリック静的メンバ定数) |
メンバ関数
operator bool |
オブジェクトを bool に変換します。 value を返します (パブリックメンバ関数) |
operator() (C++14) |
value を返します (パブリックメンバ関数) |
メンバ型
型 | 定義 |
value_type
|
bool
|
type
|
std::integral_constant<bool, value> |
例
Run this code
#include <iostream> #include <type_traits> #include <functional> struct MyBind { typedef int result_type; int operator()(int a, int b) const { return a + b; } }; namespace std { template<> struct is_bind_expression<MyBind> : public true_type {}; } int f(int n1, int n2) { return n1+n2; } int main() { // as if bind(f, bind(MyBind::operator(), _1, _2), 2) auto b = std::bind(f, MyBind(), 2); std::cout << "Adding 2 to the sum of 10 and 11 gives " << b(10, 11) << '\n'; }
出力:
Adding 2 to the sum of 10 and 11 gives 23
関連項目
(C++11) |
関数オブジェクトに1つ以上の引数をバインドします (関数テンプレート) |