removed c_str(), size(), operator<< abstractions from basic_symbol_text

This commit is contained in:
Ramzi Sabra
2020-03-24 22:18:54 +02:00
committed by Mateusz Pusz
parent e9272ac108
commit f6d9a1cbda
4 changed files with 5 additions and 15 deletions

View File

@@ -56,7 +56,7 @@ int main()
std::cout << "therefore ratio lengthA / lengthB == " << lengthA / lengthB << "\n\n";
std::cout << "conversion factor from lengthA::unit of "
<< units_str(lengthA) << " to lengthB::unit of " << units_str(lengthB) << " :\n\n"
<< units_str(lengthA).standard() << " to lengthB::unit of " << units_str(lengthB).standard() << " :\n\n"
<< "lengthB.count( " << lengthB.count() << " ) == lengthA.count( " << lengthA.count()
<< " ) * conversion_factor( " << conversion_factor(lengthB, lengthA) << " )\n";
}

View File

@@ -168,8 +168,8 @@ std::basic_string<CharT> to_string(const Q& q)
std::basic_ostringstream<CharT, Traits> s;
s << q.count();
constexpr auto symbol = unit_text<typename Q::dimension, typename Q::unit>();
if constexpr (symbol.size()) {
s << " " << symbol;
if constexpr (symbol.standard().size()) {
s << " " << symbol.standard();
}
return s.str();
}

View File

@@ -456,9 +456,9 @@ public:
// default format should print value followed by the unit separated with 1 space
to_quantity_buffer = units::detail::format_units_quantity_value<CharT>(to_quantity_buffer, q.count(), rep_specs);
constexpr auto symbol = units::detail::unit_text<Dimension, Unit>();
if(symbol.size()) {
if(symbol.standard().size()) {
*to_quantity_buffer++ = CharT(' ');
format_to(to_quantity_buffer, "{}", symbol.c_str());
format_to(to_quantity_buffer, "{}", symbol.standard().c_str());
}
}
else {

View File

@@ -21,9 +21,6 @@ struct basic_symbol_text {
[[nodiscard]] constexpr auto& ascii() { return ascii_; }
[[nodiscard]] constexpr const auto& ascii() const { return ascii_; }
[[nodiscard]] constexpr std::size_t size() const noexcept { return standard_.size(); }
[[nodiscard]] constexpr const StandardCharT* c_str() const noexcept { return standard_.c_str(); }
template<std::size_t N2, std::size_t M2>
[[nodiscard]] constexpr friend basic_symbol_text<StandardCharT, ASCIICharT, N + N2, M + M2> operator+(
const basic_symbol_text& lhs, const basic_symbol_text<StandardCharT, ASCIICharT, N2, M2>& rhs) noexcept
@@ -67,13 +64,6 @@ struct basic_symbol_text {
{
return false;
}
template<class Traits>
friend std::basic_ostream<StandardCharT, Traits>& operator<<(std::basic_ostream<StandardCharT, Traits>& os,
const basic_symbol_text& symbol)
{
return os << symbol.standard_.c_str();
}
};
template<typename StandardCharT>