名前空間
変種
操作

「cpp/utility/functional/is bind expression」の版間の差分

提供: cppreference.com
< cpp‎ | utility‎ | functional
(Fix some translations)
1行: 1行:
{{tr_note}}
 
 
{{cpp/title|is_bind_expression}}
 
{{cpp/title|is_bind_expression}}
 
{{cpp/utility/functional/navbar}}
 
{{cpp/utility/functional/navbar}}
10行: 9行:
 
{{dcl end}}
 
{{dcl end}}
  
{{tr|{{tt|T}}{{lc|std::bind}}の呼び出しによって生成された型である場合、このテンプレートは、メンバ定数{{c|value}}等しい{{c|true}}を提供しています。その他のタイプのために、{{tt|value}}{{c|false}}です.|If {{tt|T}} is the type produced by a call to {{lc|std::bind}}, this template provides the member constant {{c|value}} equal {{c|true}}.  For any other type, {{tt|value}} is {{c|false}}.}}
+
{{tt|T}} {{lc|std::bind}} {{|}} {{lc|std::}}
  
{{tr|バインドで生成された関数オブジェクトが呼び出されたときに、このタイプのバインド引数が、関数として呼び出されます:このテンプレートは、それがバインド部分式のタイプであったかのように{{lc|std::bind}}によって扱われるべきであるユーザー定義型に特化することができるオブジェクトとバインドで生成したオブジェクトに渡されたすべてのバインドされていない引数が与えられます.|This template may be specialized for a user-defined type which should be treated by {{lc|std::bind}} as if it was the type of a bind subexpression: when a bind-generated function object is invoked, a bound argument of this type will be invoked as a function object and will be given all the unbound arguments passed to the bind-generated object.}}
+
{{|{{lc|std::bind}} {{lc|std::}} }}
  
{{cpp/types/integral_constant/inherit | {{tt|T}} is a function object generated by {{lc|std::bind}}}}
+
 +
 +
 +
 +
 +
 
 +
{{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時点における版

 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
関数オブジェクト
関数ラッパー
(C++11)
(C++11)
関数の部分適用
(C++20)
(C++11)
is_bind_expression
(C++11)
関数呼び出し
(C++17)
恒等関数オブジェクト
(C++20)
参照ラッパー
(C++11)(C++11)
演算子ラッパー
否定子
(C++17)
検索子
制約付き比較子
古いバインダとアダプタ
(C++17未満)
(C++17未満)
(C++17未満)
(C++17未満)
(C++17未満)(C++17未満)(C++17未満)(C++17未満)
(C++20未満)
(C++20未満)
(C++17未満)(C++17未満)
(C++17未満)(C++17未満)

(C++17未満)
(C++17未満)(C++17未満)(C++17未満)(C++17未満)
(C++20未満)
(C++20未満)
 
ヘッダ <functional> で定義
template< class T >
struct is_bind_expression;
(C++11以上)

Tstd::bind の呼び出しによって生成される型の場合、このテンプレートは std::true_type から派生します。 それ以外のあらゆる型に対しては、このテンプレートは std::false_type から派生します。

このテンプレートは、 T が bind 部分式の型であるかのように std::bind によって取り扱われるべきであることを示すために std::true_typeBaseCharacteristic を持つ 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
[静的]
Tstd::bind によって生成された関数オブジェクトならば true、そうでなければ false
(パブリック静的メンバ定数)

メンバ関数

operator bool
オブジェクトを bool に変換します。 value を返します
(パブリックメンバ関数)
operator()
(C++14)
value を返します
(パブリックメンバ関数)

メンバ型

定義
value_type bool
type std::integral_constant<bool, value>

#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つ以上の引数をバインドします
(関数テンプレート) [edit]