2つのタプルがインスタンス化されていないとします。あるセットが他のセットのサブセットであるかどうかをチェックする慣用的な方法はありますか?タプルタイプが互いにサブセットであるかどうかを確認します。
hana::tuple_c
の代わりに別のタイプが必要な場合は、これも問題ありません。実際には、私の現在の入力はstd::tuple
ですが、どちらの方法でも動作させることはできませんでした。私の現在の回避策が交差点を行い、その結果を比較することboost::mpl
を使用しています
#include <boost/hana.hpp>
using namespace boost;
using SetA = hana::tuple_c<int, char, float>;
using SetB = hana::tuple_c<int, float>;
static_assert(
hana::is_subset(SetB, SetA),
""
);
:ませ仕事を(が可能似た何かがあるべきであるように私は感じる)し
コード。これは動作しますが、私は純粋なboost::hana
ソリューションに興味がある:あなたが正しくboost::hana
を使用していない
#include <boost/mpl.hpp>
using namespace boost;
using SetA = mpl::set<int, char, float>;
using SetB = mpl::set<int, float>;
using Intersection = typename mpl::copy_if<
SetA,
mpl::has_key< SetB, mpl::_1 >,
mpl::back_inserter< mpl::vector<> >
>::type;
// since Intersection is a vector, subset also needs vector type
using Subset = typename mpl::copy<
SetB,
mpl::back_inserter< mpl::vector<> >
>::type;
static_assert(std::is_same<Intersection, Subset>::value, "");