C++ (Qt)m_name = QSharedPointer<std::string> (new std::string("abc"));// а если "abc" уже есть?
C++ (Qt)CSharedSet<std::string> theSet;...m_name = theSet.Put(new std::string("abc"));
C++ (Qt)QSharedPointer<const std::string> m_name;
C++ (Qt)std::string * temp = new std::string(*m_name.data());*temp += " edit";m_name = theSet.Put(temp);
template <class Key, class Val, class Args...>std::shared_pointer<Val> getOrCreate(Key key, Args... args){ const auto it = mHash.find(key); if (it != mHash.end()) { const auto result = it->second.lock(); if (result) // нашли в кэше return result; } auto data = std::make_shared<Val>(std::forward(args)); mHash.insert(key, data); return data;}
for (int i = 0; i < 10; ++i) { std::string hello("hello"); }