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

Add a few static assertions

parent 1733b0ac
No related branches found
No related tags found
1 merge request!131Improve Synchronizer handling
...@@ -20,7 +20,8 @@ min(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value) ...@@ -20,7 +20,8 @@ min(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value)
using data_type = std::remove_const_t<typename ItemValueType::data_type>; using data_type = std::remove_const_t<typename ItemValueType::data_type>;
using index_type = typename ItemValueType::index_type; using index_type = typename ItemValueType::index_type;
static_assert(not std::is_same_v<data_type, bool>, "min cannot be called on boolean arrays"); static_assert(std::is_arithmetic_v<data_type>, "min cannot be called on non-arithmetic data");
static_assert(not std::is_same_v<data_type, bool>, "min cannot be called on boolean data");
class ItemValueMin class ItemValueMin
{ {
...@@ -113,7 +114,9 @@ max(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value) ...@@ -113,7 +114,9 @@ max(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value)
using data_type = std::remove_const_t<typename ItemValueType::data_type>; using data_type = std::remove_const_t<typename ItemValueType::data_type>;
using index_type = typename ItemValueType::index_type; using index_type = typename ItemValueType::index_type;
static_assert(not std::is_same_v<data_type, bool>, "min cannot be called on boolean arrays"); static_assert(std::is_arithmetic_v<data_type>, "max cannot be called on non arithmetic data");
static_assert(not std::is_same_v<data_type, bool>, "max cannot be called on boolean data");
class ItemValueMax class ItemValueMax
{ {
private: private:
...@@ -205,7 +208,7 @@ sum(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value) ...@@ -205,7 +208,7 @@ sum(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value)
using data_type = std::remove_const_t<typename ItemValueType::data_type>; using data_type = std::remove_const_t<typename ItemValueType::data_type>;
using index_type = typename ItemValueType::index_type; using index_type = typename ItemValueType::index_type;
static_assert(not std::is_same_v<data_type, bool>, "sum cannot be called on boolean arrays"); static_assert(not std::is_same_v<data_type, bool>, "sum cannot be called on boolean data");
class ItemValueSum class ItemValueSum
{ {
......
...@@ -189,6 +189,9 @@ min(const Array<DataType>& array) ...@@ -189,6 +189,9 @@ min(const Array<DataType>& array)
using data_type = std::remove_const_t<typename ArrayType::data_type>; using data_type = std::remove_const_t<typename ArrayType::data_type>;
using index_type = typename ArrayType::index_type; using index_type = typename ArrayType::index_type;
static_assert(std::is_arithmetic_v<data_type>, "min cannot be called on non-arithmetic data");
static_assert(not std::is_same_v<data_type, bool>, "min cannot be called on boolean data");
class ArrayMin class ArrayMin
{ {
private: private:
...@@ -249,6 +252,9 @@ max(const Array<DataType>& array) ...@@ -249,6 +252,9 @@ max(const Array<DataType>& array)
using data_type = std::remove_const_t<typename ArrayType::data_type>; using data_type = std::remove_const_t<typename ArrayType::data_type>;
using index_type = typename ArrayType::index_type; using index_type = typename ArrayType::index_type;
static_assert(std::is_arithmetic_v<data_type>, "max cannot be called on non-arithmetic data");
static_assert(not std::is_same_v<data_type, bool>, "max cannot be called on boolean data");
class ArrayMax class ArrayMax
{ {
private: private:
...@@ -309,6 +315,8 @@ sum(const Array<DataType>& array) ...@@ -309,6 +315,8 @@ sum(const Array<DataType>& array)
using data_type = std::remove_const_t<DataType>; using data_type = std::remove_const_t<DataType>;
using index_type = typename ArrayType::index_type; using index_type = typename ArrayType::index_type;
static_assert(not std::is_same_v<data_type, bool>, "sum cannot be called on boolean data");
class ArraySum class ArraySum
{ {
private: private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment