mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: upgrade to use some C++17 constructs
- 'if constexpr (...)' * instead of std::enable_if * terminate template recursion * compile-time elimination of code - use C++14 '_t', '_v' versions, eg, std::is_integral_v<T> instead of std::is_integral<T>::value - std::begin, std::end, std::void_t instead of prev stdFoam versions - provide is_contiguous_v<..> as short form of is_contiguous<..>::value with the additional benefit of removing any cv qualifiers. ENH: include is_rotational_vectorspace trait - tests for vector-space and nComponents > 1 (ie, not sphericalTensor) ENH: improve robustness of pTraits_.. tests by removing cv qualifiers
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,10 +42,9 @@ Note
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "complex.H"
|
||||
#include "RectangularMatrix.H"
|
||||
#include "SquareMatrix.H"
|
||||
#include "scalar.H"
|
||||
#include "complex.H"
|
||||
#include "IOmanip.H"
|
||||
#include "TestTools.H"
|
||||
|
||||
@ -809,36 +808,34 @@ void test_global_opers(Type)
|
||||
|
||||
// Do compile-time recursion over the given types
|
||||
template<std::size_t I = 0, typename... Tp>
|
||||
inline typename std::enable_if<I == sizeof...(Tp), void>::type
|
||||
run_tests(const std::tuple<Tp...>& types, const List<word>& typeID){}
|
||||
|
||||
|
||||
template<std::size_t I = 0, typename... Tp>
|
||||
inline typename std::enable_if<I < sizeof...(Tp), void>::type
|
||||
run_tests(const std::tuple<Tp...>& types, const List<word>& typeID)
|
||||
void run_tests(const std::tuple<Tp...>& types, const List<word>& names)
|
||||
{
|
||||
Info<< nl << " ## Test constructors: "<< typeID[I] <<" ##" << nl;
|
||||
test_constructors(std::get<I>(types));
|
||||
if constexpr (I < sizeof...(Tp))
|
||||
{
|
||||
const auto& name = names[I];
|
||||
|
||||
Info<< nl << " ## Test member functions: "<< typeID[I] <<" ##" << nl;
|
||||
test_member_funcs(std::get<I>(types));
|
||||
Info<< nl << " ## Test constructors: " << name << " ##" << nl;
|
||||
test_constructors(std::get<I>(types));
|
||||
|
||||
Info<< nl << " ## Test member opers: "<< typeID[I] <<" ##" << nl;
|
||||
test_member_opers(std::get<I>(types));
|
||||
Info<< nl << " ## Test member functions: " << name << " ##" << nl;
|
||||
test_member_funcs(std::get<I>(types));
|
||||
|
||||
Info<< nl << " ## Test global functions: "<< typeID[I] << " ##" << nl;
|
||||
test_global_funcs(std::get<I>(types));
|
||||
Info<< nl << " ## Test member opers: " << name << " ##" << nl;
|
||||
test_member_opers(std::get<I>(types));
|
||||
|
||||
Info<< nl << " ## Test global operators: "<< typeID[I] << " ##" << nl;
|
||||
test_global_opers(std::get<I>(types));
|
||||
Info<< nl << " ## Test global functions: " << name << " ##" << nl;
|
||||
test_global_funcs(std::get<I>(types));
|
||||
|
||||
Info<< nl << " ## Test friend funcs: "<< typeID[I] <<" ##" << nl;
|
||||
test_friend_funcs(std::get<I>(types));
|
||||
Info<< nl << " ## Test global operators: " << name << " ##" << nl;
|
||||
test_global_opers(std::get<I>(types));
|
||||
|
||||
run_tests<I + 1, Tp...>(types, typeID);
|
||||
Info<< nl << " ## Test friend funcs: " << name << " ##" << nl;
|
||||
test_friend_funcs(std::get<I>(types));
|
||||
|
||||
run_tests<I + 1, Tp...>(types, names);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Main Program * * * * * * * * * * * * * * * //
|
||||
|
||||
int main()
|
||||
@ -852,8 +849,8 @@ int main()
|
||||
|
||||
const List<word> typeID
|
||||
({
|
||||
"RectangularMatrix<floatScalar>",
|
||||
"RectangularMatrix<doubleScalar>",
|
||||
"RectangularMatrix<float>",
|
||||
"RectangularMatrix<double>",
|
||||
"RectangularMatrix<complex>"
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user