[GiNaC-devel] Mysterious push_front()
Jan Rheinländer
jrheinlaender at gmx.de
Fri Mar 4 17:54:44 CET 2022
Hi Richard,
but when I try to compile this program
#include <ginac/ginac.h>
using namespace GiNaC;
int main(int argc, char** argv)
{
exprseq seq{1,2,3};
seq.prepend(0);
return 0;
}
I get error:
In file included from /usr/include/ginac/lst.h:26,
from /usr/include/ginac/normal.h:29,
from /usr/include/ginac/ginac.h:31,
from test.cpp:24:
/usr/include/ginac/container.h: In instantiation of
‘GiNaC::container<C>& GiNaC::container< <template-parameter-1-1>
>::prepend(const GiNaC::ex&) [with C = std::vector]’:
test.cpp:30:15: required from here
/usr/include/ginac/container.h:551:12: error:
‘GiNaC::container_storage<std::vector>::STLT’ {aka ‘class
std::vector<GiNaC::ex>’} has no member named ‘push_front’
551 | this->seq.push_front(b);
| ~~~~~~~~~~^~~~~~~~~~
Why not change the code of prepend() in container.h to use insert()
instead of push_front()? Then I think it will work for all STL containers.
Jan
Am 02.03.22 um 23:44 schrieb Richard B. Kreckel:
> Hi Jan,
>
> On 02.03.22 18:55, Jan Rheinländer wrote:
>> sometimes GiNaCs templates are a mystery to me. In container.h there is
>> the code
>>
>> template<template<classT, class= std::allocator<T>> classC>
>> container<C> & container<C>::prepend(constex & b)
>> {
>> ensure_if_modifiable();
>> this->seq.push_front(b);
>> return*this;
>> }
>>
>> but AFAIK the STL does not have any push_front() method. And GiNaC does
>> not seem to define it either. How can this work?
>>
>> Same applies for pop_front() and sort()
>>
>> voidsort_(std::input_iterator_tag)
>> {
>> this->seq.sort(ex_is_less());
>> }
> Well, not every STL container provides every possible method.
> But the standard does require the ones you mention for the instantiated
> template classes. Check again!
>
> -richy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ginac.de/pipermail/ginac-devel/attachments/20220304/0bbad378/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://www.ginac.de/pipermail/ginac-devel/attachments/20220304/0bbad378/attachment.sig>
More information about the GiNaC-devel
mailing list