Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::basic_common_reference<std::reference_wrapper>

      From cppreference.com
      <cpp‎ |utility‎ |functional‎ |reference wrapper
       
       
      Utilities library
       
      Function objects
      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 R,class T,

               template<class> RQual,template<class> TQual>
          requires(/*ref-wrap-common-reference-exists-with*/<R, T, RQual<R>, TQual<T>>&&
                   !/*ref-wrap-common-reference-exists-with*/<T, R, TQual<T>, RQual<R>>)

      struct basic_common_reference<R, T, RQual, TQual>;
      (1)(since C++23)
      template<class T,class R,

               template<class> TQual,template<class> RQual>
          requires(/*ref-wrap-common-reference-exists-with*/<R, T, RQual<R>, TQual<T>>&&
                   !/*ref-wrap-common-reference-exists-with*/<T, R, TQual<T>, RQual<R>>)

      struct basic_common_reference<T, R, TQual, RQual>;
      (2)(since C++23)
      Helper concepts
      template<class R,class T,class RQ,class TQ>

      concept/*ref-wrap-common-reference-exists-with*/=
         /*is-ref-wrapper*/<R>&&
          requires{typenamestd::common_reference_t<typename R::type&, TQ>;}&&

          std::convertible<RQ,std::common_reference_t<typename R::type&, TQ>>;
      (3)(exposition only*)

      The common reference type of areference_wrapper (denoted asR) and a typeT, correspondingly applied with cv and reference qualifiers (denoted asRQ andTQ respectively), is equivalent to a common reference type of underlying type ofR applied with lvalue reference and theTQ.

      The common reference type is defined only ifR is the onlyreference_wrapper, the underlying type ofR applied with lvalue reference and theTQ have a common reference type to whichRQ must be convertible.

      The exposition-only constant/*is-ref-wrapper*/<R> istrue if and only ifR is a specialization ofstd::reference_wrapper.

      Contents

      [edit]Member types

      Member type Definition
      typestd::common_reference_t<typename R::type&, TQual<T>>(1,2)

      [edit]Notes

      Feature-test macroValueStdFeature
      __cpp_lib_common_reference_wrapper202302L(C++23)Makestd::common_reference_t ofstd::reference_wrapper a reference type

      [edit]Example

      Run this code
      #include <concepts>#include <functional> static_assert(std::same_as<std::common_reference_t<int&,std::reference_wrapper<int>>,int&>);static_assert(std::same_as<std::common_reference_t<std::reference_wrapper<int>&,int&>,int&>);static_assert(std::same_as<std::common_reference_t<int&,conststd::reference_wrapper<int>&>,int&>);int main(){}

      [edit]See also

      determines the common reference type of a group of types
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/functional/reference_wrapper/basic_common_reference&oldid=168403"

      [8]ページ先頭

      ©2009-2025 Movatter.jp