diff --git a/src/OpenFOAM/primitives/predicates/predicates.H b/src/OpenFOAM/primitives/predicates/predicates.H index a44b4eec7e2749ab83e1b396e0489aa967977b5c..04ddd6a64b409a60017a8598ff7653e79eaca4d4 100644 --- a/src/OpenFOAM/primitives/predicates/predicates.H +++ b/src/OpenFOAM/primitives/predicates/predicates.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,7 @@ Namespace Foam::predicates Description - Various constant predicate types. + Constant predicate types. SourceFiles predicates.H @@ -36,6 +36,7 @@ SourceFiles #define predicates_H #include <string> +#include <type_traits> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,42 +51,29 @@ namespace predicates \*---------------------------------------------------------------------------*/ //- Unary and binary predicates that always return true, useful for templating. -struct always +struct always : std::true_type { - typedef always value_type; - - //- Null constructible - inline always() - {} - - //- Evaluated as a bool - // \return true - inline operator bool() const - { - return true; - } - //- Unary predicate // \return true template<class T> - inline bool operator()(const T&) const + constexpr bool operator()(const T&) const noexcept { - return true; + return value; } //- Binary predicate // \return true template<class T1, class T2> - inline bool operator()(const T1&, const T2&) const + constexpr bool operator()(const T1&, const T2&) const noexcept { - return true; + return value; } //- String match // \return true - inline bool match(const std::string&, bool literal=false) const + constexpr bool match(const std::string&, bool literal=false) const noexcept { - return true; + return value; } }; @@ -95,42 +83,29 @@ struct always \*---------------------------------------------------------------------------*/ //- Unary and binary predicates that never return true, useful for templating. -struct never +struct never : std::false_type { - typedef never value_type; - - //- Null constructible - inline never() - {} - - //- Evaluated as a bool - // \return false - inline operator bool() const - { - return false; - } - //- Unary predicate // \return false template<class T> - inline bool operator()(const T&) const + constexpr bool operator()(const T&) const noexcept { - return false; + return value; } //- Binary predicate // \return false template<class T1, class T2> - inline bool operator()(const T1&, const T2&) const + constexpr bool operator()(const T1&, const T2&) const noexcept { - return false; + return value; } //- String match // \return false - inline bool match(const std::string&, bool literal=false) const + constexpr bool match(const std::string&, bool literal=false) const noexcept { - return false; + return value; } }; diff --git a/src/finiteVolume/volMesh/volMesh.H b/src/finiteVolume/volMesh/volMesh.H index d132df1070ff0876acfc76cc87abb802bd65bdbb..d5e6fb7377bbbb9297fc7d9ccf7037c511927f75 100644 --- a/src/finiteVolume/volMesh/volMesh.H +++ b/src/finiteVolume/volMesh/volMesh.H @@ -27,12 +27,6 @@ Class Description Mesh data needed to do the Finite Volume discretisation. -Class - Foam::isVolMesh - -Description - Supports static assertion that a template argument is of type volMesh. - \*---------------------------------------------------------------------------*/ #ifndef volMesh_H @@ -56,7 +50,6 @@ class volMesh : public GeoMesh<fvMesh> { - public: // Constructors @@ -71,15 +64,15 @@ public: // Member Functions //- Return size - label size() const + static label size(const Mesh& mesh) { - return size(mesh_); + return mesh.nCells(); } //- Return size - static label size(const Mesh& mesh) + label size() const { - return mesh.nCells(); + return size(mesh_); } //- Return cell centres @@ -94,18 +87,10 @@ public: Class isVolMesh Declaration \*---------------------------------------------------------------------------*/ -template<class T> -class isVolMesh -: - public std::false_type -{}; - +//- Template argument for type volMesh. +template<class> struct isVolMesh : std::false_type {}; -template<> -class isVolMesh<volMesh> -: - public std::true_type -{}; +template<> struct isVolMesh<volMesh> : std::true_type {}; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //