tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
array.cpp
// SPDX-License-Identifier: BSL-1.0
// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
#include <etl/cassert.hpp>
#if defined(TETL_ENABLE_CXX_MODULES)
import etl;
#else
#include <etl/algorithm.hpp>
#include <etl/array.hpp>
#include <etl/iterator.hpp>
#endif
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:20
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:16
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:19
A container that encapsulates fixed size arrays.
Definition array.hpp:49
constexpr auto fill(const_reference value) -> void
Assigns the given value value to all elements in the container.
Definition array.hpp:253