summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-02-02 01:25:38 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-02-02 01:25:38 +0000
commit394d165d6877afe6490bad49f8b957492c5ac3e4 (patch)
treed72d64330968d2e1fccbb374eb720461983990ae
parentMerge branch 'geo-shadows' (diff)
downloadilt-394d165d6877afe6490bad49f8b957492c5ac3e4.tar.bz2
ilt-394d165d6877afe6490bad49f8b957492c5ac3e4.tar.xz
ilt-394d165d6877afe6490bad49f8b957492c5ac3e4.zip
Fix warnings in test-glContainer
Also updates static asserts to requirements
-rw-r--r--lib/glContainer.h7
-rw-r--r--test/test-glContainer.cpp36
2 files changed, 26 insertions, 17 deletions
diff --git a/lib/glContainer.h b/lib/glContainer.h
index 2ccc1c2..b4238d5 100644
--- a/lib/glContainer.h
+++ b/lib/glContainer.h
@@ -272,6 +272,7 @@ public:
void
resize(size_type newSize)
+ requires std::is_default_constructible_v<T>
{
if (newSize == size_) {
return;
@@ -327,6 +328,7 @@ public:
template<typename... P>
reference_type
emplace_back(P &&... ps)
+ requires std::is_constructible_v<T, P...>
{
auto newSize = size_ + 1;
reserve(newSize);
@@ -339,8 +341,8 @@ public:
template<typename... P>
iterator
emplace(iterator pos, P &&... ps)
+ requires std::is_nothrow_constructible_v<T, P...>
{
- static_assert(std::is_nothrow_constructible_v<T, P...>);
auto newSize = size_ + 1;
const auto idx = pos - begin();
reserve(newSize);
@@ -355,6 +357,7 @@ public:
reference_type
push_back(T p)
+ requires std::is_move_constructible_v<T>
{
auto newSize = size_ + 1;
reserve(newSize);
@@ -366,8 +369,8 @@ public:
iterator
insert(iterator pos, T p)
+ requires std::is_nothrow_move_constructible_v<T>
{
- static_assert(std::is_nothrow_move_constructible_v<T>);
auto newSize = size_ + 1;
const auto idx = pos - begin();
reserve(newSize);
diff --git a/test/test-glContainer.cpp b/test/test-glContainer.cpp
index ccf3b90..f19ca74 100644
--- a/test/test-glContainer.cpp
+++ b/test/test-glContainer.cpp
@@ -325,27 +325,33 @@ BOOST_FIXTURE_TEST_SUITE(c, glContainer<C>)
BOOST_AUTO_TEST_CASE(basic)
{
- BOOST_CHECK_NO_THROW(emplace_back(1, 2.f));
+ BOOST_CHECK_NO_THROW(emplace_back(1, 2.F));
BOOST_CHECK_EQUAL(1, begin()->x);
- BOOST_CHECK_EQUAL(2.f, begin()->y);
+ BOOST_CHECK_EQUAL(2.F, begin()->y);
BOOST_CHECK_NO_THROW(begin()->x = 3);
BOOST_CHECK_EQUAL(3, begin()->x);
- BOOST_CHECK_NO_THROW(push_back(C {4, 5.f}));
+ BOOST_CHECK_NO_THROW(push_back(C {4, 5.F}));
BOOST_CHECK_EQUAL(3, begin()->x);
- BOOST_CHECK_EQUAL(2.f, begin()->y);
+ BOOST_CHECK_EQUAL(2.F, begin()->y);
BOOST_CHECK_EQUAL(4, rbegin()->x);
- BOOST_CHECK_EQUAL(5.f, rbegin()->y);
+ BOOST_CHECK_EQUAL(5.F, rbegin()->y);
}
BOOST_AUTO_TEST_SUITE_END();
struct CC {
+ CC() = default;
+
+ CC(int a, float b) noexcept : x {a}, y {b} { }
+
~CC()
{
++x;
}
+ DEFAULT_MOVE_COPY(CC);
+
int x;
float y;
};
@@ -356,17 +362,17 @@ BOOST_FIXTURE_TEST_SUITE(cc, glContainer<CC>)
BOOST_AUTO_TEST_CASE(basic)
{
- BOOST_CHECK_NO_THROW(emplace_back(1, 2.f));
+ BOOST_CHECK_NO_THROW(emplace_back(1, 2.F));
BOOST_CHECK_EQUAL(1, begin()->x);
- BOOST_CHECK_EQUAL(2.f, begin()->y);
+ BOOST_CHECK_EQUAL(2.F, begin()->y);
BOOST_CHECK_NO_THROW(begin()->x = 3);
BOOST_CHECK_EQUAL(3, begin()->x);
- BOOST_CHECK_NO_THROW(push_back(CC {4, 5.f}));
+ BOOST_CHECK_NO_THROW(push_back(CC {4, 5.F}));
BOOST_CHECK_EQUAL(3, begin()->x);
- BOOST_CHECK_EQUAL(2.f, begin()->y);
+ BOOST_CHECK_EQUAL(2.F, begin()->y);
BOOST_CHECK_EQUAL(4, rbegin()->x);
- BOOST_CHECK_EQUAL(5.f, rbegin()->y);
+ BOOST_CHECK_EQUAL(5.F, rbegin()->y);
BOOST_CHECK_NO_THROW(pop_back());
BOOST_CHECK_EQUAL(size(), 1);
BOOST_CHECK_EQUAL(capacity(), 2);
@@ -380,11 +386,11 @@ BOOST_AUTO_TEST_CASE(basic)
BOOST_AUTO_TEST_CASE(insert_remove_test)
{
- BOOST_CHECK_NO_THROW(emplace_back(1, 2.f));
- BOOST_CHECK_NO_THROW(emplace_back(3, 4.f));
- BOOST_CHECK_NO_THROW(emplace(begin(), 5, 6.f));
- BOOST_CHECK_NO_THROW(emplace(begin() + 1, 7, 8.f));
- BOOST_CHECK_NO_THROW(emplace(begin() + 2, 9, 10.f));
+ BOOST_CHECK_NO_THROW(emplace_back(1, 2.F));
+ BOOST_CHECK_NO_THROW(emplace_back(3, 4.F));
+ BOOST_CHECK_NO_THROW(emplace(begin(), 5, 6.F));
+ BOOST_CHECK_NO_THROW(emplace(begin() + 1, 7, 8.F));
+ BOOST_CHECK_NO_THROW(emplace(begin() + 2, 9, 10.F));
BOOST_CHECK_EQUAL(capacity(), 8);
BOOST_CHECK_EQUAL(size(), 5);
BOOST_CHECK_NO_THROW(shrink_to_fit());