Skip to content

Instantly share code, notes, and snippets.

@Fuyutsubaki
Created August 5, 2014 14:49
Show Gist options
  • Save Fuyutsubaki/5294ff1fc031e4fe323b to your computer and use it in GitHub Desktop.
Save Fuyutsubaki/5294ff1fc031e4fe323b to your computer and use it in GitHub Desktop.
TMP二分木fold
namespace otmp
{
template<class list, template<class...>class Func>
class fold1
{
template<std::size_t Begin, std::size_t Len>
struct impl
:Func<typename impl<Begin, Len / 2>::type, typename impl<Begin + Len / 2, Len - Len / 2>::type>
{};
template<std::size_t Begin>
struct impl<Begin, 1>
:at<Begin, list>
{};
public:
using type = typename impl<0, getLength_t<list>::value>::type ;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment