Web lists-archives.com

Re: [Mingw-users] Copy Constructor; Programming Principles and Practice Using C++




Sorry for the top post earlier. On my phone again.

On Sun, Dec 18, 2016 at 12:18 AM, Clayton Weaver <mingwuser@xxxxxxxxx> wrote:
The second warning I'm getting is a narrowing conversion:
Vector::Vector(initializer_list<double> lst) : sz{lst.size()}, elem{new double[sz]}
samp18_1.cpp:25:59: warning: narrowing conversion of 'lst.std::initializer_list<_E>::size<double>()' from 'std::initializer_list<double>::size_type {aka unsigned int}' to 'int' inside { } [-Wnarrowing]

Full code (per book):
Vector::Vector(initializer_list<double> lst) : sz{lst.size()}, elem{new double[sz]}
{
     std::copy(lst.begin(), lst.end(), elem);
}

sz is an int, and lst.size() is an unsigned int. Just cast lst.size() to an int and move on.


 
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe