Skip to content
Snippets Groups Projects
Commit bff71102 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Use SFINAE to forbid specification of sub_item_type = item_type

parent af463f72
Branches
Tags
1 merge request!6Feature/crs
...@@ -10,15 +10,27 @@ ...@@ -10,15 +10,27 @@
#include <ConnectivityUtils.hpp> #include <ConnectivityUtils.hpp>
template <typename DataType, template <typename DataType,
ItemType SubItemType, ItemType sub_item_type,
ItemType ItemType> ItemType item_type,
class SubItemValuePerItem typename Allowed=void>
class SubItemValuePerItem;
template <typename DataType,
ItemType sub_item_type,
ItemType item_type>
class SubItemValuePerItem<DataType,
sub_item_type,
item_type,
std::enable_if_t<sub_item_type != item_type>>
{ {
private: private:
ConnectivityMatrix::HostRowType m_host_row_map; ConnectivityMatrix::HostRowType m_host_row_map;
Kokkos::View<DataType*> m_values; Kokkos::View<DataType*> m_values;
friend SubItemValuePerItem<std::add_const_t<DataType>, SubItemType, ItemType>; // Allows const version to access our data
friend SubItemValuePerItem<std::add_const_t<DataType>,
sub_item_type,
item_type>;
public: public:
class SubView class SubView
...@@ -132,7 +144,7 @@ class SubItemValuePerItem ...@@ -132,7 +144,7 @@ class SubItemValuePerItem
template <typename DataType2> template <typename DataType2>
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
SubItemValuePerItem& SubItemValuePerItem&
operator=(const SubItemValuePerItem<DataType2, SubItemType, ItemType>& sub_item_value_per_item) operator=(const SubItemValuePerItem<DataType2, sub_item_type, item_type>& sub_item_value_per_item)
{ {
// ensures that DataType is the same as source DataType2 // ensures that DataType is the same as source DataType2
static_assert(std::is_same<std::remove_const_t<DataType>, std::remove_const_t<DataType2>>(), static_assert(std::is_same<std::remove_const_t<DataType>, std::remove_const_t<DataType2>>(),
...@@ -148,7 +160,7 @@ class SubItemValuePerItem ...@@ -148,7 +160,7 @@ class SubItemValuePerItem
template <typename DataType2> template <typename DataType2>
KOKKOS_INLINE_FUNCTION KOKKOS_INLINE_FUNCTION
SubItemValuePerItem(const SubItemValuePerItem<DataType2, SubItemType, ItemType>& sub_item_value_per_item) SubItemValuePerItem(const SubItemValuePerItem<DataType2, sub_item_type, item_type>& sub_item_value_per_item)
{ {
this->operator=(sub_item_value_per_item); this->operator=(sub_item_value_per_item);
} }
...@@ -158,7 +170,7 @@ class SubItemValuePerItem ...@@ -158,7 +170,7 @@ class SubItemValuePerItem
SubItemValuePerItem(const IConnectivity& connectivity) SubItemValuePerItem(const IConnectivity& connectivity)
{ {
ConnectivityMatrix connectivity_matrix ConnectivityMatrix connectivity_matrix
= connectivity.getMatrix(ItemType,SubItemType); = connectivity.getMatrix(item_type, sub_item_type);
m_host_row_map = connectivity_matrix.rowsMap(); m_host_row_map = connectivity_matrix.rowsMap();
m_values = Kokkos::View<DataType*>("values", connectivity_matrix.numEntries()); m_values = Kokkos::View<DataType*>("values", connectivity_matrix.numEntries());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment