C++ (Qt)using MutexPtr = std::shared_ptr<std::mutex>;std::vector<MutexPtr> vec;vec.push_back(std::make_shared<std::mutex>());
C++ (Qt)#include <vector>#include <mutex>#include <memory>#include <iostream> int main(){ using namespace std; using UniqueMutex = unique_ptr< mutex >; UniqueMutex unique_mutex = make_unique< mutex >(); vector< UniqueMutex > my_vector; my_vector.push_back( std::move( unique_mutex ) ); my_vector.push_back( make_unique< mutex >() ); for ( size_t i = 0; i < my_vector.size(); ++i ) cout << "mutex[" << i << "].try_lock = " << boolalpha << my_vector[i]->try_lock() << endl; return 0;}
C++ (Qt)std::vector<std::mutex *> band;band.push_back(new std::mutex);...qDeleteAll(band);