Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::is_bind_expression

      From cppreference.com
      <cpp‎ |utility‎ |functional
       
       
      Utilities library
       
      Function objects
      Partial function application
      (C++20)(C++23)
      (C++11)
      is_bind_expression
      (C++11)
      Function invocation
      (C++17)(C++23)
      Identity function object
      (C++20)
      Old binders and adaptors
      (until C++17*)
      (until C++17*)
      (until C++17*)
      (until C++17*)  
      (until C++17*)
      (until C++17*)(until C++17*)(until C++17*)(until C++17*)
      (until C++20*)
      (until C++20*)
      (until C++17*)(until C++17*)
      (until C++17*)(until C++17*)

      (until C++17*)
      (until C++17*)(until C++17*)(until C++17*)(until C++17*)
      (until C++20*)
      (until C++20*)
       
      Defined in header<functional>
      template<class T>
      struct is_bind_expression;
      (since C++11)

      IfT is a type produced by a call tostd::bind (but notstd::bind_front orstd::bind_back), this template is derived fromstd::true_type. For any other type (unless user-specialized), this template is derived fromstd::false_type.

      A program may specialize this template for aprogram-defined typeT to implementUnaryTypeTrait with base characteristic ofstd::true_type to indicate thatT should be treated bystd::bind as if it were 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.

      Contents

      [edit]Helper variable template

      template<class T>
      constexprbool is_bind_expression_v= is_bind_expression<T>::value;
      (since C++17)
      [edit]

      Inherited fromstd::integral_constant

      Member constants

      value
      [static]
      true ifT is a function object generated bystd::bind,false otherwise
      (public static member constant)

      Member functions

      operator bool
      converts the object tobool, returnsvalue
      (public member function)
      operator()
      (C++14)
      returnsvalue
      (public member function)

      Member types

      Type Definition
      value_typebool
      typestd::integral_constant<bool, value>

      [edit]Example

      Run this code
      #include <functional>#include <iostream>#include <type_traits> struct MyBind{typedefint 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(), _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';}

      Output:

      Adding 2 to the sum of 10 and 11 gives 23

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2010C++11program-defined specializations could
      only be derived fromstd::false_type
      can be derived from
      std::true_type

      [edit]See also

      (C++11)
      binds one or more arguments to a function object
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/functional/is_bind_expression&oldid=176456"

      [8]ページ先頭

      ©2009-2025 Movatter.jp