Topic: Container adaptor - missing container support operation


Author: Akira Takahashi <faithandbrave@gmail.com>
Date: Tue, 24 Apr 2012 11:03:54 -0700 (PDT)
Raw View
Hi,

I read N3337's Container adaptors specification.
I think missing support operation : emplace_back().

23.6.3.1 queue definition
Any sequence container supporting operations front(), back(),
push_back() and pop_front() can be used to instantiate queue.

=> add emplace_back().


23.6.4 Class template priority_queue
Any sequence container with random access iterator and supporting
operations front(), push_back() and pop_back() can be used to
instantiate priority_queue.

=> add emplace_back().


23.6.5 Class template stack
Any sequence container supporting operations back(), push_back() and
pop_back() can be used to instantiate stack.

=> add emplace_back().


Regards,
Akira


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]




Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?=<daniel.kruegler@googlemail.com>
Date: Wed, 25 Apr 2012 13:56:05 -0700 (PDT)
Raw View
Am 24.04.2012 20:03, schrieb Akira Takahashi:
>  I read N3337's Container adaptors specification.
>  I think missing support operation : emplace_back().
>
>  23.6.3.1 queue definition
>  Any sequence container supporting operations front(), back(),
>  push_back() and pop_front() can be used to instantiate queue.
>
>  =>   add emplace_back().
>
>
>  23.6.4 Class template priority_queue
>  Any sequence container with random access iterator and supporting
>  operations front(), push_back() and pop_back() can be used to
>  instantiate priority_queue.
>
>  =>   add emplace_back().
>
>
>  23.6.5 Class template stack
>  Any sequence container supporting operations back(), push_back() and
>  pop_back() can be used to instantiate stack.
>
>  =>   add emplace_back().

I agree that adding these would seem to be more appropriate, even though
the current state does not really look like a defect to me, because
above quoted parts are more like introductory descriptions, not strong
requirements (but the latter following argumentation of mine is moving
slightly on this position). Strictly speaking, not even front() or
push_back (for example) are necessary when such a *container* adaptor is
instantiated.

Based on the same arguments you could argue that you need to add
operator<,>,<=, and>= as well, which are (now) optional as well.

I tend to say that the current wording state is better than adding these
or even further requirements because this would invalidate *existing*
user-provided C++03 sequence containers to be adapted. Consider a very
strict library implementation which considers these wordings as binding
requirements: It might add static assertions to the class body of these
adaptors to ensure that above functions exist: It would be a bad idea to
break existing adaptions that do not provide these functions.

Just my opinion - HTH&  Greetings from Bremen,

Daniel Kr   gler



--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]




Author: Jason McKesson<jmckesson@gmail.com>
Date: Wed, 25 Apr 2012 13:56:33 -0700 (PDT)
Raw View
On Tuesday, April 24, 2012 11:03:54 AM UTC-7, Akira Takahashi wrote:
>  Hi,
>
>  I read N3337's Container adaptors specification.
>  I think missing support operation : emplace_back().
>
>  23.6.3.1 queue definition
>  Any sequence container supporting operations front(), back(),
>  push_back() and pop_front() can be used to instantiate queue.
>
>  =>  add emplace_back().
>
>
>  23.6.4 Class template priority_queue
>  Any sequence container with random access iterator and supporting
>  operations front(), push_back() and pop_back() can be used to
>  instantiate priority_queue.
>
>  =>  add emplace_back().
>
>
>  23.6.5 Class template stack
>  Any sequence container supporting operations back(), push_back() and
>  pop_back() can be used to instantiate stack.
>
>  =>  add emplace_back().
>
>
>  Regards,
>  Akira
>
>

All of those containers have "emplace" functions, which does the same thing. You can only push into one place on the adapters, so "_back" is meaningless.


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]




Author: "Nevin \":-]\" Liber" <nevin@eviloverlord.com>
Date: Wed, 25 Apr 2012 15:44:17 -0700 (PDT)
Raw View
In article
<60068140-4f4a-434e-af9d-d6391c284fb8@g6g2000pbq.googlegroups.com>,
 Akira Takahashi <faithandbrave@gmail.com> wrote:

> Hi,
>
> I read N3337's Container adaptors specification.
> I think missing support operation : emplace_back().

The adaptors all have emplace methods in C++11.  Why is that not
sufficient?

--
Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>


[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]




Author: Jason McKesson<jmckesson@gmail.com>
Date: Thu, 26 Apr 2012 11:07:22 -0700 (PDT)
Raw View
On Wednesday, April 25, 2012 3:44:17 PM UTC-7, Nevin :-] Liber wrote:
>  >  Hi,
>  >
>  >  I read N3337's Container adaptors specification.
>  >  I think missing support operation : emplace_back().
>
>  The adaptors all have emplace methods in C++11.  Why is that not
>  sufficient?
>
>  --
>  Nevin ":-)" Liber<mailto:nevin@eviloverlord.com>

Actually, I realized after I replied that he's talking about the *requirements* of the base container. That is, `std::stack::emplace` is supposed to call `emplace_back` on the container, right? But the requirements on the `std::stack` container doesn't say that `emplace_back` is *required*. And you can't call functions on something that you didn't require to actually have those functions.


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]




Author: Akira Takahashi<faithandbrave@gmail.com>
Date: Thu, 26 Apr 2012 11:07:42 -0700 (PDT)
Raw View
>  You can only push into one place on the adapters, so "_back" is meaningless.

I think all container-adaptor requires "emplace_back" not "emplace".
Your approach is "emplace(c.end(), args...);" ?


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]




Author: Akira Takahashi <faithandbrave@gmail.com>
Date: Fri, 27 Apr 2012 11:12:21 -0700 (PDT)
Raw View
> But the requirements on the `std::stack` container doesn't say that `emplace_back` is *required*. And you can't call functions on something that you didn't require to actually have those functions.

I see.
I understand, container-adaptor's member function template is optional
support operation.
Right?


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]