From: "Henrik Mannerström" <henrik.mannerstrom@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Defaulted initializer constructor
Date: Mon, 26 Nov 2012 09:49:00 -0000 [thread overview]
Message-ID: <50B33B04.2010304@gmail.com> (raw)
Hello!
If I write
class MT {
public:
int k[3];
};
then g++(4.6.3) accepts
MT a{{0,1,2}};
but if I add a constructor
MT() {
for (int i = 0;i!=3;i++)
k[i] = 0;
}
then MT a{{0,1,2}}; gives me
error: no matching function for call to ‘MT::MT(<brace-enclosed
initializer list>)Â’
Now, if I add
MT(std::initializer_list<int> list) = default;
I get
error: ‘MT::MT(std::initializer_list<int>)’ cannot be defaulted
What constructor was I (gcc) using earlier and how can I get i back?
BR,
Henrik Mannerstrom
next reply other threads:[~2012-11-26 9:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-26 9:49 Henrik Mannerström [this message]
2012-11-26 10:31 ` Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50B33B04.2010304@gmail.com \
--to=henrik.mannerstrom@gmail.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).