Boost logo

Boost Users :

Subject: [Boost-users] Type Erasure: Infinite loop when accessing an element of a container of any<>, where the element is another container
From: Alexandre Pretyman (alexandre.pretyman_at_[hidden])
Date: 2013-10-08 14:51:02

Hi Boost list!

After watching Sean Parent's lightning-talk "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?


Alexandre Pretyman

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at