DxLibEx
dxle::point_c< T, > Class Template Referencefinal

Template class for 2D points specified by its coordinates x and y. More...

#include <point2d.hpp>

Public Types

typedef std::remove_cv< T >::type value_type
 

Public Member Functions

DXLE_CONSTEXPR point_c () DXLE_NOEXCEPT_IF((std
 
DXLE_CONSTEXPR point_c (const value_type &x_, const value_type &y_) DXLE_NOEXCEPT_IF((std
 
DXLE_CONSTEXPR point_c (value_type &&x_, value_type &&y_) DXLE_NOEXCEPT_OR_NOTHROW
 
template<typename Tp2_ >
DXLE_CONSTEXPR point_c (const point_c< Tp2_ > &other) DXLE_NOEXCEPT_IF((dxle
 
template<typename Tp2_ >
DXLE_CONSTEXPR point_c (point_c< Tp2_ > &&other) DXLE_NOEXCEPT_IF((dxle
 
DXLE_CONSTEXPR point_c (const point_c< value_type > &o) DXLE_NOEXCEPT_IF((std
 
DXLE_CONSTEXPR point_c (point_c< value_type > &&o) DXLE_NOEXCEPT_OR_NOTHROW
 
template<typename Tp2_ >
DXLE_CONSTEXPR point_c (const size_c< Tp2_, nullptr > &other) DXLE_NOEXCEPT_IF((dxle
 
template<typename Tp2_ >
DXLE_CONSTEXPR point_c (size_c< Tp2_, nullptr > &&other) DXLE_NOEXCEPT_IF((dxle
 
DXLE_CONSTEXPR point_c (const size_c< value_type, nullptr > &other) DXLE_NOEXCEPT_IF((dxle
 
DXLE_CONSTEXPR point_c (size_c< value_type, nullptr > &&other) DXLE_NOEXCEPT_IF((dxle
 
point_coperator= (const point_c< value_type > &r) DXLE_NOEXCEPT_IF((std
 
point_coperator= (point_c< value_type > &&r) DXLE_NOEXCEPT_OR_NOTHROW
 
DXLE_CONSTEXPR operator bool () const DXLE_NOEXCEPT_IF_EXPR((dxle
 
template<typename Tp2_ >
 operator std::pair< Tp2_, Tp2_ > () const DXLE_NOEXCEPT_IF((dxle
 

Public Attributes

value_type x
 
value_type y
 

Related Functions

(Note that these are not member functions.)

template<typename T >
point_c< T > make_point_c (const std::pair< T, T > &pa) DXLE_NOEXCEPT_IF(std
 conversion from std::pair More...
 
template<typename T >
point_c< T > make_point_c (std::pair< T, T > &&pa) DXLE_NOEXCEPT_OR_NOTHROW
 conversion from std::pair More...
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const point_c< T > &p)
 ostream operator More...
 
template<typename T >
std::wostream & operator<< (std::wostream &os, const point_c< T > &p)
 ostream operator More...
 
template<typename T >
std::istream & operator>> (std::istream &is, point_c< T > &p)
 istream operator More...
 
template<typename T >
std::wistream & operator>> (std::wistream &is, point_c< T > &p)
 istream operator More...
 
template<typename T >
DXLE_CONSTEXPR point_c< T > operator- (const point_c< T > &r) DXLE_NOEXCEPT_IF_EXPR(-r.x)
 Overload of unary operator -. More...
 
template<typename T >
DXLE_CONSTEXPR point_c< T > operator+ (const point_c< T > &r) DXLE_NOEXCEPT_IF(std
 Overload of unary operator +. More...
 
template<typename T >
DXLE_CONSTEXPR point_c< T > && operator+ (point_c< T > &&r) DXLE_NOEXCEPT_OR_NOTHROW
 Overload of unary operator +. More...
 
template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point_c< T1 > & operator+= (point_c< T1 > &l, const point_c< T2 > &r) DXLE_NOEXCEPT_IF_EXPR(l.x+
 Overload of binary operator +=. More...
 
template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator- (const point_c< T1 > &l, const point_c< T2 > &r) DXLE_NOEXCEPT_IF_EXPR(l.x - r.x) -> point_c< decltype(std::declval< std::remove_cv_t< T1 >>() - std::declval< std::remove_cv_t< T2 >>())>
 Overload of binary operator -. More...
 
template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator* (const point_c< T1 > &l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x *r) -> point_c< decltype(std::declval< std::remove_cv_t< T1 >>() *std::declval< std::remove_cv_t< T2 >>())>
 Overload of binary operator *. More...
 
template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator* (T1 l, const point_c< T2 > &r) DXLE_NOEXCEPT_IF_EXPR(l *r.x) -> point_c< decltype(std::declval< std::remove_cv_t< T1 >>() *std::declval< std::remove_cv_t< T2 >>())>
 Overload of binary operator *. More...
 
template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point_c< T1 > & operator*= (point_c< T1 > &l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x *
 Overload of binary operator *=. More...
 
template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point_c< T1 > & operator/= (point_c< T1 > &l, T2 r) DXLE_NOEXCEPT_IF_EXPR(l.x/
 Overload of binary operator /=. More...
 
template<typename T1 , typename T2 >
DXLE_CONSTEXPR double cross (const point_c< T1 > &p1, const point_c< T2 > &p2) DXLE_NOEXCEPT_IF_EXPR((static_cast_if< T1
 Computes a cross-product of two point_c value as vectors. More...
 
template<typename T1 , typename T2 >
distance_result_type_t< T1, T2distance (const point_c< T1 > &p1, const point_c< T2 > &p2) DXLE_NOEXCEPT_IF_EXPR(hypot(safe_dist(std
 Calculate the distance of the two point_c class object based on the Pythagorean theorem(std::hypot) More...
 
template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point_c< T1 > & operator+= (point_c< T1 > &l, const size_c< T2 > &r) DXLE_NOEXCEPT_IF_EXPR(l.x+
 Overload of binary operator +=. More...
 
template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator- (const point_c< T1 > &l, const size_c< T2 > &r) DXLE_NOEXCEPT_IF_EXPR(l.x - r.width) -> point_c< decltype(std::declval< std::remove_cv_t< T1 >>() - std::declval< std::remove_cv_t< T2 >>())>
 Overload of binary operator -. More...
 

Detailed Description

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
class dxle::point_c< T, >

Template class for 2D points specified by its coordinates x and y.

An instance of the claess is interchangeable with std::pair. There is also a cast operator to convert point coordinates to the specified type (using static_cast). Commonly, the conversion uses this operation for each of the coordinates. Besides the class members listed in the declaration above, the following operations on points are implemented:

pt1 = pt2 + pt3;
pt1 = pt2 - pt3;
pt1 = pt2 * a;
pt1 = a * pt2;
pt1 = pt2 / a;
pt1 += pt2;
pt1 -= pt2;
pt1 *= a;
pt1 /= a;
pt1 == pt2;
pt1 != pt2;

For your convenience, the following type aliases are defined:

typedef point_c<int> pointi;
typedef point_c<std::uint8_t> pointu8i;
typedef point_c<std::int8_t> point8i;
typedef point_c<double> pointd;
typedef point_c<float> pointf;

Example:

dxle::pointf a(0.3f, 0.f), b(0.f, 0.4f);
dxle::pointi pt = (a + b)*10.f;
std::cout << pt << std::endl;
Template Parameters
TT is the type of the elements. T must meet the requirements of NothrowMoveAssignable and NothrowConstructable. T is expected the following conditions to use all features.

Definition at line 105 of file point2d.hpp.

Member Typedef Documentation

§ value_type

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
typedef std::remove_cv<T>::type dxle::point_c< T, >::value_type

Definition at line 108 of file point2d.hpp.

Constructor & Destructor Documentation

§ point_c() [1/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( )
inline

Definition at line 110 of file point2d.hpp.

§ point_c() [2/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( const value_type x_,
const value_type y_ 
)
inline

Definition at line 111 of file point2d.hpp.

§ point_c() [3/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( value_type &&  x_,
value_type &&  y_ 
)
inline

Definition at line 112 of file point2d.hpp.

§ point_c() [4/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
template<typename Tp2_ >
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( const point_c< Tp2_ > &  other)
inlineexplicit

conversion from another data type

Definition at line 116 of file point2d.hpp.

§ point_c() [5/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
template<typename Tp2_ >
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( point_c< Tp2_ > &&  other)
inlineexplicit

conversion from another data type

Definition at line 119 of file point2d.hpp.

§ point_c() [6/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( const point_c< value_type > &  o)
inline

Definition at line 122 of file point2d.hpp.

§ point_c() [7/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( point_c< value_type > &&  o)
inline

Definition at line 124 of file point2d.hpp.

§ point_c() [8/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
template<typename Tp2_ >
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( const size_c< Tp2_, nullptr > &  other)
inlineexplicit

conversion from size_c

Definition at line 129 of file point2d.hpp.

§ point_c() [9/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
template<typename Tp2_ >
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( size_c< Tp2_, nullptr > &&  other)
inlineexplicit

conversion from size_c

Definition at line 133 of file point2d.hpp.

§ point_c() [10/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( const size_c< value_type, nullptr > &  other)
inline

conversion from size_c

Definition at line 137 of file point2d.hpp.

§ point_c() [11/11]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point_c< T, >::point_c ( size_c< value_type, nullptr > &&  other)
inline

conversion from size_c

Definition at line 141 of file point2d.hpp.

Member Function Documentation

§ operator bool()

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
DXLE_CONSTEXPR dxle::point_c< T, >::operator bool ( ) const
inlineexplicit

operator bool

  1. operator bool
  2. operator != (nullptr)
  3. default constector + operator !=

Definition at line 162 of file point2d.hpp.

§ operator std::pair< Tp2_, Tp2_ >()

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
template<typename Tp2_ >
dxle::point_c< T, >::operator std::pair< Tp2_, Tp2_ > ( ) const
inlineexplicit

conversion to std::pair

Definition at line 167 of file point2d.hpp.

§ operator=() [1/2]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
point_c& dxle::point_c< T, >::operator= ( const point_c< value_type > &  r)
inline

Definition at line 145 of file point2d.hpp.

§ operator=() [2/2]

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
point_c& dxle::point_c< T, >::operator= ( point_c< value_type > &&  r)
inline

Definition at line 152 of file point2d.hpp.

Friends And Related Function Documentation

§ cross()

template<typename T1 , typename T2 >
DXLE_CONSTEXPR double cross ( const point_c< T1 > &  p1,
const point_c< T2 > &  p2 
)
related

Computes a cross-product of two point_c value as vectors.

Parameters
p1point_c value
p2point_c value
Returns
Computed result.

§ distance()

template<typename T1 , typename T2 >
distance_result_type_t< T1, T2 > distance ( const point_c< T1 > &  p1,
const point_c< T2 > &  p2 
)
related

Calculate the distance of the two point_c class object based on the Pythagorean theorem(std::hypot)

Parameters
p1point_c value
p2point_c value
Returns
Computed result.

Definition at line 660 of file point2d.hpp.

§ make_point_c() [1/2]

template<typename T >
point_c< T > make_point_c ( const std::pair< T, T > &  pa)
related

conversion from std::pair

Parameters
paconst-lvalue reference to std::pair
Returns
point_c value

Definition at line 183 of file point2d.hpp.

§ make_point_c() [2/2]

template<typename T >
point_c< T > make_point_c ( std::pair< T, T > &&  pa)
related

conversion from std::pair

Parameters
parvalue reference to std::pair
Returns
point_c value

Definition at line 196 of file point2d.hpp.

§ operator*() [1/2]

template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator* ( const point_c< T1 > &  l,
T2  r 
) -> point_c<decltype(std::declval<std::remove_cv_t<T1>>() * std::declval<std::remove_cv_t<T2>>())>
related

Overload of binary operator *.

Parameters
lconst-lvalue reference to point_c value
rarithmetic value
Returns
Memberwise multiplication by 2nd argument

Definition at line 409 of file point2d.hpp.

§ operator*() [2/2]

template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator* ( T1  l,
const point_c< T2 > &  r 
) -> point_c<decltype(std::declval<std::remove_cv_t<T1>>() * std::declval<std::remove_cv_t<T2>>())>
related

Overload of binary operator *.

Parameters
larithmetic value
rconst-lvalue reference to point_c value
Returns
Memberwise multiplication by 1st argument

Definition at line 427 of file point2d.hpp.

§ operator*=()

template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point_c< T1 > & operator*= ( point_c< T1 > &  l,
T2  r 
)
related

Overload of binary operator *=.

Parameters
lconst-lvalue reference to point_c value
rarithmetic value
Returns
lvalue reference to 1st argument

§ operator+() [1/2]

template<typename T >
DXLE_CONSTEXPR point_c< T > operator+ ( const point_c< T > &  r)
related

Overload of unary operator +.

Parameters
rconst-lvalue reference to point_c value
Returns
const-lvalue reference to first argument

Definition at line 309 of file point2d.hpp.

§ operator+() [2/2]

template<typename T >
DXLE_CONSTEXPR point_c< T > && operator+ ( point_c< T > &&  r)
related

Overload of unary operator +.

Parameters
rrvalue reference to point_c value
Returns
rvalue reference to first argument

Definition at line 321 of file point2d.hpp.

§ operator+=() [1/2]

template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point_c< T1 > & operator+= ( point_c< T1 > &  l,
const size_c< T2 > &  r 
)
related

Overload of binary operator +=.

Parameters
llvalue reference to point_c value
rconst-lvalue reference to size_c value
Returns
lvalue reference to first argument

§ operator+=() [2/2]

template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point_c< T1 > & operator+= ( point_c< T1 > &  l,
const point_c< T2 > &  r 
)
related

Overload of binary operator +=.

Parameters
llvalue reference to point_c value
rconst-lvalue reference to point_c value
Returns
lvalue reference to first argument

§ operator-() [1/3]

template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator- ( const point_c< T1 > &  l,
const size_c< T2 > &  r 
) -> point_c<decltype(std::declval<std::remove_cv_t<T1>>() - std::declval<std::remove_cv_t<T2>>())>
related

Overload of binary operator -.

Parameters
lconst-lvalue reference to point_c value
rconst-lvalue reference to size_c value
Returns
Memberwise addition of both point_c value

Definition at line 142 of file basic_types.hpp.

§ operator-() [2/3]

template<typename T >
DXLE_CONSTEXPR point_c< T > operator- ( const point_c< T > &  r)
related

Overload of unary operator -.

Parameters
rpoint_c value to negate
Returns
Memberwise opposite of the point_c value

Definition at line 294 of file point2d.hpp.

§ operator-() [3/3]

template<typename T1 , typename T2 >
DXLE_CONSTEXPR auto operator- ( const point_c< T1 > &  l,
const point_c< T2 > &  r 
) -> point_c<decltype(std::declval<std::remove_cv_t<T1>>() - std::declval<std::remove_cv_t<T2>>())>
related

Overload of binary operator -.

Parameters
lconst-lvalue reference to point_c value
rconst-lvalue reference to point_c value
Returns
Memberwise subtraction of both point_c value

Definition at line 391 of file point2d.hpp.

§ operator/=()

template<typename T1 , typename T2 , enable_if_t< is_representable< T2, T1 >::value, nullptr_t > = nullptr>
point_c< T1 > & operator/= ( point_c< T1 > &  l,
T2  r 
)
related

Overload of binary operator /=.

Parameters
lconst-lvalue reference to point_c value
rarithmetic value
Returns
lvalue reference to 1st argument

§ operator<<() [1/2]

template<typename T >
std::ostream & operator<< ( std::ostream &  os,
const point_c< T > &  p 
)
related

ostream operator

Parameters
oslvalue reference to ostream
pconst-lvalue reference to point_c
Returns
lvalue reference to ostream whitch is specified at first argument

Definition at line 230 of file point2d.hpp.

§ operator<<() [2/2]

template<typename T >
std::wostream & operator<< ( std::wostream &  os,
const point_c< T > &  p 
)
related

ostream operator

Parameters
oslvalue reference to ostream
pconst-lvalue reference to point_c
Returns
lvalue reference to ostream whitch is specified at first argument

Definition at line 246 of file point2d.hpp.

§ operator>>() [1/2]

template<typename T >
std::istream & operator>> ( std::istream &  is,
point_c< T > &  p 
)
related

istream operator

Parameters
islvalue reference to istream
pconst-lvalue reference to point_c
Returns
lvalue reference to istream whitch is specified at first argument

Definition at line 262 of file point2d.hpp.

§ operator>>() [2/2]

template<typename T >
std::wistream & operator>> ( std::wistream &  is,
point_c< T > &  p 
)
related

istream operator

Parameters
islvalue reference to istream
pconst-lvalue reference to point_c
Returns
lvalue reference to istream whitch is specified at first argument

Definition at line 278 of file point2d.hpp.

Member Data Documentation

§ x

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
value_type dxle::point_c< T, >::x

Definition at line 109 of file point2d.hpp.

§ y

template<typename T, enable_if_t< std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value, nullptr_t > = nullptr>
value_type dxle::point_c< T, >::y

Definition at line 109 of file point2d.hpp.


The documentation for this class was generated from the following files: