當前位置: 首頁>>代碼示例>>C++>>正文


C++ BOOST_HANA_CONSTANT_CHECK函數代碼示例

本文整理匯總了C++中BOOST_HANA_CONSTANT_CHECK函數的典型用法代碼示例。如果您正苦於以下問題:C++ BOOST_HANA_CONSTANT_CHECK函數的具體用法?C++ BOOST_HANA_CONSTANT_CHECK怎麽用?C++ BOOST_HANA_CONSTANT_CHECK使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BOOST_HANA_CONSTANT_CHECK函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: main

int main() {
    // Interoperation with hana::integral_constant
    BOOST_HANA_CONSTANT_CHECK(mpl::integral_c<int, 1>{} == hana::int_c<1>);
    BOOST_HANA_CONSTANT_CHECK(mpl::integral_c<int, 1>{} == hana::long_c<1>);

    BOOST_HANA_CONSTANT_CHECK(mpl::integral_c<int, 2>{} != hana::int_c<3>);
}
開發者ID:LocutusOfBorg,項目名稱:poedit,代碼行數:7,代碼來源:interop.cpp

示例2: main

int main() {
    auto container = ::seq;

    {
        auto storage = container();
        auto transformed = hana::experimental::transformed(storage, undefined<99>{});
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(transformed),
            hana::size_c<0>
        ));
    }{
        auto storage = container(undefined<0>{});
        auto transformed = hana::experimental::transformed(storage, undefined<99>{});
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(transformed),
            hana::size_c<1>
        ));
    }{
        auto storage = container(undefined<0>{}, undefined<1>{});
        auto transformed = hana::experimental::transformed(storage, undefined<99>{});
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(transformed),
            hana::size_c<2>
        ));
    }{
        auto storage = container(undefined<0>{}, undefined<1>{}, undefined<2>{});
        auto transformed = hana::experimental::transformed(storage, undefined<99>{});
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(transformed),
            hana::size_c<3>
        ));
    }
}
開發者ID:Ding8222,項目名稱:abelkhan,代碼行數:33,代碼來源:length.cpp

示例3: main

int main() {
    BOOST_HANA_CONSTANT_CHECK(hana::length(hana::make_tuple()) == hana::size_c<0>);
    BOOST_HANA_CONSTANT_CHECK(hana::length(hana::make_tuple(1, '2', 3.0)) == hana::size_c<3>);

    BOOST_HANA_CONSTANT_CHECK(hana::length(hana::nothing) == hana::size_c<0>);
    BOOST_HANA_CONSTANT_CHECK(hana::length(hana::just('x')) == hana::size_c<1>);
}
開發者ID:LocutusOfBorg,項目名稱:poedit,代碼行數:7,代碼來源:length.cpp

示例4: main

int main() {
    // Conversion from any `Foldable` containing `type`s
    auto foldable = ::seq;
    auto to_list = hana::to<hana::ext::boost::mpl::list_tag>;
    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        to_list(foldable()),
        mpl::list<>{}
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        to_list(foldable(hana::type_c<t1>)),
        mpl::list<t1>{}
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        to_list(foldable(hana::type_c<t1>, hana::type_c<t2>)),
        mpl::list<t1, t2>{}
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        to_list(foldable(hana::type_c<t1>, hana::type_c<t2>, hana::type_c<t3>)),
        mpl::list<t1, t2, t3>{}
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        to_list(foldable(hana::type_c<t1>, hana::type_c<t2>, hana::type_c<t3>, hana::type_c<t4>)),
        mpl::list<t1, t2, t3, t4>{}
    ));
}
開發者ID:LocutusOfBorg,項目名稱:poedit,代碼行數:29,代碼來源:to.cpp

示例5: main

int main() {
    auto container = ::seq;

    {
        auto storage1 = container();
        auto storage2 = container();
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::is_empty(joined));
    }
    {
        auto storage1 = container(undefined<0>{});
        auto storage2 = container();
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined)));
    }
    {
        auto storage1 = container(undefined<0>{});
        auto storage2 = container(undefined<1>{});
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined)));
    }
    {
        auto storage1 = container();
        auto storage2 = container(undefined<0>{});
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined)));
    }
}
開發者ID:LocutusOfBorg,項目名稱:poedit,代碼行數:28,代碼來源:is_empty.cpp

示例6: main

int main() {
    // works with elements whose `less` does not return a Constant
    {
        constexpr auto xs = hana::make_tuple(1, 2, 3, 4);
        constexpr auto ys = hana::make_tuple(1, 6, 3, 4);
        static_assert(hana::lexicographical_compare(xs, ys), "");
    }

    // and with those that do
    {
        auto xs = hana::make_tuple(hana::int_<1>, hana::int_<2>, hana::int_<3>);
        auto ys = hana::make_tuple(hana::int_<1>, hana::int_<5>, hana::int_<3>);
        BOOST_HANA_CONSTANT_CHECK(hana::lexicographical_compare(xs, ys));
    }

    // it also accepts a custom predicate
    {
        auto xs = hana::make_tuple(hana::type<int>, hana::type<char>, hana::type<void*>);
        auto ys = hana::make_tuple(hana::type<int>, hana::type<long>, hana::type<void*>);
        BOOST_HANA_CONSTANT_CHECK(
            hana::lexicographical_compare(xs, ys, [](auto t, auto u) {
                return hana::sizeof_(t) < hana::sizeof_(u);
            })
        );
    }
}
開發者ID:huaxiufeng,項目名稱:hana,代碼行數:26,代碼來源:lexicographical_compare.cpp

示例7: main

int main() {
    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::make<hana::type_tag>(T{}),
        hana::decltype_(T{})
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::make<hana::type_tag>(hana::type_c<T>),
        hana::decltype_(hana::type_c<T>)
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::make_type(T{}),
        hana::make<hana::type_tag>(T{})
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::make_type(hana::type_c<T>),
        hana::make<hana::type_tag>(hana::type_c<T>)
    ));

    // make sure we don't read from non-constexpr variables
    {
        auto t = hana::type_c<T>;
        auto x = 1;
        constexpr auto r1 = hana::make<hana::type_tag>(t); (void)r1;
        constexpr auto r2 = hana::make<hana::type_tag>(x); (void)r2;
    }
}
開發者ID:Ding8222,項目名稱:abelkhan,代碼行數:29,代碼來源:make.cpp

示例8: main

int main() {
    auto deref = [](auto x) { return *x; };
    auto deref3 = hana::compose(deref, deref, deref);

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        *hana::type_c<char*>,
        hana::type_c<char&>
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        deref(hana::type_c<int*>),
        hana::type_c<int&>
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        deref3(hana::type_c<int***>),
        hana::type_c<int&>
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::type_c<int> + hana::type_c<float>,
        hana::type_c<float>
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        ++hana::type_c<int&>,
        hana::type_c<int&>
    ));
}
開發者ID:npk48,項目名稱:hana,代碼行數:29,代碼來源:type_operators.cpp

示例9: main

int main() {
    hana::test::_injection<0> f{};

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<0>), f),
        f()
    ));
    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<1>), f),
        f(hana::int_c<0>)
    ));
    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<2>), f),
        f(hana::int_c<0>, hana::int_c<1>)
    ));
    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<3>), f),
        f(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>)
    ));

    // Previously, we would only unpack with `std::size_t`s. Make
    // sure this does not happen.
    hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<1>), [](auto x) {
        using T = hana::tag_of_t<decltype(x)>;
        static_assert(std::is_same<typename T::value_type, int>{}, "");
    });
}
開發者ID:jinby,項目名稱:hana,代碼行數:27,代碼來源:unpack.cpp

示例10: main

int main() {
    BOOST_HANA_CONSTANT_CHECK(hana::char_c<'c'> ^hana::in^ BOOST_HANA_STRING("abcde"));
    BOOST_HANA_CONSTANT_CHECK(!(hana::char_c<'z'> ^hana::in^ BOOST_HANA_STRING("abcde")));

    BOOST_HANA_CONSTANT_CHECK(
        hana::find(BOOST_HANA_STRING("abcxefg"), hana::char_c<'x'>) == hana::just(hana::char_c<'x'>)
    );
}
開發者ID:Ding8222,項目名稱:abelkhan,代碼行數:8,代碼來源:searchable.cpp

示例11: main

int main() {
    BOOST_HANA_CONSTANT_CHECK(
        hana::to<hana::tuple_tag>(hana::tuple_c<int, 0, 1, 2>)
            ==
        hana::make_tuple(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>)
    );

    BOOST_HANA_CONSTANT_CHECK(hana::front(hana::tuple_c<int, 0, 1, 2>) == hana::int_c<0>);
}
開發者ID:surmountian,項目名稱:hana,代碼行數:9,代碼來源:tuple_c.cpp

示例12: main

int main() {
    constexpr auto ints = hana::tuple_c<int, 1, 2, 3, 2, 2, 4, 2>;
    BOOST_HANA_CONSTANT_CHECK(hana::count(ints, hana::int_<2>) == hana::size_t<4>);
    static_assert(hana::count(ints, 2) == 4, "");


    constexpr auto types = hana::tuple_t<int, char, long, short, char, double>;
    BOOST_HANA_CONSTANT_CHECK(hana::count(types, hana::type<char>) == hana::size_t<2>);
}
開發者ID:huaxiufeng,項目名稱:hana,代碼行數:9,代碼來源:count.cpp

示例13: main

int main() {
    constexpr auto x = hana::make<hana::optional_tag>();
    BOOST_HANA_CONSTANT_CHECK(x == hana::make_optional());
    BOOST_HANA_CONSTANT_CHECK(hana::is_nothing(x));

    constexpr auto just_x = hana::make<hana::optional_tag>('x');
    static_assert(just_x == hana::make_optional('x'), "");
    BOOST_HANA_CONSTANT_CHECK(hana::is_just(just_x));
}
開發者ID:LocutusOfBorg,項目名稱:poedit,代碼行數:9,代碼來源:make.cpp

示例14: main

int main() {
    static_assert(hana::to<hana::tuple_tag>(hana::just(1)) == hana::make_tuple(1), "");
    BOOST_HANA_CONSTANT_CHECK(hana::to<hana::tuple_tag>(hana::nothing) == hana::make_tuple());

    BOOST_HANA_CONSTANT_CHECK(
        hana::to<hana::tuple_tag>(hana::make_range(hana::int_c<3>, hana::int_c<6>))
            ==
        hana::tuple_c<int, 3, 4, 5>
    );
}
開發者ID:surmountian,項目名稱:hana,代碼行數:10,代碼來源:to.cpp

示例15: main

int main() {
    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::at_key(hana::make_map(p<0, 0>()), key<0>()),
        val<0>()
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::at_key(hana::make_map(p<0, 0>(), p<1,1>()), key<0>()),
        val<0>()
    ));
    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::at_key(hana::make_map(p<0, 0>(), p<1,1>()), key<1>()),
        val<1>()
    ));

    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::at_key(hana::make_map(p<0, 0>(), p<1,1>(), p<2,2>()), key<0>()),
        val<0>()
    ));
    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::at_key(hana::make_map(p<0, 0>(), p<1,1>(), p<2,2>()), key<1>()),
        val<1>()
    ));
    BOOST_HANA_CONSTANT_CHECK(hana::equal(
        hana::at_key(hana::make_map(p<0, 0>(), p<1,1>(), p<2,2>()), key<2>()),
        val<2>()
    ));

    // check operators
    auto m = hana::make_map(p<2, 2>(), p<1, 1>());
    auto const const_m = hana::make_map(p<2, 2>(), p<1, 1>());
    BOOST_HANA_CONSTANT_CHECK(hana::equal(m[key<1>()], val<1>()));
    BOOST_HANA_CONSTANT_CHECK(hana::equal(const_m[key<1>()], val<1>()));
    BOOST_HANA_CONSTANT_CHECK(hana::equal(std::move(m)[key<1>()], val<1>()));
}
開發者ID:jinby,項目名稱:hana,代碼行數:35,代碼來源:at_key.cpp


注:本文中的BOOST_HANA_CONSTANT_CHECK函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。