IDS peak IPL v1.17.2
Loading...
Searching...
No Matches
peak::common::detail::SizeT< T > Class Template Reference

Represents a two-dimensional size with non-negative width and height. More...

#include <peak_common/types/geometry/peak_common_size.hpp>

Public Member Functions

constexpr SizeT ()=default
 Default constructor for SizeT.
template<typename H = T>
constexpr SizeT (T width, T height)
 Constructs a SizeT object from integral width and height.
template<typename H = T>
constexpr SizeT (T width, T height)
 Constructs a SizeT object from floating-point width and height.
PEAK_COMMON_NO_DISCARD constexpr T GetWidth () const
 Returns the width.
PEAK_COMMON_NO_DISCARD constexpr T GetHeight () const
 Returns the height.
PEAK_COMMON_NO_DISCARD constexpr SizeT< T > Transposed () const
 Returns a transposed size with width and height swapped.
template<typename H>
constexpr bool operator== (const SizeT< H > &rhs) const
 Equality operator for integral types.
template<typename H>
constexpr bool operator== (const SizeT< H > &rhs) const
 Equality operator for floating point types.
template<typename H>
constexpr bool operator!= (const SizeT< H > &rhs) const
 Inequality operator.
PEAK_COMMON_NO_DISCARD std::string ToString () const
 Convert the SizeT instance to a string representation.

Friends

std::ostream & operator<< (std::ostream &os, SizeT size)
 Stream operator to output SizeT in a readable format.

Detailed Description

template<typename T>
class peak::common::detail::SizeT< T >

Represents a two-dimensional size with non-negative width and height.

A SizeT stores the width and height of an object or area. Both dimensions must be greater than or equal to zero.

Template Parameters
TArithmetic type used for width and height.
Since
ids_peak_common 1.0

Constructor & Destructor Documentation

◆ SizeT() [1/3]

template<typename T>
peak::common::detail::SizeT< T >::SizeT ( )
constexprdefault

Default constructor for SizeT.

Initializes a size with default values for width and height.

Since
ids_peak_common 1.0

◆ SizeT() [2/3]

template<typename T>
template<typename H = T>
peak::common::detail::SizeT< T >::SizeT ( T width,
T height )
inlineconstexpr

Constructs a SizeT object from integral width and height.

Initializes the size with the specified width and height values.

Parameters
widthWidth of the size.
heightHeight of the size.
Since
ids_peak_common 1.0

◆ SizeT() [3/3]

template<typename T>
template<typename H = T>
peak::common::detail::SizeT< T >::SizeT ( T width,
T height )
inlineconstexpr

Constructs a SizeT object from floating-point width and height.

Initializes the size with the specified width and height values. Throws an exception if either value is negative.

Parameters
widthWidth of the size.
heightHeight of the size.
Exceptions
InvalidParameterExceptionIf width or height is less than zero.
Since
ids_peak_common 1.0

Member Function Documentation

◆ GetHeight()

template<typename T>
PEAK_COMMON_NO_DISCARD constexpr T peak::common::detail::SizeT< T >::GetHeight ( ) const
inlineconstexpr

Returns the height.

Returns
The height value.
Since
ids_peak_common 1.0

◆ GetWidth()

template<typename T>
PEAK_COMMON_NO_DISCARD constexpr T peak::common::detail::SizeT< T >::GetWidth ( ) const
inlineconstexpr

Returns the width.

Returns
The width value.
Since
ids_peak_common 1.0

◆ operator!=()

template<typename T>
template<typename H>
bool peak::common::detail::SizeT< T >::operator!= ( const SizeT< H > & rhs) const
inlineconstexpr

Inequality operator.

Returns true if the sizes are not equal.

Parameters
rhsThe SizeT object to compare against.
Returns
true if sizes are different; false otherwise.
Since
ids_peak_common 1.0

◆ operator==() [1/2]

template<typename T>
template<typename H>
bool peak::common::detail::SizeT< T >::operator== ( const SizeT< H > & rhs) const
inlineconstexpr

Equality operator for integral types.

Compares width and height for exact equality.

Parameters
rhsThe SizeT object to compare against.
Returns
true if both width and height are equal; false otherwise.
Since
ids_peak_common 1.0

◆ operator==() [2/2]

template<typename T>
template<typename H>
bool peak::common::detail::SizeT< T >::operator== ( const SizeT< H > & rhs) const
inlineconstexpr

Equality operator for floating point types.

Compares width and height using a tolerance based on ULP (Units in Last Place).

Parameters
rhsThe SizeT object to compare against.
Returns
true if both width and height are approximately equal within tolerance; false otherwise.
Since
ids_peak_common 1.0

◆ ToString()

template<typename T>
PEAK_COMMON_NO_DISCARD std::string peak::common::detail::SizeT< T >::ToString ( ) const
inline

Convert the SizeT instance to a string representation.

Outputs width and height in the form: { width: ..., height: ... }

Returns
String representation of the size
Since
ids_peak_common 1.0

◆ Transposed()

template<typename T>
PEAK_COMMON_NO_DISCARD constexpr SizeT< T > peak::common::detail::SizeT< T >::Transposed ( ) const
inlineconstexpr

Returns a transposed size with width and height swapped.

Returns
A new SizeT object with width and height swapped.
Since
ids_peak_common 1.0

◆ operator<<

template<typename T>
std::ostream & operator<< ( std::ostream & os,
SizeT< T > size )
friend

Stream operator to output SizeT in a readable format.

Outputs width and height in the form: { width: ..., height: ... }

Parameters
osOutput stream
sizeSizeT instance to output
Returns
Reference to the output stream
Since
ids_peak_common 1.0

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