Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      decay-copy

      From cppreference.com
      <cpp‎ |standard library
       
       
      Standard library
      Customization point object(C++20)
      Exposition-only entities
      decay-copy
      (C++11)
       
      template<class T>
      typenamestd::decay<T>::type decay-copy( T&& value);
      (since C++11)
      (until C++20)
      (exposition only*)
      template<class T>

          requiresstd::convertible_to<T,std::decay_t<T>>
      constexprstd::decay_t<T> decay-copy( T&& value)

         noexcept(std::is_nothrow_convertible_v<T,std::decay_t<T>>);
      (since C++20)
      (exposition only*)

      Returnsstd::forward<T>(value) (implicitly converted to the decayed type), a decayed prvalue copy ofvalue.

      Contents

      [edit]Parameters

      value - the value to be copied

      [edit]Return value

      A decayed copy ofvalue as a prvalue.

      [edit]Notes

      decay-copy was introduced by the resolution ofLWG issue 929. It is initially used in theconcurrency support library to ensure that arguments are decayed when passing-by-value, and is later used in theranges library.

      The language featureauto(x) introduced in C++23 also allows decayed copies to be created as prvalues. The only difference is thatdecay-copy alwaysmaterializesvalue and produces a copy, whileauto(expr) is a no-op ifexpr is a prvalue.

      All usages ofdecay-copy in the standard library (see below) exceptviews::all,ranges::take_view andranges::drop_view are replaced withauto(x) since C++23.

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 3724C++20decay-copy was not constrainedconstrained

      [edit]See also

      constructs newthread object
      (public member function ofstd::thread)[edit]
      constructs newjthread object
      (public member function ofstd::jthread)[edit]
      (C++11)
      runs a function asynchronously (potentially in a new thread) and returns astd::future that will hold the result
      (function template)[edit]
      returns an iterator to the beginning of a range
      (customization point object)[edit]
      returns a sentinel indicating the end of a range
      (customization point object)[edit]
      returns a reverse iterator to a range
      (customization point object)[edit]
      returns a reverse end iterator to a range
      (customization point object)[edit]
      returns an integer equal to the size of a range
      (customization point object)[edit]
      obtains a pointer to the beginning of a contiguous range
      (customization point object)[edit]
      aview that includes all elements of arange
      (alias template)(range adaptor object)[edit]
      aview consisting of the first N elements of anotherview
      (class template)(range adaptor object)[edit]
      aview consisting of elements of anotherview, skipping the first N elements
      (class template)(range adaptor object)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/standard_library/decay-copy&oldid=157132"

      [8]ページ先頭

      ©2009-2025 Movatter.jp