58 (*this)(_os, _obj, 0);
63 template <
typename Up>
64 auto operator()(std::ostream& _os,
const Up& _obj,
int)
const
65 ->
decltype((void) _obj.get_display(), (void) _obj.get_display_unit(),
66 (void) _obj.get_label(), void())
68 auto _value = _obj.get_display();
69 auto _disp = _obj.get_display_unit();
70 auto _label = _obj.get_label();
72 sfinae(_os, 0, _value, _disp, _label);
75 template <
typename Up>
76 void operator()(std::ostream&,
const Up&,
long)
const
85 template <
typename ValueT,
typename DispT,
typename LabelT>
86 auto sfinae(std::ostream& _os,
int, ValueT& _value, DispT& _disp, LabelT& _label,
87 enable_if_t<not_string<ValueT, LabelT, DispT>(),
int> = 0) const
88 -> decltype((_value.size() + _disp.size() + _label.size()),
void())
90 auto _prec = type::get_precision();
91 auto _width = type::get_width();
92 auto _flags = type::get_format_flags();
94 std::stringstream ss_value;
95 std::stringstream ss_extra;
96 ss_value.setf(_flags);
98 auto _vn = _value.size();
99 auto _dn = _disp.size();
100 auto _ln = _label.size();
101 auto _n = std::min<size_t>(_vn, std::min<size_t>(_dn, _ln));
102 std::stringstream _ss;
103 for(
size_t i = 0; i < _n; ++i)
105 ss_value << std::setw(_width) << std::setprecision(_prec)
106 << _value.at(i % _vn);
109 if(ss_value.str().find_first_not_of(
' ') == std::string::npos)
113 constexpr bool units_print = !trait::custom_unit_printing<type>::value;
114 constexpr bool label_print = !trait::custom_label_printing<type>::value;
116 print_tag<units_print>(ss_extra, _disp.at(i % _dn));
117 print_tag<label_print>(ss_extra, _label.at(i % _ln));
119 _ss << ss_value.str() << ss_extra.str();
133 template <
typename ValueT,
typename DispT,
typename LabelT>
134 auto sfinae(std::ostream& _os,
int, ValueT& _value, DispT& _disp, LabelT& _label,
135 enable_if_t<not_string<ValueT, LabelT>() && is_string<DispT>(),
long> =
136 0L)
const ->
decltype((_value.size() + _label.size()),
void())
138 auto _prec = type::get_precision();
139 auto _width = type::get_width();
140 auto _flags = type::get_format_flags();
142 std::stringstream ss_value;
143 std::stringstream ss_extra;
144 ss_value.setf(_flags);
146 auto _vn = _value.size();
147 auto _ln = _label.size();
148 auto _n = std::min<size_t>(_vn, _ln);
149 std::stringstream _ss;
150 for(
size_t i = 0; i < _n; ++i)
152 ss_value << std::setw(_width) << std::setprecision(_prec)
153 << _value.at(i % _vn);
156 if(ss_value.str().find_first_not_of(
' ') == std::string::npos)
160 constexpr bool units_print = !trait::custom_unit_printing<type>::value;
161 constexpr bool label_print = !trait::custom_label_printing<type>::value;
164 print_tag<units_print>(ss_extra, _disp);
165 print_tag<label_print>(ss_extra, _label.at(i % _ln));
167 _ss << ss_value.str() << ss_extra.str();
181 template <
typename ValueT,
typename DispT,
typename LabelT>
182 auto sfinae(std::ostream& _os,
int, ValueT& _value, DispT& _disp, LabelT& _label,
183 enable_if_t<not_string<ValueT>() && is_string<LabelT, DispT>(),
double> =
184 0.0) const -> decltype((_value.size() + _label.size()),
void())
186 auto _prec = type::get_precision();
187 auto _width = type::get_width();
188 auto _flags = type::get_format_flags();
190 std::stringstream ss_value;
191 std::stringstream ss_extra;
192 ss_value.setf(_flags);
194 auto _vn = _value.size();
195 auto _ln = _label.size();
196 auto _n = std::min<size_t>(_vn, _ln);
197 std::stringstream _ss;
198 for(
size_t i = 0; i < _n; ++i)
200 ss_value << std::setw(_width) << std::setprecision(_prec)
201 << _value.at(i % _vn);
204 if(ss_value.str().find_first_not_of(
' ') == std::string::npos)
210 constexpr bool units_print = !trait::custom_unit_printing<type>::value;
211 constexpr bool label_print = !trait::custom_label_printing<type>::value;
213 print_tag<units_print>(ss_extra, _disp);
214 print_tag<label_print>(ss_extra, _label);
217 _ss << ss_value.str() << ss_extra.str();
231 template <
typename ValueT,
typename DispT,
typename LabelT>
232 auto sfinae(std::ostream& _os,
long, ValueT& _value, DispT& _disp,
233 LabelT& _label)
const
235 auto _prec = type::get_precision();
236 auto _width = type::get_width();
237 auto _flags = type::get_format_flags();
239 std::stringstream ss_value;
240 std::stringstream ss_extra;
241 ss_value.setf(_flags);
242 ss_value << std::setw(_width) << std::setprecision(_prec) << _value;
245 if(ss_value.str().find_first_not_of(
' ') == std::string::npos)
249 constexpr bool units_print = !trait::custom_unit_printing<type>::value;
250 constexpr bool label_print = !trait::custom_label_printing<type>::value;
252 print_tag<units_print>(ss_extra, _disp);
253 print_tag<label_print>(ss_extra, _label);
255 _os << ss_value.str() << ss_extra.str();
typename std::enable_if< B, T >::type enable_if_t
Alias template for enable_if.
The declaration for the types for operations without definitions.
Include the macros for operations.
Declare the operations types.
invoked from the base class to provide default printing behavior
base_printer(std::ostream &_os, const type &_obj)
std::ostream & operator()(std::ostream &_os, const type &_obj) const
std::vector< int64_t > widths_t
common string manipulation utilities