piranha  0.10
print_coefficient.hpp
1 /* Copyright 2009-2017 Francesco Biscani (bluescarni@gmail.com)
2 
3 This file is part of the Piranha library.
4 
5 The Piranha library is free software; you can redistribute it and/or modify
6 it under the terms of either:
7 
8  * the GNU Lesser General Public License as published by the Free
9  Software Foundation; either version 3 of the License, or (at your
10  option) any later version.
11 
12 or
13 
14  * the GNU General Public License as published by the Free Software
15  Foundation; either version 3 of the License, or (at your option) any
16  later version.
17 
18 or both in parallel, as here.
19 
20 The Piranha library is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 for more details.
24 
25 You should have received copies of the GNU General Public License and the
26 GNU Lesser General Public License along with the Piranha library. If not,
27 see https://www.gnu.org/licenses/. */
28 
29 #ifndef PIRANHA_PRINT_COEFFICIENT_HPP
30 #define PIRANHA_PRINT_COEFFICIENT_HPP
31 
32 #include <iostream>
33 #include <utility>
34 
35 #include <piranha/type_traits.hpp>
36 
37 namespace piranha
38 {
39 
41 
44 template <typename T, typename = void>
47 
60  template <typename U>
61  auto operator()(std::ostream &os, const U &cf) const -> decltype(os << cf)
62  {
63  return os << cf;
64  }
65 };
66 
68 
82 template <typename T>
83 inline auto print_coefficient(std::ostream &os, const T &cf) -> decltype(print_coefficient_impl<T>()(os, cf))
84 {
85  return print_coefficient_impl<T>()(os, cf);
86 }
87 
89 
93 template <typename T>
95 {
96  template <typename T1>
97  using print_coefficient_t
98  = decltype(piranha::print_coefficient(std::declval<std::ostream &>(), std::declval<const T1 &>()));
99  static const bool implementation_defined = is_detected<print_coefficient_t, T>::value;
100 
101 public:
103  static const bool value = implementation_defined;
104 };
105 
106 template <typename T>
108 }
109 
110 #endif
auto operator()(std::ostream &os, const U &cf) const -> decltype(os<< cf)
Call operator.
Type trait for classes implementing piranha::print_coefficient.
static const bool value
Value of the type trait.
Root piranha namespace.
Definition: array_key.hpp:52
Type traits.
auto print_coefficient(std::ostream &os, const T &cf) -> decltype(print_coefficient_impl< T >()(os, cf))
Print series coefficient.
Default functor for piranha::print_coefficient().