close
Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
Filter by
Sorted by
Tagged with
Filter by Employee ID
Score of 10
3 answers
5480 views

Let's say I am writing a class that passes a std::variant<A,B> to another class. While I design the class, I decide I'd like to keep a copy of the last thing that was passed to that other class. ...
Score of 1
0 answers
685 views

In the example below, how would I construct the node object for data = monostate ?? class node : public header { using value_type = variant<monostate, string, deque<string>>; ...
Score of 0
2 answers
290 views

Example: std::function<std::monostate()> convert(std::function<void()> func){ return *reinterpret_cast<std::function<std::monostate()> * >(&func); } Are std::function&...
Score of 1
1 answer
604 views

i have two classes BaseNode and BaseEdge which i can use connect method to connect tow nodes via an edge in these classes. code here is my BaseNode: class BaseNode: def __init__(self,edges=[],value=...
Score of 3
3 answers
468 views

I am evaluating a way of use the Singleton Pattern called Monostate in JavaScript. I have some code like the following: class Boss { get name() { return Boss._name } set name(value) { Boss....
Score of 13
1 answer
6931 views

I want to have a variant which may contain type Foo, (disjoint) type Bar, or nothing. Well, naturally, I was thinking of using std::variant<Foo, Bar, void> - but this doesn't seem to work. That ...
Score of 0
2 answers
161 views

I'm trying to implement monostate class which manages some std::thread. Thread is running until flag become equals to false. After flag changes to false - thread stops. But looks like I have to call ...
Score of 2
2 answers
944 views

I'm designing some classes to access and control the peripherals of a microcontroller (adc, port, usart etc). The device have just a few (in some cases just one) instances of each peripheral, so I ...
user avatar
Score of 0
1 answer
33 views

I have an instance of Main that I should be able to access anywhere. If I want to access a variable on level I should be able do: _root.level.my_value However .level is showing up null when I call ...
Score of 2
1 answer
163 views

I'm having issues with the monostate pattern in Firefox 35, using Polymer 0.5.2. My element looks like this: <polymer-element name="tracer-globals"> <script> (function() { ...
Score of 7
1 answer
397 views

Suppose a class needs to load an external library which takes some time to load and thus should be loaded only once. Two natural solutions to this would be to use the singleton pattern or the ...
Score of 5
2 answers
1376 views

I have a basic Monostate with Python 2.6. class Borg(object): __shared_state = {} def __new__(cls, *args, **kwargs): self = object.__new__(cls, *args, **kwargs) self.__dict__ =...
Score of 1
1 answer
303 views

I have a Person Class and based on some help I received in this post. MonoState, Singleton, or Derived Forms: Best approach for CRUD app? I have a CurrentPerson class around(??) it and I access the ...
Score of 17
5 answers
7936 views

Isn’t a class with only static members a kind of singleton design pattern? Is there any disadvantage of having such a class? A detailed explanation would help.