[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

Chris Cotter via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 20 08:50:17 PST 2023


ccotter added a comment.

In

  template <int tagValue, typename T>
  struct SomeClass
  {
  public:
    explicit SomeClass(T&& value) : value(std::forward<T>(value)) {}
   T value;
  };

`T` is not a universal reference in the constructor, it's an rvalue reference to `T`. There is no deducing context, so universal references are not involved here (and, `std::forward` would also be incorrect here). The following would be a deducing context with a universal reference:

  template <int tagValue, typename T>
  struct SomeClass
  {
  public:
    template <class T2>
    explicit SomeClass(T2&& value) : value(std::forward<T2>(value)) {}
   T value;
  };


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141569/new/

https://reviews.llvm.org/D141569



More information about the cfe-commits mailing list