C++コンパイル期間短縮-テンプレートメタプログラミングを実現

5555 ワード

https://blog.csdn.net/huanghongxun/article/details/85065406
上記のブログを参考にしますが、具体的な実装は異なります.
#pragma once
#include
namespace mystd {
	template 
	struct integral_constant {
		static constexpr T value = v;
		typedef T value_type;
		//constexpr operator T() const noexcept { return value; }
		//constexpr T operator()() const noexcept { return value; }
	};

	template 
	using integer_constant = integral_constant;

	//      
	template 
	struct integral_sequence { typedef T value_type;};

	template 
	using integer_sequence = integral_sequence;

	//  
	template
	struct mylength {};

	template
	struct mylength,T> :integral_constant {};

	template
	using length=mylength;



	template
	struct push_front_t {};

	template
	struct push_front_t> { using type=integral_sequence; };

	template
	using push_front=typename push_front_t::type;

	//push_back
	template
	struct push_back_t {};

	template
	struct push_back_t> { using type=integral_sequence; };

	template
	using push_back=typename push_back_t::type;


	//print
	template 
	struct print { };

	template
	struct print> {
		static void print_integer() {
			std::cout << start << ' ';
			print>::print_integer();
		}
	};
	template<>
	struct print> {
		static void print_integer() { ; }
	};

	//empty
	template
	struct empty;
	template<>
	struct empty> :std::true_type {};

	template
	struct empty> :std::false_type {};


	//  
	template
	struct conditional {};

	template
	struct conditional { using type=T; };

	template
	struct conditional { using type=F; };

	//map
	template
#include
#include"test.h"
#include

using namespace mystd;
void main() {
	//print>::type>::print_integer();
	print>::type>::print_integer();
}