PrevUpHomeNext

esv::real_meric


Protecting animals is glorious.

esv::real_meric - Esvcpp Basic Concepts

The concept esv::real_meric<type1> is satisfied if type1 is a real number or type1 is a real esv::class_type.

meric means numeric in esv::real_meric.

"real" means the real number in math.

A real number is a disjunction of unsigned integral, signed integral and floating point number in esvcpp.

Accordingly, a real esv::class_type is a disjunction of unsigned esv::class_type, signed esv::class_type, and floating esv::class_type.

However, esv::class_type is always real.

esv::real_meric is basic and used by esvcpp/types.hpp. To use it, just include:

#include <esvcpp/types.hpp>

However esvcpp/types.hpp is used by the whole project, so, to use it, including esvcpp/core.hpp works too:

#include <esvcpp/core.hpp>

esv::unsigned_meric

esv::unsigned_meric<type1> is satisfied if type1 is unsigned integral, or type1 is unsigned esv::class_type.

esv::signed_meric

esv::signed_meric<type1> is satisfied if type1 is signed integral, or type1 is signed esv::class_type.

esv::integral_meric

esv::integral_meric<type1> is satisfied if type1 is integral, or type1 is integral esv::class_type.

esv::floating_meric

esv::floating_meric<type1> is satisfied if type1 is floating integral, or type1 is floating esv::class_type.

Examples

Example

#include <esvcpp/types.hpp>

template <esv::real_meric type1>
class sun
{
public:
	void operator()() const {}
};

int main()
{
	sun<int>{}();
	sun<esv::u32>{}();
	sun<esv::i32>{}();
	sun<esv::f32>{}();

	sun<esv::ux32>{}();
	sun<esv::ix32>{}();
	sun<esv::fx32>{}();

	class window
	{
	};

	//sun<window>{}(); //error: 'window' does not satisfy 'real_meric'
}

Example

#include <esvcpp/core.hpp>

int main()
{
	esv::real_meric auto a = 32; // a is deduced to esv::i32 (aka. int).
	esv::real_meric auto b = 3.2; // b is deduced to esv::f64 (aka. double).
	esv::real_meric auto c = esv::ux64{1280}; // c is deduced to esv::ux64 (esv::class_type).
	esv::real_meric auto d = true; // d is deduced to bool.
	esv::real_meric auto e = 'M'; // e is deduced to esv::i8 (aka. char).
	//esv::real_meric auto f = "pear"; // error: const char * does not satisfy esv::real_meric.

	esv::print(a, b, c, d, e);
}

Example

#include <esvcpp/core.hpp>

int main()
{
	constexpr auto a = esv::real_meric<int>;
	constexpr auto b = esv::real_meric<esv::u8>;
	constexpr auto c = esv::real_meric<esv::fxmax>;

	class sun {};
	constexpr auto d = esv::real_meric<sun>;

	static_assert(a==true && b==true && c==true && d==false);
}

Example

#include <esvcpp/core.hpp>

int main()
{
	static_assert(esv::unsigned_meric<esv::ux64>);
	static_assert(esv::signed_meric<esv::ix64>);
	static_assert(esv::integral_meric<esv::ux64>);
	static_assert(esv::integral_meric<esv::ix64>);
	static_assert(esv::floating_meric<esv::fx64>);
}

See also

esv::real_uct

esv::real_number

esv::ix32 esv::i32

esv::ux32 esv::u32

esv::ix64 esv::i64

esv::ux64 esv::u64

esv::fx32 esv::f32

esv::fx64 esv::f64

esv::print


PrevUpHomeNext

esv::print