PrevUpHomeNext

utx::mean_t


utx::mean_t - utx::mean

utx::mean_t is a computing type-trait to get the type from second template parameter or third template parameter depending on the condition is met or not.

utx::mean_t is a compile-time conditional if-else template class for type identification.

utx::mean_t has already been used in many cases of utxcpp library. It is proved very useful in practice. Many things become simple after using utx::mean_t.

utx::mean_t - utx::mean

template <bool condition, typename type1, typename type2>
class mean
{
public:
	using type = ???;
};

If condition is true, utx::mean::type equals to type1; else utx::mean::type equals to type2.

template <bool condition, typename type1, typename type2>
using mean_t = utx::mean<condition, type1, type2>::type;

Include

#include <utxcpp/core.hpp>

c++ example

#include <utxcpp/core.hpp>

int main()
{
	using type1 = utx::mean_t<true, utx::i32, std::string>;
	static_assert(std::same_as<type1, utx::i32>);

	using type2 = utx::mean_t<false, utx::i32, std::string>;
	static_assert(std::same_as<type2, std::string>);
}

See Also

utx::mean_v

Last revised: February 24, 2024 at 08:57:24 GMT


PrevUpHomeNext