10#ifndef LIB_STRINGIFY_H_
11#define LIB_STRINGIFY_H_
26 virtual void dbprint(std::ostream &out)
const = 0;
31inline std::ostream &operator<<(std::ostream &out,
const IHasDbPrint &obj) {
36inline std::ostream &operator<<(std::ostream &out,
const IHasDbPrint *obj) {
46template <
class,
class =
void>
51 std::void_t<decltype(std::declval<T>().dbprint(std::declval<std::ostream &>()))>>
57template <
class,
class =
void>
62 T,
std::void_t<decltype(std::declval<std::ostream &>() << std::declval<T>())>>
66inline constexpr bool has_ostream_operator_v = has_ostream_operator<T>::value;
72template <class, class = void>
73struct has_toString : std::false_type {};
76struct has_toString<T, std::void_t<decltype(std::declval<T>().toString())>> : std::true_type {};
79inline constexpr bool has_toString_v = has_toString<T>::value;
81template <typename T, typename = decltype(std::to_string(std::declval<T>()))>
82cstring toString(T value) {
83 return cstring(std::to_string(value));
87auto toString(const T &value) -> typename std::enable_if_t<has_toString_v<T>, cstring> {
88 return value.toString();
92auto toString(T &value) ->
typename std::enable_if_t<has_toString_v<T>,
cstring> {
93 return value.toString();
97auto toString(
const T *value) ->
typename std::enable_if_t<has_toString_v<T>,
cstring> {
98 return value->toString();
102auto toString(T *value) ->
typename std::enable_if_t<has_toString_v<T>, cstring> {
103 return value->toString();
107cstring toString(
const std::string &value);
108cstring toString(
const char *value);
110cstring toString(std::string_view value);
112cstring toString(
const big_int &value,
unsigned width,
bool sign,
unsigned int base = 10);
113cstring toString(
const void *value);
115char DigitToChar(
int digit);
Definition stringify.h:24
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13
Definition stringify.h:47
Definition stringify.h:58