خرید بک لینک

Vote count: 0

Considering a variant type and a template function, how can I check the template type is one of the types of the variant ? Is there a more elegant way than the following ?

typedef boost::variant<Foo,Bar> Var;

template <typename T>
void f(const T& x)
{
  BOOST_STATIC_ASSERT(
       boost::is_same<T,Foo>::value
    || boost::is_same<T,Bar>::value
  );
}

Note : I use Boost 1.57 and gcc 4.8.3. I don't use C++11 for compatibility with old gcc versions.

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 11 خرداد 1395 ساعت: 14:19

صفحه بندی