Type Erasure: Infinite loop when accessing an element of a container of any<>, where the element is another container

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-Cla...), 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? Regards, -- Alexandre Pretyman

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-Cla...), 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
participants (2)
-
Alexandre Pretyman
-
Steven Watanabe