From c335b7765ad01fb5d1d965ea67def18f470a612e Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Fri, 8 Sep 2023 02:10:25 +0200 Subject: [PATCH] Replace std::source_location by SourceLocation --- src/mesh/ParallelChecker.hpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/mesh/ParallelChecker.hpp b/src/mesh/ParallelChecker.hpp index 05f90bba9..8f40766bf 100644 --- a/src/mesh/ParallelChecker.hpp +++ b/src/mesh/ParallelChecker.hpp @@ -6,7 +6,7 @@ #include <utils/HDF5.hpp> #include <utils/Messenger.hpp> -#include <experimental/source_location> +#include <utils/SourceLocation.hpp> #include <fstream> #include <utils/Demangle.hpp> @@ -18,7 +18,7 @@ namespace parallel template <typename DataType, ItemType item_type, typename ConnectivityPtr> void check(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value, const std::string& name, - const std::experimental::source_location& source_location = std::experimental::source_location::current()); + const SourceLocation& source_location = SourceLocation{}); class ParallelChecker { @@ -32,13 +32,13 @@ class ParallelChecker ParallelChecker() = default; void - _printHeader(const std::string& name, const std::experimental::source_location& source_location) const + _printHeader(const std::string& name, const SourceLocation& source_location) const { std::cout << rang::fg::cyan << " | " << rang::fgB::cyan << "parallel checker" << rang::fg::cyan << " for \"" << rang::fgB::magenta << name << rang::fg::cyan << "\" tag " << rang::fgB::blue << m_tag << rang::fg::reset << '\n'; - std::cout << rang::fg::cyan << " | from " << rang::fgB::blue << source_location.file_name() << rang::fg::reset - << ':' << rang::style::bold << source_location.line() << rang::style::reset << '\n'; + std::cout << rang::fg::cyan << " | from " << rang::fgB::blue << source_location.filename() << rang::fg::reset << ':' + << rang::style::bold << source_location.line() << rang::style::reset << '\n'; } public: @@ -52,16 +52,14 @@ class ParallelChecker } template <typename DataType, ItemType item_type, typename ConnectivityPtr> - friend void check(const ItemValue<DataType, item_type, ConnectivityPtr>&, - const std::string&, - const std::experimental::source_location&); + friend void check(const ItemValue<DataType, item_type, ConnectivityPtr>&, const std::string&, const SourceLocation&); private: template <typename DataType, ItemType item_type, typename ConnectivityPtr> void write(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value, const std::string& name, - const std::experimental::source_location& source_location) + const SourceLocation& source_location) { this->_printHeader(name, source_location); @@ -76,8 +74,8 @@ class ParallelChecker auto values_group_id = HDF5::createOrOpenGroup(file_id, "/values"); auto group_id = HDF5::createOrOpenGroup(values_group_id, std::to_string(m_tag)); - HDF5::writeAttribute(group_id, "filename", std::string{source_location.file_name()}); - HDF5::writeAttribute(group_id, "function", source_location.function_name()); + HDF5::writeAttribute(group_id, "filename", std::string{source_location.filename()}); + HDF5::writeAttribute(group_id, "function", source_location.function()); HDF5::writeAttribute(group_id, "line", static_cast<size_t>(source_location.line())); HDF5::writeAttribute(group_id, "name", name); @@ -122,7 +120,7 @@ class ParallelChecker void compare(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value, const std::string& name, - const std::experimental::source_location& source_location) + const SourceLocation& source_location) { this->_printHeader(name, source_location); @@ -172,7 +170,7 @@ class ParallelChecker std::cout << rang::fg::cyan << " | " << rang::fgB::magenta << "reference function " << rang::fgB::blue << reference_function_name << rang::fg::reset << '\n'; std::cout << rang::fg::cyan << " | " << rang::fgB::magenta << "target function " << rang::fgB::blue - << source_location.function_name() << rang::fg::reset << '\n'; + << source_location.function() << rang::fg::reset << '\n'; } if (not parallel::allReduceAnd(is_comparable)) { @@ -318,7 +316,7 @@ template <typename DataType, ItemType item_type, typename ConnectivityPtr> void check(const ItemValue<DataType, item_type, ConnectivityPtr>& item_value, const std::string& name, - const std::experimental::source_location& source_location) + const SourceLocation& source_location) { const bool write_mode = (parallel::size() == 1); @@ -337,7 +335,7 @@ template <typename DataType, ItemType item_type, typename ConnectivityPtr> void check(const ItemValue<DataType, item_type, ConnectivityPtr>&, const std::string&, - const std::experimental::source_location& = std::experimental::source_location::current()) + const SourceLocation& = SourceLocation{}) { throw UnexpectedError("parallel checker cannot be used without HDF5 support"); } -- GitLab