Skip to content

Commit b45cf0f

Browse files
committed
Fixed build with GCC 11
1 parent 473a6e1 commit b45cf0f

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

compass_interfaces/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ target_include_directories(${PROJECT_NAME}_string_utils PUBLIC
2626
)
2727
target_link_libraries(${PROJECT_NAME}_string_utils
2828
PUBLIC "${cpp_typesupport_target}"
29-
PRIVATE cras_cpp_common::cras_string_utils)
29+
PRIVATE cras_cpp_common::cras_format cras_cpp_common::cras_string_utils)
3030

3131
install(DIRECTORY include/ DESTINATION include)
3232

compass_interfaces/src/string_utils.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* \author Martin Pecka, Adam Herold (ROS2 transcription)
88
*/
99

10-
#include <format>
1110
#include <string>
1211

1312
#include <compass_interfaces/msg/azimuth.hpp>
1413
#include <compass_interfaces/string_utils.hpp>
14+
#include <cras_cpp_common/format.hpp>
1515
#include <cras_cpp_common/string_utils.hpp>
1616

1717
namespace compass_interfaces
@@ -26,7 +26,7 @@ std::string unitToString(const msg::Azimuth::_unit_type unit)
2626
case compass_interfaces::msg::Azimuth::UNIT_DEG:
2727
return "deg";
2828
default:
29-
throw std::runtime_error(std::format("Invalid compass_interfaces::msg::Azimuth::unit {}", std::to_string(unit)));
29+
throw std::runtime_error(cras::format("Invalid compass_interfaces::msg::Azimuth::unit {}", std::to_string(unit)));
3030
}
3131
}
3232

@@ -38,7 +38,7 @@ msg::Azimuth::_unit_type parseUnit(const std::string& unitStr)
3838
else if (unit == "deg")
3939
return compass_interfaces::msg::Azimuth::UNIT_DEG;
4040
else
41-
throw std::runtime_error(std::format("Invalid compass_interfaces::msg::Azimuth::unit '{}'", unitStr.c_str()));
41+
throw std::runtime_error(cras::format("Invalid compass_interfaces::msg::Azimuth::unit '{}'", unitStr.c_str()));
4242
}
4343

4444
std::string orientationToString(const msg::Azimuth::_orientation_type orientation)
@@ -51,7 +51,7 @@ std::string orientationToString(const msg::Azimuth::_orientation_type orientatio
5151
return "NED";
5252
default:
5353
throw std::runtime_error(
54-
std::format("Invalid compass_interfaces::msg::Azimuth::orientation {}", std::to_string(orientation)));
54+
cras::format("Invalid compass_interfaces::msg::Azimuth::orientation {}", std::to_string(orientation)));
5555
}
5656
}
5757

@@ -64,7 +64,7 @@ msg::Azimuth::_orientation_type parseOrientation(const std::string& orientationS
6464
return compass_interfaces::msg::Azimuth::ORIENTATION_NED;
6565
else
6666
throw std::runtime_error(
67-
std::format("Invalid compass_interfaces::msg::Azimuth::orientation '{}'", orientationStr.c_str()));
67+
cras::format("Invalid compass_interfaces::msg::Azimuth::orientation '{}'", orientationStr.c_str()));
6868
}
6969

7070
std::string referenceToString(const msg::Azimuth::_reference_type reference)
@@ -79,7 +79,7 @@ std::string referenceToString(const msg::Azimuth::_reference_type reference)
7979
return "UTM";
8080
default:
8181
throw std::runtime_error(
82-
std::format("Invalid compass_interfaces::msg::Azimuth::reference {}", std::to_string(reference)));
82+
cras::format("Invalid compass_interfaces::msg::Azimuth::reference {}", std::to_string(reference)));
8383
}
8484
}
8585

@@ -94,7 +94,7 @@ msg::Azimuth::_reference_type parseReference(const std::string& referenceStr)
9494
return compass_interfaces::msg::Azimuth::REFERENCE_UTM;
9595
else
9696
throw std::runtime_error(
97-
std::format("Invalid compass_interfaces::msg::Azimuth::reference '{}'", referenceStr.c_str()));
97+
cras::format("Invalid compass_interfaces::msg::Azimuth::reference '{}'", referenceStr.c_str()));
9898
}
9999

100100
}

magnetic_model/src/magnetic_model.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
#include <ctime>
11-
#include <format>
1211
#include <memory>
1312
#include <string>
1413

@@ -17,6 +16,7 @@
1716

1817
#include <angles/angles.h>
1918
#include <cras_cpp_common/expected.hpp>
19+
#include <cras_cpp_common/format.hpp>
2020
#include <cras_cpp_common/string_utils.hpp>
2121
#include <cras_cpp_common/time_utils.hpp>
2222
#include <magnetic_model/magnetic_model.hpp>
@@ -79,7 +79,7 @@ MagneticModel::MagneticModel(
7979
}
8080
catch (const GeographicLib::GeographicErr& e)
8181
{
82-
throw std::invalid_argument(std::format(
82+
throw std::invalid_argument(cras::format(
8383
"Could not create magnetic field model {} because of the following error: {}", name.c_str(), e.what()));
8484
}
8585

@@ -189,7 +189,7 @@ cras::expected<MagneticField, std::string> MagneticModel::getMagneticField(
189189
const auto maxYear = this->data->magneticModel->MaxTime();
190190
if (year < minYear || year > maxYear)
191191
{
192-
const auto err = std::format("Using magnetic field model {} for an invalid year {}!",
192+
const auto err = cras::format("Using magnetic field model {} for an invalid year {}!",
193193
this->data->magneticModel->MagneticModelName().c_str(), std::to_string(year));
194194
if (this->strict)
195195
{
@@ -206,7 +206,7 @@ cras::expected<MagneticField, std::string> MagneticModel::getMagneticField(
206206
const auto maxAlt = this->data->magneticModel->MaxHeight();
207207
if (fix.altitude < minAlt || fix.altitude > maxAlt)
208208
{
209-
const auto err = std::format(
209+
const auto err = cras::format(
210210
"Using magnetic field model {} in altitude {} m which is outside the model range.",
211211
this->data->magneticModel->MagneticModelName().c_str(), std::to_string(fix.altitude));
212212
if (this->strict)
@@ -259,7 +259,7 @@ cras::expected<MagneticFieldComponentProperties, std::string> MagneticModel::get
259259
const auto maxAlt = this->data->magneticModel->MaxHeight();
260260
if (fix.altitude < minAlt || fix.altitude > maxAlt)
261261
{
262-
const auto err = std::format(
262+
const auto err = cras::format(
263263
"Using magnetic field model {} in altitude {} m which is outside the model range.",
264264
this->data->magneticModel->MagneticModelName().c_str(), std::to_string(fix.altitude));
265265
if (this->strict)
@@ -304,7 +304,7 @@ cras::expected<MagneticFieldComponentProperties, std::string> MagneticModel::get
304304
const auto maxYear = this->data->magneticModel->MaxTime();
305305
if (year < minYear || year > maxYear)
306306
{
307-
const auto err = std::format("Using magnetic field model {} for an invalid year {}!",
307+
const auto err = cras::format("Using magnetic field model {} for an invalid year {}!",
308308
this->data->magneticModel->MagneticModelName().c_str(), std::to_string(year));
309309
if (this->strict)
310310
{

magnetic_model/src/magnetic_model_manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
* \author Martin Pecka, Adam Herold (ROS2 transcription)
88
*/
99

10-
#include <format>
1110
#include <map>
1211
#include <memory>
1312
#include <optional>
@@ -19,6 +18,7 @@
1918

2019
#include <ament_index_cpp/get_package_share_directory.hpp>
2120
#include <cras_cpp_common/expected.hpp>
21+
#include <cras_cpp_common/format.hpp>
2222
#include <cras_cpp_common/string_utils.hpp>
2323
#include <cras_cpp_common/time_utils.hpp>
2424
#include <magnetic_model/magnetic_model.hpp>
@@ -113,7 +113,7 @@ cras::expected<std::shared_ptr<MagneticModel>, std::string> MagneticModelManager
113113
if (!model.has_value())
114114
return cras::make_unexpected(model.error());
115115
if (strict && !model.value()->isValid(stamp))
116-
return cras::make_unexpected(std::format(
116+
return cras::make_unexpected(cras::format(
117117
"The best magnetic model {} is not valid at time {}.", name, cras::to_pretty_string(stamp)));
118118
return *model;
119119
}

0 commit comments

Comments
 (0)