Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Problem with copy construction of std::vector from Upp::Vector
Problem with copy construction of std::vector from Upp::Vector [message #43818] Tue, 28 October 2014 15:32 Go to next message
masu is currently offline  masu
Messages: 378
Registered: February 2006
Senior Member
Hi,

when trying to copy construct std::vector from Upp::Vector like this:
Vector<int> v;
v << 1 << 2 << 3;
std::vector<int> std_v(v);

I get the following error:
error: invalid user-defined conversion from 'Upp::Vector<int>' to 'std::vector<int>::size_type {aka 
	long long unsigned int}' [-fpermissive]

std::vector constructor using iterators works well with Upp::Vector:
std::vector<int> siv(v.Begin(), v.End());

[EDIT]
Ok, the compiler takes another constructor with size_type argument since Upp::Vector is not a std::vector and therefore the copy constructor cannot be used.
It seems the easiest to use the std::vector constructor using iterators when one wants to copy an Upp::Vector to a std::vector or is there a simpler way of doing this?

Regards
Matthias


931b81e7ea53320dccc37375b34b38c3

[Updated on: Tue, 28 October 2014 18:33]

Report message to a moderator

Re: Problem with copy construction of std::vector from Upp::Vector [message #43821 is a reply to message #43818] Wed, 29 October 2014 09:54 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I think using iterators is the correct approach:

- we obviously cannot add a new copy contructor to std::vector
- it might be possible to add operator std::vector<T> to Vector, but that would be confusing at best (e.g. because of clone/pick semantics)
- besides, AFAIK vector does not have a copy constructor e.g. from deque or list, so this is the corresponding approach

Mirek
Previous Topic: How to get value from parent AppWindow class?
Next Topic: Any good reason why SSL support is hardcoded to SSLv3 usage?
Goto Forum:
  


Current Time: Thu Apr 18 10:13:22 CEST 2024

Total time taken to generate the page: 0.02186 seconds