diff --git a/include/vclib/algorithms/create/dodecahedron.h b/include/vclib/algorithms/create/dodecahedron.h index bad930057..516c3e013 100644 --- a/include/vclib/algorithms/create/dodecahedron.h +++ b/include/vclib/algorithms/create/dodecahedron.h @@ -54,9 +54,7 @@ MeshType createDodecahedron(LogType& log = nullLogger) const ScalarType s2 = std::pow(fi, 2); const ScalarType s3 = 1; - if constexpr (isLoggerValid()) { - log.log(0, "Adding vertices to PolyMesh..."); - } + log.log(0, "Adding vertices to PolyMesh..."); mesh.addVertices( CoordType(-s1, -s1, s1), @@ -80,10 +78,8 @@ MeshType createDodecahedron(LogType& log = nullLogger) CoordType(s1, -s1, s1), CoordType(-s1, -s1, -s1)); - if constexpr (isLoggerValid()) { - log.log(50, "Vertices added to PolyMesh."); - log.log(50, "Adding faces to PolyMesh..."); - } + log.log(50, "Vertices added to PolyMesh."); + log.log(50, "Adding faces to PolyMesh..."); mesh.reserveFaces(12); mesh.addFace(14, 11, 18, 2, 1); @@ -99,9 +95,7 @@ MeshType createDodecahedron(LogType& log = nullLogger) mesh.addFace(16, 12, 11, 14, 5); mesh.addFace(18, 11, 12, 0, 10); - if constexpr (isLoggerValid()) { - log.log(100, "Faces added to PolyMesh."); - } + log.log(100, "Faces added to PolyMesh."); return mesh; } @@ -121,17 +115,13 @@ MeshType createDodecahedron(LogType& log = nullLogger) template MeshType createDodecahedron(LogType& log = nullLogger) { - if constexpr (isLoggerValid()) { - log.startNewTask(0, 75, "Create Polygonal Dodecahedron."); - } + log.startNewTask(0, 75, "Create Polygonal Dodecahedron."); detail::TMPSimplePolyMesh pmesh = createDodecahedron(log); - if constexpr (isLoggerValid()) { - log.endTask("Create Polygonal Dodecahedron."); - log.log(75, "Copying vertices into TriMesh..."); - } + log.endTask("Create Polygonal Dodecahedron."); + log.log(75, "Copying vertices into TriMesh..."); MeshType mesh; using ST = MeshType::VertexType::CoordType::ScalarType; @@ -140,10 +130,8 @@ MeshType createDodecahedron(LogType& log = nullLogger) mesh.addVertex(v.coord().cast()); } - if constexpr (isLoggerValid()) { - log.log(80, "Vertices copied into TriMesh."); - log.log(80, "Triangularize and copy Faces into TriMesh..."); - } + log.log(80, "Vertices copied into TriMesh."); + log.log(80, "Triangularize and copy Faces into TriMesh..."); for (const auto& f : pmesh.faces()) { std::vector ind = earCut(f); @@ -155,9 +143,7 @@ MeshType createDodecahedron(LogType& log = nullLogger) } } - if constexpr (isLoggerValid()) { - log.log(100, "Faces triangularized and copied into TriMesh."); - } + log.log(100, "Faces triangularized and copied into TriMesh."); return mesh; } diff --git a/include/vclib/algorithms/distance/mesh.h b/include/vclib/algorithms/distance/mesh.h index a90b86db4..267db8351 100644 --- a/include/vclib/algorithms/distance/mesh.h +++ b/include/vclib/algorithms/distance/mesh.h @@ -23,8 +23,6 @@ #ifndef VCL_ALGORITHMS_DISTANCE_MESH_H #define VCL_ALGORITHMS_DISTANCE_MESH_H -#include - #include #include #include @@ -69,16 +67,11 @@ HausdorffDistResult hausdorffDist( HausdorffDistResult res; res.histogram = Histogramd(0, m.boundingBox().diagonal() / 100, 100); - if constexpr (vcl::isLoggerValid()) { - log.log( - 5, - "Computing distances for " + std::to_string(s.size()) + - " samples..."); - } + log.log( + 5, + "Computing distances for " + std::to_string(s.size()) + " samples..."); - if constexpr (vcl::isLoggerValid()) { - log.startProgress("", s.size()); - } + log.startProgress("", s.size()); std::mutex mutex; @@ -102,26 +95,19 @@ HausdorffDistResult hausdorffDist( mutex.unlock(); } - if constexpr (vcl::isLoggerValid()) { - mutex.lock(); - ++i; - log.progress(i); - mutex.unlock(); - } + log.progress(++i); // } }); - if constexpr (vcl::isLoggerValid()) { - log.endProgress(); - log.log(100, "Computed " + std::to_string(ns) + " distances."); - if (ns != s.size()) { - log.log( - 100, - LogType::WARNING, - std::to_string(s.size() - ns) + - " samples were not counted because no closest vertex/face " - "was found."); - } + log.endProgress(); + log.log(100, "Computed " + std::to_string(ns) + " distances."); + if (ns != s.size()) { + log.log( + 100, + LogType::WARNING, + std::to_string(s.size() - ns) + + " samples were not counted because no closest vertex/face " + "was found."); } res.meanDist /= ns; @@ -145,16 +131,13 @@ HausdorffDistResult samplerMeshHausdorff( if constexpr (HasName) { meshName = m.name(); } - if constexpr (vcl::isLoggerValid()) { - log.log(0, "Building Grid on " + meshName + " vertices..."); - } + + log.log(0, "Building Grid on " + meshName + " vertices..."); vcl::StaticGrid3 grid(m.vertices() | views::addrOf); grid.build(); - if constexpr (vcl::isLoggerValid()) { - log.log(5, "Grid built."); - } + log.log(5, "Grid built."); return hausdorffDist(m, s, grid, log); } @@ -177,31 +160,24 @@ HausdorffDistResult samplerMeshHausdorff( meshName = m.name(); } if (m.faceNumber() == 0) { - if constexpr (vcl::isLoggerValid()) { - log.log(0, "Building Grid on " + meshName + " vertices..."); - } + log.log(0, "Building Grid on " + meshName + " vertices..."); vcl::StaticGrid3 grid( m.vertices() | views::addrOf); grid.build(); - if constexpr (vcl::isLoggerValid()) { - log.log(5, "Grid built."); - } + log.log(5, "Grid built."); return hausdorffDist(m, s, grid, log); } else { - if constexpr (vcl::isLoggerValid()) { - log.log(0, "Building Grid on " + meshName + " faces..."); - } + log.log(0, "Building Grid on " + meshName + " faces..."); + vcl::StaticGrid3 grid( m.faces() | views::addrOf); grid.build(); - if constexpr (vcl::isLoggerValid()) { - log.log(5, "Grid built."); - } + log.log(5, "Grid built."); return hausdorffDist(m, s, grid, log); } @@ -231,12 +207,10 @@ HausdorffDistResult hausdorffDistance( meshName2 = m2.name(); } - if constexpr (vcl::isLoggerValid()) { - log.log( - 0, - "Sampling " + meshName2 + " with " + std::to_string(nSamples) + - " samples..."); - } + log.log( + 0, + "Sampling " + meshName2 + " with " + std::to_string(nSamples) + + " samples..."); if constexpr (METHOD == HAUSDORFF_VERTEX_UNIFORM) { sampler = vcl::vertexUniformPointSampling( @@ -250,19 +224,13 @@ HausdorffDistResult hausdorffDistance( m2, nSamples, birth, deterministic); } - if constexpr (vcl::isLoggerValid()) { - log.log(5, meshName2 + " sampled."); - log.startNewTask( - 5, - 100, - "Computing distance between samples and " + meshName1 + "..."); - } + log.log(5, meshName2 + " sampled."); + log.startNewTask( + 5, 100, "Computing distance between samples and " + meshName1 + "..."); auto res = samplerMeshHausdorff(m1, sampler, log); - if constexpr (vcl::isLoggerValid()) { - log.endTask("Distance between samples and " + meshName1 + " computed."); - } + log.endTask("Distance between samples and " + meshName1 + " computed."); return res; } diff --git a/include/vclib/algorithms/import/matrix.h b/include/vclib/algorithms/import/matrix.h index d6f1bd64a..768558065 100644 --- a/include/vclib/algorithms/import/matrix.h +++ b/include/vclib/algorithms/import/matrix.h @@ -52,7 +52,7 @@ void importElementNormalsFromMatrix(MeshType& mesh, const NMatrix& normals) if (normals.cols() != 3) throw WrongSizeException( - "The input " + std::string(elementEnumString()) + + "The input " + elementEnumString() + " normal matrix must have 3 columns"); // matrix rows must be equal to the number of elements of the given type @@ -60,7 +60,7 @@ void importElementNormalsFromMatrix(MeshType& mesh, const NMatrix& normals) throw WrongSizeException( "The input normal matrix must have the same number of rows " "as the number of " + - std::string(elementEnumString()) + " element in the mesh"); + elementEnumString() + " element in the mesh"); enableIfPerElementComponentOptional(mesh); requirePerElementComponent(mesh); @@ -79,7 +79,7 @@ void importElementColorsFromMatrix(MeshType& mesh, const CMatrix& colors) if (colors.cols() != 3 && colors.cols() != 4) throw WrongSizeException( - "The input " + std::string(elementEnumString()) + + "The input " + elementEnumString() + " color matrix must have 3 or 4 columns"); // matrix rows must be equal to the number of elements of the given type @@ -87,7 +87,7 @@ void importElementColorsFromMatrix(MeshType& mesh, const CMatrix& colors) throw WrongSizeException( "The input color matrix must have the same number of rows " "as the number of " + - std::string(elementEnumString()) + " element in the mesh"); + elementEnumString() + " element in the mesh"); enableIfPerElementComponentOptional(mesh); requirePerElementComponent(mesh); diff --git a/include/vclib/algorithms/update/curvature.h b/include/vclib/algorithms/update/curvature.h index 4ecfc5ac9..9051a62b2 100644 --- a/include/vclib/algorithms/update/curvature.h +++ b/include/vclib/algorithms/update/curvature.h @@ -67,18 +67,14 @@ void updatePrincipalCurvatureTaubin95(MeshType& m, LogType& log) bool isBorder; }; - if constexpr (vcl::isLoggerValid()) { - log.log(0, "Updating per vertex normals..."); - } + log.log(0, "Updating per vertex normals..."); vcl::updatePerVertexNormalsAngleWeighted(m); vcl::normalizePerVertexNormals(m); - if constexpr (vcl::isLoggerValid()) { - log.log(5, "Computing per vertex curvature..."); - // log every 5%, starting from 5% to 100% - log.startProgress("", m.vertexNumber(), 5, 5, 100); - } + log.log(5, "Computing per vertex curvature..."); + // log every 5%, starting from 5% to 100% + log.startProgress("", m.vertexNumber(), 5, 5, 100); for (VertexType& v : m.vertices()) { std::vector weights; @@ -232,15 +228,11 @@ void updatePrincipalCurvatureTaubin95(MeshType& m, LogType& log) v.principalCurvature().maxValue() = principalCurv1; v.principalCurvature().minValue() = principalCurv2; - if constexpr (vcl::isLoggerValid()) { - log.progress(m.index(v)); - } + log.progress(m.index(v)); } - if constexpr (vcl::isLoggerValid()) { - log.endProgress(); - log.log(100, "Per vertex curvature computed."); - } + log.endProgress(); + log.log(100, "Per vertex curvature computed."); } /** @@ -274,17 +266,13 @@ void updatePrincipalCurvaturePCA( VGrid pGrid; ScalarType area; - if constexpr (vcl::isLoggerValid()) { - log.log(0, "Updating per vertex normals..."); - } + log.log(0, "Updating per vertex normals..."); vcl::updatePerVertexNormalsAngleWeighted(m); vcl::normalizePerVertexNormals(m); - if constexpr (vcl::isLoggerValid()) { - log.log(0, "Computing per vertex curvature..."); - log.startProgress("", m.vertexNumber()); - } + log.log(0, "Computing per vertex curvature..."); + log.startProgress("", m.vertexNumber()); if (montecarloSampling) { area = vcl::surfaceArea(m); @@ -377,16 +365,12 @@ void updatePrincipalCurvaturePCA( v.principalCurvature().maxDir()); } - if constexpr (vcl::isLoggerValid()) { - log.progress(m.index(v)); - } + log.progress(m.index(v)); //} }); - if constexpr (vcl::isLoggerValid()) { - log.endProgress(); - log.log(100, "Per vertex curvature computed."); - } + log.endProgress(); + log.log(100, "Per vertex curvature computed."); } template diff --git a/include/vclib/algorithms/update/normal.h b/include/vclib/algorithms/update/normal.h index a89834ddd..6fb7e3a39 100644 --- a/include/vclib/algorithms/update/normal.h +++ b/include/vclib/algorithms/update/normal.h @@ -39,10 +39,7 @@ void normalizePerElementNormals( { vcl::requirePerElementComponent(mesh); - if constexpr (isLoggerValid()) { - log.log( - 0, "Normalizing per-" + elementEnumString() + " normals"); - } + log.log(0, "Normalizing per-" + elementEnumString() + " normals"); for (auto& elem : mesh.template elements()) { try { @@ -50,9 +47,7 @@ void normalizePerElementNormals( } catch (const std::exception& e) { if (noThrow) { - if constexpr (isLoggerValid()) { - log.log(LogType::WARNING, e.what()); - } + log.log(LogType::WARNING, e.what()); } else { throw e; @@ -60,11 +55,8 @@ void normalizePerElementNormals( } } - if constexpr (isLoggerValid()) { - log.log( - 100, - "Per-" + elementEnumString() + " normals normalized."); - } + log.log( + 100, "Per-" + elementEnumString() + " normals normalized."); } template diff --git a/include/vclib/concepts/logger.h b/include/vclib/concepts/logger.h index 5a8519a9a..cdfeaedaa 100644 --- a/include/vclib/concepts/logger.h +++ b/include/vclib/concepts/logger.h @@ -29,8 +29,6 @@ namespace vcl { -class NullLogger; - /** * @brief The LoggerConcept is evaluated to true when the input type is a valid * Logger type. @@ -42,7 +40,6 @@ class NullLogger; */ template concept LoggerConcept = - std::is_same::value || requires (T o, const T& co, std::string msg, typename T::LogLevel lvl) { // clang-format off typename T::LogLevel; @@ -67,7 +64,12 @@ concept LoggerConcept = { o.log(uint(), msg) } -> std::same_as; { o.log(uint(), lvl, msg) } -> std::same_as; - { o.startProgress(msg, uint(), uint(), uint(), uint())} -> std::same_as; + + { o.startProgress(msg, uint()) } -> std::same_as; + { o.startProgress(msg, uint(), uint()) } -> std::same_as; + { o.startProgress(msg, uint(), uint(), uint()) } -> std::same_as; + { o.startProgress(msg, uint(), uint(), uint(), uint()) } -> + std::same_as; { o.endProgress() } -> std::same_as; { o.progress(uint()) } -> std::same_as; // clang-format off diff --git a/include/vclib/io/mesh/obj/load.h b/include/vclib/io/mesh/obj/load.h index b6c788a19..f9b93107e 100644 --- a/include/vclib/io/mesh/obj/load.h +++ b/include/vclib/io/mesh/obj/load.h @@ -484,11 +484,9 @@ void loadObj( detail::loadObjMaterials(materialMap, m, mtlfile); } catch (vcl::CannotOpenFileException) { - if constexpr (isLoggerValid()) { - log.log( - LogType::WARNING, - "Cannot open material file " + mtlfile); - } + log.log( + LogType::WARNING, + "Cannot open material file " + mtlfile); } } // use a new material - change currentMaterial @@ -499,11 +497,9 @@ void loadObj( currentMaterial = it->second; } else { // material not found - warning - if constexpr (isLoggerValid()) { - log.log( - LogType::WARNING, - "Material " + matname + " not found."); - } + log.log( + LogType::WARNING, + "Material " + matname + " not found."); } } // read vertex (and for some non-standard obj files, also vertex diff --git a/include/vclib/io/mesh/ply/detail/ply.h b/include/vclib/io/mesh/ply/detail/ply.h index b3e60bde7..32426b428 100644 --- a/include/vclib/io/mesh/ply/detail/ply.h +++ b/include/vclib/io/mesh/ply/detail/ply.h @@ -23,8 +23,6 @@ #ifndef VCL_IO_PLY_H #define VCL_IO_PLY_H -#include -#include #include #include diff --git a/include/vclib/io/mesh/stl/load.h b/include/vclib/io/mesh/stl/load.h index 886383b78..82a2bd241 100644 --- a/include/vclib/io/mesh/stl/load.h +++ b/include/vclib/io/mesh/stl/load.h @@ -117,9 +117,7 @@ void readStlBin( fp.seekg(80); // size of the header uint fnum = io::readUInt(fp); - if constexpr (vcl::isLoggerValid()) { - log.startProgress("Loading STL file", fnum); - } + log.startProgress("Loading STL file", fnum); m.addVertices(fnum * 3); if constexpr (HasFaces) { @@ -168,13 +166,9 @@ void readStlBin( vi += 3; - if constexpr (vcl::isLoggerValid()) { - log.progress(i); - } - } - if constexpr (vcl::isLoggerValid()) { - log.endProgress(); + log.progress(i); } + log.endProgress(); } template @@ -249,15 +243,11 @@ void readStlAscii( } tokens = readAndTokenizeNextNonEmptyLineNoThrow(fp); - if constexpr (vcl::isLoggerValid()) { - log.progress(fp.tellg()); - } + log.progress(fp.tellg()); } while (fp); } - if constexpr (vcl::isLoggerValid()) { - log.endProgress(); - } + log.endProgress(); } } // namespace detail @@ -312,9 +302,7 @@ void loadStl( loadedInfo.setFaceNormals(); } - if constexpr (isLoggerValid()) { - log.log(0, "Loading STL file"); - } + log.log(0, "Loading STL file"); if (isBinary) detail::readStlBin( @@ -323,9 +311,7 @@ void loadStl( detail::readStlAscii( m, inputStlStream, loadedInfo, log, enableOptionalComponents); - if constexpr (isLoggerValid()) { - log.log(100, "STL file loaded"); - } + log.log(100, "STL file loaded"); } /** @@ -487,18 +473,14 @@ void loadStl( LogType& log = nullLogger, bool enableOptionalComponents = true) { - if constexpr (isLoggerValid()) { - log.log(0, "Checking STL file"); - } + log.log(0, "Checking STL file"); bool isBinary; std::size_t filesize; if (detail::isBinStlMalformed(filename, isBinary, filesize)) throw MalformedFileException(filename + " is malformed."); - if constexpr (isLoggerValid()) { - log.log(0, "Opening STL file"); - } + log.log(0, "Opening STL file"); std::ifstream fp = openInputFileStream(filename); diff --git a/include/vclib/io/mesh/stl/save.h b/include/vclib/io/mesh/stl/save.h index 36965b3f3..9d311b0d3 100644 --- a/include/vclib/io/mesh/stl/save.h +++ b/include/vclib/io/mesh/stl/save.h @@ -112,9 +112,7 @@ void saveStl( // available in the mesh. meshInfo = info.intersect(meshInfo); - if constexpr (isLoggerValid()) { - log.log(0, "Saving STL file"); - } + log.log(0, "Saving STL file"); detail::writeStlHeader(fp, magicsMode, binary); @@ -125,9 +123,7 @@ void saveStl( io::writeInt(fp, m.faceNumber()); } - if constexpr (vcl::isLoggerValid()) { - log.startProgress("Loading STL file", m.faces()); - } + log.startProgress("Loading STL file", m.faceNumber()); for (const FaceType& f : m.faces()) { // For each triangle write the normal, the three coords and a short @@ -168,13 +164,10 @@ void saveStl( } } - if constexpr (vcl::isLoggerValid()) { - log.progress(m.index(f)); - } - } - if constexpr (vcl::isLoggerValid()) { - log.endProgress(); + log.progress(m.index(f)); } + + log.endProgress(); } if (!binary) { diff --git a/include/vclib/math/base.h b/include/vclib/math/base.h index ee2dd5354..49407021e 100644 --- a/include/vclib/math/base.h +++ b/include/vclib/math/base.h @@ -23,7 +23,7 @@ #ifndef VCL_MATH_BASE_H #define VCL_MATH_BASE_H -#include +#include #include #include diff --git a/include/vclib/mesh/requirements/element_requirements.h b/include/vclib/mesh/requirements/element_requirements.h index 36dc109fa..894c714b1 100644 --- a/include/vclib/mesh/requirements/element_requirements.h +++ b/include/vclib/mesh/requirements/element_requirements.h @@ -159,7 +159,7 @@ void requireElementContainerCompactness(const MeshType& m) { if (!isElementContainerCompact(m)) throw vcl::MissingCompactnessException( - std::string(elementEnumString()) + + elementEnumString() + " Container of the Mesh is not compact."); } diff --git a/include/vclib/misc/logger/logger.h b/include/vclib/misc/logger/logger.h index 7a6aa4c56..2872ee187 100644 --- a/include/vclib/misc/logger/logger.h +++ b/include/vclib/misc/logger/logger.h @@ -23,6 +23,7 @@ #ifndef VCL_MISC_LOGGER_LOGGER_H #define VCL_MISC_LOGGER_LOGGER_H +#include #include #include #include diff --git a/include/vclib/misc/logger/null_logger.h b/include/vclib/misc/logger/null_logger.h index 860137fbb..eb3a30831 100644 --- a/include/vclib/misc/logger/null_logger.h +++ b/include/vclib/misc/logger/null_logger.h @@ -28,27 +28,45 @@ namespace vcl { /** - * @brief The NullLogger class is an empty class that is used as default type in - * all the library functions that take as input a logger type. + * @brief The NullLogger class is used as default type in all the library + * functions that take as input a logger type. * - * This class satisfies the LoggerConcept. - * - * Before using a logger object, you should check if the type of the logger is - * valid in the following way: - * - * @code{.cpp} - * if constexpr (vcl::isLoggerValid()) { - * // use here the log object - * } - * @endcode - * - * This allows to compile the log code only when the user gives a proper Logger - * object that satisfies the LoggerConcept. + * This class satisfies the LoggerConcept, and just does nothing in all its + * member functions. * * @ingroup miscellaneous */ class NullLogger { +public: + enum LogLevel { ERROR = 0, WARNING, PROGRESS, DEBUG }; + + NullLogger() = default; + + void enableIndentation() {} + void disableIndentation() {} + + void reset() {} + + void setMaxLineWidth(uint) {} + void setPrintTimer(bool) {} + void startTimer() {} + + void startNewTask(double, double, std::string) {} + void endTask(std::string) {} + + double percentage() const { return 0; } + void setPercentage(uint) {} + + void log(std::string) {} + void log(LogLevel, std::string) {} + void log(uint, std::string) {} + void log(uint, LogLevel, std::string) {} + + void startProgress(std::string, uint, uint = 0, uint = 0, uint = 0) {} + void endProgress() {} + void progress(uint) {} + }; /** @@ -63,24 +81,26 @@ class NullLogger * { * // code of the function... * - * if constexpr (vcl::isLoggerValid()) { - * log.log("log!"); - * } + * // empty function will be called if the user does not give a logger + * log.log("log!"); * * } * @endcode * * In this way, when the user does not give a logger argument, the default will - * be an object of NullLogger type that allows to check at compile time if the - * logger object is valid. + * be an object of NullLogger. * * @ingroup miscellaneous */ static inline NullLogger nullLogger; /** - * @brief The isLoggerValid() function returns true if the type T is not the - * NullLogger type. + * @brief The isLoggerValid() function returns true at compile time if the type + * T is not the NullLogger type. + * + * It is useful when you need to perform some operation explicitely for logging + * that should not be done if the user does not give a logger. In this case the + * code will not be compiled. * * @tparam T: the type to test if is a valid Logger. It must satisfy the * LoggerConcept. diff --git a/include/vclib/misc/nested_initializer_lists.h b/include/vclib/misc/nested_initializer_lists.h index 888aa36d4..46c8977cc 100644 --- a/include/vclib/misc/nested_initializer_lists.h +++ b/include/vclib/misc/nested_initializer_lists.h @@ -26,7 +26,7 @@ /* @link https://zcrou.com/blog/dev/nested-initializers */ #include -#include +#include #include #include #include diff --git a/include/vclib/space/array.h b/include/vclib/space/array.h index f5d1426fa..7754698bd 100644 --- a/include/vclib/space/array.h +++ b/include/vclib/space/array.h @@ -24,7 +24,7 @@ #define VCL_SPACE_ARRAY_H #include -#include +#include #include #include #include diff --git a/include/vclib/space/graph/bipartite/bipartite_graph.h b/include/vclib/space/graph/bipartite/bipartite_graph.h index 14a34f2b1..919adfbd4 100644 --- a/include/vclib/space/graph/bipartite/bipartite_graph.h +++ b/include/vclib/space/graph/bipartite/bipartite_graph.h @@ -23,7 +23,7 @@ #ifndef VCL_SPACE_GRAPH_BIPARTITE_BIPARTITE_GRAPH_H #define VCL_SPACE_GRAPH_BIPARTITE_BIPARTITE_GRAPH_H -#include +#include #include #include #include diff --git a/include/vclib/space/vector.h b/include/vclib/space/vector.h index cf5cb7be5..5d3660ac7 100644 --- a/include/vclib/space/vector.h +++ b/include/vclib/space/vector.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/vclib/types/base.h b/include/vclib/types/base.h index 840b16637..ce046b67e 100644 --- a/include/vclib/types/base.h +++ b/include/vclib/types/base.h @@ -23,7 +23,7 @@ #ifndef VCL_TYPES_BASE_H #define VCL_TYPES_BASE_H -#include +#include #include #include diff --git a/include/vclib/types/mesh_elements.h b/include/vclib/types/mesh_elements.h index e34369614..6844f9663 100644 --- a/include/vclib/types/mesh_elements.h +++ b/include/vclib/types/mesh_elements.h @@ -23,6 +23,8 @@ #ifndef VCL_TYPES_MESH_ELEMENTS_H #define VCL_TYPES_MESH_ELEMENTS_H +#include + #include "base.h" namespace vcl { @@ -61,7 +63,7 @@ struct ElemenetString }; template -constexpr const char* elementEnumString() +constexpr const char* elementEnumCString() { static_assert( ElemenetString().str != nullptr, @@ -71,6 +73,15 @@ constexpr const char* elementEnumString() return ElemenetString().str; } +// Todo: make this function constexpr when upgrading to C++23. +template +const std::string& elementEnumString() +{ + static const std::string str = elementEnumCString(); + + return str; +} + } // namespace vcl #endif // VCL_TYPES_MESH_ELEMENTS_H