I was trying to compile c++ code got from internet, unfortunately it is not failed to compile. Since it is heavily templeted code I am struggling to understand and fixing this. The code is giving below.
template<typename Derived, typename... Elements>
class ElementVectorBaseNew {
private:
typedef std::tuple<Elements...> Tuple;
public:
static const int kN = sizeof...(Elements);
//static const bool kIsVectorSpace = CheckAllTrue<Elements::kIsVectorSpace...>::kVal;
template<int I, int C = 0, typename std::enable_if<(std::tuple_element<C, Tuple>::type::kI == I)>::type * = nullptr>
static constexpr int GetC() {
return C;
}
template<int I, int C = 0, typename std::enable_if<((std::tuple_element<C, Tuple>::type::kI !=
I))>::type * = nullptr>
static constexpr int GetC() {
static_assert(C < kN - 1, "Index not found in ElementVector");
return GetC<I, C + 1>();
}
template<int I>
typename std::tuple_element<GetC<I>(), Tuple>::type::Type &Get() {
return static_cast<Derived &>(*this).Get<I>();
}
};
Getting following error
In member function ‘typename std::tuple_element<GetC<I>(), std::tuple<_Elements ...> >::type::Type& ElementVectorBaseNew<Derived, Elements>::Get()’:
/home/elan/Dev/state_est/externel/two_state_information_filter/include/tsif/element_vector_new.h:33:53: error: expected primary-expression before ‘)’ token
33 | return static_cast<Derived &>(*this).Get<I>();
I am using gcc 9 for compiling. Can anybody have a look and give more information of what is wrong with this code.
Aucun commentaire:
Enregistrer un commentaire