diff --git a/include/frg/array.hpp b/include/frg/array.hpp index 64c8c45..e5d9bbb 100644 --- a/include/frg/array.hpp +++ b/include/frg/array.hpp @@ -152,30 +152,6 @@ constexpr const T &&get(const frg::array &&a) noexcept { namespace std { -template -constexpr T &get(frg::array &a) noexcept { - static_assert(I < N, "array index is not within bounds"); - return a[I]; -}; - -template -constexpr T &&get(frg::array &&a) noexcept { - static_assert(I < N, "array index is not within bounds"); - return std::move(a[I]); -}; - -template -constexpr const T &get(const frg::array &a) noexcept { - static_assert(I < N, "array index is not within bounds"); - return a[I]; -}; - -template -constexpr const T &&get(const frg::array &&a) noexcept { - static_assert(I < N, "array index is not within bounds"); - return std::move(a[I]); -}; - template struct tuple_size> : integral_constant { }; diff --git a/tests/tests.cpp b/tests/tests.cpp index e247891..8260bd5 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -149,6 +149,32 @@ TEST(tuples, reference_test) { EXPECT_EQ(&z, &t2.get<2>()); } +#include + +TEST(array, basic_test) { + constexpr int N = 4; + frg::array arr{0, 1, 2, 3}; + for (int i = 0; i < N; i++) + EXPECT_EQ(arr[i], i); + + const auto [a, b, c, d] = arr; + EXPECT_EQ(a, 0); + EXPECT_EQ(b, 1); + EXPECT_EQ(c, 2); + EXPECT_EQ(d, 3); + + arr[0] = 1; + EXPECT_NE(a, arr[0]); // Make sure a doesn't change when array changes + + const auto& [e, f, g, h] = arr; + EXPECT_EQ(e, 1); + arr[0] = 2; + EXPECT_EQ(e, 2); // Make sure e does change when array changes + + static_assert(std::tuple_size_v == N, "tuple_size produces wrong result"); + static_assert(std::is_same_v, int>, "tuple_element produces wrong result"); +} + #include #include #include // std::string