jeudi 20 avril 2017

error in type_trait with template-meta programming

I have two types of dataStorage classes, they both resemble a vector-like data container behavior while providing unique feature sets. to reduce the lines of code I have to implement to add utilities to this classes ( operator overloading), I created a template storage class the as below:

template<typename VT>
struct StorageBase
{
    typedef VT VectorType;  //!Type of the vector.

    inline VectorType& operator~() noexcept
    {
        return *static_cast<VectorType*>(this);
    }

    inline const VectorType& operator~() const noexcept
    {
        return *static_cast<const VectorType*>(this);
    }
};

both of my container classes are public classes of StorageBase. to write the + operator, I have something like this:

template<typename T1, typename T2, typename TYPE = GetVectorType<T1, T2> >
TYPE operator+(const StorageBase<T1> & lhs, const StorageBase<T2> & rhs)
{
    TYPE answer;

    // implementation

    return answer;
}

GetVectorType decides the tyope of output vctor, for example (vector + vector -> vector, list + vector - > list , ... )

however, when I want to compile my code, I get the following error at the line of return answer;:

 no matching function for call to
 DataVector2D<double>::DataVector2D(DataVector2D<double>&)

below are the constructors of the DataVector2D

explicit inline DataVector2D();
explicit inline DataVector2D(const DataVector2D<T> &);
explicit inline DataVector2D(DataVector2D<T> &);
explicit inline DataVector2D(const size_t &, const size_t &);
explicit inline DataVector2D(const size_t &, const size_t &, const T &);
explicit inline DataVector2D(const size_t &, const std::vector<T> &);

Can someone help me resolve this issue?

Peace !!!

Aucun commentaire:

Enregistrer un commentaire