Hello, thanks for the reply. Actually I use list of lists to perform quick test. A last question: is there any king of NULL (as in Maple) object in GiNaC ? Thanks in advance, Jerome Sheplyakov Alexei wrote:
Hello,
On Sun, Feb 04, 2007 at 02:19:42AM +0800, Jerome BENOIT wrote:
I have just noticed that:
lst list; list = lst(lst(1,1),lst(2,4),lst(3,9));
gives a list of list as expected, whereas
lst list; list = lst(1,1),lst(2,4),lst(3,9);
Probably you want this:
list = ex(lst(1, 1)), lst(2, 4), lst(3,9);
gives the first list (namely lst(1,1))
Not exactly, your code gives lst(1, 1) as opposed to lst(lst(1, 1)).
is it a bug ?
No. This is how C++ function overload resolution works. There are several overloaded instances of operator= in the lst class:
lst& operator=(const lst&); container_init<ex, std::list> operator=(const ex&);
First one gives the best match (no type conversion form lst to ex is necessary), so your code basically reads as:
class foo { int i; public: foo(); foo(int i_); foo& operator=(const foo& o); };
void demo() { // lst list; foo a; // list = lst(1, 1), lst(2, 4), lst(3, 9); a = foo(1), foo(2), foo(3); }
foo::foo() { i = 0; } foo::foo(int i_) { i = i_; } foo& foo::operator=(const foo& o) { if (&o != this) i = o.i; return *this; }
or is it a wrong thing to do ?
There is nothing wrong about list of lists. But the code operating on such lists will be [probably] somewhat inefficient.
Best regards, Alexei
-- Jerome BENOIT jgmbenoit_at_mailsnare_dot_net