Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
Morpheus_MirrorContainers_Impl.hpp
1
24#ifndef MORPHEUS_MIRRORCONTAINERS_IMPL_HPP
25#define MORPHEUS_MIRRORCONTAINERS_IMPL_HPP
26
27#include <type_traits>
28
29namespace Morpheus {
30namespace Impl {
31
32template <class Space, template <class, class...> class Container, class T,
33 class... P>
35 // The incoming container_type
36 using src_container_type = Container<T, P...>;
37 // The memory space for the mirror container
38 using memory_space = typename Space::memory_space;
39 // Check whether it is the same memory space
40 enum {
41 is_same_memspace =
42 std::is_same<memory_space,
43 typename src_container_type::memory_space>::value
44 };
45 // The data type (we probably want it non-const since otherwise we can't even
46 // deep_copy to it.
47 using value_type = typename src_container_type::non_const_value_type;
48 using index_type = typename src_container_type::index_type;
49 using array_layout = typename src_container_type::array_layout;
50 // The destination container type if it is not the same memory space - note
51 // that the new container will always be managed even when the source is
52 // unmanaged
53 using dest_container_type =
54 Container<value_type, index_type, array_layout, Space>;
55 // If it is the same memory_space return the existsing container_type
56 using container_type =
57 typename std::conditional<is_same_memspace, src_container_type,
58 dest_container_type>::type;
59};
60
61template <class Space, template <class, class...> class Container, class T,
62 class... P>
63struct MirrorType {
64 // The incoming container_type
65 using src_container_type = Container<T, P...>;
66
67 // we want it non-const to allow deep_copy.
68 using value_type = typename src_container_type::non_const_value_type;
69 using index_type = typename src_container_type::non_const_index_type;
70 using array_layout = typename src_container_type::array_layout;
71 // The destination container type if it is not the same memory space - note
72 // that the new container will always be managed even when the source is
73 // unmanaged
74 using container_type = Container<value_type, index_type, array_layout, Space>;
75};
76
77} // namespace Impl
78} // namespace Morpheus
79
80#endif // MORPHEUS_MIRRORCONTAINERS_IMPL_HPP
Generic Morpheus interfaces.
Definition: dummy.cpp:24
Definition: Morpheus_MirrorContainers_Impl.hpp:34
Definition: Morpheus_MirrorContainers_Impl.hpp:63