tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
array.cpp
// SPDX-License-Identifier: BSL-1.0
#undef NDEBUG
#include <etl/array.hpp>
#include <etl/cassert.hpp>
#include <etl/iterator.hpp>
auto main() -> int
{
auto src = etl::array{1, 2, 3, 4}; // size & type are deduced
src.fill(42);
assert(etl::all_of(src.begin(), src.end(), [](auto v) { return v == 42; }));
decltype(src) dest = {};
assert(etl::all_of(dest.begin(), dest.end(), [](auto v) { return v == 0; }));
etl::copy(src.begin(), src.end(), dest.begin());
assert(etl::all_of(dest.begin(), dest.end(), [](auto v) { return v == 42; }));
return 0;
}
#define assert(...)
Definition cassert.hpp:19
constexpr auto all_of(InputIt first, InputIt last, Predicate p) -> bool
Checks if unary predicate p returns true for all elements in the range [first, last).
Definition all_of.hpp:15
constexpr auto copy(InputIt first, InputIt last, OutputIt destination) -> OutputIt
Copies the elements in the range, defined by [first, last), to another range beginning at destination...
Definition copy.hpp:18
A container that encapsulates fixed size arrays.
Definition array.hpp:48
constexpr auto fill(const_reference value) -> void
Assigns the given value value to all elements in the container.
Definition array.hpp:207