Skip to content
Snippets Groups Projects
Commit f424f583 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

Use helper classes as is_same_v and the like.

is_same_v<> for is_same<>::value
decay_t<> for decay<>::type
is_integral_v<> for is_integral<>::value
invoke_result_t<> for invoke_result<>::type
parent a9e1cb31
No related branches found
No related tags found
No related merge requests found
......@@ -67,8 +67,8 @@ public:
std::vector<T> const& vec)
{
static_assert(
std::is_same<T, std::string>::value ||
std::is_same<T, double>::value || std::is_same<T, int>::value,
std::is_same_v<T, std::string> || std::is_same_v<T, double> ||
std::is_same_v<T, int>,
"CsvInterface can only write vectors of strings, doubles or ints.");
if (!_data.empty())
......
......@@ -51,12 +51,11 @@
/// A type used for indexing of global vectors and matrices. It is equal to the
/// GlobalMatrix::IndexType and the GlobalVector::IndexType.
static_assert(std::is_integral<GlobalMatrix::IndexType>::value,
static_assert(std::is_integral_v<GlobalMatrix::IndexType>,
"The index type for global matrices is not an integral type.");
static_assert(std::is_integral<GlobalVector::IndexType>::value,
static_assert(std::is_integral_v<GlobalVector::IndexType>,
"The index type for global vectors is not an integral type.");
static_assert(std::is_same<GlobalMatrix::IndexType,
GlobalVector::IndexType>::value,
static_assert(std::is_same_v<GlobalMatrix::IndexType, GlobalVector::IndexType>,
"The global matrix and vector index types do not match.");
// Both types are integral types and equal, define a single GlobalIndexType.
using GlobalIndexType = GlobalMatrix::IndexType;
......
......@@ -51,10 +51,9 @@ public:
RegulaFalsi(Function const& f, double a, double b)
: _f(f), _a(a), _b(b), _fa(f(a)), _fb(f(b))
{
static_assert(
std::is_same<double, decltype(f(0.0))>::value,
"Using this class for functions that do not return double"
" involves a lot of casts. Hence it is disabled.");
static_assert(std::is_same_v<double, decltype(f(0.0))>,
"Using this class for functions that do not return double"
" involves a lot of casts. Hence it is disabled.");
if (detail::almost_zero(_fa)) {
_b = _a;
......
......@@ -83,7 +83,7 @@ namespace ODE
*/
class CVodeSolverImpl final
{
static_assert(std::is_same<realtype, double>::value,
static_assert(std::is_same_v<realtype, double>,
"CVode's realtype is not the same as double");
public:
......
......@@ -80,8 +80,8 @@ class ExtrapolatableLocalAssemblerCollection
public:
//! LocalAssemblerCollection contains many LocalAssembler's.
using LocalAssembler =
typename std::decay<decltype(*std::declval<LocalAssemblerCollection>()
[static_cast<std::size_t>(0)])>::type;
typename std::decay_t<decltype(*std::declval<LocalAssemblerCollection>()
[static_cast<std::size_t>(0)])>;
static_assert(std::is_base_of<ExtrapolatableElement, LocalAssembler>::value,
"Local assemblers used for extrapolation must be derived "
......
......@@ -26,8 +26,8 @@ GenericNaturalBoundaryCondition<BoundaryConditionData,
unsigned const global_dim, MeshLib::Mesh const& bc_mesh, Data&& data)
: _data(std::forward<Data>(data)), _bc_mesh(bc_mesh)
{
static_assert(std::is_same<typename std::decay<BoundaryConditionData>::type,
typename std::decay<Data>::type>::value,
static_assert(std::is_same_v<typename std::decay_t<BoundaryConditionData>,
typename std::decay_t<Data>>,
"Type mismatch between declared and passed BC data.");
// check basic data consistency
......
......@@ -50,22 +50,22 @@ struct SecondaryVariableFunctions final
{
// Used to detect nasty implicit conversions.
static_assert(
std::is_same<
std::is_same_v<
GlobalVector const&,
typename std::invoke_result<
typename std::invoke_result_t<
F1, double const, std::vector<GlobalVector*> const&,
std::vector<NumLib::LocalToGlobalIndexMap const*> const&,
std::unique_ptr<GlobalVector>&>::type>::value,
std::unique_ptr<GlobalVector>&>>,
"The function eval_field_ does not return a const reference"
" to a GlobalVector");
static_assert(
std::is_same<
std::is_same_v<
GlobalVector const&,
typename std::invoke_result<
typename std::invoke_result_t<
F2, double const, std::vector<GlobalVector*> const&,
std::vector<NumLib::LocalToGlobalIndexMap const*> const&,
std::unique_ptr<GlobalVector>&>::type>::value,
std::unique_ptr<GlobalVector>&>>,
"The function eval_residuals_ does not return a const reference"
" to a GlobalVector");
}
......@@ -78,12 +78,12 @@ struct SecondaryVariableFunctions final
{
// Used to detect nasty implicit conversions.
static_assert(
std::is_same<
std::is_same_v<
GlobalVector const&,
typename std::invoke_result<
typename std::invoke_result_t<
F1, double const, std::vector<GlobalVector*> const&,
std::vector<NumLib::LocalToGlobalIndexMap const*> const&,
std::unique_ptr<GlobalVector>&>::type>::value,
std::unique_ptr<GlobalVector>&>>,
"The function eval_field_ does not return a const reference"
" to a GlobalVector");
}
......
......@@ -145,13 +145,10 @@ private:
using NodalMatrixType = typename LAT::LocalMatrix;
using NodalVectorType = typename LAT::LocalVector;
static_assert(
std::is_same<NodalMatrixType, typename LAT::LocalMatrix>::value,
"local matrix and data traits matrix do not coincide");
static_assert(
std::is_same<NodalVectorType, typename LAT::LocalVector>::value,
"local vector and data traits vector do not coincide");
static_assert(std::is_same_v<NodalMatrixType, typename LAT::LocalMatrix>,
"local matrix and data traits matrix do not coincide");
static_assert(std::is_same_v<NodalVectorType, typename LAT::LocalVector>,
"local vector and data traits vector do not coincide");
};
} // namespace TES
......
......@@ -53,10 +53,13 @@ TYPED_TEST(MathLibRegulaFalsi, QuadraticFunction)
auto const error = std::abs(f(rf.getResult()));
if (!std::is_same<NL::Unmodified, TypeParam>::value) {
if (!std::is_same_v<NL::Unmodified, TypeParam>)
{
EXPECT_GT(std::numeric_limits<double>::epsilon(), old_range);
EXPECT_GT(std::numeric_limits<double>::epsilon(), error);
} else {
}
else
{
// The unmodified regula falsi method converges very slowly.
EXPECT_GT(100.0*std::numeric_limits<double>::epsilon(), error);
}
......
......@@ -123,7 +123,7 @@ private:
};
template <typename TimeDisc, typename ODE, NumLib::NonlinearSolverTag NLTag>
typename std::enable_if<std::is_same<TimeDisc, NumLib::BackwardEuler>::value,
typename std::enable_if<std::is_same_v<TimeDisc, NumLib::BackwardEuler>,
Solution>::type
run_test_case(const unsigned num_timesteps)
{
......
......@@ -46,20 +46,20 @@ struct NaturalPointGenerator
result_type intervalMap(result_type const& tuple) const
{
if (std::is_same<ShapeFunction, NumLib::ShapeLine2>::value ||
std::is_same<ShapeFunction, NumLib::ShapeLine3>::value ||
std::is_same<ShapeFunction, NumLib::ShapeQuad4>::value ||
std::is_same<ShapeFunction, NumLib::ShapeQuad8>::value ||
std::is_same<ShapeFunction, NumLib::ShapeQuad9>::value ||
std::is_same<ShapeFunction, NumLib::ShapeHex8>::value ||
std::is_same<ShapeFunction, NumLib::ShapeHex20>::value)
if (std::is_same_v<ShapeFunction, NumLib::ShapeLine2> ||
std::is_same_v<ShapeFunction, NumLib::ShapeLine3> ||
std::is_same_v<ShapeFunction, NumLib::ShapeQuad4> ||
std::is_same_v<ShapeFunction, NumLib::ShapeQuad8> ||
std::is_same_v<ShapeFunction, NumLib::ShapeQuad9> ||
std::is_same_v<ShapeFunction, NumLib::ShapeHex8> ||
std::is_same_v<ShapeFunction, NumLib::ShapeHex20>)
{
return tuple;
}
if (std::is_same<ShapeFunction, NumLib::ShapeTri3>::value ||
std::is_same<ShapeFunction, NumLib::ShapeTri6>::value ||
std::is_same<ShapeFunction, NumLib::ShapeTet4>::value ||
std::is_same<ShapeFunction, NumLib::ShapeTet10>::value)
if (std::is_same_v<ShapeFunction, NumLib::ShapeTri3> ||
std::is_same_v<ShapeFunction, NumLib::ShapeTri6> ||
std::is_same_v<ShapeFunction, NumLib::ShapeTet4> ||
std::is_same_v<ShapeFunction, NumLib::ShapeTet10>)
{
// Map square (x, y) \in [-1, 1]^2 to a triangle such that x,y
// \in [0, 1], and x+y \in [0, 2/2].
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment