Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libcxx/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ AttributeMacros: [
'_LIBCPP_CONSTEXPR_SINCE_CXX17',
'_LIBCPP_CONSTEXPR_SINCE_CXX20',
'_LIBCPP_CONSTEXPR_SINCE_CXX23',
'_LIBCPP_CONSTEXPR_SINCE_CXX26',
'_LIBCPP_CONSTEXPR',
'_LIBCPP_CONSTINIT',
'_LIBCPP_DEPRECATED_IN_CXX11',
Expand Down
165 changes: 92 additions & 73 deletions libcxx/include/stack

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,21 @@
#include "nasty_containers.h"
#include "test_container_comparisons.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
assert((test_sequence_container_adaptor_spaceship<std::stack, std::deque>()));
assert((test_sequence_container_adaptor_spaceship<std::stack, std::list>()));
assert((test_sequence_container_adaptor_spaceship<std::stack, std::vector>()));
assert((test_sequence_container_adaptor_spaceship<std::stack, nasty_list>()));
assert((test_sequence_container_adaptor_spaceship<std::stack, nasty_vector>()));
// `std::stack` is not constexpr, so no `static_assert` test here.

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# include "test_convertible.h"
#endif

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
typedef std::vector<int, limited_allocator<int, 10> > Container;
typedef std::stack<int, Container> Q;
Q q;
Expand All @@ -37,5 +37,14 @@ int main(int, char**) {
static_assert(test_convertible<Q>(), "");
#endif

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void test_return_type() {
#endif
}

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
test_return_type<std::stack<int> >();
test_return_type<std::stack<int, std::vector<int> > >();

Expand All @@ -57,5 +57,14 @@ int main(int, char**) {
assert(q.size() == 3);
assert(q.top() == Emplaceable(3, 4.5));

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@

#include "test_macros.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<int> q;
assert(q.empty());
q.push(1);
assert(!q.empty());
q.pop();
assert(q.empty());

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "test_macros.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<int> q;
assert(q.size() == 0);
q.push(1);
Expand All @@ -32,5 +32,14 @@ int main(int, char**) {
q.pop();
assert(q.size() == 0);

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "test_macros.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<int> q;
q.push(1);
assert(q.size() == 1);
Expand All @@ -29,3 +29,12 @@ int main(int, char**) {

return 0;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "../../push_range_container_adaptors.h"
#include "test_macros.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
test_push_range<std::stack<int, std::deque<int, Alloc>>, Iter, Sent>();
});
Expand All @@ -29,5 +29,14 @@ int main(int, char**) {
test_push_range_exception_safety_throwing_copy<std::stack>();
test_push_range_exception_safety_throwing_allocator<std::stack, std::deque, int>();

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "test_macros.h"
#include "MoveOnly.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<MoveOnly> q;
q.push(MoveOnly(1));
assert(q.size() == 1);
Expand All @@ -30,5 +30,14 @@ int main(int, char**) {
assert(q.size() == 3);
assert(q.top() == MoveOnly(3));

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@

#include "test_macros.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<int> q;
assert(q.size() == 0);
q.push(1);
assert(q.size() == 1);

return 0;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
#include "test_macros.h"

template <class C>
C make(int n) {
TEST_CONSTEXPR_CXX26 C make(int n) {
C c;
for (int i = 0; i < n; ++i)
c.push(i);
return c;
}

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<int> q1 = make<std::stack<int> >(5);
std::stack<int> q2 = make<std::stack<int> >(10);
std::stack<int> q1_save = q1;
Expand All @@ -32,5 +32,14 @@ int main(int, char**) {
assert(q1 == q2_save);
assert(q2 == q1_save);

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "test_macros.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<int> q;
assert(q.size() == 0);
q.push(1);
Expand All @@ -26,3 +26,12 @@ int main(int, char**) {

return 0;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "test_macros.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<int> q;
assert(q.size() == 0);
q.push(1);
Expand All @@ -25,5 +25,14 @@ int main(int, char**) {
const int& cir = cqr.top();
assert(cir == 3);

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
#include "test_macros.h"

template <class C>
C make(int n) {
TEST_CONSTEXPR_CXX26 C make(int n) {
C c;
for (int i = 0; i < n; ++i)
c.push(i);
return c;
}

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<int> q1 = make<std::stack<int> >(5);
std::stack<int> q2 = make<std::stack<int> >(10);
std::stack<int> q1_save = q1;
Expand All @@ -36,5 +36,14 @@ int main(int, char**) {
assert(q1 != q2);
assert(q2 == q2_save);

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,29 @@
#include "test_macros.h"

template <class C>
C make(int n) {
TEST_CONSTEXPR_CXX26 C make(int n) {
C c;
for (int i = 0; i < n; ++i)
c.push(i);
return c;
}

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<int> q1 = make<std::stack<int> >(5);
std::stack<int> q2 = make<std::stack<int> >(10);
assert(q1 < q2);
assert(q2 > q1);
assert(q1 <= q2);
assert(q2 >= q1);

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
#include "test_macros.h"

template <class C>
C make(int n) {
TEST_CONSTEXPR_CXX26 C make(int n) {
C c;
for (int i = 0; i < n; ++i)
c.push(i);
return c;
}

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
std::stack<int> q1 = make<std::stack<int> >(5);
std::stack<int> q2 = make<std::stack<int> >(10);
std::stack<int> q1_save = q1;
Expand All @@ -33,5 +33,14 @@ int main(int, char**) {
assert(q1 == q2_save);
assert(q2 == q1_save);

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Loading