Boost logo

Boost Users :

Subject: Re: [Boost-users] Type Erasure: Infinite loop when accessing an element of a container of any<>, where the element is another container
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-10-09 10:24:12


AMDG

On 10/08/2013 11:51 AM, Alexandre Pretyman wrote:
> Hi Boost list!
>
> After watching Sean Parent's lightning-talk "Inheritance is the base class
> of Evil" (
> http://channel9.msdn.com/Events/GoingNative/2013/Inheritance-Is-The-Base-Class-of-Evil),
> I decided to try a similar example with Boost's Type Erasure library,
> but did not succeed.
>
> I created a vector of any<.., ostreamable<>,...>, implemented the stream
> operator to print this vector type and I can print its' elements. A problem
> arises, however, when I insert this vector as an element of a second
> vector. When I print the second vector I encounter an infinite loop ending
> with a stack overflow when accessing the vector type when it is an element
> of second vector.
>
> The example which demonstrates this behaviour follows attached on this
> message. I am using Boost 1.55 from the trunk with clang 3.2 from Apple,
> compiling it with the flags "-std=c++11 -stdlib=libc++" and linking with
> "-stdlib=libc++". I would be grateful if anyone could try this on your
> local boost version and compiler.
>
> Can anyone shed some light on why this happens?
>

Your overload of operator<<:
using dobject_container = std::vector<deobject> ;
std::ostream & operator<<(std::ostream &os, dobject_container const & c);
cannot be found by argument dependent lookup. I don't know
what is being found instead, but that's the source of the problem.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net