FayIge

https://fayige.top

c++ programming language

c++ is the most popular and good programming langauge in the world. c++ is object-oriented.

c++ concepts

c++ concepts make c++ template greatful.

template <typename type_t>
concept has_size =
	requires ()
	{
		type_t{}.size();
	}
;
template <typename type_t>
concept has_type =
	requires ()
	{
		typename type_t::type;
	}
;

c++ template specialization

Primary template: the first declaration

template <typename the_type>
class my_class
{
public:
	void print() const
	{
		std::cout << "I am general" << std::endl;
	}
};

EX: Int specialization

template <>
class my_class<int>
{
public:
	void print() const
	{
		std::cout << "I am int" << std::endl;
	}
};

EX: floating point specialization

template <std::floating_point the_type>
class my_class<the_type>
{
public:
	void print() const
	{
		std::cout << "I am some float type" << std::endl;
	}
};

c++