PrevUpHomeNext

utx::real_meric


utx::real_meric - Utxcpp Basic Concepts

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

meric means numeric in utx::real_meric.

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

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

However, utx::class_type is always real.

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

#include <utxcpp/types.hpp>

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

#include <utxcpp/core.hpp>

utx::unsigned_meric

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

utx::signed_meric

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

utx::integral_meric

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

utx::floating_meric

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

Examples

Example

#include <utxcpp/types.hpp>

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

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

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

	class window
	{
	};

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

Example

#include <utxcpp/core.hpp>

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

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

Example

#include <utxcpp/core.hpp>

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

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

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

Example

#include <utxcpp/core.hpp>

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

See Also

utx::ix32

utx::ux32

utx::fx32

utx::fx64


PrevUpHomeNext