23 std::enable_if_t<std::is_integral_v<T>,
int> = 0>
24 void print_ip(T t, std::ostream &stream = std::cout) {
25 constexpr
size_t type_size {
sizeof(T) };
28 unsigned char bytes[type_size];
34 for (
int i { type_size - 1 }; i >= 0; i--) {
36 if (i != 0) stream <<
'.';
52 is_iterable_v<T> && !std::is_same_v<T, std::string>,
54 void print_ip(T
const &t, std::ostream &stream = std::cout) {
55 auto begin { t.cbegin() };
56 auto end { t.cend() };
57 for (
auto it { begin }; it != end; it++) {
58 if (it != begin) stream <<
'.';
75 std::enable_if_t<is_specialisation_of_v<std::tuple, T>,
int> = 0>
76 void print_ip(T
const &t, std::ostream &stream = std::cout) {
88 std::enable_if_t<std::is_same_v<T, std::string>,
int> = 0>
89 void print_ip(T
const &t, std::ostream &stream = std::cout) {
90 stream << t << std::endl;
101 std::enable_if_t<std::is_same_v<T, const char*>,
int> = 0>
102 void print_ip(T t, std::ostream &stream = std::cout) {
103 stream << t << std::endl;
std::string to_string(T t)
Wrapper function to make string.
void print_ip(T t, std::ostream &stream=std::cout)
Pretty print IP address.
void print_ip_tuple_impl(std::tuple< T1, T2 > const &t, std::ostream &stream=std::cout)
Pretty print IP address.