PrevUpHomeNext

Class Types


Table of Contents

esv::ix8
esv::ix16
esv::ix32
esv::ix64
esv::ixlast
esv::ixmax
esv::ixlost
esv::ux8
esv::ux16
esv::ux32
esv::ux64
esv::uxlast
esv::uxmax
esv::uxlost
esv::fx32
esv::fx64
esv::fx128
esv::fxmax
esv::fxlast
esv::mbx
esv::mtx
esv::mtx8
esv::mtx16
esv::mtx32
esv::wmtx
.is_nan method
.is_inf method
.abs method
.floor_fpp method
.floor method
.fpp method
.ceil method
.quo_mod method
.quo method
.mod method
.cast method

esvcpp class types

esv::class_type

esv::class_type is used to define basic integral and floating point types, but it is class. So the data types defined by esv::class_type have both the basic data type features and object-oriented features.

operators defined in esv::class_type :

esv::mbx

bool class

using mbx = esv::class_type<esv::mb>;

esv::ux8 esv::ux16 esv::ux32 esv::ux64 esv::uxmax

unsigned integral class

using ux8 = esv::class_type<esv::u8>;
using ux16 = esv::class_type<esv::u16>;
using ux32 = esv::class_type<esv::u32>;
using ux64 = esv::class_type<esv::u64>;
using uxmax = esv::class_type<esv::umax>;

esv::ix8 esv::ix16 esv::ix32 esv::ix64 esv::ixmax

signed integral class

using ix8 = esv::class_type<esv::i8>;
using ix16 = esv::class_type<esv::i16>;
using ix32 = esv::class_type<esv::i32>;
using ix64 = esv::class_type<esv::i64>;
using ixmax = esv::class_type<esv::imax>;

esv::fx32 esv::fx64 esv::fx128 esv::fxmax

floating point class

using fx32 = esv::class_type<esv::f32>;
using fx64 = esv::class_type<esv::f64>;
using fx128 = esv::class_type<esv::f128>;
using fxmax = esv::class_type<esv::fmax>;

.value(), operator(), operator basic_type

These three member functions return __value by value.

.value_ref()

Member function .value_ref() returns __value by ref.

esv::class_type does not overload .value() to support both by-value and by-ref, but uses .value_ref() to get by ref.

include

esvcpp/types.hpp :

#include <esvcpp/types.hpp>

esvcpp/types.hpp is included by the whole system, so using esvcpp/core.hpp works too:

#include <esvcpp/core.hpp>

examples

example: Using esv::class_type, and constexpr support

#include <esvcpp/core.hpp>

int main()
{
	constexpr esv::ux64 a = 123;
	constexpr esv::ix64 b = 321;
	constexpr esv::fx64 c = 321.123;
	esv::print(a, b, c);
}

output:

123 321 321.123000

example: esv::class_type value as template parameter

#include <esvcpp/core.hpp>

template <auto __value>
class power
{
public:
	constexpr auto operator()() const
	{
		return __value*__value;
	}
};

int main()
{
	constexpr esv::fx32 value = 123.456f;
	constexpr auto p2 = power<value>{}();
	esv::print(p2);
}

output:

15241.383789

example: esv::class_type inheritence, polymorphism, pointer

esv::class_type does not support polymorphism itself, but it can be used as the base class of another polymorphism base class.

#include <esvcpp/core.hpp>
#include <memory>

class base: public esv::ix64
{
public:
	base(const auto & value): esv::ix64{value}
	{
	}
	virtual ~base()
	{
		esv::print("~base");
	}
};

class derived: virtual public base
{
public:
	derived(const auto & value): base{value}
	{
	}
	~derived()
	{
		esv::print("~derived");
	}
};

int main()
{
	base * ptr = new derived{123};
	esv::print(*ptr);
	delete ptr;

	{
		std::unique_ptr<base> ptr = std::make_unique<derived>(32);
		esv::print(*ptr);
	}
}

output:

123
~derived
~base
32
~derived
~base

PrevUpHomeNext

esv::print