CPP Homework 04
Exercise from OTUS C++ developer course.
print_ip.h File Reference
#include <iostream>
#include <list>
#include <string>
#include <tuple>
#include <type_traits>
#include <vector>
#include "helpers.h"
#include "traits.h"
Include dependency graph for print_ip.h:

Go to the source code of this file.

Functions

template<typename T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
void print_ip (T t, std::ostream &stream=std::cout)
 Pretty print IP address. More...
 
template<typename T , std::enable_if_t< is_iterable_v< T > &&!std::is_same_v< T, std::string >, int > = 0>
void print_ip (T const &t, std::ostream &stream=std::cout)
 Pretty print IP address. More...
 

Function Documentation

◆ print_ip() [1/2]

template<typename T , std::enable_if_t< std::is_integral_v< T >, int > = 0>
void print_ip ( t,
std::ostream &  stream = std::cout 
)

Pretty print IP address.

Overload print integer-valued data as a dot-separated IP address. Octets is bytes of given value.

Parameters
tInteger-valued data.
streamOutput stream to push in.

Print string as is.

Parameters
tC-style string to be printed.
streamOutput stream to push in.

Definition at line 24 of file print_ip.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_ip() [2/2]

template<typename T , std::enable_if_t< is_iterable_v< T > &&!std::is_same_v< T, std::string >, int > = 0>
void print_ip ( T const &  t,
std::ostream &  stream = std::cout 
)

Pretty print IP address.

Print STL-style container as a dot-separated IP address. Every item is an octet.

Parameters
tIterable with T:begin(), T::end() container. Items can have primitive numeric, C-style or std::string type.
streamOutput stream to push in.

Print tuple as a dot-separated IP address.

Parameters
tTuple of same typed items.
streamOutput stream to push in.
Exceptions
static_assertWhen items of tuple is not same typed.
Todo:

Ref.

Throw.

Print string as is.

Parameters
tstd::string to be printed.
streamOutput stream to push in.

Definition at line 54 of file print_ip.h.

Here is the call graph for this function: