summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2017-11-15 05:51:26 +0000
committerMarshall Clow <mclow.lists@gmail.com>2017-11-15 05:51:26 +0000
commit88626bf496e9a1276652790438b389e65950629f (patch)
treed975e9769477acff346690e7bfffa48a7ebd4ffc /include
parent2645a49a67cd23f82f3a431adeb4488ff7a53d55 (diff)
First part of P0600 - '[[nodiscard] in the standard library'. Mark the 'empty()' methods of all the containers as nodiscard. If you're calling empty() w/o looking at the result, you probably meanto to call 'clear()'. c++2a only
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@318269 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/array2
-rw-r--r--include/deque2
-rw-r--r--include/forward_list2
-rw-r--r--include/list2
-rw-r--r--include/map4
-rw-r--r--include/queue4
-rw-r--r--include/set4
-rw-r--r--include/stack2
-rw-r--r--include/unordered_map4
-rw-r--r--include/unordered_set4
-rw-r--r--include/vector4
11 files changed, 17 insertions, 17 deletions
diff --git a/include/array b/include/array
index 12780992e..4eb2fe6fc 100644
--- a/include/array
+++ b/include/array
@@ -183,7 +183,7 @@ struct _LIBCPP_TEMPLATE_VIS array
_LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
// element access:
diff --git a/include/deque b/include/deque
index fee75614b..08cb29540 100644
--- a/include/deque
+++ b/include/deque
@@ -1314,7 +1314,7 @@ public:
void resize(size_type __n);
void resize(size_type __n, const value_type& __v);
void shrink_to_fit() _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return __base::size() == 0;}
// element access:
diff --git a/include/forward_list b/include/forward_list
index 8bfa9a084..7b8204137 100644
--- a/include/forward_list
+++ b/include/forward_list
@@ -728,7 +728,7 @@ public:
const_iterator cbefore_begin() const _NOEXCEPT
{return const_iterator(base::__before_begin());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT
{return base::__before_begin()->__next_ == nullptr;}
_LIBCPP_INLINE_VISIBILITY
diff --git a/include/list b/include/list
index 857d8a7a0..32e9a27bd 100644
--- a/include/list
+++ b/include/list
@@ -896,7 +896,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT {return base::__sz();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return base::empty();}
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT
diff --git a/include/map b/include/map
index 71f18693f..952149389 100644
--- a/include/map
+++ b/include/map
@@ -1012,7 +1012,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT {return __tree_.size();}
@@ -1669,7 +1669,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT {return __tree_.size();}
diff --git a/include/queue b/include/queue
index feaae8920..670fbb722 100644
--- a/include/queue
+++ b/include/queue
@@ -268,7 +268,7 @@ public:
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const {return c.empty();}
_LIBCPP_INLINE_VISIBILITY
size_type size() const {return c.size();}
@@ -490,7 +490,7 @@ public:
_Alloc>::value>::type* = 0);
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const {return c.empty();}
_LIBCPP_INLINE_VISIBILITY
size_type size() const {return c.size();}
diff --git a/include/set b/include/set
index 30f2fa88f..b4c6b2ef8 100644
--- a/include/set
+++ b/include/set
@@ -575,7 +575,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT {return __tree_.size();}
@@ -984,7 +984,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
const_reverse_iterator crend() const _NOEXCEPT {return rend();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return __tree_.size() == 0;}
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT {return __tree_.size();}
diff --git a/include/stack b/include/stack
index b2d4e2395..0cb4c6ca9 100644
--- a/include/stack
+++ b/include/stack
@@ -181,7 +181,7 @@ public:
: c(_VSTD::move(__s.c), __a) {}
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const {return c.empty();}
_LIBCPP_INLINE_VISIBILITY
size_type size() const {return c.size();}
diff --git a/include/unordered_map b/include/unordered_map
index 0546c0e2f..725cb6af2 100644
--- a/include/unordered_map
+++ b/include/unordered_map
@@ -885,7 +885,7 @@ public:
allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(__table_.__node_alloc());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return __table_.size() == 0;}
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT {return __table_.size();}
@@ -1634,7 +1634,7 @@ public:
allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(__table_.__node_alloc());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return __table_.size() == 0;}
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT {return __table_.size();}
diff --git a/include/unordered_set b/include/unordered_set
index a14fb0004..3ae024a45 100644
--- a/include/unordered_set
+++ b/include/unordered_set
@@ -450,7 +450,7 @@ public:
allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(__table_.__node_alloc());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return __table_.size() == 0;}
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT {return __table_.size();}
@@ -968,7 +968,7 @@ public:
allocator_type get_allocator() const _NOEXCEPT
{return allocator_type(__table_.__node_alloc());}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT {return __table_.size() == 0;}
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT {return __table_.size();}
diff --git a/include/vector b/include/vector
index b2f8f092c..54b1e8831 100644
--- a/include/vector
+++ b/include/vector
@@ -634,7 +634,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type capacity() const _NOEXCEPT
{return __base::capacity();}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT
{return this->__begin_ == this->__end_;}
size_type max_size() const _NOEXCEPT;
@@ -2290,7 +2290,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type size() const _NOEXCEPT
{return __size_;}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
bool empty() const _NOEXCEPT
{return __size_ == 0;}
void reserve(size_type __n);