PrevUpHomeNext

SizeType

oglplus/size_type.hpp

OGLplus defines a wrapper for size types represented in OpenGL, OpenAL, etc. by integer like GLsizei or GLsizeiptr.

Instances of this type are constructible from integral types and the constructors can throw if the initial value is negative or out of range.

Implementation

#if OGLPLUS_LOW_PROFILE

template <typename T>
struct SizeImpl
{
	typedef T Type;
};

#else // !OGLPLUS_LOW_PROFILE

template <typename T>
struct SizeImpl
{
public:
	typedef SizeImpl Type;

	SizeImpl(void) 1
	noexcept;

	template <typename X, typename = typename is_integral<X>::type>
	SizeImpl(X v); 2

	explicit
	operator bool (void) const
	noexcept; 3

	bool operator ! (void) const
	noexcept; 4

	operator T (void) const 5
	noexcept;

	template <typename X>
	explicit
	operator X (void) const; 6

	friend bool operator == (SizeImpl s1, SizeImpl s2);

	friend bool operator != (SizeImpl s1, SizeImpl s2);

	friend bool operator <  (SizeImpl s1, SizeImpl s2);

	friend bool operator <= (SizeImpl s1, SizeImpl s2);

	friend bool operator >  (SizeImpl s1, SizeImpl s2);

	friend bool operator >= (SizeImpl s1, SizeImpl s2);

	friend bool operator + (SizeImpl s1, SizeImpl s2);

	friend bool operator - (SizeImpl s1, SizeImpl s2);

	friend bool operator * (SizeImpl s1, SizeImpl s2);

	friend bool operator / (SizeImpl s1, SizeImpl s2);

	friend bool operator % (SizeImpl s1, SizeImpl s2);
};

1

Constructs a zero size instance.

2

Conversion from other signed or unsigned integral types. Throws if the passed value is negative or out of range of T.

3

Indicates if the stored value is valid i.e. nonnegativa and was in range of T when initialized.

4

Indicates if the stored value is invalid i.e. negative or was out of range of T when initialized.

5

Implicit conversion to T.

6

Explicit conversion to other (integral) types. May throw if the stored value is negative and X is unsigned or if it is out of range of X.

Definition

typedef typename SizeImpl<GLsizei>::Type SizeType;
typedef typename SizeImpl<GLsizeiptr>::Type BigSizeType;

template <typename X, typename = typename is_integral<X>::type>
SizeImpl MakeSizeImpl(X v, std::nothrow_t)
noexcept; 1

1

Constructs a SizeImpl from other signed or unsigned integral types. Does not throw.


PrevUpHomeNext