- a linked list with element different types in C++ - 11 Updates
- sizeof in a template, applied in a template type - 3 Updates
- Onwards and upwards - 6 Updates
- truncating and rounding - 1 Update
Jerry Stuckle <jstucklex@attglobal.net>: Oct 03 10:10PM -0400 On 10/3/2017 5:23 PM, Chris Vine wrote: > for type erasure, and you are right that it is probably the most > reasonable approach if unions are not suitable and a variant type is > not available. I agree I don't like to use inheritance in cases like this where there is not a direct relationship in the model. But nothing's perfect, either. And even if you use unions you need to keep some type of indicator as to what member(s) is being used. Not a good answer, either. But the real question here is - why would one need a collection of such disparate types? I think that's where the problem lies, and also the real answer to the problem. I think this is a case of poor design. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
Ian Collins <ian-news@hotmail.com>: Oct 04 04:48PM +1300 On 10/ 4/17 03:10 PM, Jerry Stuckle wrote: > But the real question here is - why would one need a collection of such > disparate types? I think that's where the problem lies, and also the > real answer to the problem. I think this is a case of poor design. Representing JSON objects or something similar. -- Ian |
David Brown <david.brown@hesbynett.no>: Oct 04 08:49AM +0200 On 03/10/17 21:04, Chris Vine wrote: > With C++17 you can use std::variant. Otherwise you are probably going > to have to implement your own hack with unions or using pointers with > run-time type introspection. std::list<std::any> ? I have never used it myself. |
asetofsymbols@gmail.com: Oct 04 12:35AM -0700 In Axiom (cas system) a generic List of type generic has type "List Any" |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 04 12:59PM +0100 On Wed, 4 Oct 2017 00:35:04 -0700 (PDT) > In Axiom (cas system) a generic List of type generic has type "List > Any" Lists in C++ are generic. They are also homogeneous. Different languages make different choices. Dynamically typed languages tend to have heterogeneous containers (lisp, scheme, python); statically typed languages tend to have homogeneous containers, so you have to use a variant type to mix types in the container (C++, Ocaml, Haskell). So far as C++ is concerned this follows the principle that you don't pay for what you don't use. Homogeneous containers such as vectors can be implemented in contiguous memory; heterogeneous containers require addition indirection. |
Jerry Stuckle <jstucklex@attglobal.net>: Oct 04 09:45AM -0400 On 10/3/2017 11:48 PM, Ian Collins wrote: >> disparate types? I think that's where the problem lies, and also the >> real answer to the problem. I think this is a case of poor design. > Representing JSON objects or something similar. And why would that be necessary? JSON is a means of communicating objects, i.e. between systems or in files. Every time I've used JSON objects the first thing I've done in getting one is create a real object out of it - and do whatever is appropriate for that object. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
Cholo Lennon <chololennon@hotmail.com>: Oct 04 01:36PM -0300 On 04/10/17 03:49, David Brown wrote: >> to have to implement your own hack with unions or using pointers with >> run-time type introspection. > std::list<std::any> ? I have never used it myself. +1 IMHO, a list of any (std::any or boost::any) is the way to go in this particular case (unless the OP adds more information to consider using a list of variant) Regards -- Cholo Lennon Bs.As. ARG |
legalize+jeeves@mail.xmission.com (Richard): Oct 04 06:48PM [Please do not mail me a copy of your followup] Ian Collins <ian-news@hotmail.com> spake the secret code >> disparate types? I think that's where the problem lies, and also the >> real answer to the problem. I think this is a case of poor design. >Representing JSON objects or something similar. JSON isn't open-ended though, a value is either null, bool, number, string, array of value or dictionary of value (map of string -> value). So while they are "different types" it's easily handled with a suitable recursive variant. It's things like Java's "list of Object" that aren't easily done in C++ because Java/C# have that idea that every reference type derives from Object. -- "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> |
Ian Collins <ian-news@hotmail.com>: Oct 05 08:10AM +1300 On 10/ 5/17 07:48 AM, Richard wrote: > string, array of value or dictionary of value (map of string -> value). > So while they are "different types" it's easily handled with a > suitable recursive variant. It's those types that were in the the OP's original list! No matter how you represent it, it is still a collection of disparate types. -- Ian |
legalize+jeeves@mail.xmission.com (Richard): Oct 04 07:37PM [Please do not mail me a copy of your followup] Ian Collins <ian-news@hotmail.com> spake the secret code >> suitable recursive variant. >It's those types that were in the the OP's original list! No matter how >you represent it, it is still a collection of disparate types. Disparate types where you know all the types of what it could be in advance, so std::variant should be able to do the job. -- "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> |
Ian Collins <ian-news@hotmail.com>: Oct 05 10:01AM +1300 On 10/ 5/17 08:37 AM, Richard wrote: >> you represent it, it is still a collection of disparate types. > Disparate types where you know all the types of what it could be in > advance, so std::variant should be able to do the job. Quite. My own JSON library uses a variant like object with constructors from and conversions to the set of types used by JSON. The acceptable types are specified as std::tuple<int64_t,bool,double,Null,std::string,Object,Array>; My original answer still stands: JSON objects are a valid use case for a collection of disparate (all be it known) types. -- Ian |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Oct 04 04:36PM On Tue, 2017-10-03, Richard wrote: ... > reason to reject Herb's advice, because it is consistent with my own > programming experience. Once I started using smart pointers and standard > library containers to manage the ownership of resources, I stopped having ^^^^^^^^^^ > memory/resource leaks. I was waiting for that. IME, almost all objects live either on the stack, as a member, or in a container. I only rarely encounter situations where I have to operator new anything. So from my point of view, you're fighting over a rarely useful edge case. Unless the opposition believes the standard containers are just C++ dogma, too. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
legalize+jeeves@mail.xmission.com (Richard): Oct 04 06:45PM [Please do not mail me a copy of your followup] Jorgen Grahn <grahn+nntp@snipabacken.se> spake the secret code >> memory/resource leaks. >I was waiting for that. IME, almost all objects live either on the >stack, as a member, or in a container. This is exactly the point of Herb Sutter's presentation. >I only rarely encounter >situations where I have to operator new anything. So from my point of >view, you're fighting over a rarely useful edge case. Well, to be honest, we haven't seen the offending code in question, just an indirect discussion of "smart pointers are inefficient" without seeing how they are being used in the actual code. If smart pointers were generally inefficient when properly used, then I think we would have heard about it from more than just one person posting on usenet. It's not like there are only a few people who care about performance with C++. -- "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> |
"Öö Tiib" <ootiib@hot.ee>: Oct 04 12:31PM -0700 On Wednesday, 4 October 2017 21:45:53 UTC+3, Richard wrote: > I think we would have heard about it from more than just one person > posting on usenet. It's not like there are only a few people who care > about performance with C++. I thought we know it. The 'std::shared_ptr' is quite heavy since it has additional level of indirection, two thread safe reference counts (shared count and weak count) and deleter functor. Also when the object is not made with 'std::make_shared' then additional allocation (and deallocation) is made per object. That all can cripple performance if it is used in that 5% of code base that is executed 95% of run time. The 'std::unique_ptr' does the things what we would do anyway when needing a dynamic member. IMHO it affects performance only when we did not need dynamically allocated object there at all (so rough pointer would be as bad waste there). |
woodbrian77@gmail.com: Oct 04 08:59AM -0700 "Make the lives of all C++ developers on the planet better." That's what Daniel Moth says his goal is here: https://duckduckgo.com/?q=cppcon+videos+2017&atb=v72-1__&ia=videos&iax=1&iai=jsdn3kXFVdA (around the 2 minute mark) That's my goal with the C++ Middleware Writer and this thread going onwards and upwards -- adding new functionality and increasing the quality of the existing service. Brian Ebenezer Enterprises - "So then, while we have opportunity, let us do good to all people, and especially to those who are of the household of the faith." Galatians 6:10 http://webEbenezer.net |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 04 09:09AM -0700 > That's my goal with the C++ Middleware Writer and this > thread going onwards and upwards -- adding new functionality > and increasing the quality of the existing service. It seems to be the common theme this year at 2017 C++ DevCon. Steve Carroll and Daniel Moth explain new features of VS2017: New VS2017 features: http://www.youtube.com/watch?v=jsdn3kXFVdA It is a one-stop platform for Windows, Android, iPhone, and Linux development. It even directly integrates natively now with remote Linux computers running gcc and gdb, inside a host Windows machine running VS2017, and it work swith CMake and folder files natively. It's quite an impressive assembly actually. Add that to Bjarne Stroustrup speaking on wanting to improve C++'s image, and it adds up to a new turn for C++: Learning and Teaching Modern C++ https://www.youtube.com/watch?v=fX2W3nNjJIo Thank you, Rick C. Hodgin |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 04 06:09PM +0100 On Wed, 4 Oct 2017 09:09:43 -0700 (PDT) > up to a new turn for C++: > Learning and Teaching Modern C++ > https://www.youtube.com/watch?v=fX2W3nNjJIo I wonder what it is with the attraction of religious maniacs to online videos? I suspect it correlates with a desire to take instruction from supposed authority figures, as an alternative to thinking for themselves. Anyway, given stuff like this http://comp.lang.cpp.narkive.com/q0Yuq9Cf/comments-on-interview-of-scott-meyers it would be wrong for you to encourage Brian in his bizarre view of himself and the world. |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 04 01:22PM -0400 On 10/04/2017 01:09 PM, Chris Vine wrote: > online videos? I suspect it correlates with a desire to take > instruction from supposed authority figures, as an alternative to > thinking for themselves. I can't speak for religious maniacs, but for myself it's because I have dyslexia. Reading large quantities of text is exceedingly difficult for me. Even in reading these Usenet posts, I often mis- read things, write wrong words in my replies, leave in extra words when editing, etc. It's just hard to read words. It's much easier to listen to things and watch things. > http://comp.lang.cpp.narkive.com/q0Yuq9Cf/comments-on-interview-of-scott-meyers > it would be wrong for you to encourage Brian in his bizarre view of > himself and the world. My post wasn't for Brian. It was for the C++ group. -- Thank you, | Indianapolis, Indiana | God is love -- 1 John 4:7-9 Rick C. Hodgin | http://www.libsf.org/ | http://tinyurl.com/yaogvqhj ------------------------------------------------------------------------- Software: LSA/C, Debi, RDC, CAlive, ES/2, VJr, VFrP, Logician, C90/99 Hardware: Aroxda Desktop CPU -- 40-bit multi-core 80386 with many extensions Arxita Embedded CPU -- Low power, low pin count 80386 w/128 registers Arlina Compute FPGA -- Scalable compute cores, large GPIO pin count |
woodbrian77@gmail.com: Oct 04 10:40AM -0700 On Wednesday, October 4, 2017 at 12:09:57 PM UTC-5, Chris Vine wrote: > http://comp.lang.cpp.narkive.com/q0Yuq9Cf/comments-on-interview-of-scott-meyers > it would be wrong for you to encourage Brian in his bizarre view of > himself and the world. I've been pursuing a SaaS-based approach to software development for over 18 years -- I know... crazy. https://www.infoworld.com/article/3226386/saas/what-is-saas-the-modern-way-to-run-software.html Brian Ebenezer Enterprises - In G-d we trust. http://webEbenezer.net |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 04 07:06PM +0100 On Wed, 4 Oct 2017 10:40:03 -0700 (PDT) > I've been pursuing a SaaS-based approach to software > development for over 18 years -- I know... crazy. > https://www.infoworld.com/article/3226386/saas/what-is-saas-the-modern-way-to-run-software.html Try to keep up with the point in issue. It must surely be obvious that I was not commenting on your approach to software development. I was commenting on your liking for authority figures (in the particular context of online videos) read with your religious mania and your delusions about your "leadership" role for C++ http://comp.lang.cpp.narkive.com/q0Yuq9Cf/comments-on-interview-of-scott-meyers |
Manfred <noname@invalid.add>: Oct 04 01:22PM +0200 On 10/3/2017 8:50 PM, fir wrote: >> result in 8 using integer division. > i must say i dont quite understood what you say i say > (weak english) but probably dont matter You first referred to the relation with arithmetic operations in this thread. The difference is that you mentioned mixed float/integer operations, while I made a more basic point. |
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