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
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();}
|
||||
|
||||
@@ -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();}
|
||||
|
||||
@@ -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();}
|
||||
|
||||
@@ -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();}
|
||||
|
||||
@@ -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();}
|
||||
|
||||
@@ -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();}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class map
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::map<int, int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
28
test/std/containers/associative/multimap/empty.fail.cpp
Normal file
28
test/std/containers/associative/multimap/empty.fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <map>
|
||||
|
||||
// class multimap
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::multimap<int, int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
28
test/std/containers/associative/multiset/empty.fail.cpp
Normal file
28
test/std/containers/associative/multiset/empty.fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class multiset
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::multiset<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
28
test/std/containers/associative/set/empty.fail.cpp
Normal file
28
test/std/containers/associative/set/empty.fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <set>
|
||||
|
||||
// class set
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::set<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <queue>
|
||||
|
||||
// class priority_queue
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::priority_queue<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <queue>
|
||||
|
||||
// class queue
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::queue<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <stack>
|
||||
|
||||
// class stack
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <stack>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::stack<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
28
test/std/containers/sequences/array/empty.fail.cpp
Normal file
28
test/std/containers/sequences/array/empty.fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <array>
|
||||
|
||||
// class array
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::array<int, 1> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <deque>
|
||||
|
||||
// class deque
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <deque>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::deque<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
28
test/std/containers/sequences/forwardlist/empty.fail.cpp
Normal file
28
test/std/containers/sequences/forwardlist/empty.fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <forward_list>
|
||||
|
||||
// class forward_list
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <forward_list>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::forward_list<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <list>
|
||||
|
||||
// class list
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::list<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
28
test/std/containers/sequences/vector.bool/empty.fail.cpp
Normal file
28
test/std/containers/sequences/vector.bool/empty.fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <vector>
|
||||
|
||||
// class vector
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::vector<bool> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <vector>
|
||||
|
||||
// class vector
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::vector<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
28
test/std/containers/unord/unord.map/empty.fail.cpp
Normal file
28
test/std/containers/unord/unord.map/empty.fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <unordered_map>
|
||||
|
||||
// class unordered_map
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::unordered_map<int, int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
28
test/std/containers/unord/unord.multimap/empty.fail.cpp
Normal file
28
test/std/containers/unord/unord.multimap/empty.fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <unordered_map>
|
||||
|
||||
// class unordered_multimap
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::unordered_multimap<int, int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
28
test/std/containers/unord/unord.multiset/empty.fail.cpp
Normal file
28
test/std/containers/unord/unord.multiset/empty.fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <unordered_set>
|
||||
|
||||
// class unordered_multiset
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::unordered_multiset<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
28
test/std/containers/unord/unord.set/empty.fail.cpp
Normal file
28
test/std/containers/unord/unord.set/empty.fail.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <unordered_set>
|
||||
|
||||
// class unordered_set
|
||||
|
||||
// bool empty() const noexcept;
|
||||
|
||||
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||
// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, clang-3.8
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::unordered_set<int> c;
|
||||
c.empty(); // expected-error {{ignoring return value of function declared with 'nodiscard' attribute}}
|
||||
}
|
||||
Reference in New Issue
Block a user