本文主要是介绍Crow:Middlewares 庖丁解牛2 产生序列,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
include\crow\utility.h内有这样一段比较晦涩难懂的代码:
template<class T>
using Invoke = typename T::type;template<unsigned...>
struct seq
{using type = seq;
};template<class S1, class S2>
struct concat;template<unsigned... I1, unsigned... I2>
struct concat<seq<I1...>, seq<I2...>> : seq<I1..., (sizeof...(I1) + I2)...>
{};template<class S1, class S2>
using Concat = Invoke<concat<S1, S2>>;template<unsigned N>
struct gen_seq;
template<unsigned N>
using GenSeq = Invoke<gen_seq<N>>;template<unsigned N>
struct gen_seq : Concat<GenSeq<N / 2>, GenSeq<N - N / 2>>
{};template<>
struct gen_seq<0> : seq<>
{};
template<>
struct gen_seq<1> : seq<0>
{};
这段代码是做什么的呢?
先说结论,是产生一个序列的:
template<unsigned...
这篇关于Crow:Middlewares 庖丁解牛2 产生序列的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!