This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Initializer List Ctor
- From: Julius Witte <julius dot witte at iwr dot uni-heidelberg dot de>
- To: gcc-help at gcc dot gnu dot org
- Date: Tue, 5 Sep 2017 15:06:29 +0200
- Subject: Initializer List Ctor
- Authentication-results: sourceware.org; auth=none
In a class such as this one:
#include <initializer_list>
class A
{
public:
A(int i, double d){}
A(std::initializer_list<double> l){}
};
why an instantiation with curly braces as this one
int main()
{
A a{2,2.} ;
}
shall default to the initializer list constructor?
I understand why a call like "A a{2.,2.}" would default to it,
but in my eyes it would make more sense to default
to the first constructor when the types match it exactly.
--
Julius Witte
Mathematical Methods for Simulation (Head: Prof. G. Kanschat)
Interdisciplinary Center for Scientific Computing (IWR)
Heidelberg University
Room 1.235, INF 205, 69120 Heidelberg, Germany
Web: http://www.mathsim.eu