Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:Callable

      From cppreference.com
      <cpp‎ |named req
       
       
      C++ named requirements
       

      ACallable type is a type for which theINVOKE andINVOKE<R> operations (used by, e.g.,std::function,std::bind, andstd::thread::thread) are applicable.

      INVOKE can be performed explicitly using the library functionstd::invoke.

      (since C++17)

      INVOKE<R> can be performed explicitly using the library functionstd::invoke_r.

      (since C++23)

      Contents

      [edit]Requirements

      The typeT satisfiesCallable if

      Given

      • f, an object of typeT,
      • ArgTypes, suitable list of argument types,
      • R, suitable return type.

      The following expressions must be valid:

      ExpressionRequirements
      INVOKE<R>(f,std::declval<ArgTypes>()...)The expression is well-formed in unevaluated context.

      [edit]Notes

      Pointers to data members areCallable, even though no function calls take place.

      [edit]Standard library

      In addition, the following standard library facilities accept anyCallable type (not justFunctionObject):

      (C++11)
      copyable wrapper of any copy constructible callable object
      (class template)[edit]
      move-only wrapper of any callable object that supports qualifiers in a given call signature
      (class template)[edit]
      copyable wrapper of any copy constructible callable object that supports qualifiers in a given call signature
      (class template)[edit]
      non-owning wrapper of any callable object
      (class template)[edit]
      (C++11)
      binds one or more arguments to a function object
      (function template)[edit]
      (C++20)(C++23)
      bind a variable number of arguments, in order, to a function object
      (function template)[edit]
      CopyConstructible andCopyAssignable reference wrapper
      (class template)[edit]
      (C++11)(removed in C++20)(C++17)
      deduces the result type of invoking a callable object with a set of arguments
      (class template)[edit]
      (C++11)
      manages a separate thread
      (class)[edit]
      (C++20)
      std::thread with support for auto-joining and cancellation
      (class)[edit]
      (C++11)
      invokes a function only once even if called from multiple threads
      (function template)[edit]
      (C++11)
      runs a function asynchronously (potentially in a new thread) and returns astd::future that will hold the result
      (function template)[edit]
      packages a function to store its return value for asynchronous retrieval
      (class template)[edit]

      [edit]See also

      checks if a type can be invoked (as if bystd::invoke) with the given argument types
      (class template)[edit]
      specifies that a callable type can be invoked with a given set of argument types
      (concept)[edit]
      (C++17)(C++23)
      invokes anyCallable object with given argumentsand possibility to specify return type(since C++23)
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/Callable&oldid=173956"

      [8]ページ先頭

      ©2009-2025 Movatter.jp