piranha  0.10
key_is_multipliable.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_KEY_IS_MULTIPLIABLE_HPP
30 #define PIRANHA_KEY_IS_MULTIPLIABLE_HPP
31 
32 #include <array>
33 #include <cstddef>
34 #include <type_traits>
35 #include <utility>
36 
37 #include <piranha/is_cf.hpp>
38 #include <piranha/is_key.hpp>
39 #include <piranha/symbol_utils.hpp>
40 #include <piranha/term.hpp>
41 #include <piranha/type_traits.hpp>
42 
43 namespace piranha
44 {
45 
46 inline namespace impl
47 {
48 
49 template <typename Cf, typename Key, typename = void>
50 struct key_is_multipliable_impl : std::false_type {
51 };
52 
53 template <typename Cf, typename Key>
54 struct key_is_multipliable_impl<Cf, Key,
55  enable_if_t<std::is_same<const std::size_t, decltype(Key::multiply_arity)>::value
56  && (Key::multiply_arity > 0u)>> {
57  template <typename Cf1, typename Key1>
58  using multiply_t
59  = decltype(Key1::multiply(std::declval<std::array<term<Cf1, Key1>, Key1::multiply_arity> &>(),
60  std::declval<const term<Cf1, Key1> &>(), std::declval<const term<Cf1, Key1> &>(),
61  std::declval<const symbol_fset &>()));
62  static const bool value = is_detected<multiply_t, Cf, Key>::value;
63 };
64 }
65 
67 
79 template <typename Cf, typename Key>
81 {
82  PIRANHA_TT_CHECK(is_cf, uncvref_t<Cf>);
83  PIRANHA_TT_CHECK(is_key, uncvref_t<Key>);
84  static const bool implementation_defined = key_is_multipliable_impl<uncvref_t<Cf>, uncvref_t<Key>>::value;
85 
86 public:
88  static const bool value = implementation_defined;
89 };
90 
91 template <typename Cf, typename Key>
93 }
94 
95 #endif
Type trait for multipliable key.
static const bool value
Value of the type trait.
Type trait to detect coefficient types.
Definition: is_cf.hpp:55
Key type concept check.
Definition: is_key.hpp:65
STL namespace.
Root piranha namespace.
Definition: array_key.hpp:52
Type traits.