Details
Description
Pretty-printing fails ind QtCreator if std::map, boost::shared_ptr and boost::enable_shared_from_this are used in conjunction.
Compile the code below in debug mode and set a break point at asm("nop"), run the program and see that all entries (*.second) of map are not accessible:
testme.cpp:
#include <map> #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> class T : public boost::enable_shared_from_this<T> { public: T() : y(987) {} int x = 123; int y; }; using TPtr = boost::shared_ptr<T>; using TMap = std::map<std::string, TPtr>; int main(int, char**) { TMap map; for (int i = 0; i < 300; ++i) { boost::shared_ptr<T> t(new T); map[std::string("item_") + std::to_string(i)] = t; } asm("nop"); }
CMakeLists.txt:
project(test_project)
cmake_minimum_required(VERSION 3.14)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions("-O0")
find_package(Boost)
add_executable(testme
testme
)
target_include_directories(testme
PRIVATE ${Boost_INCLUDE_DIRS}
)
target_link_libraries(testme
${Boost_LIBRARIES}
)