1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- // -*- mode: c++; coding: utf-8 -*-
- // ra-ra/test - Const transfer from Container to View
- // (c) Daniel Llorens - 2021-2023
- // This library is free software; you can redistribute it and/or modify it under
- // the terms of the GNU Lesser General Public License as published by the Free
- // Software Foundation; either version 3 of the License, or (at your option) any
- // later version.
- #include <iostream>
- #include "mpdebug.hh"
- #include "ra/test.hh"
- using std::cout, std::endl, std::flush, std::tuple, ra::TestRecorder;
- template <class T> constexpr bool is_cref_v = std::is_reference_v<T> && std::is_const_v<std::remove_reference_t<T>>;
- template <class T> constexpr bool is_ncref_v = std::is_reference_v<T> && !std::is_const_v<std::remove_reference_t<T>>;
- int main()
- {
- TestRecorder tr(std::cout);
- auto test =
- [&](auto & a, auto & b)
- {
- tr.test(is_ncref_v<decltype(*(a.data()))>);
- tr.test(is_cref_v<decltype(*(b.data()))>);
- tr.test(is_ncref_v<decltype(*(a().data()))>);
- tr.test(is_cref_v<decltype(*(b().data()))>);
- tr.test(is_ncref_v<decltype(*(a(ra::all).data()))>);
- tr.test(is_cref_v<decltype(*(b(ra::all).data()))>);
- };
- tr.section("dynamic rank");
- {
- ra::Big<int> a = {1, 2, 3, 4};
- ra::Big<int> const b = {9, 8, 7, 6};
- test(a, b);
- }
- tr.section("static rank");
- {
- ra::Big<int, 1> a = {1, 2, 3, 4};
- ra::Big<int, 1> const b = {9, 8, 7, 6};
- test(a, b);
- }
- tr.section("static dimensions");
- {
- ra::Small<int, 4> a = {1, 2, 3, 4};
- ra::Small<int, 4> const b = {9, 8, 7, 6};
- test(a, b);
- }
- return tr.summary();
- }
|