LArSoft
v07_13_02
Liquid Argon Software toolkit - http://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 105 of file hexfloat.h.
|
private |
Definition at line 134 of file hexfloat.h.
|
inline |
Constructor: if start_active is true, it will print floats in base 16.
Definition at line 110 of file hexfloat.h.
|
inline |
Disables base 16 printing.
Definition at line 121 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 118 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 115 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 125 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 129 of file hexfloat.h.
References lar::details::OptionalHexFloatFormatter< T >::value.
|
private |
whether we are writing in base 16
Definition at line 136 of file hexfloat.h.