jimmy-park / singleton Goto Github PK
View Code? Open in Web Editor NEWC++11/17/20 thread-safe singleton pattern using CRTP
License: MIT License
C++11/17/20 thread-safe singleton pattern using CRTP
License: MIT License
I tried the following code, but it did not work:
class WebsocketManager : public SingletonDclp<WebsocketManager> {
// ...
void sendAction(types::WsAction action);
void sendAction(types::WsAction action, nlohmann::json&& data);
}
enum class WsAction {
CompletionAccept,
CompletionCache,
CompletionCancel,
CompletionGenerate,
DebugSync,
};
// Failed to compile
thread(&WebsocketManager::sendAction, WebsocketManager::GetInstance(), WsAction::CompletionCancel).detach();
The compile log is:
C:\xxxx\CompletionManager.cc(246): error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'std::thread'
C:\xxxx\CompletionManager.cc(246): note: 'std::thread::thread': function does not take 3 arguments
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include\thread(92): note: could be 'std::thread::thread(_Fn &&,_Args &&...)'
C:\xxxx\CompletionManager.cc(246): note: while trying to match the argument list '(overloaded-function, Derived *, types::WsAction)'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.