19#ifndef LIB_STRINGIFY_H_
20#define LIB_STRINGIFY_H_
35 virtual void dbprint(std::ostream &out)
const = 0;
40inline std::ostream &operator<<(std::ostream &out,
const IHasDbPrint &obj) {
45inline std::ostream &operator<<(std::ostream &out,
const IHasDbPrint *obj) {
55template <
class,
class =
void>
60 std::void_t<decltype(std::declval<T>().dbprint(std::declval<std::ostream &>()))>>
66template <
class,
class =
void>
71 T,
std::void_t<decltype(std::declval<std::ostream &>() << std::declval<T>())>>
75inline constexpr bool has_ostream_operator_v = has_ostream_operator<T>::value;
81template <class, class = void>
82struct has_toString : std::false_type {};
85struct has_toString<T, std::void_t<decltype(std::declval<T>().toString())>> : std::true_type {};
88inline constexpr bool has_toString_v = has_toString<T>::value;
90template <typename T, typename = decltype(std::to_string(std::declval<T>()))>
91cstring toString(T value) {
92 return cstring(std::to_string(value));
96auto toString(const T &value) -> typename std::enable_if_t<has_toString_v<T>, cstring> {
97 return value.toString();
101auto toString(T &value) ->
typename std::enable_if_t<has_toString_v<T>,
cstring> {
102 return value.toString();
106auto toString(
const T *value) ->
typename std::enable_if_t<has_toString_v<T>,
cstring> {
107 return value->toString();
111auto toString(T *value) ->
typename std::enable_if_t<has_toString_v<T>, cstring> {
112 return value->toString();
115cstring toString(
bool value);
116cstring toString(
const std::string &value);
117cstring toString(
const char *value);
118cstring toString(cstring value);
119cstring toString(std::string_view value);
121cstring toString(
const big_int &value,
unsigned width,
bool sign,
unsigned int base = 10);
122cstring toString(
const void *value);
124char DigitToChar(
int digit);
Definition stringify.h:33
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition stringify.h:56
Definition stringify.h:67