- Still no inheritiance for enums? - 4 Updates
- Netcdf how to use? - 6 Updates
- About this newsgroup and netiquette (some factual info) - 3 Updates
- Fwiw, a thread-safe c++ deque example... - 4 Updates
| Christopher Pisz <christopherpisz@gmail.com>: Mar 20 01:13PM -0700 Is there still no mechanism to handle enums in derived classes even in C++11, 14, and 17? For example class Base { enum Color {RED, BLUE, GREEN}; }; class Derived : public Base { enum Color {Yellow}; }; where we want derived to have Colors: RED, BLUE, GREEN, and YELLOW Is the way to do this still to use static const values instead? |
| legalize+jeeves@mail.xmission.com (Richard): Mar 20 08:35PM [Please do not mail me a copy of your followup] Christopher Pisz <christopherpisz@gmail.com> spake the secret code > enum Color {Yellow}; >}; >where we want derived to have Colors: RED, BLUE, GREEN, and YELLOW Inheritance in C++ serves two purposes IMO. There is "implementation inheritance" where you reuse code by glomming onto a bunch of stuff from our base class and there is "interface inheritance" where we use polymorphism to reuse code by expressing a class as a specialization of a base class while preserving the interface. It seems you want "implementation inheritance" for enums, but I don't see how that is particularly useful. When a function accepts an argument of type Base, what is it supposed to do when I hand it an argument of type Derived and the value isn't defined by Base? -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
| Christopher Pisz <christopherpisz@gmail.com>: Mar 20 01:47PM -0700 On Monday, March 20, 2017 at 3:35:23 PM UTC-5, Richard wrote: > When a function accepts an argument of type Base, what is it supposed > to do when I hand it an argument of type Derived and the value isn't > defined by Base? Well, if we are making up how things should work, my opinion is: Base::Foo(DERIVED::Color::YELLOW); should throws unless Foo is virtual and it resolves to derived. In fact, I should have to qualify Derived::YELLOW in the call, anyway. Base::Foo(BASE::Color::RED) should work fine as is. P.S do you see my email address every time I post to this newsgroup via crappy Google Groups? I see it when I hit reply. The thought of the incoming spam is scarey. |
| Jerry Stuckle <jstucklex@attglobal.net>: Mar 20 06:49PM -0400 On 3/20/2017 4:35 PM, Richard wrote: > When a function accepts an argument of type Base, what is it supposed > to do when I hand it an argument of type Derived and the value isn't > defined by Base? I can see where this could be useful in some circumstances. But if the function expects a value that's only defined in Derived it should not accept a type Base. Just like if the function called a method that's only defined in Derived. However, there's another argument that Derived should be a specialization of Base, and adding more colors violates that specialization. I think good cases can be made both for and against it. But if it were implemented, would it break any existing code? -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
| thebtc@hotmail.com: Mar 20 09:49AM -0700 Hi, I made a program that outputs a text file with two columns in it, of data. Instead of the text file output, I want to make my output binary, in netcdf format. There doesn't seem to be anything useful online. I found only the netcdf header file but it doesn't really help me. How do I turn a text file output into binary netcdf format? Thanks |
| "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 20 07:22PM +0100 > data. Instead of the text file output, I want to make my output > binary, in netcdf format. There doesn't seem to be anything useful > online. Google directed me to Wikipedia, which has an article about netcdf: <url: https://en.wikipedia.org/wiki/NetCDF#Access_libraries> > I found only the netcdf header file but it doesn't really > help me. > How do I turn a text file output into binary netcdf format? Just find those access libraries. ;-) Cheers!, - Alf |
| thebtc@hotmail.com: Mar 20 12:16PM -0700 I'm sorry Alf, I don't really understand what I'm supposed to do. I already have the libraries downloaded. I don't know what to do in my actual code. I need to replace the command that writes my output to a textfile...with something. Much like if I were to just do ordinary binary output I would replace .txt with .bin. But I assume with netcdf its more complicated. I looked around some more and found a few examples of where the results are being pasted to the netcdf binary output files as arrays. But supposing you don't know the length of your array? I would need things like NX and NY but I don't want to hardcode array length in case sometimes I want to make fewer result values and sometimes I want to make more result values. |
| Jorgen Grahn <grahn+nntp@snipabacken.se>: Mar 20 08:35PM > would need things like NX and NY but I don't want to hardcode array > length in case sometimes I want to make fewer result values and > sometimes I want to make more result values. I followed the Wikipedia article to http://www.unidata.ucar.edu/software/netcdf/ which seems to have tons of stuff: FAQs, tools, documentation, tutorials ... I don't know if this is a good idea. NetCDF seems fairly specialized, the phrase "array-oriented scientific data" gets used, and FORTRAN is mentioned. You may find you're supposed to have domain knowledge to use it. What's your background? Why do you want to create NetCDF files instead of the text files you create today? /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
| thebtc@hotmail.com: Mar 20 01:53PM -0700 @Jorgen, I was also following that site but its very confusing. My text file has 2 columns, but the rows are 52 million. I was trying to make my output into an array for netcdf but how can I do that without specifying the number of rows? What if I don't know how many rows there are? My background is very minimal in coding. I have very small amount of experience in matlab, and started learning c++ two months ago. The netcdf thing is for my homework. It wasn't taught in my lecture but its a part of the assignment. |
| Jorgen Grahn <grahn+nntp@snipabacken.se>: Mar 20 09:53PM > output into an array for netcdf but how can I do that without > specifying the number of rows? What if I don't know how many rows > there are? (You just said they were 52e6, but I guess that was just an example.) That's a good question. But I cannot answer it. Maybe someone else here can, but I suspect few have come in contact with this library, and digging into the API is likely to take some time even for experienced programmers. Perhaps that's just not part of the problem they try to solve. Perhaps your data should be like a huge, fixed-size Excel sheet (although that seems very limiting). I cannot tell, since I don't understand the domain. > experience in matlab, and started learning c++ two months ago. The > netcdf thing is for my homework. It wasn't taught in my lecture but > its a part of the assignment. Ok, I see. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
| Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 20 05:21PM > On Saturday, March 18, 2017 at 8:07:28 PM UTC-5, Alf P. Steinbach wrote: > Please don't swear here. Fuck. Off. You. Cunt. /Flibble |
| fir <profesor.fir@gmail.com>: Mar 20 12:25PM -0700 W dniu poniedziałek, 20 marca 2017 17:27:26 UTC+1 użytkownik Richard napisał: > unread messages when I started and over 50% were ditched by filtering. > I'd join a group of moderators for such a group as long as I didn't > have to do it alone. the view that commes to mind is 'primiticves forming a queue to moderate some brighter people able to point out their stupidity' (and this is ALWAYS the case, not not virtual this is always the EXISTING case - in any moderated forum that exist in the world, i belive (even when i was a moderator (as i am on some places) i got tendency to disrespect some other 'standpoints' than my own ) [some solutions could be wourk out however, but at this moment i (personally) dont care ) |
| "Chris M. Thomasson" <invalid@invalid.invalid>: Mar 20 01:51PM -0700 On 3/20/2017 5:10 AM, K. Frank wrote: > low point (due, I think, both to decreased signal -- maybe > because of other discussion forums -- and, for whatever > reason, to increased noise). We should plot the damn ebbs and flows in a vector field. ;^) |
| "Chris M. Thomasson" <invalid@invalid.invalid>: Mar 20 12:36PM -0700 On 3/19/2017 9:07 PM, Alf P. Steinbach wrote: >> (pastebin link without ads! ;^) >> <code> >> _________________________________________ [...] > It works with MinGW g++ 6.3.0 and Visual C++ 2017, but Windows Defender > detects the executable from Visual C++ as "Trojan: Win32/Fuery.B!cl"… > :) First of all thank you for giving it a go Alf. :^) However, your comment has me sort on edge here. What exactly is going on wrt the Windows Defender detection of a God damn virus! WTF!?!?!?!?! One of the compilers I am using is MSVC 2015 ver:14.0.25424.0 Update 3 under Win10 with most recent updates. I have produced many executable's with it, and Windows Defender never barfed up a warning. Are you sort of trying to say that MSVC 2017 injects viral code into its compiled exe's? Confused, and worried here Alf! ;^o |
| "Chris M. Thomasson" <invalid@invalid.invalid>: Mar 20 12:41PM -0700 On 3/19/2017 10:37 PM, Alf P. Steinbach wrote: > Dealing with your code prompted me to define $with and $with_var > statements, used below. > The code got shorter and IMHO a little more clear. [...] I see what you are doing here with $with and $with_var. I have to admit that it does seem like a sort of "different" language. IIRC, I used some macros back in the day wrt trying to automate for loops a bit. ;^) |
| "Chris M. Thomasson" <invalid@invalid.invalid>: Mar 20 12:44PM -0700 On 3/20/2017 2:32 AM, Bonita Montero wrote: > Your queue lacks a pop() with a timeout - like the ConcurrentLinkedQueue > in Java. Yes it does: Also, it lacks a try_pop()! FWIW, I basically quickly created this for Kushal Bhattacharya in the following thread: https://groups.google.com/d/topic/comp.lang.c++/yrgAm7Cf1QY/discussion as an example of how one can use a deque from multiple threads. |
| "Chris M. Thomasson" <invalid@invalid.invalid>: Mar 20 01:33PM -0700 On 3/20/2017 6:13 AM, Chris Vine wrote: > to splice, which only swaps some pointers). I say "generic" because if > you know T will be a fundamental type or an aggregate of fundamental > types, a deque would be better. I like how you basically covered both bases here. Using a list is fine. Separating object creation from any synchronization is very important. Object init should be private and complete, before the execution of any release-style membar. The release membar should be completed before any aspect of the the object makes itself visible to any potential reader threads. Fwiw, an intrusive queue can be a single pointer overhead in a user item, and we need head and tail pointers in the queue structure itself. <general layout> struct intruder_node // ;^) { node* m_next; }; struct queue { intruder_node* m_head; intruder_node* m_tail; // [...] }; struct USER_DATA { intruder_node m_intrusion_node; // [...] user data... }; [...] > You might well want rate-limiting on a queue of this kind to prevent > producers overrunning consumers. That introduces all sorts of other > trade-offs. I need more time to read your detailed response and properly respond here Chris. Thank you for posting. Will get back later on today. I am hoping we can talk a little shop about a restricted "lock-free" version of this lock-based construct. Restricted in the sense that I am going to post a simple lock-free version of this code that takes advantage of the single producer/multi consumer nature of the "test code itself". Since C++ is std now wrt atomic ops, membars, and a lot of that fancy dandy stuff. For some reason, I want to focus all my future posts to this group on C++ -> and what it can offer wrt multi-threading, good and bad... Should I link to comp.programming.threads? Its an infested rat nest now. ;^o Gotta go. |
| 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