Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #11338 > unrolled thread
| Started by | dec4106 <dec4106@gmail.com> |
|---|---|
| First post | 2011-11-09 07:29 -0800 |
| Last post | 2011-11-13 02:26 -0800 |
| Articles | 11 — 8 participants |
Back to article view | Back to comp.lang.c++
Is this valid c++? dec4106 <dec4106@gmail.com> - 2011-11-09 07:29 -0800
Re: Is this valid c++? Richard Damon <news.x.richarddamon@xoxy.net> - 2011-11-09 10:47 -0500
Re: Is this valid c++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-09 17:48 +0000
Re: Is this valid c++? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-11-09 14:04 -0500
Re: Is this valid c++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-10 20:20 +0000
Re: Is this valid c++? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-11-10 16:36 -0500
Re: Is this valid c++? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-12 08:29 +0000
Re: Is this valid c++? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-11-09 16:55 +0100
Re: Is this valid c++? Krice <paulkp@mbnet.fi> - 2011-11-09 23:12 -0800
Re: Is this valid c++? Juha Nieminen <nospam@thanks.invalid> - 2011-11-10 07:53 +0000
Re: Is this valid c++? Daryle Walker <darylew@gmail.com> - 2011-11-13 02:26 -0800
| From | dec4106 <dec4106@gmail.com> |
|---|---|
| Date | 2011-11-09 07:29 -0800 |
| Subject | Is this valid c++? |
| Message-ID | <d42e7802-cfd7-475f-88c5-b2b81b0e9c12@g27g2000pre.googlegroups.com> |
Earlier today I came across a code example that looked something like
this:
template <typename T, unsigned S>
class MyClass
{
public:
MyClass() = default;
...
"default" is not defined anywhere in the example. I've never seen an
expression like this before and don't understand how it could work,
and haven't been able to make it work. Is this a C++11 thing?
[toc] | [next] | [standalone]
| From | Richard Damon <news.x.richarddamon@xoxy.net> |
|---|---|
| Date | 2011-11-09 10:47 -0500 |
| Message-ID | <j9e79n$qlb$1@dont-email.me> |
| In reply to | #11338 |
On 11/9/11 10:29 AM, dec4106 wrote:
> Earlier today I came across a code example that looked something like
> this:
>
>
> template<typename T, unsigned S>
> class MyClass
> {
> public:
> MyClass() = default;
> ...
>
> "default" is not defined anywhere in the example. I've never seen an
> expression like this before and don't understand how it could work,
> and haven't been able to make it work. Is this a C++11 thing?
>
Yes, that is a new C++11 construct, it tells the compiler to make a
standard default constructor MyClass() with the "default"
implementation, even if some other constructor is defined that would
suppress the generation of the default constructor.
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2011-11-09 17:48 +0000 |
| Message-ID | <slrnjblf6i.1bk.grahn+nntp@frailea.sa.invalid> |
| In reply to | #11339 |
On Wed, 2011-11-09, Richard Damon wrote:
> On 11/9/11 10:29 AM, dec4106 wrote:
>> Earlier today I came across a code example that looked something like
>> this:
>>
>>
>> template<typename T, unsigned S>
>> class MyClass
>> {
>> public:
>> MyClass() = default;
>> ...
>>
>> "default" is not defined anywhere in the example. I've never seen an
>> expression like this before and don't understand how it could work,
>> and haven't been able to make it work. Is this a C++11 thing?
>>
>
> Yes, that is a new C++11 construct, it tells the compiler to make a
> standard default constructor MyClass() with the "default"
> implementation, even if some other constructor is defined that would
> suppress the generation of the default constructor.
I hope this doesn't become the norm -- mixing C++11 into examples,
discussions etc -- just yet. I bet most of us cannot switch, due
to having to support some system which doesn't have a bleeding edge
compiler yet. (My Debian Stable systems have gcc 4.4, which
implements maybe 50%.)
C++11 is great, and it seems it will propagate out to the end users
much faster than C++98 did ... but we have to survive while waiting
for it, too.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | Victor Bazarov <v.bazarov@comcast.invalid> |
|---|---|
| Date | 2011-11-09 14:04 -0500 |
| Message-ID | <j9eism$efs$1@dont-email.me> |
| In reply to | #11344 |
On 11/9/2011 12:48 PM, Jorgen Grahn wrote:
> On Wed, 2011-11-09, Richard Damon wrote:
>> On 11/9/11 10:29 AM, dec4106 wrote:
>>> Earlier today I came across a code example that looked something like
>>> this:
>>>
>>>
>>> template<typename T, unsigned S>
>>> class MyClass
>>> {
>>> public:
>>> MyClass() = default;
>>> ...
>>>
>>> "default" is not defined anywhere in the example. I've never seen an
>>> expression like this before and don't understand how it could work,
>>> and haven't been able to make it work. Is this a C++11 thing?
>>>
>>
>> Yes, that is a new C++11 construct, it tells the compiler to make a
>> standard default constructor MyClass() with the "default"
>> implementation, even if some other constructor is defined that would
>> suppress the generation of the default constructor.
>
> I hope this doesn't become the norm -- mixing C++11 into examples,
> discussions etc -- just yet. I bet most of us cannot switch, due
> to having to support some system which doesn't have a bleeding edge
> compiler yet. (My Debian Stable systems have gcc 4.4, which
> implements maybe 50%.)
>
> C++11 is great, and it seems it will propagate out to the end users
> much faster than C++98 did ... but we have to survive while waiting
> for it, too.
And how long do you think we should wait?
V
--
I do not respond to top-posted replies, please don't ask
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2011-11-10 20:20 +0000 |
| Message-ID | <slrnjbocgo.1bk.grahn+nntp@frailea.sa.invalid> |
| In reply to | #11345 |
On Wed, 2011-11-09, Victor Bazarov wrote:
> On 11/9/2011 12:48 PM, Jorgen Grahn wrote:
>> On Wed, 2011-11-09, Richard Damon wrote:
>>> On 11/9/11 10:29 AM, dec4106 wrote:
>>>> Earlier today I came across a code example that looked something like
>>>> this:
>>>>
>>>>
>>>> template<typename T, unsigned S>
>>>> class MyClass
>>>> {
>>>> public:
>>>> MyClass() = default;
>>>> ...
>>>>
>>>> "default" is not defined anywhere in the example. I've never seen an
>>>> expression like this before and don't understand how it could work,
>>>> and haven't been able to make it work. Is this a C++11 thing?
>>>>
>>>
>>> Yes, that is a new C++11 construct, it tells the compiler to make a
>>> standard default constructor MyClass() with the "default"
>>> implementation, even if some other constructor is defined that would
>>> suppress the generation of the default constructor.
>>
>> I hope this doesn't become the norm -- mixing C++11 into examples,
>> discussions etc -- just yet. I bet most of us cannot switch, due
>> to having to support some system which doesn't have a bleeding edge
>> compiler yet. (My Debian Stable systems have gcc 4.4, which
>> implements maybe 50%.)
>>
>> C++11 is great, and it seems it will propagate out to the end users
>> much faster than C++98 did ... but we have to survive while waiting
>> for it, too.
>
> And how long do you think we should wait?
I won't know until it happens (and I'll make sure to tell you).
It's subjective of course; I'm just saying I think we're not there yet,
for e.g. the reasons I listed above.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | Victor Bazarov <v.bazarov@comcast.invalid> |
|---|---|
| Date | 2011-11-10 16:36 -0500 |
| Message-ID | <j9hg4j$qrt$1@dont-email.me> |
| In reply to | #11370 |
On 11/10/2011 3:20 PM, Jorgen Grahn wrote:
> On Wed, 2011-11-09, Victor Bazarov wrote:
>> On 11/9/2011 12:48 PM, Jorgen Grahn wrote:
>>> On Wed, 2011-11-09, Richard Damon wrote:
>>>> On 11/9/11 10:29 AM, dec4106 wrote:
>>>>> Earlier today I came across a code example that looked something like
>>>>> this:
>>>>>
>>>>>
>>>>> template<typename T, unsigned S>
>>>>> class MyClass
>>>>> {
>>>>> public:
>>>>> MyClass() = default;
>>>>> ...
>>>>>
>>>>> "default" is not defined anywhere in the example. I've never seen an
>>>>> expression like this before and don't understand how it could work,
>>>>> and haven't been able to make it work. Is this a C++11 thing?
>>>>>
>>>>
>>>> Yes, that is a new C++11 construct, it tells the compiler to make a
>>>> standard default constructor MyClass() with the "default"
>>>> implementation, even if some other constructor is defined that would
>>>> suppress the generation of the default constructor.
>>>
>>> I hope this doesn't become the norm -- mixing C++11 into examples,
>>> discussions etc -- just yet. I bet most of us cannot switch, due
>>> to having to support some system which doesn't have a bleeding edge
>>> compiler yet. (My Debian Stable systems have gcc 4.4, which
>>> implements maybe 50%.)
>>>
>>> C++11 is great, and it seems it will propagate out to the end users
>>> much faster than C++98 did ... but we have to survive while waiting
>>> for it, too.
>>
>> And how long do you think we should wait?
>
> I won't know until it happens (and I'll make sure to tell you).
<sarcasm> We'll all wait with baited breath. </sarcasm>
> It's subjective of course; I'm just saying I think we're not there yet,
> for e.g. the reasons I listed above.
<shrug> You're not there. I'm not there. Shouldn't preclude those who
want to discuss C++11 from talking about it and giving code snippets
with the language _a Standard for which has already been approved_.
The more "we" (as a c.l.c++ community) do the "mixing C++11 into
examples", the sooner it is learned by "us" (and that means you, as well).
I say, go for it! As an old Russian saying goes, to learn to swim one
must go into water.
V
--
I do not respond to top-posted replies, please don't ask
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2011-11-12 08:29 +0000 |
| Message-ID | <slrnjbsbij.1bk.grahn+nntp@frailea.sa.invalid> |
| In reply to | #11374 |
On Thu, 2011-11-10, Victor Bazarov wrote:
> On 11/10/2011 3:20 PM, Jorgen Grahn wrote:
>> On Wed, 2011-11-09, Victor Bazarov wrote:
>>> On 11/9/2011 12:48 PM, Jorgen Grahn wrote:
>>>> On Wed, 2011-11-09, Richard Damon wrote:
>>>>> On 11/9/11 10:29 AM, dec4106 wrote:
>>>>>> Earlier today I came across a code example that looked something like
>>>>>> this:
>>>>>>
>>>>>>
>>>>>> template<typename T, unsigned S>
>>>>>> class MyClass
>>>>>> {
>>>>>> public:
>>>>>> MyClass() = default;
>>>>>> ...
>>>>>>
>>>>>> "default" is not defined anywhere in the example. I've never seen an
>>>>>> expression like this before and don't understand how it could work,
>>>>>> and haven't been able to make it work. Is this a C++11 thing?
>>>>>>
>>>>>
>>>>> Yes, that is a new C++11 construct, it tells the compiler to make a
>>>>> standard default constructor MyClass() with the "default"
>>>>> implementation, even if some other constructor is defined that would
>>>>> suppress the generation of the default constructor.
>>>>
>>>> I hope this doesn't become the norm -- mixing C++11 into examples,
>>>> discussions etc -- just yet. I bet most of us cannot switch, due
>>>> to having to support some system which doesn't have a bleeding edge
>>>> compiler yet. (My Debian Stable systems have gcc 4.4, which
>>>> implements maybe 50%.)
>>>>
>>>> C++11 is great, and it seems it will propagate out to the end users
>>>> much faster than C++98 did ... but we have to survive while waiting
>>>> for it, too.
>>>
>>> And how long do you think we should wait?
>>
>> I won't know until it happens (and I'll make sure to tell you).
>
> <sarcasm> We'll all wait with baited breath. </sarcasm>
I think you missed /my/ sarcasm above ;-)
>> It's subjective of course; I'm just saying I think we're not there yet,
>> for e.g. the reasons I listed above.
>
> <shrug> You're not there. I'm not there. Shouldn't preclude those who
> want to discuss C++11 from talking about it and giving code snippets
> with the language _a Standard for which has already been approved_.
Of course C++11 needs to be discussed et cetera like you say; I don't
propose to treat it as a second-class language for N more years.
I'm just afraid that while the early adopters are having fun with the
new features (and all the positive effects which come with that), the
big crowd of C++ users are partly left behind, some of them being
/more/ confused than they already were.
> The more "we" (as a c.l.c++ community) do the "mixing C++11 into
> examples", the sooner it is learned by "us" (and that means you, as well).
>
> I say, go for it! As an old Russian saying goes, to learn to swim one
> must go into water.
I'd like to, but my code has to compile & run on a few different
machines not under my direct control. When g++ 4.6 hits Debian Stable
is when I personally can consider flipping the -std=c++11 switch, or
whatever it's called. By that time, I expect most systems which have
C++98 today, will also have large parts of C++11 (because Debian isn't
known for it's bleeding-edge-ness).
(At work is another issue: as is often the case, I'm stuck with even
older tools there. But that's not new; I can't even use C99 there.)
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | Alain Ketterlin <alain@dpt-info.u-strasbg.fr> |
|---|---|
| Date | 2011-11-09 16:55 +0100 |
| Message-ID | <87bosl70kn.fsf@dpt-info.u-strasbg.fr> |
| In reply to | #11338 |
dec4106 <dec4106@gmail.com> writes:
> template <typename T, unsigned S>
> class MyClass
> {
> public:
> MyClass() = default;
> ...
>
> "default" is not defined anywhere in the example. I've never seen an
> expression like this before and don't understand how it could work,
> and haven't been able to make it work. Is this a C++11 thing?
Yes, it lets the compiler generate the ctor for you, with default
behavior.
-- Alain.
[toc] | [prev] | [next] | [standalone]
| From | Krice <paulkp@mbnet.fi> |
|---|---|
| Date | 2011-11-09 23:12 -0800 |
| Message-ID | <aebcd08f-f274-42db-8f45-70944ca1b42d@p1g2000yqh.googlegroups.com> |
| In reply to | #11340 |
On 9 marras, 17:55, Alain Ketterlin <al...@dpt-info.u-strasbg.fr> wrote: > Yes, it lets the compiler generate the ctor for you, with default > behavior. What is that default behaviour?
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2011-11-10 07:53 +0000 |
| Message-ID | <4ebb82dc$0$4394$7b1e8fa0@news.nbl.fi> |
| In reply to | #11358 |
Krice <paulkp@mbnet.fi> wrote: > On 9 marras, 17:55, Alain Ketterlin <al...@dpt-info.u-strasbg.fr> > wrote: >> Yes, it lets the compiler generate the ctor for you, with default >> behavior. > > What is that default behaviour? All member objects are default-constructed (after which the derived class default constructor is called if this was really an object of a derived class).
[toc] | [prev] | [next] | [standalone]
| From | Daryle Walker <darylew@gmail.com> |
|---|---|
| Date | 2011-11-13 02:26 -0800 |
| Message-ID | <b7c39568-1f57-4c85-b03c-0591916991a5@d17g2000yql.googlegroups.com> |
| In reply to | #11338 |
On Nov 9, 10:29 am, dec4106 <dec4...@gmail.com> wrote:
> Earlier today I came across a code example that looked something like
> this:
>
> template <typename T, unsigned S>
> class MyClass
> {
> public:
> MyClass() = default;
> ...
>
> "default" is not defined anywhere in the example. I've never seen an
> expression like this before and don't understand how it could work,
> and haven't been able to make it work. Is this a C++11 thing?
I think this is from one of my posts.
Ironically, considering the rest of this thread, I don't even have a C+
+11 compiler (or a system ready to use one). I'm learning C++11 from
web sites and Usenet posts.
I, nor anyone else, can define "default" in an example since it's a
keyword!
Daryle W.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web