LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
|
Helper for formatting floats in base 16. More...
#include "hexfloat.h"
Public Member Functions | |
OptionalHexFloat (bool start_active=true) | |
Constructor: if start_active is true, it will print floats in base 16. More... | |
bool | enabled () const |
Returns whether base 16 printing is enabled. More... | |
void | enable (bool enable=true) |
Enables base 16 printing (or disables it if enable is false) More... | |
void | disable () |
Disables base 16 printing. More... | |
template<typename T > | |
auto | operator() (T value) const |
Returns an object that knows what to do with an output stream. More... | |
template<typename T > | |
auto | operator() (bool this_active, T value) const |
Returns an object that knows what to do with an output stream. More... | |
Private Types | |
template<typename T > | |
using | formatter_t = details::OptionalHexFloatFormatter< T > |
Private Attributes | |
bool | active |
whether we are writing in base 16 More... | |
Helper for formatting floats in base 16.
Example of use:
lar::OptionalHexFloat hexfloat; constexpr double value = 0.375; std::cout << "Hex: " << hexfloat(value) << std::endl; hexfloat.disable(); std::cout << "Dec: " << hexfloat(value) << std::endl;
The first printout is expected to be in base 16, the second one in base 10.
Definition at line 109 of file hexfloat.h.
|
private |
Definition at line 140 of file hexfloat.h.
|
inline |
Constructor: if start_active is true, it will print floats in base 16.
Definition at line 113 of file hexfloat.h.
|
inline |
Disables base 16 printing.
Definition at line 122 of file hexfloat.h.
References lar::details::OptionalHexFloatFormatter< T >::active.
|
inline |
Enables base 16 printing (or disables it if enable is false)
Definition at line 119 of file hexfloat.h.
References lar::details::OptionalHexFloatFormatter< T >::active, and enable().
Referenced by enable().
|
inline |
Returns whether base 16 printing is enabled.
Definition at line 116 of file hexfloat.h.
References lar::details::OptionalHexFloatFormatter< T >::active.
|
inline |
Returns an object that knows what to do with an output stream.
Definition at line 126 of file hexfloat.h.
References lar::details::OptionalHexFloatFormatter< T >::active, and lar::details::OptionalHexFloatFormatter< T >::value.
|
inline |
Returns an object that knows what to do with an output stream.
Definition at line 133 of file hexfloat.h.
References lar::details::OptionalHexFloatFormatter< T >::value.
|
private |
whether we are writing in base 16
Definition at line 142 of file hexfloat.h.