-
Notifications
You must be signed in to change notification settings - Fork 5
/
const.cc
52 lines (46 loc) · 1.68 KB
/
const.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// -*- 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();
}