Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
feelcore/traits.hpp
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2005-07-28
7 
8  Copyright (C) 2007,2009 Université de Grenoble 1
9  Copyright (C) 2005,2006 EPFL
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 3.0 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
30 #ifndef FEELPP_TRAITS_HPP
31 #define FEELPP_TRAITS_HPP 1
32 
33 #include <cmath>
34 
35 #include <boost/rational.hpp>
36 
37 #include <boost/mpl/vector.hpp>
38 #include <boost/mpl/max_element.hpp>
39 #include <boost/mpl/transform_view.hpp>
40 #include <boost/mpl/sizeof.hpp>
41 
42 #include <feel/feelcore/feel.hpp>
43 
45 #include <feel/feelcore/ublastraits.hpp>
46 
47 namespace Feel
48 {
49 template <typename T1, typename T2, typename T3 = mpl::void_, typename T4 = mpl::void_, typename T5 = mpl::void_>
50 struct strongest_numeric_type
51 {
52  typedef mpl::vector<T1, T2, T3, T4, T5> types;
53  typedef typename mpl::max_element<mpl::transform_view< types,mpl::sizeof_<mpl::_1> > >::type iter;
54  typedef typename mpl::deref<typename iter::base>::type type;
55 };
56 
57 template <typename T1, typename T2>
58 struct strongest_numeric_type<T1,std::complex<T2> >
59 {
60  typedef typename type_traits<T1>::real_type R1;
61  typedef std::complex<typename strongest_numeric_type<R1,T2>::type > type;
62 };
63 template <typename T1, typename T2>
64 struct strongest_numeric_type<std::complex<T1>,T2 >
65 {
66  typedef typename type_traits<T2>::real_type R2;
67  typedef std::complex<typename strongest_numeric_type<T1,R2>::type > type;
68 };
69 template <typename T1, typename T2>
70 struct strongest_numeric_type<std::complex<T1>,std::complex<T2> >
71 {
72  typedef std::complex<typename strongest_numeric_type<T1,T2>::type > type;
73 };
74 
75 
76 template <class T>
77 struct is_shared_ptr
78  : mpl::false_
79 {
80 };
81 
82 template <class T>
83 struct is_shared_ptr<boost::shared_ptr<T> >
84  : mpl::true_
85 {
86 };
87 
88 template <class T>
89 struct remove_shared_ptr
90 {
91  typedef T type;
92 };
93 
94 template <class T>
95 struct remove_shared_ptr<boost::shared_ptr<T> >
96 {
97  typedef T type;
98 };
99 
100 } // namespace Feel
101 #endif
102 
103 

Generated on Sun Dec 22 2013 13:11:15 for Feel++ by doxygen 1.8.5