trace.h
Go to the documentation of this file.
1 /*
2  * This file is a part of TiledArray.
3  * Copyright (C) 2015 Virginia Tech
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 should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Justus Calvin
19  * Department of Chemistry, Virginia Tech
20  *
21  * kernels.h
22  * Jun 1, 2015
23  *
24  */
25 
26 #ifndef TILEDARRAY_TRACE_H__INCLUDED
27 #define TILEDARRAY_TRACE_H__INCLUDED
28 
29 #include <type_traits> // enable_if, true_type, false_type
30 
31 namespace TiledArray {
32 namespace detail {
33 
46 template <typename T, typename Enabler = void>
47 struct TraceIsDefined : std::false_type {};
48 
56 template <typename T>
58 
60 template <typename T, typename U = void>
61 using enable_if_trace_is_defined_t = std::enable_if_t<trace_is_defined_v<T>, U>;
62 
69 template <typename TileType, typename Enabler = void>
70 struct Trace;
71 
72 } // namespace detail
73 
91 template<typename T, typename = detail::enable_if_trace_is_defined_t<T>>
92 decltype(auto) trace(const T& t){
93  detail::Trace<T> tracer;
94  return tracer(t);
95 }
96 
101 template<typename T>
102 using result_of_trace_t = decltype(trace(std::declval<T>()));
103 
104 } // namespace TiledArray
105 #endif // TILEDARRAY_TRACE_H__INCLUDED
std::enable_if_t< trace_is_defined_v< T >, U > enable_if_trace_is_defined_t
SFINAE type for enabling code when the trace operation is defined.
Definition: trace.h:61
decltype(trace(std::declval< T >())) result_of_trace_t
Definition: trace.h:102
decltype(auto) trace(const Tile< Arg > &arg)
Sum the hyper-diagonal elements a tile.
Definition: tile.h:1477
constexpr auto trace_is_defined_v
Definition: trace.h:57