plasma_effectのメモ帳的ブログのようなsomething
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
#pragma once
#include"type_traits.hpp"
#include"preprocess.hpp"
namespace dcl
{
//index_tuple
template<int...>struct index_tuple{};
namespace detail
{
//get_index_next
constexpr int get_index_next(int a)
{
return (a%2==0 ? a/2 : (a-1)/2);
}
//index_next
template<class Index,int N,bool is_even>struct index_next;
template<int N,int... Nums>//even
struct index_next<dcl::index_tuple<Nums...>,N,true>
{
using type = index_tuple<Nums...,(N+Nums)...>;
};
template<int N,int... Nums>//odd
struct index_next<dcl::index_tuple<Nums...>,N,false>
{
using type = index_tuple<Nums...,(N+Nums)...,2*N>;
};
template<>//0
struct index_next<dcl::index_tuple<>,0,false>
{
using type = index_tuple<0>;
};
//index_count_impl
template<int End>struct index_count_impl
{
using type = typename index_next<
typename index_count_impl<get_index_next(End)>::type,
get_index_next(End),
End%2==0>::type;
};
template<>struct index_count_impl<0>
{
using type = index_tuple<>;
};
}
//index_count
template<size_t N>class index_count
{
public:
using type = typename detail::index_count_impl<N>::type;
};
//index_range
namespace detail
{
template<class,int,int>struct index_range_impl;
template<int... Nums,int Start,int Step>
struct index_range_impl<index_tuple<Nums...>,Start,Step>
{
using type = index_tuple<(Start+Nums*Step)...>;
};
}
template<int Start,int End,int Step=1>class index_range
{
public:
using type = typename detail::index_range_impl<
typename index_count<1+(End-Start)/Step>::type,
Start,
Step>::type;
};
//index_merge
namespace detail
{
template<class,class,class,class,class,class>struct index_merge_impl;
template<int... NumsA,int... NumsB,int... NumsC,int... NumsD,int... NumsE,int... NumsF>
struct index_merge_impl<
index_tuple<NumsA...>,
index_tuple<NumsB...>,
index_tuple<NumsC...>,
index_tuple<NumsD...>,
index_tuple<NumsE...>,
index_tuple<NumsF...>>
{
using type = index_tuple<NumsA...,NumsB...,NumsC...,NumsD...,NumsE...,NumsF...>;
};
}
template<class IndexA,class IndexB,class IndexC=index_tuple<>,class IndexD=index_tuple<>,class IndexE=index_tuple<>,class IndexF=index_tuple<>>class index_merge
{
public:
using type = typename detail::index_merge_impl<IndexA,IndexB,IndexC,IndexD,IndexE,IndexF>::type;
};
//DCL_COUNT_DOWN_USING
#define DCL_COUNT_DOWN_USING(TO,FROM)\
template<class>struct DCL_PP_CAT(impl_index_range_cat_,TO);\
template<int... Nums>struct \
DCL_PP_CAT(impl_index_range_cat_,TO)<dcl::index_tuple<Nums...>>\
{using type = FROM<Nums...>;};\
template<int N>\
using TO = typename DCL_PP_CAT(impl_index_range_cat_,TO)\
<typename dcl::index_count<N>::type>::type;
//DCL_INDEX_RANGE_USING
#define DCL_INDEX_RANGE_USING(TO,FROM)\
template<class>struct DCL_PP_CAT(impl_index_range_cat_,TO);\
template<int... Nums>struct \
DCL_PP_CAT(impl_index_range_cat_,TO)<dcl::index_tuple<Nums...>>\
{using type = FROM<Nums...>;};\
template<int Start,int End,int Step=0>\
using TO = typename DCL_PP_CAT(impl_index_range_cat_,TO)\
<typename dcl::index_range<Start,End,Step>::type>::type;
}
カレンダー
カテゴリー
フリーエリア
最新CM
最新記事
プロフィール
ブログ内検索
P R