PrevUpHomeNext

esv::mean_t


One sky, one home.

esv::mean_t - esv::mean

esv::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.

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

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

esv::mean_t - esv::mean

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

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

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

Include

#include <esvcpp/core.hpp>

c++ example

#include <esvcpp/core.hpp>

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

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

See Also

esv::mean_v


PrevUpHomeNext

esv::print