TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
vector.hpp
Go to the documentation of this file.
1// Copyright (c) 2019--present, The Simons Foundation
2// This file is part of TRIQS/nda and is licensed under the Apache License, Version 2.0.
3// SPDX-License-Identifier: Apache-2.0
4// See LICENSE in the root of this distribution for details.
5
10
11#pragma once
12
13#include "../clef.hpp"
14
15#include <utility>
16#include <vector>
17
18namespace nda::clef {
19
24
25 namespace detail {
26
27 // Helper function to auto assign to a std::vector object.
28 template <typename T, typename RHS>
29 void clef_auto_assign_std_vector_impl(T &x, RHS &&rhs) {
30 x = std::forward<RHS>(rhs);
31 }
32
33 // Helper function to auto assign to a std::vector object.
34 template <typename Expr, int... Is, typename T>
35 void clef_auto_assign_std_vector_impl(T &x, make_fun_impl<Expr, Is...> &&rhs) { // NOLINT (why rvalue reference?)
36 clef_auto_assign_subscript(x, std::forward<make_fun_impl<Expr, Is...>>(rhs));
37 }
38
39 } // namespace detail
40
49 template <typename T, typename F>
50 void clef_auto_assign_subscript(std::vector<T> &v, F f) {
51 for (size_t i = 0; i < v.size(); ++i) detail::clef_auto_assign_std_vector_impl(v[i], f(i));
52 }
53
55
56} // namespace nda::clef
Includes all relevant headers for the core clef library.
void clef_auto_assign_subscript(std::vector< T > &v, F f)
Overload of clef_auto_assign_subscript function for std::vector.
Definition vector.hpp:50