From: Daniel Garcia-Sanchez Date: Tue, 30 Oct 2018 07:36:45 +0000 (+0100) Subject: Use overload instead of enable_if X-Git-Tag: v9.1.0-rc1~453^2~19 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=351b71b452e663a695fabd3be35ca63dfcbe3b4f;p=dealii.git Use overload instead of enable_if --- diff --git a/source/base/hdf5.cc b/source/base/hdf5.cc index 60287de5e1..8e8db82d8f 100644 --- a/source/base/hdf5.cc +++ b/source/base/hdf5.cc @@ -116,35 +116,27 @@ namespace HDF5 // // Instead of using functions with std::enable_if, "constexpr if" from C++17 // could be used - template - typename std::enable_if< - std::is_same>::value, - std::vector>::type - get_container_dimensions(const Container &data) + template + std::vector + get_container_dimensions(const std::vector &data) { return std::vector{data.size()}; } - template - typename std::enable_if< - std::is_same>::value, - std::vector>::type - get_container_dimensions(const Container &data) + template + std::vector + get_container_dimensions(const Vector &data) { return std::vector{data.size()}; } - template - typename std::enable_if< - std::is_same>::value, - std::vector>::type - get_container_dimensions(const Container &data) + template + std::vector + get_container_dimensions(const FullMatrix &data) { return std::vector{data.m(), data.n()}; } @@ -155,35 +147,27 @@ namespace HDF5 // For a std::vector the function returns int(vector_size) // For a Vector the function returns int(vector_size) // For a FullMatrix the function returns int(rows*columns) - template - typename std::enable_if< - std::is_same>::value, - unsigned int>::type - get_container_size(const Container &data) + template + unsigned int + get_container_size(const std::vector &data) { return static_cast(data.size()); } - template - typename std::enable_if< - std::is_same>::value, - unsigned int>::type - get_container_size(const Container &data) + template + unsigned int + get_container_size(const Vector &data) { return static_cast(data.size()); } - template - typename std::enable_if< - std::is_same>::value, - unsigned int>::type - get_container_size(const Container &data) + template + unsigned int + get_container_size(const FullMatrix &data) { return static_cast(data.m() * data.n()); } @@ -191,12 +175,9 @@ namespace HDF5 // This function returns the pointer to the raw data of a container - template - typename std::enable_if< - std::is_same>::value, - void *>::type - get_container_pointer(Container &data) + template + void * + get_container_pointer(std::vector &data) { // It is very important to pass the variable "data" by reference otherwise // the pointer will be wrong @@ -205,11 +186,9 @@ namespace HDF5 - template - typename std::enable_if< - std::is_same>::value, - void *>::type - get_container_pointer(Container &data) + template + void * + get_container_pointer(Vector &data) { // It is very important to pass the variable "data" by reference otherwise // the pointer will be wrong. @@ -219,12 +198,9 @@ namespace HDF5 - template - typename std::enable_if< - std::is_same>::value, - void *>::type - get_container_pointer(Container &data) + template + void * + get_container_pointer(FullMatrix &data) { // It is very important to pass the variable "data" by reference otherwise // the pointer will be wrong. @@ -237,12 +213,9 @@ namespace HDF5 // This function returns the pointer to the raw data of a container // The returned pointer is const, which means that it can be used only to // read the data - template - typename std::enable_if< - std::is_same>::value, - const void *>::type - get_container_const_pointer(const Container &data) + template + const void * + get_container_const_pointer(const std::vector &data) { // It is very important to pass the variable "data" by reference otherwise // the pointer will be wrong @@ -251,11 +224,9 @@ namespace HDF5 - template - typename std::enable_if< - std::is_same>::value, - const void *>::type - get_container_const_pointer(const Container &data) + template + const void * + get_container_const_pointer(const Vector &data) { // It is very important to pass the variable "data" by reference otherwise // the pointer will be wrong. @@ -265,12 +236,9 @@ namespace HDF5 - template - typename std::enable_if< - std::is_same>::value, - const void *>::type - get_container_const_pointer(const Container &data) + template + const void * + get_container_const_pointer(const FullMatrix &data) { // It is very important to pass the variable "data" by reference otherwise // the pointer will be wrong.