Eigen ref with child matrix class - c++

I've got the following code:
#include <iostream>
#include <eigen3/Eigen/Dense>
class MyVectorType: public Eigen::Matrix<double, 3, 1> {
public:
MyVectorType(void) :
Eigen::Matrix<double, 3, 1>() {
}
typedef Eigen::Matrix<double, 3, 1> Base;
// This constructor allows you to construct MyVectorType from Eigen expressions
template<typename OtherDerived>
MyVectorType(const Eigen::MatrixBase<OtherDerived>& other) :
Eigen::Matrix<double, 3, 1>(other) {
}
// This method allows you to assign Eigen expressions to MyVectorType
template<typename OtherDerived>
MyVectorType & operator=(const Eigen::MatrixBase<OtherDerived>& other) {
this->Base::operator=(other);
return *this;
}
//other custom methods here
};
void init(Eigen::Ref<MyVectorType>& m) {
for (int i = 0; i < 3; i++)
for (int j = 0; j < 1; j++)
m(i, j) = 1;
}
int main() {
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign, 12,
12> mm(3, 1);
Eigen::Ref<MyVectorType> rr(mm);
init(rr);
std::cout << mm << std::endl;
return 0;
}
I defined my own class but when I try to the Ref class I have the following error from gcc:
make all
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -std=c++98 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.cpp"
In file included from /usr/include/eigen3/Eigen/Core:449:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Map.h: In instantiation of ‘struct Eigen::internal::traits<Eigen::Map<MyVectorType, 0, Eigen::OuterStride<> > >’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:18:8: required from ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:32:54: required from ‘struct Eigen::internal::accessors_level<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:113:75: required from ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/Map.h:18:8: error: invalid use of incomplete type ‘struct Eigen::internal::traits<MyVectorType>’
struct traits<Map<PlainObjectType, MapOptions, StrideType> >
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:346:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:17:29: note: declaration of ‘struct Eigen::internal::traits<MyVectorType>’
template<typename T> struct traits;
^~~~~~
In file included from /usr/include/eigen3/Eigen/Core:449:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Map.h:30:32: error: incomplete type ‘Eigen::internal::traits<Eigen::Map<MyVectorType, 0, Eigen::OuterStride<> > >::TraitsBase {aka Eigen::internal::traits<MyVectorType>}’ used in nested name specifier
Flags0 = TraitsBase::Flags & (~NestByRefBit),
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:348:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h: In instantiation of ‘struct Eigen::internal::is_lvalue<MyVectorType>’:
/usr/include/eigen3/Eigen/src/Core/Map.h:31:47: required from ‘struct Eigen::internal::traits<Eigen::Map<MyVectorType, 0, Eigen::OuterStride<> > >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:18:8: required from ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:32:54: required from ‘struct Eigen::internal::accessors_level<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/util/ForwardDeclarations.h:113:75: required from ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/util/XprHelper.h:642:53: error: incomplete type ‘Eigen::internal::traits<MyVectorType>’ used in nested name specifier
bool(traits<ExpressionType>::Flags & LvalueBit) };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h: In instantiation of ‘class Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:58:34: required from ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: error: no type named ‘XprKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:42:62: error: no type named ‘XprKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::dense_xpr_base<Derived>::type Base;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:43:10: error: ‘RowsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
enum {
^
/usr/include/eigen3/Eigen/src/Core/MapBase.h:43:10: error: ‘ColsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/MapBase.h:49:61: error: no type named ‘StorageKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::traits<Derived>::StorageKind StorageKind;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:50:56: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::traits<Derived>::Scalar Scalar;
^~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:51:60: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename internal::packet_traits<Scalar>::type PacketScalar;
^~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:52:46: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
typedef typename NumTraits<Scalar>::Real RealScalar;
^~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:57:22: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
PointerType;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:59:17: error: using-declaration for non-member at class scope
using Base::derived;
^~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:63:17: error: using-declaration for non-member at class scope
using Base::MaxRowsAtCompileTime;
^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:64:17: error: using-declaration for non-member at class scope
using Base::MaxColsAtCompileTime;
^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:65:17: error: using-declaration for non-member at class scope
using Base::MaxSizeAtCompileTime;
^~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:66:17: error: using-declaration for non-member at class scope
using Base::IsVectorAtCompileTime;
^~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:67:17: error: using-declaration for non-member at class scope
using Base::Flags;
^~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:68:17: error: using-declaration for non-member at class scope
using Base::IsRowMajor;
^~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:70:17: error: using-declaration for non-member at class scope
using Base::rows;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:71:17: error: using-declaration for non-member at class scope
using Base::cols;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:72:17: error: using-declaration for non-member at class scope
using Base::size;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:73:17: error: using-declaration for non-member at class scope
using Base::coeff;
^~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:74:17: error: using-declaration for non-member at class scope
using Base::coeffRef;
^~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:75:17: error: using-declaration for non-member at class scope
using Base::lazyAssign;
^~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:76:17: error: using-declaration for non-member at class scope
using Base::eval;
^~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:78:17: error: using-declaration for non-member at class scope
using Base::innerStride;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:79:17: error: using-declaration for non-member at class scope
using Base::outerStride;
^~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:80:17: error: using-declaration for non-member at class scope
using Base::rowStride;
^~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:81:17: error: using-declaration for non-member at class scope
using Base::colStride;
^~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:84:25: error: using-declaration for non-member at class scope
using Base::operator=;
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘class Eigen::RefBase<Eigen::Ref<MyVectorType> >’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:190:76: required from ‘class Eigen::Ref<MyVectorType>’
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘StorageKind’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no type named ‘StorageIndex’ in ‘struct Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘RowsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘ColsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::RefBase<Eigen::Ref<MyVectorType> > >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘MaxSizeAtCompileTime’ is not a member of ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: ‘IsVectorAtCompileTime’ is not a member of ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no members matching ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}::derived’ in ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka class Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:67:3: error: no members matching ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}::const_cast_derived’ in ‘Eigen::RefBase<Eigen::Ref<MyVectorType> >::Base {aka class Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>}’
EIGEN_DENSE_PUBLIC_INTERFACE(RefBase)
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘class Eigen::Ref<MyVectorType>’:
../main.cpp:26:10: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘Scalar’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
In file included from /usr/include/eigen3/Eigen/Core:72:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘StorageKind’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no type named ‘StorageIndex’ in ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: ‘RowsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: ‘ColsAtCompileTime’ is not a member of ‘Eigen::internal::traits<Eigen::Ref<MyVectorType> >’
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no members matching ‘Eigen::Ref<MyVectorType>::Base {aka Eigen::RefBase<Eigen::Ref<MyVectorType> >}::derived’ in ‘Eigen::Ref<MyVectorType>::Base {aka class Eigen::RefBase<Eigen::Ref<MyVectorType> >}’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
/usr/include/eigen3/Eigen/src/Core/Ref.h:201:5: error: no members matching ‘Eigen::Ref<MyVectorType>::Base {aka Eigen::RefBase<Eigen::Ref<MyVectorType> >}::const_cast_derived’ in ‘Eigen::Ref<MyVectorType>::Base {aka class Eigen::RefBase<Eigen::Ref<MyVectorType> >}’
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
^
../main.cpp: In function ‘void init(Eigen::Ref<MyVectorType>&)’:
../main.cpp:26:10: error: no match for call to ‘(Eigen::Ref<MyVectorType>) (int&, int&)’
m(i, j) = 1;
^
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘struct Eigen::internal::traits<Eigen::Ref<MyVectorType> >::match<Eigen::Matrix<double, -1, -1, 0, 12, 12> >’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:197:63: required by substitution of ‘template<class Derived> Eigen::Ref<MyVectorType>::Ref(const Eigen::PlainObjectBase<Derived>&, typename Eigen::internal::enable_if<(bool)(Eigen::internal::traits<Eigen::Ref<MyVectorType> >::match<Derived>::MatchAtCompileTime), Derived>::type*) [with Derived = Eigen::Matrix<double, -1, -1, 0, 12, 12>]’
../main.cpp:32:32: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:44:25: error: incomplete type ‘Eigen::internal::traits<MyVectorType>’ used in nested name specifier
AlignmentMatch = (int(traits<PlainObjectType>::Alignment)==int(Unaligned)) || (DerivedAlignment >= int(Alignment)), // FIXME the first condition is not very clear, it should be replaced by the required alignment
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:347:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h: In instantiation of ‘static void Eigen::PlainObjectBase<Derived>::_check_template_params() [with Derived = Eigen::Matrix<double, 3, 1, 0, 12, 12>]’:
/usr/include/eigen3/Eigen/src/Core/Matrix.h:261:35: required from ‘Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::Matrix() [with _Scalar = double; int _Rows = 3; int _Cols = 1; int _Options = 0; int _MaxRows = 12; int _MaxCols = 12]’
../main.cpp:7:58: required from here
/usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:899:7: error: ‘INVALID_MATRIX_TEMPLATE_PARAMETERS’ is not a member of ‘Eigen::internal::static_assertion<false>’
EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, (Options&RowMajor)==RowMajor)
^
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘Eigen::RefBase<Derived>::RefBase() [with Derived = Eigen::Ref<MyVectorType>]’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:208:5: required from ‘Eigen::Ref<PlainObjectType, Options, StrideType>::Ref(Eigen::PlainObjectBase<OtherDerived>&, typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type*) [with Derived = Eigen::Matrix<double, -1, -1, 0, 12, 12>; PlainObjectType = MyVectorType; int Options = 0; StrideType = Eigen::OuterStride<>; typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type = Eigen::Matrix<double, -1, -1, 0, 12, 12>]’
../main.cpp:32:32: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:86:100: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(int, int, int)’
StrideType::InnerStrideAtCompileTime==Dynamic?0:StrideType::InnerStrideAtCompileTime)
^
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h: In instantiation of ‘void Eigen::RefBase<Derived>::construct(Expression&) [with Expression = Eigen::Matrix<double, -1, -1, 0, 12, 12>; Derived = Eigen::Ref<MyVectorType>]’:
/usr/include/eigen3/Eigen/src/Core/Ref.h:210:22: required from ‘Eigen::Ref<PlainObjectType, Options, StrideType>::Ref(Eigen::PlainObjectBase<OtherDerived>&, typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type*) [with Derived = Eigen::Matrix<double, -1, -1, 0, 12, 12>; PlainObjectType = MyVectorType; int Options = 0; StrideType = Eigen::OuterStride<>; typename Eigen::internal::enable_if<(bool)(typename Eigen::internal::traits<Eigen::Ref<PlainObjectType, RefOptions, StrideType> >::match<Derived>::MatchAtCompileTime), Derived>::type = Eigen::Matrix<double, -1, -1, 0, 12, 12>]’
../main.cpp:32:32: required from here
/usr/include/eigen3/Eigen/src/Core/Ref.h:101:7: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Scalar*, int, Eigen::EigenBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Index)’
::new (static_cast<Base*>(this)) Base(expr.data(), 1, expr.size());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:106:7: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Scalar*, Eigen::EigenBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Index, int)’
::new (static_cast<Base*>(this)) Base(expr.data(), expr.size(), 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
In file included from /usr/include/eigen3/Eigen/Core:450:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/Ref.h:109:7: error: no matching function for call to ‘Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, 12, 12> >::Scalar*, Eigen::Index, Eigen::Index)’
::new (static_cast<Base*>(this)) Base(expr.data(), expr.rows(), expr.cols());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/eigen3/Eigen/Core:448:0,
from /usr/include/eigen3/Eigen/Dense:1,
from ../main.cpp:2:
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase()
template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 0 arguments, 3 provided
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate: Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>::MapBase(const Eigen::MapBase<Eigen::Ref<MyVectorType>, 0>&)
/usr/include/eigen3/Eigen/src/Core/MapBase.h:37:34: note: candidate expects 1 argument, 3 provided
Is possible to pass by reference a dynamic matrix to a fixed one using a custom child class?

Eigen::Ref is not intended to work with own custom types (that would be possible, but is way to complicated for this purpose). Simply use Eigen::Ref<MyVectorType::Base>. Also if a Ref is intended to be an L-value (i.e., writable), you should pass it by-value, like so
void init(Eigen::Ref<MyVectorType::Base> m) {
// ...
That way you don't need to manually generate a temporary when calling init:
int main() {
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign, 12,
12> mm(3, 1);
// Eigen::Ref<MyVectorType> rr(mm); // not necessary!
init(mm); // implicitly generates a temporary `Ref` object
// ...
For more details, see the online documentation of Ref: https://eigen.tuxfamily.org/dox/classEigen_1_1Ref.html

Related

c++ compilation terminal in file included error/warning

I have a c++ program that outputs what seems to be what I want but i am unsure if the values are correct as some of them are constantly zero which seems a bit suspicious to me. The program uses a C++ implementation of Giraffe found on github at https://github.com/enlighter/giraffe/tree/f3609a7b20d9817bdc543db6832148f26524c298 . The only thing weird that i noticed is that when i compile using VSC, i get a bunch of messages in the terminal prior to the output. I think they are warnings? but i'm not sure as it is my first time using VSC. Below is a log dump of what appears in the terminal. The correct output starts from GLOBAL 0; onwards in the screenshot.
In file included from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Core:302,
from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Dense:1,
from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\matrix_ops.h:23,
from ann/ann.h:39,
from ann/features_conv.h:29,
from own.cpp:43:
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:60:39: warning: ignoring attributes on template argument '__m128' [-Wignored-attributes]
60 | template<> struct is_arithmetic<__m128> { enum { value = true }; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:61:40: warning: ignoring attributes on template argument '__m128i' [-Wignored-attributes]
61 | template<> struct is_arithmetic<__m128i> { enum { value = true }; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:62:40: warning: ignoring attributes on template argument '__m128d' [-Wignored-attributes]
62 | template<> struct is_arithmetic<__m128d> { enum { value = true }; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:147:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
147 | template<> struct unpacket_traits<Packet4f> { typedef float type; enum {size=4}; typedef Packet4f half; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:148:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
148 | template<> struct unpacket_traits<Packet2d> { typedef double type; enum {size=2}; typedef Packet2d half; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:149:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i' {aka '__m128i'} [-Wignored-attributes]
149 | template<> struct unpacket_traits<Packet4i> { typedef int type; enum {size=4}; typedef Packet4i half; };
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:468:37: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
468 | struct protate_impl<offset, Packet4f>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:476:37: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i' {aka '__m128i'} [-Wignored-attributes]
476 | struct protate_impl<offset, Packet4i>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:484:37: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
484 | struct protate_impl<offset, Packet2d>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:756:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
756 | struct palign_impl<Offset,Packet4f>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:779:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i' {aka '__m128i'} [-Wignored-attributes]
779 | struct palign_impl<Offset,Packet4i>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:802:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
802 | struct palign_impl<Offset,Packet2d>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:816:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
816 | ptranspose(PacketBlock<Packet4f,4>& kernel) {
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:821:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
821 | ptranspose(PacketBlock<Packet2d,2>& kernel) {
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/PacketMath.h:828:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i' {aka '__m128i'} [-Wignored-attributes]
828 | ptranspose(PacketBlock<Packet4i,4>& kernel) {
| ^
In file included from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Core:304:
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/Complex.h:233:63: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
233 | template<> struct conj_helper<Packet4f, Packet2cf, false,false>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/Complex.h:242:63: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f' {aka '__m128'} [-Wignored-attributes]
242 | template<> struct conj_helper<Packet2cf, Packet4f, false,false>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/Complex.h:435:63: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
435 | template<> struct conj_helper<Packet2d, Packet1cd, false,false>
| ^
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/arch/SSE/Complex.h:444:63: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d' {aka '__m128d'} [-Wignored-attributes]
444 | template<> struct conj_helper<Packet1cd, Packet2d, false,false>
| ^
In file included from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Core:328:
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 4, 1>, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 4, 1>, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 4, 1>, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Matrix<float, 4, 1>, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Matrix<float, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Matrix<float, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:91:7: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<float, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<float, 4, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/Quaternion.h:283:16: required from 'class Eigen::Quaternion<float>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/arch/Geometry_SSE.h:22:3: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
55 | >::type PacketReturnType;
| ^~~~~~~~~~~~~~~~
In file included from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Core:344:
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h: In instantiation of 'class Eigen::DenseStorage<float, 4, 4, 1, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:129:113: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<float, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<float, 4, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/Quaternion.h:283:16: required from 'class Eigen::Quaternion<float>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/arch/Geometry_SSE.h:22:3: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:38:38: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
38 | bool Match = bool((Size%unpacket_traits<Packet>::size)==0),
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:39:33: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
39 | bool TryHalf = bool(int(unpacket_traits<Packet>::size) > 1)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:33: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
40 | && bool(int(unpacket_traits<Packet>::size) > int(unpacket_traits<typename unpacket_traits<Packet>::half>::size)) >
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:70: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
40 | && bool(int(unpacket_traits<Packet>::size) > int(unpacket_traits<typename unpacket_traits<Packet>::half>::size)) >
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:70: warning: ignoring attributes on template argument 'Eigen::internal::unpacket_traits<__vector(4) float>::half' {aka '__m128'} [-Wignored-attributes]
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:64:60: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
64 | int Alignment = (MatrixOrArrayOptions&DontAlign) ? 0
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
65 | : compute_default_alignment<T,Size>::value >
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Matrix<double, 4, 1>, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<double, 4, 1>, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<double, 4, 1>, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Matrix<double, 4, 1>, double, double, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Matrix<double, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Matrix<double, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:91:7: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<double, 4, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/Quaternion.h:283:16: required from 'class Eigen::Quaternion<double>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/arch/Geometry_SSE.h:75:3: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attribute
]
55 | >::type PacketReturnType;
| ^~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h: In instantiation of 'class Eigen::DenseStorage<double, 4, 4, 1, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:129:113: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<double, 4, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/Quaternion.h:283:16: required from 'class Eigen::Quaternion<double>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Geometry/arch/Geometry_SSE.h:75:3: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:38:38: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
38 | bool Match = bool((Size%unpacket_traits<Packet>::size)==0),
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:39:33: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
39 | bool TryHalf = bool(int(unpacket_traits<Packet>::size) > 1)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:33: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
40 | && bool(int(unpacket_traits<Packet>::size) > int(unpacket_traits<typename unpacket_traits<Packet>::half>::size)) >
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:70: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
40 | && bool(int(unpacket_traits<Packet>::size) > int(unpacket_traits<typename unpacket_traits<Packet>::half>::size)) >
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:40:70: warning: ignoring attributes on template argument 'Eigen::internal::unpacket_traits<__vector(2) double>::half' {aka '__m128d'} [-Wignored-attributes]
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseStorage.h:64:60: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
64 | int Alignment = (MatrixOrArrayOptions&DontAlign) ? 0
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
65 | : compute_default_alignment<T,Size>::value >
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 1, -1>, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 1, -1>, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, 1, -1>, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Matrix<float, 1, -1>, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Matrix<float, 1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Matrix<float, 1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:91:7: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<float, 1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<float, 1, -1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Map.h:75:53: required from 'struct Eigen::internal::traits<Eigen::Map<Eigen::Matrix<float, 1, -1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/ForwardDeclarations.h:32:48: required from 'struct Eigen::internal::accessors_level<Eigen::Map<Eigen::Matrix<float, 1, -1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/ForwardDeclarations.h:116:75: required from 'class Eigen::Map<Eigen::Matrix<float, 1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\matrix_ops.h:169:52: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
55 | >::type PacketReturnType;
| ^~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Map<Eigen::Matrix<float, 1, -1> >, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Map<Eigen::Matrix<float, 1, -1> >, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Map<Eigen::Matrix<float, 1, -1> >, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Map<Eigen::Matrix<float, 1, -1> >, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Map<Eigen::Matrix<float, 1, -1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Map<Eigen::Matrix<float, 1, -1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MapBase.h:27:34: required from 'class Eigen::MapBase<Eigen::Map<Eigen::Matrix<float, 1, -1> >, 0>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MapBase.h:171:34: required from 'class Eigen::MapBase<Eigen::Map<Eigen::Matrix<float, 1, -1> >, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Map.h:89:79: required from 'class Eigen::Map<Eigen::Matrix<float, 1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\matrix_ops.h:169:52: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
In file included from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/SparseCore:30,
from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/Sparse:19,
from C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\matrix_ops.h:24:
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/SparseCore/SparseMatrixBase.h: In instantiation of 'class Eigen::SparseMatrixBase<Eigen::SparseMatrix<float, 0, int> >':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/SparseCore/SparseCompressedBase.h:26:7: required from 'class Eigen::SparseCompressedBase<Eigen::SparseMatrix<float, 0, int> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/SparseCore/SparseMatrix.h:92:7: required from 'class Eigen::SparseMatrix<float, 0, int>'
ann/ann.h:61:44: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/SparseCore/SparseMatrixBase.h:42:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
42 | >::type PacketReturnType;
| ^~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1>, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1>, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1>, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Matrix<float, -1, -1>, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Matrix<float, -1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Matrix<float, -1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:91:7: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<float, -1, -1>'
ann/ann.h:82:50: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
55 | >::type PacketReturnType;
| ^~~~~~~~~~~~~~~~
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1, 1>, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1, 1>, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::Matrix<float, -1, -1, 1>, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::Matrix<float, -1, -1, 1>, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::Matrix<float, -1, -1, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/MatrixBase.h:48:34: required from 'class Eigen::MatrixBase<Eigen::Matrix<float, -1, -1, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/PlainObjectBase.h:91:7: required from 'class Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 1> >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/Matrix.h:128:7: required from 'class Eigen::Matrix<float, -1, -1, 1>'
ann/ann_impl.h:180:99: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> >, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> >, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> >, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> >, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/ArrayBase.h:39:34: required from 'class Eigen::ArrayBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/ArrayWrapper.h:41:7: required from 'class Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1, 1> >'
ann/ann_impl.h:337:43: required from here
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<float>::type' {aka '__m128'} [-Wignored-attributes]
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h: In instantiation of 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> >, 0>':
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:282:7: required from 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> >, 1>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseCoeffsBase.h:519:7: required from 'class Eigen::DenseCoeffsBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> >, 3>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/util/XprHelper.h:426:8: required from 'struct Eigen::internal::special_scalar_op_base<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> >, float, float, false>'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/DenseBase.h:41:34: required from 'class Eigen::DenseBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> > >'
C:\Users\Admin\Desktop\fyp stuff\Giraffe-master\Eigen/src/Core/ArrayBase.h:39:34: required from 'class Eigen::ArrayBase<Eigen::ArrayWrapper<Eigen::Matrix<float, -1, -1> > >'
I have attached a screenshot if it helps. Not sure what the highlighted purple means?
Heres an album of the terminal output: https://imgur.com/a/QIi3X81
Are the purple messages warnings that I need to resolve? Im still getting an output but not sure if these warnings are causing some incorrect values. Seems like all of them are a result of wignoredattribute?

C++17 forward declarations of custom structures in not working with custom Hash maps

This is little frustrating me at this point, but I am not sure what am I doing wrong. My code is not compiling for using a hashmap with a custom hash function, which I think should be just okay to compiler.
#include <iostream>
#include <queue>
#include <unordered_map>
struct Key;
struct THash;
struct TEqual;
class Cache {
private:
uint64_t capacity;
uint64_t time_ticker;
std::unordered_map<Key, int32_t, THash, TEqual> map_keys;
std::priority_queue<Key> lru_min_heap;
void RehashPriorityQueue()
{
lru_min_heap = std::priority_queue<Key>();
for (auto &&iter : map_keys) lru_min_heap.emplace(iter.first);
}
public:
Cache(const uint64_t cache_size=1) : capacity(cache_size), time_ticker(0) {}
~Cache(){}
void Set(int32_t key, int32_t value) {
time_ticker++;
auto _key = Key(key, time_ticker);
auto find_key = map_keys.find(_key);
if(capacity) capacity--;
else
{
auto lru = lru_min_heap.top(); lru_min_heap.pop();
auto find_key_lru = map_keys.find(lru);
if(find_key_lru != map_keys.end()) map_keys.erase(find_key_lru);
}
if(find_key != map_keys.end())
{
map_keys.erase(find_key);
RehashPriorityQueue();
}
map_keys.emplace(_key, value);
lru_min_heap.emplace(_key);
}
int32_t Get(int32_t key) {
time_ticker++;
int ret = 0;
auto _key = Key(key, time_ticker);
auto find_key = map_keys.find(_key);
if(find_key != map_keys.end()) {
ret = find_key->second;
map_keys.erase(find_key);
RehashPriorityQueue();
map_keys.emplace(_key, ret);
lru_min_heap.emplace(_key);
}
else
{
std::cout<<"None ";
}
return ret;
}
};
struct Key {
int32_t id;
uint64_t weightage;
Key(int32_t id, uint64_t weightage=1) : id(id), weightage(weightage) {};
bool operator<(const Key &other) const { return weightage > other.weightage;}
size_t operator()(const Key& tr) const {
return std::hash<int32_t>()(tr.id);
}
};
struct THash {
size_t operator()(const Key& tr) const {
return std::hash<int32_t>()(tr.id);
}
};
struct TEqual {
bool operator()(const Key& tr1, const Key& tr2) const {
if (tr1.id == tr2.id) return true;
return false;
}
};
int main()
{
Cache cache(2);
cache.Set(3, 3);
std::cout<<cache.Get(3)<<"\n";
return 0;
}
compiler error:
In file included from /usr/include/c++/4.9/bits/hashtable.h:35:0,
from /usr/include/c++/4.9/unordered_map:47,
from 3:
/usr/include/c++/4.9/bits/hashtable_policy.h: In instantiation of 'struct std::__detail::__is_noexcept_hash<Key, THash>':
/usr/include/c++/4.9/type_traits:134:12: required from 'struct std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> >'
/usr/include/c++/4.9/type_traits:145:38: required from 'struct std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
/usr/include/c++/4.9/bits/unordered_map.h:100:66: required from 'class std::unordered_map<Key, int, THash, TEqual>'
13:53: required from here
/usr/include/c++/4.9/bits/hashtable_policy.h:85:33: error: no match for call to '(const THash) (const Key&)'
noexcept(declval<const _Hash&>()(declval<const _Key&>()))>
^
In file included from /usr/include/c++/4.9/bits/move.h:57:0,
from /usr/include/c++/4.9/bits/stl_pair.h:59,
from /usr/include/c++/4.9/bits/stl_algobase.h:64,
from /usr/include/c++/4.9/bits/char_traits.h:39,
from /usr/include/c++/4.9/ios:40,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/type_traits: In instantiation of 'struct std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >':
/usr/include/c++/4.9/bits/unordered_map.h:100:66: required from 'class std::unordered_map<Key, int, THash, TEqual>'
13:53: required from here
/usr/include/c++/4.9/type_traits:145:38: error: 'value' is not a member of 'std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> >'
: public integral_constant<bool, !_Pp::value>
^
In file included from /usr/include/c++/4.9/unordered_map:48:0,
from 3:
/usr/include/c++/4.9/bits/unordered_map.h: In instantiation of 'class std::unordered_map<Key, int, THash, TEqual>':
13:53: required from here
/usr/include/c++/4.9/bits/unordered_map.h:100:66: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable;
^
/usr/include/c++/4.9/bits/unordered_map.h:107:45: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::key_type key_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:108:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::value_type value_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:109:48: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::mapped_type mapped_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:110:43: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::hasher hasher;
^
/usr/include/c++/4.9/bits/unordered_map.h:111:46: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::key_equal key_equal;
^
/usr/include/c++/4.9/bits/unordered_map.h:112:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::allocator_type allocator_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:117:45: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::pointer pointer;
^
/usr/include/c++/4.9/bits/unordered_map.h:118:50: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::const_pointer const_pointer;
^
/usr/include/c++/4.9/bits/unordered_map.h:119:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::reference reference;
^
/usr/include/c++/4.9/bits/unordered_map.h:120:52: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::const_reference const_reference;
^
/usr/include/c++/4.9/bits/unordered_map.h:121:46: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::iterator iterator;
^
/usr/include/c++/4.9/bits/unordered_map.h:122:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::const_iterator const_iterator;
^
/usr/include/c++/4.9/bits/unordered_map.h:123:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::local_iterator local_iterator;
^
/usr/include/c++/4.9/bits/unordered_map.h:124:57: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::const_local_iterator const_local_iterator;
^
/usr/include/c++/4.9/bits/unordered_map.h:125:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::size_type size_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:126:52: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
typedef typename _Hashtable::difference_type difference_type;
^
/usr/include/c++/4.9/bits/unordered_map.h:242:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
operator=(initializer_list<value_type> __l)
^
/usr/include/c++/4.9/bits/unordered_map.h:340:2: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
emplace(_Args&&... __args)
^
/usr/include/c++/4.9/bits/unordered_map.h:392:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
insert(const value_type& __x)
^
/usr/include/c++/4.9/bits/unordered_map.h:399:2: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
insert(_Pair&& __x)
^
/usr/include/c++/4.9/bits/unordered_map.h:459:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
insert(initializer_list<value_type> __l)
^
/usr/include/c++/4.9/bits/unordered_map.h:604:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
equal_range(const key_type& __x)
^
/usr/include/c++/4.9/bits/unordered_map.h:608:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<THash>, std::__detail::__is_noexcept_hash<Key, THash> > >'
equal_range(const key_type& __x) const
^
In file included from /usr/include/c++/4.9/bits/stl_algobase.h:64:0,
from /usr/include/c++/4.9/bits/char_traits.h:39,
from /usr/include/c++/4.9/ios:40,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/stl_pair.h: In instantiation of 'struct std::pair<const Key, int>':
19:28: required from here
/usr/include/c++/4.9/bits/stl_pair.h:101:11: error: 'std::pair<_T1, _T2>::first' has incomplete type
_T1 first; /// #c first is a copy of the first object
^
5:8: error: forward declaration of 'const struct Key'
In member function 'void Cache::RehashPriorityQueue()':
19:28: error: no matching function for call to 'begin(std::unordered_map<Key, int, THash, TEqual>&)'
19:28: note: candidates are:
In file included from /usr/include/c++/4.9/bits/basic_string.h:42:0,
from /usr/include/c++/4.9/string:52,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/initializer_list:89:5: note: template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)
begin(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.9/initializer_list:89:5: note: template argument deduction/substitution failed:
19:28: note: 'std::unordered_map<Key, int, THash, TEqual>' is not derived from 'std::initializer_list<_Tp>'
In file included from /usr/include/c++/4.9/string:51:0,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/range_access.h:87:5: note: template<class _Tp, long unsigned int _Nm> _Tp* std::begin(_Tp (&)[_Nm])
begin(_Tp (&__arr)[_Nm])
^
/usr/include/c++/4.9/bits/range_access.h:87:5: note: template argument deduction/substitution failed:
19:28: note: mismatched types '_Tp [_Nm]' and 'std::unordered_map<Key, int, THash, TEqual>'
In file included from /usr/include/c++/4.9/string:51:0,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/range_access.h:58:5: note: template<class _Container> decltype (__cont.begin()) std::begin(const _Container&)
begin(const _Container& __cont) -> decltype(__cont.begin())
^
/usr/include/c++/4.9/bits/range_access.h:58:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::unordered_map<Key, int, THash, TEqual>]':
19:28: required from here
/usr/include/c++/4.9/bits/range_access.h:58:5: error: 'const class std::unordered_map<Key, int, THash, TEqual>' has no member named 'begin'
/usr/include/c++/4.9/bits/range_access.h:48:5: note: template<class _Container> decltype (__cont.begin()) std::begin(_Container&)
begin(_Container& __cont) -> decltype(__cont.begin())
^
/usr/include/c++/4.9/bits/range_access.h:48:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::unordered_map<Key, int, THash, TEqual>]':
19:28: required from here
/usr/include/c++/4.9/bits/range_access.h:48:5: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'begin'
19:28: error: no matching function for call to 'end(std::unordered_map<Key, int, THash, TEqual>&)'
19:28: note: candidates are:
In file included from /usr/include/c++/4.9/bits/basic_string.h:42:0,
from /usr/include/c++/4.9/string:52,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/initializer_list:99:5: note: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
end(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.9/initializer_list:99:5: note: template argument deduction/substitution failed:
19:28: note: 'std::unordered_map<Key, int, THash, TEqual>' is not derived from 'std::initializer_list<_Tp>'
In file included from /usr/include/c++/4.9/string:51:0,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/range_access.h:97:5: note: template<class _Tp, long unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
end(_Tp (&__arr)[_Nm])
^
/usr/include/c++/4.9/bits/range_access.h:97:5: note: template argument deduction/substitution failed:
19:28: note: mismatched types '_Tp [_Nm]' and 'std::unordered_map<Key, int, THash, TEqual>'
In file included from /usr/include/c++/4.9/string:51:0,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/range_access.h:78:5: note: template<class _Container> decltype (__cont.end()) std::end(const _Container&)
end(const _Container& __cont) -> decltype(__cont.end())
^
/usr/include/c++/4.9/bits/range_access.h:78:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(const _Container&) [with _Container = std::unordered_map<Key, int, THash, TEqual>]':
19:28: required from here
/usr/include/c++/4.9/bits/range_access.h:78:5: error: 'const class std::unordered_map<Key, int, THash, TEqual>' has no member named 'end'
/usr/include/c++/4.9/bits/range_access.h:68:5: note: template<class _Container> decltype (__cont.end()) std::end(_Container&)
end(_Container& __cont) -> decltype(__cont.end())
^
/usr/include/c++/4.9/bits/range_access.h:68:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.9/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(_Container&) [with _Container = std::unordered_map<Key, int, THash, TEqual>]':
19:28: required from here
/usr/include/c++/4.9/bits/range_access.h:68:5: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'end'
In constructor 'Cache::Cache(uint64_t)':
23:77: error: no matching function for call to 'std::unordered_map<Key, int, THash, TEqual>::unordered_map()'
23:77: note: candidates are:
In file included from /usr/include/c++/4.9/unordered_map:48:0,
from 3:
/usr/include/c++/4.9/bits/unordered_map.h:172:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&&) [with _Key = Key; _Tp = int; _Hash = THash; _Pred = TEqual; _Alloc = std::allocator<std::pair<const Key, int> >]
unordered_map(unordered_map&&) = default;
^
/usr/include/c++/4.9/bits/unordered_map.h:172:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/4.9/bits/unordered_map.h:169:7: note: std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>&) [with _Key = Key; _Tp = int; _Hash = THash; _Pred = TEqual; _Alloc = std::allocator<std::pair<const Key, int> >]
unordered_map(const unordered_map&) = default;
^
/usr/include/c++/4.9/bits/unordered_map.h:169:7: note: candidate expects 1 argument, 0 provided
In member function 'void Cache::Set(int32_t, int32_t)':
28:41: error: invalid use of incomplete type 'struct Key'
5:8: error: forward declaration of 'struct Key'
29:34: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'find'
34:41: error: 'Key lru' has incomplete type
35:42: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'find'
36:41: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'end'
36:57: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'erase'
39:33: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'end'
41:22: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'erase'
45:18: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'emplace'
In member function 'int32_t Cache::Get(int32_t)':
52:41: error: invalid use of incomplete type 'struct Key'
5:8: error: forward declaration of 'struct Key'
53:34: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'find'
54:33: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'end'
56:22: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'erase'
58:22: error: 'class std::unordered_map<Key, int, THash, TEqual>' has no member named 'emplace'

Compiler error with std::map and dense_hash_map in GTEST

I am getting this error when I try to use my project/module in my GOOGLE TESTS.
gcc.compile.c++ bin/gcc-4.8.3/debug/link-static/gmock_test.o
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:130:11: error: redefinition of ‘class std::tuple< <template-parameter-1-1> >’
class tuple : public _Tuple_impl<0, _Elements...>
^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:388:11: error: previous definition of ‘class std::tuple< <template-parameter-1-1> >’
class tuple : public _Tuple_impl<0, _Elements...>
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:164:20: error: redefinition of ‘class std::tuple<>’
template<> class tuple<> { };
^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:512:11: error: previous definition of ‘class std::tuple<>’
class tuple<>
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:168:11: error: redefinition of ‘class std::tuple<_T1, _T2>’
class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:521:11: error: previous definition of ‘class std::tuple<_T1, _T2>’
class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
^
In file included from /usr/include/c++/4.8.2/tuple:38:0,
from /usr/include/c++/4.8.2/bits/stl_map.h:63,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/utility:83:24: error: template parameter ‘long unsigned int _Int’
template<std::size_t _Int, class _Tp>
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:223:12: error: redeclared here as ‘int __i’
struct tuple_element;
^
/usr/include/c++/4.8.2/tr1/tuple:230:12: error: specialization of ‘template<long unsigned int _Int, class _Tp> struct std::tuple_element’ in different namespace [-fpermissive]
struct tuple_element<__i, tuple<_Head, _Tail...> >
^
In file included from /usr/include/c++/4.8.2/tuple:38:0,
from /usr/include/c++/4.8.2/bits/stl_map.h:63,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/utility:84:11: error: from definition of ‘template<long unsigned int _Int, class _Tp> struct std::tuple_element’ [-fpermissive]
class tuple_element;
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:237:12: error: redefinition of ‘struct std::tuple_element<0ul, std::tuple<_El0, _El ...> >’
struct tuple_element<0, tuple<_Head, _Tail...> >
^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:687:12: error: previous definition of ‘struct std::tuple_element<0ul, std::tuple<_El0, _El ...> >’
struct tuple_element<0, tuple<_Head, _Tail...> >
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:248:12: error: redefinition of ‘struct std::tuple_size<std::tuple<_Args1 ...> >’
struct tuple_size<tuple<_Elements...> >
^
In file included from /usr/include/c++/4.8.2/bits/stl_map.h:63:0,
from /usr/include/c++/4.8.2/map:61,
from 8k/include/Source.h:12,
from src/unit_tests_theo.cpp:2:
/usr/include/c++/4.8.2/tuple:737:12: error: previous definition of ‘struct std::tuple_size<std::tuple<_Args1 ...> >’
struct tuple_size<tuple<_Elements...>>
^
In file included from /usr/include/c++/4.8.2/tr1/functional:39:0,
from /usr/local/include/google/dense_hash_map:106,
from sagarmatha/utils/include/multicast_receiver.h:11,
from include/transmitter/mcx_receiver.h:25,
from src/unit_tests_theo.cpp:7:
/usr/include/c++/4.8.2/tr1/tuple:254:49: error: definition of ‘std::tuple_size<std::tuple<_Args1 ...> >::value’ is not in namespace enclosing ‘std::tuple_size<std::tuple<_Args1 ...> >’ [-fpermissive]
const int tuple_size<tuple<_Elements...> >::value;
Is it related to map and dense_hash_map usage together ? Please help?
Since it solved your problem I'm making this an answer: set -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=0 to instruct the compilation not to use tr1 tuple nor its own tuple implementation.

Tensorflow Serving bazel build Error: mnist_inference_2.cc - Signatures' has not been declared

I am trying to replicate tensorflow serving examples from https://tensorflow.github.io/serving/serving_advanced.html
But I get following error. It is possibly Tensorflow library error. Any help will be greatly appreciated.
:
~/serving$ bazel build //tensorflow_serving/example:mnist_inference_2
INFO: Found 1 target...
ERROR: /home/ubuntu/serving/tensorflow_serving/session_bundle/BUILD:125:1: C++ compilation of rule '//tensorflow_serving/session_bundle:session_bundle' failed: gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wl,-z,-relro,-z,now -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -iquote . ... (remaining 103 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
In file included from ./tensorflow_serving/session_bundle/session_bundle.h:30:0,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
./tensorflow_serving/session_bundle/signature.h:40:22: error: 'Signatures' has not been declared
Signatures* signatures);
^
./tensorflow_serving/session_bundle/signature.h:43:28: error: 'Signatures' does not name a type
Status SetSignatures(const Signatures& signatures,
^
./tensorflow_serving/session_bundle/signature.h:43:40: error: ISO C++ forbids declaration of 'signatures' with no type [-fpermissive]
Status SetSignatures(const Signatures& signatures,
^
./tensorflow_serving/session_bundle/signature.h:51:5: error: 'ClassificationSignature' has not been declared
ClassificationSignature* signature);
^
./tensorflow_serving/session_bundle/signature.h:58:5: error: 'ClassificationSignature' has not been declared
ClassificationSignature* signature);
^
./tensorflow_serving/session_bundle/signature.h:64:31: error: 'RegressionSignature' has not been declared
RegressionSignature* signature);
^
./tensorflow_serving/session_bundle/signature.h:73:32: error: 'ClassificationSignature' does not name a type
Status RunClassification(const ClassificationSignature& signature,
^
./tensorflow_serving/session_bundle/signature.h:73:57: error: ISO C++ forbids declaration of 'signature' with no type [-fpermissive]
Status RunClassification(const ClassificationSignature& signature,
^
./tensorflow_serving/session_bundle/signature.h:83:28: error: 'RegressionSignature' does not name a type
Status RunRegression(const RegressionSignature& signature, const Tensor& input,
^
./tensorflow_serving/session_bundle/signature.h:83:49: error: ISO C++ forbids declaration of 'signature' with no type [-fpermissive]
Status RunRegression(const RegressionSignature& signature, const Tensor& input,
^
./tensorflow_serving/session_bundle/signature.h:90:28: error: 'GenericSignature' has not been declared
GenericSignature* signature);
^
./tensorflow_serving/session_bundle/signature.h:94:28: error: 'Signature' has not been declared
Signature* default_signature);
^
./tensorflow_serving/session_bundle/signature.h:100:26: error: 'Signature' has not been declared
Signature* default_signature);
^
./tensorflow_serving/session_bundle/signature.h:106:32: error: 'GenericSignature' does not name a type
Status BindGenericInputs(const GenericSignature& signature,
^
./tensorflow_serving/session_bundle/signature.h:106:50: error: ISO C++ forbids declaration of 'signature' with no type [-fpermissive]
Status BindGenericInputs(const GenericSignature& signature,
^
./tensorflow_serving/session_bundle/signature.h:117:31: error: 'GenericSignature' does not name a type
Status BindGenericNames(const GenericSignature& signature,
^
./tensorflow_serving/session_bundle/signature.h:117:49: error: ISO C++ forbids declaration of 'signature' with no type [-fpermissive]
Status BindGenericNames(const GenericSignature& signature,
^
tensorflow_serving/session_bundle/session_bundle.cc:68:49: error: 'AssetFile' was not declared in this scope
const std::vector<AssetFile>& asset_files,
^
tensorflow_serving/session_bundle/session_bundle.cc:68:49: note: suggested alternative:
In file included from ./tensorflow_serving/session_bundle/manifest.pb.h:19:0,
from ./tensorflow_serving/session_bundle/session_bundle.h:29,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
bazel-out/local-fastbuild/genfiles/external/org_tensorflow/tensorflow/contrib/session_bundle/manifest.pb.h:237:7: note: 'tensorflow::contrib::AssetFile'
class AssetFile : public ::google::protobuf::Message {
^
tensorflow_serving/session_bundle/session_bundle.cc:68:58: error: template argument 1 is invalid
const std::vector<AssetFile>& asset_files,
^
tensorflow_serving/session_bundle/session_bundle.cc:68:58: error: template argument 2 is invalid
tensorflow_serving/session_bundle/session_bundle.cc: In function 'void tensorflow::serving::{anonymous}::AddAssetsTensorsToInputs(tensorflow::StringPiece, const int&, std::vector<std::pair<std::basic_string<char>, tensorflow::Tensor> >*)':
tensorflow_serving/session_bundle/session_bundle.cc:70:20: error: request for member 'empty' in 'asset_files', which is of non-class type 'const int'
if (!asset_files.empty()) {
^
tensorflow_serving/session_bundle/session_bundle.cc:71:24: error: no matching function for call to 'begin(const int&)'
for (auto& asset : asset_files) {
^
tensorflow_serving/session_bundle/session_bundle.cc:71:24: note: candidates are:
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/stdexcept:39,
from /usr/include/c++/4.8/array:38,
from /usr/include/c++/4.8/tuple:39,
from /usr/include/c++/4.8/functional:55,
from /usr/include/c++/4.8/memory:79,
from ./tensorflow_serving/session_bundle/session_bundle.h:21,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
/usr/include/c++/4.8/bits/range_access.h:87:5: note: template<class _Tp, long unsigned int _Nm> _Tp* std::begin(_Tp (&)[_Nm])
begin(_Tp (&__arr)[_Nm])
^
/usr/include/c++/4.8/bits/range_access.h:87:5: note: template argument deduction/substitution failed:
tensorflow_serving/session_bundle/session_bundle.cc:71:24: note: mismatched types '_Tp [_Nm]' and 'const int'
for (auto& asset : asset_files) {
^
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/stdexcept:39,
from /usr/include/c++/4.8/array:38,
from /usr/include/c++/4.8/tuple:39,
from /usr/include/c++/4.8/functional:55,
from /usr/include/c++/4.8/memory:79,
from ./tensorflow_serving/session_bundle/session_bundle.h:21,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
/usr/include/c++/4.8/bits/range_access.h:58:5: note: template<class _Container> decltype (__cont.begin()) std::begin(const _Container&)
begin(const _Container& __cont) -> decltype(__cont.begin())
^
/usr/include/c++/4.8/bits/range_access.h:58:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) [with _Container = int]':
tensorflow_serving/session_bundle/session_bundle.cc:71:24: required from here
/usr/include/c++/4.8/bits/range_access.h:58:5: error: request for member 'begin' in '__cont', which is of non-class type 'const int'
/usr/include/c++/4.8/bits/range_access.h:48:5: note: template<class _Container> decltype (__cont.begin()) std::begin(_Container&)
begin(_Container& __cont) -> decltype(__cont.begin())
^
/usr/include/c++/4.8/bits/range_access.h:48:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(_Container&) [with _Container = const int]':
tensorflow_serving/session_bundle/session_bundle.cc:71:24: required from here
/usr/include/c++/4.8/bits/range_access.h:48:5: error: request for member 'begin' in '__cont', which is of non-class type 'const int'
In file included from /usr/include/c++/4.8/utility:74:0,
from /usr/include/c++/4.8/tuple:38,
from /usr/include/c++/4.8/functional:55,
from /usr/include/c++/4.8/memory:79,
from ./tensorflow_serving/session_bundle/session_bundle.h:21,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
/usr/include/c++/4.8/initializer_list:89:5: note: template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)
begin(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.8/initializer_list:89:5: note: template argument deduction/substitution failed:
tensorflow_serving/session_bundle/session_bundle.cc:71:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
for (auto& asset : asset_files) {
^
tensorflow_serving/session_bundle/session_bundle.cc:71:24: error: no matching function for call to 'end(const int&)'
tensorflow_serving/session_bundle/session_bundle.cc:71:24: note: candidates are:
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/stdexcept:39,
from /usr/include/c++/4.8/array:38,
from /usr/include/c++/4.8/tuple:39,
from /usr/include/c++/4.8/functional:55,
from /usr/include/c++/4.8/memory:79,
from ./tensorflow_serving/session_bundle/session_bundle.h:21,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
/usr/include/c++/4.8/bits/range_access.h:97:5: note: template<class _Tp, long unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
end(_Tp (&__arr)[_Nm])
^
/usr/include/c++/4.8/bits/range_access.h:97:5: note: template argument deduction/substitution failed:
tensorflow_serving/session_bundle/session_bundle.cc:71:24: note: mismatched types '_Tp [_Nm]' and 'const int'
for (auto& asset : asset_files) {
^
In file included from /usr/include/c++/4.8/string:51:0,
from /usr/include/c++/4.8/stdexcept:39,
from /usr/include/c++/4.8/array:38,
from /usr/include/c++/4.8/tuple:39,
from /usr/include/c++/4.8/functional:55,
from /usr/include/c++/4.8/memory:79,
from ./tensorflow_serving/session_bundle/session_bundle.h:21,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
/usr/include/c++/4.8/bits/range_access.h:78:5: note: template<class _Container> decltype (__cont.end()) std::end(const _Container&)
end(const _Container& __cont) -> decltype(__cont.end())
^
/usr/include/c++/4.8/bits/range_access.h:78:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(const _Container&) [with _Container = int]':
tensorflow_serving/session_bundle/session_bundle.cc:71:24: required from here
/usr/include/c++/4.8/bits/range_access.h:78:5: error: request for member 'end' in '__cont', which is of non-class type 'const int'
/usr/include/c++/4.8/bits/range_access.h:68:5: note: template<class _Container> decltype (__cont.end()) std::end(_Container&)
end(_Container& __cont) -> decltype(__cont.end())
^
/usr/include/c++/4.8/bits/range_access.h:68:5: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(_Container&) [with _Container = const int]':
tensorflow_serving/session_bundle/session_bundle.cc:71:24: required from here
/usr/include/c++/4.8/bits/range_access.h:68:5: error: request for member 'end' in '__cont', which is of non-class type 'const int'
In file included from /usr/include/c++/4.8/utility:74:0,
from /usr/include/c++/4.8/tuple:38,
from /usr/include/c++/4.8/functional:55,
from /usr/include/c++/4.8/memory:79,
from ./tensorflow_serving/session_bundle/session_bundle.h:21,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
/usr/include/c++/4.8/initializer_list:99:5: note: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
end(initializer_list<_Tp> __ils) noexcept
^
/usr/include/c++/4.8/initializer_list:99:5: note: template argument deduction/substitution failed:
tensorflow_serving/session_bundle/session_bundle.cc:71:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
for (auto& asset : asset_files) {
^
tensorflow_serving/session_bundle/session_bundle.cc:76:69: error: no matching function for call to 'std::vector<std::pair<std::basic_string<char>, tensorflow::Tensor> >::push_back(<brace-enclosed initializer list>)'
{asset.tensor_binding().tensor_name(), assets_file_tensor});
^
tensorflow_serving/session_bundle/session_bundle.cc:76:69: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
from external/protobuf/src/google/protobuf/unknown_field_set.h:43,
from external/protobuf/src/google/protobuf/metadata.h:43,
from bazel-out/local-fastbuild/genfiles/external/org_tensorflow/tensorflow/core/lib/core/error_codes.pb.h:25,
from external/org_tensorflow/tensorflow/core/lib/core/status.h:22,
from ./tensorflow_serving/session_bundle/session_bundle.h:23,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<std::basic_string<char>, tensorflow::Tensor>; _Alloc = std::allocator<std::pair<std::basic_string<char>, tensorflow::Tensor> >; std::vector<_Tp, _Alloc>::value_type = std::pair<std::basic_string<char>, tensorflow::Tensor>]
push_back(const value_type& __x)
^
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<std::basic_string<char>, tensorflow::Tensor>&}'
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<std::basic_string<char>, tensorflow::Tensor>; _Alloc = std::allocator<std::pair<std::basic_string<char>, tensorflow::Tensor> >; std::vector<_Tp, _Alloc>::value_type = std::pair<std::basic_string<char>, tensorflow::Tensor>]
push_back(value_type&& __x)
^
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<std::basic_string<char>, tensorflow::Tensor> >::value_type&& {aka std::pair<std::basic_string<char>, tensorflow::Tensor>&&}'
tensorflow_serving/session_bundle/session_bundle.cc: At global scope:
tensorflow_serving/session_bundle/session_bundle.cc:103:39: error: 'AssetFile' was not declared in this scope
const std::vector<AssetFile>& asset_files,
^
tensorflow_serving/session_bundle/session_bundle.cc:103:39: note: suggested alternative:
In file included from ./tensorflow_serving/session_bundle/manifest.pb.h:19:0,
from ./tensorflow_serving/session_bundle/session_bundle.h:29,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
bazel-out/local-fastbuild/genfiles/external/org_tensorflow/tensorflow/contrib/session_bundle/manifest.pb.h:237:7: note: 'tensorflow::contrib::AssetFile'
class AssetFile : public ::google::protobuf::Message {
^
tensorflow_serving/session_bundle/session_bundle.cc:103:48: error: template argument 1 is invalid
const std::vector<AssetFile>& asset_files,
^
tensorflow_serving/session_bundle/session_bundle.cc:103:48: error: template argument 2 is invalid
tensorflow_serving/session_bundle/session_bundle.cc:117:36: error: 'AssetFile' was not declared in this scope
const std::vector<AssetFile>& asset_files,
^
tensorflow_serving/session_bundle/session_bundle.cc:117:36: note: suggested alternative:
In file included from ./tensorflow_serving/session_bundle/manifest.pb.h:19:0,
from ./tensorflow_serving/session_bundle/session_bundle.h:29,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
bazel-out/local-fastbuild/genfiles/external/org_tensorflow/tensorflow/contrib/session_bundle/manifest.pb.h:237:7: note: 'tensorflow::contrib::AssetFile'
class AssetFile : public ::google::protobuf::Message {
^
tensorflow_serving/session_bundle/session_bundle.cc:117:45: error: template argument 1 is invalid
const std::vector<AssetFile>& asset_files,
^
tensorflow_serving/session_bundle/session_bundle.cc:117:45: error: template argument 2 is invalid
tensorflow_serving/session_bundle/session_bundle.cc: In function 'tensorflow::Status tensorflow::serving::LoadSessionBundleFromPath(const tensorflow::SessionOptions&, tensorflow::StringPiece, tensorflow::serving::SessionBundle*)':
tensorflow_serving/session_bundle/session_bundle.cc:165:15: error: 'AssetFile' was not declared in this scope
std::vector<AssetFile> asset_files;
^
tensorflow_serving/session_bundle/session_bundle.cc:165:15: note: suggested alternative:
In file included from ./tensorflow_serving/session_bundle/manifest.pb.h:19:0,
from ./tensorflow_serving/session_bundle/session_bundle.h:29,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
bazel-out/local-fastbuild/genfiles/external/org_tensorflow/tensorflow/contrib/session_bundle/manifest.pb.h:237:7: note: 'tensorflow::contrib::AssetFile'
class AssetFile : public ::google::protobuf::Message {
^
tensorflow_serving/session_bundle/session_bundle.cc:165:24: error: template argument 1 is invalid
std::vector<AssetFile> asset_files;
^
tensorflow_serving/session_bundle/session_bundle.cc:165:24: error: template argument 2 is invalid
tensorflow_serving/session_bundle/session_bundle.cc:165:37: error: invalid type in declaration before ';' token
std::vector<AssetFile> asset_files;
^
tensorflow_serving/session_bundle/session_bundle.cc:170:17: error: expected ';' before 'asset_file'
AssetFile asset_file;
^
tensorflow_serving/session_bundle/session_bundle.cc:171:25: error: the value of 'AssetFile' is not usable in a constant expression
if (!any_asset.Is<AssetFile>()) {
^
tensorflow_serving/session_bundle/session_bundle.cc:165:15: note: 'AssetFile' was not declared 'constexpr'
std::vector<AssetFile> asset_files;
^
tensorflow_serving/session_bundle/session_bundle.cc:171:36: error: no matching function for call to 'google::protobuf::Any::Is() const'
if (!any_asset.Is<AssetFile>()) {
^
tensorflow_serving/session_bundle/session_bundle.cc:171:36: note: candidate is:
In file included from bazel-out/local-fastbuild/genfiles/external/org_tensorflow/tensorflow/core/protobuf/meta_graph.pb.h:32:0,
from ./tensorflow_serving/session_bundle/session_bundle.h:25,
from tensorflow_serving/session_bundle/session_bundle.cc:16:
external/protobuf/src/google/protobuf/any.pb.h:66:29: note: template<class T> bool google::protobuf::Any::Is() const
template<typename T> bool Is() const {
^
external/protobuf/src/google/protobuf/any.pb.h:66:29: note: template argument deduction/substitution failed:
tensorflow_serving/session_bundle/session_bundle.cc:174:13: error: 'asset_file' was not declared in this scope
asset_file.descriptor()->full_name(), ". Got: ",
^
tensorflow_serving/session_bundle/session_bundle.cc:178:32: error: 'asset_file' was not declared in this scope
if (!any_asset.UnpackTo(&asset_file)) {
^
tensorflow_serving/session_bundle/session_bundle.cc:182:19: error: request for member 'push_back' in 'asset_files', which is of non-class type 'int'
asset_files.push_back(asset_file);
^
tensorflow_serving/session_bundle/session_bundle.cc:182:29: error: 'asset_file' was not declared in this scope
asset_files.push_back(asset_file);
^
Target //tensorflow_serving/example:mnist_inference_2 failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 4.822s, Critical Path: 4.54s
From the page you linked: "Before getting started, please complete the prerequisites."
The type Signatures is defined in a header generated by following said prereqs process, so you've either not followed those steps or not followed them correctly – there's no way to tell which just from the compiler errors.

Invoking Template Function using Random Access Iterator

As part of an MOC, I am implementing the merge_sort subroutine, and just for curiosity's sake, I would like to implement it using a function signature similar to what std::sort does.
The code I have so far is as follows.
#include <iostream>
#include <vector>
template <typename T>
bool read_number_list(const std::string& filename, std::vector<T>& output_array){
// ... read number list into an array
return true;
}
template<typename RandomAccessIterator>
void merge_sort_array (RandomAccessIterator first, RandomAccessIterator last, std::vector<decltype(*first)>& merge_array){
// ... merge routine
}
template<typename RandomAccessIterator>
void sort_array (RandomAccessIterator first, RandomAccessIterator last){
std::vector<decltype(*first)> merge_array;
merge_array.assign(first, last);
merge_sort_array(first, last, merge_array);
}
int main(){
std::vector<int> number_array;
read_number_list<int>("file.txt", number_array);
sort_array(number_array.begin(), number_array.end());
return 0;
}
I am seeing errors in the step where I make a copy of the array to be sorted, and also at the point where I invoke the merge_sort_array method. As is customary in templated code, I get the following plethora of errors (which I find quite inscrutable):
In file included from /usr/include/x86_64-linux-gnu/c++/4.8/bits/c++allocator.h:33:0,
from /usr/include/c++/4.8/bits/allocator.h:46,
from /usr/include/c++/4.8/string:41,
from /usr/include/c++/4.8/random:41,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /home/balajeerc/Projects/algorithms/src/main/cpp/lib/algorithms/sorting/merge_sorter.h:8,
from /home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:1:
/usr/include/c++/4.8/ext/new_allocator.h: In instantiation of 'class __gnu_cxx::new_allocator<int&>':
/usr/include/c++/4.8/bits/allocator.h:92:11: required from 'class std::allocator<int&>'
/usr/include/c++/4.8/bits/alloc_traits.h:90:43: required from 'struct std::allocator_traits<std::allocator<int&> >'
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/ext/new_allocator.h:63:26: error: forming pointer to reference type 'int&'
typedef _Tp* pointer;
^
/usr/include/c++/4.8/ext/new_allocator.h:64:26: error: forming pointer to reference type 'int&'
typedef const _Tp* const_pointer;
^
In file included from /usr/include/c++/4.8/string:41:0,
from /usr/include/c++/4.8/random:41,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /home/balajeerc/Projects/algorithms/src/main/cpp/lib/algorithms/sorting/merge_sorter.h:8,
from /home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:1:
/usr/include/c++/4.8/bits/allocator.h: In instantiation of 'class std::allocator<int&>':
/usr/include/c++/4.8/bits/alloc_traits.h:90:43: required from 'struct std::allocator_traits<std::allocator<int&> >'
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/allocator.h:97:26: error: forming pointer to reference type 'int&'
typedef _Tp* pointer;
^
/usr/include/c++/4.8/bits/allocator.h:98:26: error: forming pointer to reference type 'int&'
typedef const _Tp* const_pointer;
^
In file included from /usr/include/c++/4.8/ext/alloc_traits.h:36:0,
from /usr/include/c++/4.8/bits/stl_construct.h:61,
from /usr/include/c++/4.8/bits/stl_tempbuf.h:60,
from /usr/include/c++/4.8/bits/stl_algo.h:62,
from /usr/include/c++/4.8/algorithm:62,
from /home/balajeerc/Projects/algorithms/src/main/cpp/lib/algorithms/sorting/merge_sorter.h:8,
from /home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:1:
/usr/include/c++/4.8/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<std::allocator<int&> >':
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/alloc_traits.h:100:1: error: forming pointer to reference type 'std::allocator_traits<std::allocator<int&> >::value_type {aka int&}'
_GLIBCXX_ALLOC_TR_NESTED_TYPE(pointer, value_type*)
^
/usr/include/c++/4.8/bits/alloc_traits.h:100:1: error: no matching function for call to 'std::allocator_traits<std::allocator<int&> >::_S_pointer_helper(std::allocator<int&>*)'
_GLIBCXX_ALLOC_TR_NESTED_TYPE(pointer, value_type*)
^
/usr/include/c++/4.8/bits/alloc_traits.h:100:1: note: candidate is:
/usr/include/c++/4.8/bits/alloc_traits.h:100:1: note: template<class _Tp> static typename _Tp::pointer std::allocator_traits<_Alloc>::_S_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>]
_GLIBCXX_ALLOC_TR_NESTED_TYPE(pointer, value_type*)
^
/usr/include/c++/4.8/bits/alloc_traits.h:100:1: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/alloc_traits.h:109:1: error: no matching function for call to 'std::allocator_traits<std::allocator<int&> >::_S_const_pointer_helper(std::allocator<int&>*)'
_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:109:1: note: candidate is:
/usr/include/c++/4.8/bits/alloc_traits.h:109:1: note: template<class _Tp> static typename _Tp::const_pointer std::allocator_traits<_Alloc>::_S_const_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>]
_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:109:1: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: error: no matching function for call to 'std::allocator_traits<std::allocator<int&> >::_S_void_pointer_helper(std::allocator<int&>*)'
_GLIBCXX_ALLOC_TR_NESTED_TYPE(void_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: note: candidate is:
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: note: template<class _Tp> static typename _Tp::void_pointer std::allocator_traits<_Alloc>::_S_void_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>]
_GLIBCXX_ALLOC_TR_NESTED_TYPE(void_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/alloc_traits.h: In substitution of 'template<class _Tp> static typename _Tp::void_pointer std::allocator_traits<_Alloc>::_S_void_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>] [with _Tp = std::allocator<int&>]':
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: required from 'struct std::allocator_traits<std::allocator<int&> >'
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/alloc_traits.h:120:1: error: no type named 'void_pointer' in 'class std::allocator<int&>'
/usr/include/c++/4.8/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<std::allocator<int&> >':
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: error: no matching function for call to 'std::allocator_traits<std::allocator<int&> >::_S_const_void_pointer_helper(std::allocator<int&>*)'
_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_void_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: note: candidate is:
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: note: template<class _Tp> static typename _Tp::const_void_pointer std::allocator_traits<_Alloc>::_S_const_void_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>]
_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_void_pointer,
^
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: note: template argument deduction/substitution failed:
/usr/include/c++/4.8/bits/alloc_traits.h: In substitution of 'template<class _Tp> static typename _Tp::const_void_pointer std::allocator_traits<_Alloc>::_S_const_void_pointer_helper(_Tp*) [with _Tp = _Tp; _Alloc = std::allocator<int&>] [with _Tp = std::allocator<int&>]':
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: required from 'struct std::allocator_traits<std::allocator<int&> >'
/usr/include/c++/4.8/ext/alloc_traits.h:121:10: required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/alloc_traits.h:131:1: error: no type named 'const_void_pointer' in 'class std::allocator<int&>'
In file included from /usr/include/c++/4.8/bits/stl_construct.h:61:0,
from /usr/include/c++/4.8/bits/stl_tempbuf.h:60,
from /usr/include/c++/4.8/bits/stl_algo.h:62,
from /usr/include/c++/4.8/algorithm:62,
from /home/balajeerc/Projects/algorithms/src/main/cpp/lib/algorithms/sorting/merge_sorter.h:8,
from /home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:1:
/usr/include/c++/4.8/ext/alloc_traits.h: In instantiation of 'struct __gnu_cxx::__alloc_traits<std::allocator<int&> >':
/usr/include/c++/4.8/bits/stl_vector.h:75:28: required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/include/c++/4.8/bits/stl_vector.h:210:11: required from 'class std::vector<int&, std::allocator<int&> >'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/ext/alloc_traits.h:137:23: error: no members matching '__gnu_cxx::__alloc_traits<std::allocator<int&> >::_Base_type {aka std::allocator_traits<std::allocator<int&> >}::allocate' in '__gnu_cxx::__alloc_traits<std::allocator<int&> >::_Base_type {aka struct std::allocator_traits<std::allocator<int&> >}'
using _Base_type::allocate;
^
/usr/include/c++/4.8/ext/alloc_traits.h:138:23: error: no members matching '__gnu_cxx::__alloc_traits<std::allocator<int&> >::_Base_type {aka std::allocator_traits<std::allocator<int&> >}::deallocate' in '__gnu_cxx::__alloc_traits<std::allocator<int&> >::_Base_type {aka struct std::allocator_traits<std::allocator<int&> >}'
using _Base_type::deallocate;
^
In file included from /usr/include/c++/4.8/vector:64:0,
from /usr/include/c++/4.8/bits/random.h:34,
from /usr/include/c++/4.8/random:50,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /home/balajeerc/Projects/algorithms/src/main/cpp/lib/algorithms/sorting/merge_sorter.h:8,
from /home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:1:
/usr/include/c++/4.8/bits/stl_vector.h: In instantiation of 'class std::vector<int&, std::allocator<int&> >':
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:20:35: required from 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]'
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/usr/include/c++/4.8/bits/stl_vector.h:237:20: error: no members matching 'std::vector<int&, std::allocator<int&> >::_Base {aka std::_Vector_base<int&, std::allocator<int&> >}::_M_allocate' in 'std::vector<int&, std::allocator<int&> >::_Base {aka struct std::_Vector_base<int&, std::allocator<int&> >}'
using _Base::_M_allocate;
^
/usr/include/c++/4.8/bits/stl_vector.h:238:20: error: no members matching 'std::vector<int&, std::allocator<int&> >::_Base {aka std::_Vector_base<int&, std::allocator<int&> >}::_M_deallocate' in 'std::vector<int&, std::allocator<int&> >::_Base {aka struct std::_Vector_base<int&, std::allocator<int&> >}'
using _Base::_M_deallocate;
^
/usr/include/c++/4.8/bits/stl_vector.h:878:7: error: forming pointer to reference type 'int&'
data() _GLIBCXX_NOEXCEPT
^
/usr/include/c++/4.8/bits/stl_vector.h:886:7: error: forming pointer to reference type 'int&'
data() const _GLIBCXX_NOEXCEPT
^
/usr/include/c++/4.8/bits/stl_vector.h:919:7: error: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int&; _Alloc = std::allocator<int&>; std::vector<_Tp, _Alloc>::value_type = int&]' cannot be overloaded
push_back(value_type&& __x)
^
/usr/include/c++/4.8/bits/stl_vector.h:901:7: error: with 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int&; _Alloc = std::allocator<int&>; std::vector<_Tp, _Alloc>::value_type = int&]'
push_back(const value_type& __x)
^
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc: In instantiation of 'void sort_array(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >]':
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:34:56: required from here
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:22:46: error: 'merge_sort_array' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
merge_sort_array(first, last, merge_array);
^
/home/balajeerc/Projects/algorithms/src/test/cpp/lib/algorithms/sorting/test_inversion_count.cc:26:6: note: 'template<class RandomAccessIterator> void merge_sort_array(RandomAccessIterator, RandomAccessIterator, std::vector<decltype (* first)>&)' declared here, later in the translation unit
void merge_sort_array (RandomAccessIterator first, RandomAccessIterator last, std::vector<decltype(*first)>& merge_array){
^
make[2]: *** [src/test/cpp/lib/algorithms/sorting/CMakeFiles/test_inversion_count.dir/test_inversion_count.cc.o] Error 1
make[1]: *** [src/test/cpp/lib/algorithms/sorting/CMakeFiles/test_inversion_count.dir/all] Error 2
make: *** [all] Error 2
What am I doing wrong?
Your problem is the misuse of decltype:
decltype( expression )
yields T& for lvalue expressions of type T, and you cannot have an std::vector<int&>. Thus the error.
To fix that, use typename std::iterator_traits<RandomAccessIterator>::value_type as template parameter instead.