Quantum++  v0.8.2
C++11 quantum computing library
traits.h
Go to the documentation of this file.
1 /*
2  * Quantum++
3  *
4  * Copyright (c) 2013 - 2015 Vlad Gheorghiu (vgheorgh@gmail.com)
5  *
6  * This file is part of Quantum++.
7  *
8  * Quantum++ is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * Quantum++ is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Quantum++. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
27 #ifndef TRAITS_H_
28 #define TRAITS_H_
29 
30 // Collection of some useful type traits
31 
32 namespace qpp
33 {
34 
40 template<class ...>
41 using to_void = void;
42 
51 template<typename T, typename = void>
52 struct is_iterable : std::false_type
53 {
54 };
55 
60 template<typename T>
61 struct is_iterable<T,
63  decltype(std::declval<T>().end()),
64  typename T::value_type
65  >> : std::true_type
66 {
67 };
68 
77 template<typename Derived>
78 struct is_matrix_expression : std::false_type
79 {
80 };
81 
86 template<typename Derived>
88  std::true_type
89 {
90 };
91 
98 template<typename T>
99 struct is_complex : std::false_type
100 {
101 };
102 
107 template<typename T>
108 struct is_complex<std::complex<T>> : std::true_type
109 {
110 };
111 
112 
113 } /* namespace qpp */
114 
115 #endif /* TRAITS_H_ */
116 
Quantum++ main namespace.
Definition: codes.h:30
STL namespace.
Checks whether T is compatible with an STL-like iterable container.
Definition: traits.h:52
Checks whether the type is an Eigen matrix expression.
Definition: traits.h:78
void to_void
Alias template that implements the proposal for void_t.
Definition: traits.h:41
Checks whether the type is a complex type.
Definition: traits.h:99