ChessPlusPlus  WIP
cplusplus.com Community Project
chesspp::util Namespace Reference

Classes

class  JsonReader
 
class  KeyIter
 
struct  MakeSigned
 
class  Position
 
class  Range
 

Typedefs

template<typename T >
using IsSigned = typename std::is_same< T, typename MakeSigned< T >::type >
 

Enumerations

enum  Direction {
  Direction::None, Direction::North, Direction::NorthEast, Direction::East,
  Direction::SouthEast, Direction::South, Direction::SouthWest, Direction::West,
  Direction::NorthWest
}
 

Functions

Direction Rotate (Direction d, signed r) noexcept
 
std::ostream & operator<< (std::ostream &os, Direction const &d) noexcept
 
std::istream & operator>> (std::istream &is, Direction &d)
 
template<typename T >
auto operator<< (std::ostream &os, Position< T > const &p) noexcept-> typename std::enable_if< std::is_integral< T >::value &&std::is_same< T, typename MakeSigned< T >::type >::value, std::ostream & >::type
 
template<typename ItT >
auto as_range (std::pair< ItT, ItT > const &range) noexcept-> Range< ItT >
 
template<typename... Args>
std::string path_concat (std::string const &delim, Args const &...args)
 
template<typename First , typename... Rest>
std::string path_concat (std::string const &delim, First const &first, Rest const &...rest)
 
template<>
std::string path_concat (std::string const &delim)
 

Typedef Documentation

template<typename T >
using chesspp::util::IsSigned = typedef typename std::is_same<T, typename MakeSigned<T>::type>

Template alias to complement MakeSigned. Used the same way as std::is_signed.

Template Parameters
Tmust be scalar.

Enumeration Type Documentation

Represents a direction.

Enumerator
None 
North 
NorthEast 
East 
SouthEast 
South 
SouthWest 
West 
NorthWest 

Function Documentation

template<typename ItT >
auto chesspp::util::as_range ( std::pair< ItT, ItT > const &  range) -> Range<ItT>
noexcept

Takes a std::pair of iterators (e.g. the return value of some standard algorithms) and constructs a Range object from it as a convenience function.

Template Parameters
ItTThe iterator type, best if left to be deduced by the compiler.
std::ostream& chesspp::util::operator<< ( std::ostream &  os,
Direction const &  d 
)
inlinenoexcept

Serializes a direction to a stream in string format.

Parameters
osThe stream to serialize to.
dthe Direction to serialize.
Returns
os
template<typename T >
auto chesspp::util::operator<< ( std::ostream &  os,
Position< T > const &  p 
) -> typename std::enable_if < std::is_integral<T>::value && std::is_same<T, typename MakeSigned<T>::type>::value, std::ostream & >::type
noexcept

Serializes a position to a stream in the format "(x, y)". This is the signed version.

Parameters
osthe stream to write to.
pthe position to serialize into the stream.
Returns
os

Serializes a position to a stream in the format "(x, y)". This is the unsigned version.

Parameters
osthe stream to write to.
pthe position to serialize into the stream.
Returns
os

Serializes a position to a stream in the format "(x, y)". This is the float version.

Parameters
osthe stream to write to.
pthe position to serialize into the stream.
Returns
os
std::istream& chesspp::util::operator>> ( std::istream &  is,
Direction d 
)
inline
template<typename... Args>
std::string chesspp::util::path_concat ( std::string const &  delim,
Args const &...  args 
)

Allows unpacking a template parameter pack into a string path with a custom delimiter.

Template Parameters
...ArgsThe type parameter pack.
Parameters
delimThe delimiter, between each arg and at the end.
...argsThe template parameter pack.
template<typename First , typename... Rest>
std::string chesspp::util::path_concat ( std::string const &  delim,
First const &  first,
Rest const &...  rest 
)
template<>
std::string chesspp::util::path_concat ( std::string const &  delim)
inline
Direction chesspp::util::Rotate ( Direction  d,
signed  r 
)
inlinenoexcept

Returns a new direction which is a rotation of the provided direction.

Parameters
dthe direction to rotate.
rthe number of times to rotate, may be negative.
Returns
the rotated direction.