NiHu  2.0
product_type.hpp
Go to the documentation of this file.
1 // This file is a part of NiHu, a C++ BEM template library.
2 //
3 // Copyright (C) 2012-2014 Peter Fiala <fiala@hit.bme.hu>
4 // Copyright (C) 2012-2014 Peter Rucz <rucz@hit.bme.hu>
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
25 #ifndef PRODUCT_TYPE_HPP_INCLUDED
26 #define PRODUCT_TYPE_HPP_INCLUDED
27 
28 namespace NiHu
29 {
30 
36 template<class Lhs, class Rhs>
38 {
43  typedef decltype(
44  (*static_cast<typename std::decay<Lhs>::type *>((void *)10))
45  *
46  (*static_cast<typename std::decay<Rhs>::type *>((void *)10))
47  ) type;
48 };
49 
50 
51 template<class Lhs, class Rhs>
52 struct sum_type
53 {
54  typedef decltype(
55  (*static_cast<typename std::decay<Lhs>::type *>((void *)10))
56  +
57  (*static_cast<typename std::decay<Rhs>::type *>((void *)10))
58  ) type;
59 };
60 
61 
62 } // end of namespace NiHu
63 
64 #endif /* PRODUCT_TYPE_HPP_INCLUDED */
NiHu::product_type::type
decltype((*static_cast< typename std::decay< Lhs >::type * >((void *) 10)) *(*static_cast< typename std::decay< Rhs >::type * >((void *) 10))) typede type)
Return type computed by decltype (void *)10 is an arbitrary pointer. Only the return type is computed...
Definition: product_type.hpp:47
NiHu::sum_type
Definition: product_type.hpp:52
NiHu::product_type
Metafunction returning the product type of two classes.
Definition: product_type.hpp:37