[libcxx-commits] [PATCH] D119881: [libc++] Make cpp17_input_iterator constexpr

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 15 12:12:32 PST 2022


philnik created this revision.
philnik added reviewers: Quuxplusone, ldionne.
philnik requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119881

Files:
  libcxx/test/std/strings/basic.string/cpp17_input_iterator.h


Index: libcxx/test/std/strings/basic.string/cpp17_input_iterator.h
===================================================================
--- libcxx/test/std/strings/basic.string/cpp17_input_iterator.h
+++ libcxx/test/std/strings/basic.string/cpp17_input_iterator.h
@@ -11,6 +11,8 @@
 
 #include <iterator>
 
+#include "test_macros.h"
+
 template <class It>
 class cpp17_input_iterator
 {
@@ -22,18 +24,18 @@
     typedef It                                                 pointer;
     typedef typename std::iterator_traits<It>::reference       reference;
 
-    cpp17_input_iterator() : it_() {}
-    explicit cpp17_input_iterator(It it) : it_(it) {}
+    TEST_CONSTEXPR cpp17_input_iterator() : it_() {}
+    TEST_CONSTEXPR explicit cpp17_input_iterator(It it) : it_(it) {}
 
-    reference operator*() const {return *it_;}
-    pointer operator->() const {return it_;}
+    TEST_CONSTEXPR reference operator*() const {return *it_;}
+    TEST_CONSTEXPR pointer operator->() const {return it_;}
 
-    cpp17_input_iterator& operator++() {++it_; return *this;}
-    cpp17_input_iterator operator++(int) {cpp17_input_iterator tmp(*this); ++(*this); return tmp;}
+    TEST_CONSTEXPR_CXX14 cpp17_input_iterator& operator++() {++it_; return *this;}
+    TEST_CONSTEXPR_CXX14 cpp17_input_iterator operator++(int) {cpp17_input_iterator tmp(*this); ++(*this); return tmp;}
 
-    friend bool operator==(const cpp17_input_iterator& x, const cpp17_input_iterator& y)
+    TEST_CONSTEXPR friend bool operator==(const cpp17_input_iterator& x, const cpp17_input_iterator& y)
         {return x.it_ == y.it_;}
-    friend bool operator!=(const cpp17_input_iterator& x, const cpp17_input_iterator& y)
+    TEST_CONSTEXPR friend bool operator!=(const cpp17_input_iterator& x, const cpp17_input_iterator& y)
         {return !(x == y);}
 };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119881.409001.patch
Type: text/x-patch
Size: 1825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220215/64f2c95f/attachment.bin>


More information about the libcxx-commits mailing list