mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-15 08:26:04 +08:00
Added 'scientific' flag to basic_format_spec to allow forcing of scientific format for all floating point values.
This commit is contained in:
parent
4a88884b39
commit
9d6e8dd92e
@ -215,6 +215,7 @@ namespace etl
|
||||
, boolalpha_(false)
|
||||
, show_base_(false)
|
||||
, fill_(typename TString::value_type(' '))
|
||||
, scientific_(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -222,7 +223,7 @@ namespace etl
|
||||
/// Constructor.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR basic_format_spec(uint_least8_t base__, uint_least8_t width__, uint_least8_t precision__, bool upper_case__, bool left_justified__,
|
||||
bool boolalpha__, bool show_base__, typename TString::value_type fill__) ETL_NOEXCEPT
|
||||
bool boolalpha__, bool show_base__, typename TString::value_type fill__, bool scientific__ = false) ETL_NOEXCEPT
|
||||
: base_(base__)
|
||||
, width_(width__)
|
||||
, precision_(precision__)
|
||||
@ -231,6 +232,7 @@ namespace etl
|
||||
, boolalpha_(boolalpha__)
|
||||
, show_base_(show_base__)
|
||||
, fill_(fill__)
|
||||
, scientific_(scientific__)
|
||||
{
|
||||
}
|
||||
|
||||
@ -246,7 +248,8 @@ namespace etl
|
||||
left_justified_ = false;
|
||||
boolalpha_ = false;
|
||||
show_base_ = false;
|
||||
fill_ = typename TString::value_type(' ');
|
||||
scientific = false;
|
||||
fill_ = typename TString::value_type(' ');
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -560,6 +563,33 @@ namespace etl
|
||||
return boolalpha_;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Sets the scientific flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& scientific(bool b) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
scientific_ = b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& scientific(bool b) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
scientific_ = b;
|
||||
return etl::move(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the scientific flag.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR bool is_scientific() const ETL_NOEXCEPT
|
||||
{
|
||||
return scientific_;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Equality operator.
|
||||
//***************************************************************************
|
||||
@ -588,6 +618,7 @@ namespace etl
|
||||
bool boolalpha_;
|
||||
bool show_base_;
|
||||
typename TString::value_type fill_;
|
||||
bool scientific_;
|
||||
};
|
||||
} // namespace etl
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user