- That's while I love C++ over C - 3 Updates
- A stack container that can pop multiple types - 5 Updates
- VLFloat, numbers view and mathematicl problems - 2 Updates
| Vir Campestris <vir.campestris@invalid.invalid>: Nov 05 09:59PM On 03/11/2021 20:28, Bart wrote: > having to instead write: > *(x == y ? &a : &b) = c; > It's not a big enough reason to switch. If you wrote that code in anything in my company I would downvote the review. Any of those versions. Andy |
| Lynn McGuire <lynnmcguire5@gmail.com>: Nov 05 05:25PM -0500 On 11/5/2021 4:59 PM, Vir Campestris wrote: > review. > Any of those versions. > Andy I would fire him. Lynn |
| red floyd <no.spam.here@its.invalid>: Nov 05 04:24PM -0700 On 11/5/2021 3:25 PM, Lynn McGuire wrote: > On 11/5/2021 4:59 PM, Vir Campestris wrote: [insanely ugly, unreadable, and unmaintainable code fragments redacted] >> review. >> Any of those versions. > I would fire him. I was going to say something along the lines of what either you or Vir said. I might not fire, but I would insist on further training. |
| "Öö Tiib" <ootiib@hot.ee>: Nov 04 04:40PM -0700 On Thursday, 4 November 2021 at 23:05:59 UTC+2, David Brown wrote: > On 04/11/2021 12:45, Frederick Gotham wrote: > > I'm writing a class called "MultiStack". It is a stack container in ... > How does it compare to: > std::stack<std::variant<int, float, std::string>> my_stack; His idea seems closer to std::stack<std::any> . |
| red floyd <no.spam.here@its.invalid>: Nov 04 08:27PM -0700 On 11/4/2021 4:40 PM, Öö Tiib wrote: >> How does it compare to: >> std::stack<std::variant<int, float, std::string>> my_stack; > His idea seems closer to std::stack<std::any> . Yeah, I was wondering about that as well. |
| David Brown <david.brown@hesbynett.no>: Nov 05 03:12PM +0100 On 05/11/2021 00:40, Öö Tiib wrote: >> How does it compare to: >> std::stack<std::variant<int, float, std::string>> my_stack; > His idea seems closer to std::stack<std::any> . Yes, that occurred to me too. But I think it is more common to have need of a type that could be one of a few different things, than to be writing code where you have no idea what types you are dealing with. But it will also be interesting to hear how Frederick sees his container compare to std::stack<std::any>. |
| Paavo Helde <myfirstname@osa.pri.ee>: Nov 05 07:18PM +0200 04.11.2021 13:45 Frederick Gotham kirjutas: > I'm writing a class called "MultiStack". It is a stack container in > which the elements can be of different types, for example you can push > an 'int' onto the stack, and then push a 'std::string' onto the stack. As others have commented, the abstraction is in the wrong place here. The stack should not concern itself about such details about its elements. Instead, one adds an abstraction layer like std::variant or std::any, and keeps the stack implementation unchanged. Otherwise you will soon find yourself reimplementing also vector, list, map, etc. A major point about C++ is that adding such abstraction layers does not cause any extra performance penalties. > float top(void) { /* implementation */ } > std::string top(void) { /* implementation */ } > }; Sure, but you can have template member functions: class MultiStack { public: template<typename T> T top(); template<typename T> bool top_is(); }; For using this I also added a type check function top_is(). A basic usage example: MultiStack stack = ...; if (stack.top_is<int>()) { int x = stack.top<int>(); } else if (stack.top_is<float>()) { float f = stack.top<float>(); } else if (stack.top_is<std::string>()) { std::string s = stack.top<std::string>(); } This usage would be about at least hundreds of times faster than abusing the exception throw/catch mechanism. Of course, this would still be abstraction in wrong place, and this all would be resolved better by using std::stack<std::any> or similar. |
| Bonita Montero <Bonita.Montero@gmail.com>: Nov 05 08:47PM +0100 Am 05.11.2021 um 00:40 schrieb Öö Tiib: >> How does it compare to: >> std::stack<std::variant<int, float, std::string>> my_stack; > His idea seems closer to std::stack<std::any> . Any allocates its items usually on the heap because there is no maximum storage requirement of the items, whereas variant is internally usually sth. like a union and a type tag, which might consume more memory, but is significantly faster. |
| Juha Nieminen <nospam@thanks.invalid>: Nov 05 06:08AM > Simply "logical", the one we use every day. > Several national institute level mathematicians know this, more had tried > not to use limit. I guess 50% professors knows this, but could not say. That answer makes literally no sense. And doesn't answer my question at all. > e^x= (1+1/???)^(???*x) ... Is'nt this form more correct? > Does the equation e^x=(1+x/???)^??? make sense as the 'definition' of > "raise e to the power of x"? That's not a counter-example. It's simply another way of defining e. |
| wij <wyniijj@gmail.com>: Nov 05 01:51AM -0700 On Friday, 5 November 2021 at 14:08:48 UTC+8, Juha Nieminen wrote: Firstly, I am not obliged and interested to make everyone understand. Actually, I don't care. The outcome is yours. > > Several national institute level mathematicians know this, more had tried > > not to use limit. I guess 50% professors knows this, but could not say. > That answer makes literally no sense. And doesn't answer my question at all. This is a most objective evidence I can provide. At least a couple of books (in Chinese) from national institute level mathematicians (I don't know how to translate that institute or name to English. But, I believe the contents is international) are published for quite some years. "Logic" can be very long, up to a couple of books to explain. Not as many students think and believe what they practically understand. So, what is exactly the question? > > Does the equation e^x=(1+x/???)^??? make sense as the 'definition' of > > "raise e to the power of x"? > That's not a counter-example. It's simply another way of defining e. Your logical sense is very weak. Several entrance questions I asked recently. Try solve/explain the following for everybody to show you are qualified. Let B≡ ∑(n=1,∞) 9/10^n Question: What is the digit three digits after the decimal point? Assume B=0.999... = 999.../10^n =(111...*3*3)/(5*2)^n =1 Explain (111...*3*3)=(5*2)^n Can you draw a line bisects a unit circle? If you can, let say A,B two chunks. Use your fossilized brain explain to everyone which parts all the points of the cutting line belong to (A or B or ...). |
| You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment