Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::invocable,std::regular_invocable

      From cppreference.com
      <cpp‎ |concepts
       
       
      Concepts library
       
      Defined in header<concepts>
      template<class F,class...Args>

      concept invocable=
          requires(F&& f, Args&&...args){
             std::invoke(std::forward<F>(f),std::forward<Args>(args)...);
                 /* not required to be equality-preserving */

         };
      (since C++20)
      template<class F,class...Args>
      concept regular_invocable= std::invocable<F, Args...>;
      (since C++20)

      Theinvocable concept specifies that a callable typeF can be called with a set of argumentsArgs... using the function templatestd::invoke.

      Theregular_invocable concept adds to theinvocable concept by requiring theinvoke expression to beequality-preserving and not modify either the function object or the arguments.

      Contents

      [edit]Equality preservation

      Expressions declared inrequires expressions of the standard library concepts are required to beequality-preserving (except where stated otherwise).

      [edit]Notes

      The distinction betweeninvocable andregular_invocable is purely semantic.

      A random number generator may satisfyinvocable but cannot satisfyregular_invocable (comical ones excluded).

      [edit]References

      • C++23 standard (ISO/IEC 14882:2024):
      • 18.7.2 Conceptinvocable [concept.invocable]
      • 18.7.3 Conceptregular_invocable [concept.regularinvocable]
      • C++20 standard (ISO/IEC 14882:2020):
      • 18.7.2 Conceptinvocable [concept.invocable]
      • 18.7.3 Conceptregular_invocable [concept.regularinvocable]

      [edit]See also

      checks if a type can be invoked (as if bystd::invoke) with the given argument types
      (class template)[edit]

      [edit]External links

      Ajoke example of a random number generator that satisfies bothinvocable andregular_invocable.
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/concepts/invocable&oldid=178596"

      [8]ページ先頭

      ©2009-2025 Movatter.jp