Operating System - HP-UX
1748195 Members
3056 Online
108759 Solutions
New Discussion

When using -Ax with aC++ 6.26 function overloads with rvalue references do not bind (error #3768).

 
SOLVED
Go to solution
agh
Occasional Advisor

When using -Ax with aC++ 6.26 function overloads with rvalue references do not bind (error #3768).

Hi,

 

Using aC++ 6.26, the following code fails to compile.

#include <vector>

template <typename T>
class Container
{
    std::vector<T> m_container;

public:
    void add(const T &value)
    {
        m_container.push_back(value);
    }

    void add(T &&value)
    {
        // Cannot do this as std::move is not implemented in aC++.
        //m_container.push_back(std::move(value));
        m_container.push_back(value);
    }
};

int main()
{
    Container<double> container;
    int item = 5;
    container.add(item);
}

 The failure is:

"rvaluetest.cxx", line 26: error #3768: an rvalue reference cannot be bound to
          an lvalue
      container.add(item);

 Which is strange, since I have overloaded the add function to take an rvalue reference as well as a const lvalue reference.

 

Surely, the compiler should pick the rvalue reference method instead of the lvalue one?

 

To me this looks like a defect in the compiler, but is there a workaround?

1 REPLY 1
Ashutosh_Nema
New Member
Solution

Re: When using -Ax with aC++ 6.26 function overloads with rvalue references do not bind (error #3768

This was a compiler defect in A.06.26 release & got fixed in A.06.27 release.

We recommend to use latest compiler to avoid such defects.

 

Regards

Ashutosh Nema | HP-UX C/C++ Compilers Team.