- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- When using -Ax with aC++ 6.26 function overloads w...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2014 09:45 AM
01-02-2014 09:45 AM
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?
Solved! Go to Solution.
- Tags:
- overloading
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2014 12:38 AM
01-06-2014 12:38 AM
SolutionThis 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.