Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-28838

QtC indentation hickup on enable_if_t<LHS < RHS> in template-initializer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Not Evaluated
    • None
    • Qt Creator 9.0.2
    • C/C++/Obj-C++ Support
    • None

    Description

      The following code snippet will cause QtC to mis-indent the remainder of the file:

      The | symbols show the cursor position after hitting return at the end of the previous line.

      template <size_t N>
      class QSmallByteArray
      {
          std::array<quint8, N> m_data;
          static_assert(N <= std::numeric_limits<std::uint8_t>::max());
          quint8 m_size = 0;
      public:
          QSmallByteArray() = default;
          // all compiler-generated SMFs are ok!
          template <std::size_t M, std::enable_if_t<M < N, bool> = true> // M == N is for copy ctor!
                    |
          QSmallByteArray(const QSmallByteArray<M> &other) noexcept
                    |
          {
                    |
              assign(other);
          }
                    |
          template <std::size_t M, std::enable_if_t<M < N, bool> = true> // M == N is for copy-assignment op!
                    |
          QSmallByteArray &operator=(const QSmallByteArray<M> &other) noexcept
                    |
          {
              assign(other);
                    |
              return *this;
          }
                    |
          template <typename Container> // ### underconstrained
          void assign(const Container &c) {
              const size_t otherSize = size_t(std::size(c));
              Q_ASSERT(otherSize < N);
              memcpy(data(), std::data(c), otherSize);
              m_size = quint8(otherSize);
          }
      
          quint8 *data() noexcept { return m_data.data(); }
          const quint8 *data() const noexcept { return m_data.data(); }
          qsizetype size() const noexcept { return qsizetype{m_size}; }
          // ~~~~
      };
      

      It does't help to wrap the M < N in parentheses, like so: (M < N); still the same problem.

      Attachments

        Activity

          People

            kandeler Christian Kandeler
            mmutz Marc Mutz
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: