Reference documentation for deal.II version 9.1.0-pre
complex_overloads.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_complex_overloads_h
17 #define dealii_complex_overloads_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <deal.II/base/template_constraints.h>
22 
23 DEAL_II_NAMESPACE_OPEN
24 
25 // Forward declarations
26 template <typename T>
28 template <typename T, typename U>
29 struct ProductType;
30 
31 #ifndef DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
32 
39 template <typename T, typename U>
40 typename ProductType<std::complex<T>, std::complex<U>>::type inline
41 operator*(const std::complex<T> &left, const std::complex<U> &right)
42 {
43  using result_type =
44  typename ProductType<std::complex<T>, std::complex<U>>::type;
45  return static_cast<result_type>(left) * static_cast<result_type>(right);
46 }
47 
48 
57 template <typename T, typename U>
59  typename EnableIfScalar<U>::type>::type inline
60 operator*(const std::complex<T> &left, const U &right)
61 {
62  using result_type = typename ProductType<std::complex<T>, U>::type;
63  return static_cast<result_type>(left) * static_cast<result_type>(right);
64 }
65 
66 
75 template <typename T, typename U>
77  std::complex<U>>::type inline
78 operator*(const T &left, const std::complex<U> &right)
79 {
80  using result_type = typename ProductType<std::complex<T>, U>::type;
81  return static_cast<result_type>(left) * static_cast<result_type>(right);
82 }
83 #endif /* DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS */
84 
85 DEAL_II_NAMESPACE_CLOSE
86 
87 #endif
ProductType< std::complex< T >, typename EnableIfScalar< U >::type >::type operator*(const std::complex< T > &left, const U &right)
ProductType< typename EnableIfScalar< T >::type, std::complex< U > >::type operator*(const T &left, const std::complex< U > &right)
ProductType< std::complex< T >, std::complex< U > >::type operator*(const std::complex< T > &left, const std::complex< U > &right)