Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
UB mutex lock
#include <memory> #include <mutex> #include <vector> #include <iostream> #include <thread> struct Test{ std::mutex mutex; std::vector<int> v = { 1,2,3,4,5}; auto fun(int n){ mutex.lock(); return std::shared_ptr<int>(v.data() + n, [this](...){mutex.unlock();}); } }; int main(){ Test tt; auto a = tt.fun(1); std::cout << *a << std::endl; auto b = tt.fun(2); std::cout << *b << std::endl; return 0; }
run
|
edit
|
history
|
help
0
Even Odd using Functions
Polimorfizm :)
BubDoubArray2
Smart Pointers
Wuninitialized
inheritance test
Спарсить полученный в виде строки JSON в объект (Boost)
Изволов#8
Bin Tree playground
Boost adapters foreach