I get some weird error messages which I don't really understand when I tried using mpl::pop_back today. The following example (more or less an exact copy of the one in the documentation): ------------------ start code ----------------- #include <boost/mpl/list.hpp> #include <boost/mpl/pop_back.hpp> using namespace boost::mpl; void f() { typedef list<int, double>::type ListType; typedef pop_back<ListType>::type PoppedList; } ------------------ end code ---------------------- fails on gcc 3.2 (Boost 1.30) with: pop_back.cpp: In instantiation of `boost::mpl::pop_back<f()::ListType>': pop_back.cpp:9: instantiated from here pop_back.cpp:9: base class ` boost::mpl::pop_back_traits<boost::mpl::aux::list_tag>::algorithm<f()::ListType> ' has incomplete type pop_back.cpp: In function `void f()': pop_back.cpp:9: ISO C++ forbids declaration of `type' with no type pop_back.cpp:9: typedef name may not be class-qualified pop_back.cpp:9: parse error before `;' token I'd appreciate if someone could clear this up for me. Regards, -- Tarjei
On Fri, 2003-05-16 at 10:09, Tarjei Knapstad wrote:
I get some weird error messages which I don't really understand when I tried using mpl::pop_back today. The following example (more or less an exact copy of the one in the documentation):
------------------ start code -----------------
#include <boost/mpl/list.hpp> #include <boost/mpl/pop_back.hpp>
using namespace boost::mpl;
void f() { typedef list<int, double>::type ListType; typedef pop_back<ListType>::type PoppedList; }
------------------ end code ----------------------
Just did a bit more testing. pop_front works without a hitch, and so does the "equivalent of" method for pop_back i.e.: typedef erase< ListType, prior< end<ListType>::type >::type >::type PoppedList; So, problem solved for now, but I'd still like to use pop_back and know why it failed... Sincerely, -- Tarjei
Tarjei Knapstad <tarjeik@chemcon.no> writes:
So, problem solved for now, but I'd still like to use pop_back and know why it failed...
list is like a singly-linked list at runtime: you can't do pop_back() because it's not an O(1) operation. HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com
On Fri, 2003-05-16 at 18:44, David Abrahams wrote:
Tarjei Knapstad <tarjeik@chemcon.no> writes:
So, problem solved for now, but I'd still like to use pop_back and know why it failed...
list is like a singly-linked list at runtime: you can't do pop_back() because it's not an O(1) operation.
I see, but does that go for the other mpl containers as well? pop_back fails on all of list, vector, list_c, vector_c and range_c. Can't say I see any good reason to supply an algorithm that's not working with any of the containers ;) Cheers, -- Tarjei
Tarjei Knapstad <tarjeik@chemcon.no> writes:
On Fri, 2003-05-16 at 18:44, David Abrahams wrote:
Tarjei Knapstad <tarjeik@chemcon.no> writes:
So, problem solved for now, but I'd still like to use pop_back and know why it failed...
list is like a singly-linked list at runtime: you can't do pop_back() because it's not an O(1) operation.
I see, but does that go for the other mpl containers as well? pop_back fails on all of list, vector, list_c, vector_c and range_c.
pop_back will work on vector[_c] soon. In fact, vector[_c] will probably be implemented as an alias to deque[_c] (coming soon) because there isn't enough savings in having a sequence that's only extensible at the front.
Can't say I see any good reason to supply an algorithm that's not working with any of the containers ;)
It's a temporary condition. Someone convinced Aleksey during the review period that vector ought to supply front- rather than back-extensibility, so that vector might be exchanged with list. We're not sure it was a good choice anymore ;-) HTH, -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Tarjei Knapstad