TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
range.hpp
Go to the documentation of this file.
1// Copyright (c) 2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018-2024 Simons Foundation
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0.txt
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Authors: Thomas Hahn, Olivier Parcollet, Nils Wentzell
18
24#pragma once
25
26#include "../traits.hpp"
27
28#include <itertools/itertools.hpp>
29
30#include <ostream>
31#include <type_traits>
32
33namespace nda {
34
41 using itertools::range;
42
49 struct ellipsis : range::all_t {};
50
57 inline std::ostream &operator<<(std::ostream &os, range::all_t) noexcept { return os << "_"; }
58
65 inline std::ostream &operator<<(std::ostream &os, ellipsis) noexcept { return os << "___"; }
66
68 template <typename... Args>
70
75 template <typename T>
76 constexpr bool is_range_or_ellipsis = is_any_of<std::remove_cvref_t<T>, range, range::all_t, ellipsis>;
77
80} // namespace nda
constexpr bool ellipsis_is_present
Constexpr variable that is true if the parameter pack Args contains an nda::ellipsis.
Definition range.hpp:69
std::ostream & operator<<(std::ostream &os, range::all_t) noexcept
Write nda::range::all_t to a std::ostream as _.
Definition range.hpp:57
constexpr bool is_range_or_ellipsis
Constexpr variable that is true if the type T is either an nda::range, an nda::range::all_t or an nda...
Definition range.hpp:76
static constexpr bool is_any_of
Constexpr variable that is true if type T is contained in the parameter pack Ts.
Definition traits.hpp:63
Mimics Python's ... syntax.
Definition range.hpp:49
Provides type traits for the nda library.