TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
view_tools.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2015 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2013-2015 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2019-2023 Simons Foundation
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You may obtain a copy of the License at
16// https://www.gnu.org/licenses/gpl-3.0.txt
17//
18// Authors: Olivier Parcollet, Nils Wentzell
19
24
25#pragma once
26
27#include <nda/nda.hpp>
28
29#include <type_traits>
30
31namespace triqs {
32
33 namespace details {
34
35 template <typename T, typename Enable = void> struct _regular {
36 using type = T;
37 };
38
39 template <typename T> struct _regular<T, std::void_t<typename T::regular_type>> {
40 using type = typename T::regular_type;
41 };
42
43 template <typename T, typename Enable = void> struct _view_or_type {
44 using type = T;
45 };
46
47 template <typename T> struct _view_or_type<T, std::void_t<typename T::view_type>> {
48 using type = typename T::view_type;
49 };
50
51 template <typename T> struct _view_or_type<T const, std::void_t<typename T::view_type>> {
52 using type = typename T::const_view_type;
53 };
54
55 template <typename T, typename Enable = void> struct _const_view_or_type {
56 using type = T;
57 };
58
59 template <typename T> struct _const_view_or_type<T, std::void_t<typename T::const_view_type>> {
60 using type = typename T::const_view_type;
61 };
62
63 } // namespace details
64
69
75 template <typename T> using regular_t = typename details::_regular<std::decay_t<T>>::type;
76
82 template <typename T> using view_or_type_t = typename details::_view_or_type<T>::type;
83
89 template <typename T> using const_view_or_type_t = typename details::_const_view_or_type<T>::type;
90
91 // Elevate nda::make_regular into the triqs namespace.
92 using nda::make_regular;
93
95
96} // namespace triqs
typename details::_view_or_type< T >::type view_or_type_t
Get the view type of a given type T if it exists.
typename details::_regular< std::decay_t< T > >::type regular_t
Get the regular type of a given type T if it exists.
typename details::_const_view_or_type< T >::type const_view_or_type_t
Get the const view type of a given type T if it exists.