-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdaw_contiguous_view_test.cpp
More file actions
37 lines (30 loc) · 1.1 KB
/
Copy pathdaw_contiguous_view_test.cpp
File metadata and controls
37 lines (30 loc) · 1.1 KB
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
// Copyright (c) Darrell Wright
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/beached/header_libraries
//
#include "daw/daw_contiguous_view.h"
#include <daw/daw_ensure.h>
#include <numeric>
int foo( daw::contiguous_view<int const> vals ) {
return std::accumulate( vals.begin( ), vals.end( ), 0 );
}
int foo( daw::contiguous_view<int> vals ) {
return std::accumulate( vals.begin( ), vals.end( ), 0 );
}
int main( ) {
static constexpr int vals[] = { 1, 2, 3 };
constexpr auto cv = daw::contiguous_view( vals );
daw_ensure( foo( cv ) == 6 );
constexpr auto vals2 = std::array{ 1, 2, 3 };
static_assert( daw::contiguous_view( vals2 )[0] == 1 );
static_assert( daw::contiguous_view( vals2, 1 )[0] == 1 );
int vals3[] = { 1, 2, 3 };
auto cv3 = daw::contiguous_view( vals3 );
daw_ensure( foo( cv3 ) == 6 );
constexpr auto vals4 = std::array{ 1, 2, 3 };
daw_ensure( daw::contiguous_view( vals4 )[0] == 1 );
daw_ensure( daw::contiguous_view( vals4, 1 )[0] == 1 );
}