fill - TumpCpp リファレンス

namespace tump {
    template <class T, std::size_t N>
    struct fill_type_arg {};

    template <auto V, std::size_t N>
    struct fill_value_arg {};

    namespace fn {
        // 大元のメタ関数定義
        template <TypeListOrValueList List, class FillArg>
        struct fill {};
    }

    // 第一級関数化
    using fill = cbk<fn::fill, 2>;

    // 定数メンバ type 呼び出し省略のエイリアステンプレート
    template <TypeListOrValueList List, class FillArg>
    using fill_t = typename fn::fill<List, FillArg>::type;
}

パラメータ

概要

tump::fillは、引数Listが持つ要素を、N個のTによるパラメータパックで置き換えます。

なお、テンプレートパラメータに非型が含まれていると、tump::expやtump::evalの式中で、使うことができないメタ関数となってしまいます。
そのため、非型パラメータは直接tump::fillではなく、tump::fill_type_argまたは、tump::fill_value_argをはさんで渡すような実装となっています。

例

#include <tuple>
#include <tump.hpp>

using list1 = tump::list<int, float, char>;
using list2 = tump::make_empty_t<std::tuple<int, float, char>>;
using list3 = tump::vlist<>;

static_assert(std::is_same_v<
    tump::fill_t<list1, tump::fill_type_arg<int, 5>>,
    tump::list<int, int, int, int, int>
> == true);

static_assert(tump::eval<
    tump::fill, list2, tump::fill_type_arg<double, 3>,
    tump::_eq,
    std::tuple<double, double, double>
>::value == true);

static_assert(tump::eval<
    tump::fill, list3, tump::fill_value_arg<long(3), 3>,
    tump::_eq,
    tump::vlist<long(3), long(3), long(3)>
>::value == true);

int main() {}

関連リンク