IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
SizeT< T > Class Template Reference

#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.
 
constexpr T GetWidth () const
 Returns the width.
 
constexpr T GetHeight () const
 Returns the height.
 
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.
 
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

Definition at line 41 of file peak_common_size.hpp.

Constructor & Destructor Documentation

◆ SizeT() [1/3]

template<typename 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>
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

Definition at line 72 of file peak_common_size.hpp.

◆ SizeT() [3/3]

template<typename T >
template<typename H = 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

Definition at line 98 of file peak_common_size.hpp.

Member Function Documentation

◆ GetHeight()

template<typename T >
T GetHeight ( ) const
inlineconstexpr

Returns the height.

Returns
The height value.
Since
ids_peak_common 1.0

Definition at line 131 of file peak_common_size.hpp.

◆ GetWidth()

template<typename T >
T GetWidth ( ) const
inlineconstexpr

Returns the width.

Returns
The width value.
Since
ids_peak_common 1.0

Definition at line 119 of file peak_common_size.hpp.

◆ operator!=()

template<typename T >
template<typename H >
bool 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

Definition at line 207 of file peak_common_size.hpp.

◆ operator==() [1/2]

template<typename T >
template<typename H >
bool 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

Definition at line 164 of file peak_common_size.hpp.

◆ operator==() [2/2]

template<typename T >
template<typename H >
bool 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

Definition at line 185 of file peak_common_size.hpp.

◆ ToString()

template<typename T >
std::string 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

Definition at line 237 of file peak_common_size.hpp.

◆ Transposed()

template<typename T >
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

Definition at line 143 of file peak_common_size.hpp.

Friends And Related Symbol Documentation

◆ 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

Definition at line 223 of file peak_common_size.hpp.