-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Core]: Change all std::to_string calls to use a workaround based on …
…stringstream This is to support toolchains that do not implement `std::to_string`.
- Loading branch information
Showing
7 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//================================================================================================ | ||
/// @file to_string.hpp | ||
/// | ||
/// @brief A compatibility template to replace `std::to_string` | ||
/// @details Some compilers don't support `std::to_string` so this file is meant to abstract it | ||
/// away with a workaround if it's not supported. This solution was inspired by Catch2's | ||
/// implementation. | ||
/// @author Adrian Del Grosso | ||
/// | ||
/// @copyright 2022 Adrian Del Grosso | ||
//================================================================================================ | ||
#ifndef TO_STRING_HPP | ||
#define TO_STRING_HPP | ||
|
||
#include <sstream> | ||
#include <string> | ||
|
||
namespace isobus | ||
{ | ||
template<typename T> | ||
/// @brief A replacement for std::to_string | ||
/// @tparam T The data type | ||
/// @param t The thing to convert to string | ||
/// @returns the string form of `t` | ||
std::string to_string(T const &t) | ||
{ | ||
std::ostringstream oss; | ||
oss << t; | ||
return oss.str(); | ||
} | ||
} // namespace isobus_utils | ||
|
||
#endif // TO_STRING_HPP |