自从我更新为1.58和VS2013以来,我一直在软件中看到崩溃.只有在编译器优化开启时,我们才会看到崩溃.使用boost 1.55,没有崩溃.我设法隔离了我所看到的问题boost::any_range以及我们如何使用它.
请参阅下面的示例代码:
#include <boost/range/any_range.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <vector>
#include <memory>
#include <cstdio>
class DummyElement
{
public:
float f_;
};
using ElementRange = boost::any_range < DummyElement*, boost::bidirectional_traversal_tag >;
using DummyElementUPtr = std::unique_ptr < DummyElement > ;
class BoostAnyTest
{
public:
BoostAnyTest()
{
for (int i = 0; i < 10; ++i)
{
auto element = DummyElementUPtr(new DummyElement());
_tprintf(_T("BoostAnyTest::ctor() 0x%p\n"), element.get());
c_.emplace_back(std::tuple<Int, DummyElementUPtr>(i, std::move(element)));
}
}
public:
ElementRange GetAll();
private:
using _ContainerType = std::vector < std::tuple<Int, std::unique_ptr<DummyElement>> > ; …Run Code Online (Sandbox Code Playgroud)