#include <iostream>
#include <string>
#include <string_view>

constexpr bool validate(std::string_view view, int n)
{
	int i = 0;
	for (auto& c : view)
	{
		if (c == '%')
		{
			i++;
		}
	}
	return i == n;
}

template<class StrLiteral, class ...Vars>
void fmt(StrLiteral str, const Vars&... args)
{
	constexpr std::string_view view = str();

	static_assert(validate(view, sizeof...(args)), "Wrong format");

	printf(view.data(), args...);
}

template<class ...Vars>
void fmt(std::string str, const Vars& ... args)
{
	printf(str.c_str(), args...);
}

#define _F(str) []() { return str; }

void main()
{
	fmt(_F("compile %d\n"), 555);
	fmt(std::string("runtime no check %d\n"), 555);
	fmt(_F("compile no args\n"));
	//fmt(_F("compile error\n"), 555);
	return;
}