Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #12548
| From | john <gh14tq5@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: would you consider this function const? |
| Date | 2011-12-15 12:42 -0500 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <jcdbi9$ren$1@speranza.aioe.org> (permalink) |
| References | (3 earlier) <jccs9c$ovg$1@dont-email.me> <jcctkm$i7j$1@speranza.aioe.org> <jccv7e$8if$1@dont-email.me> <jcd09b$umt$1@speranza.aioe.org> <jcd2dn$r0e$1@dont-email.me> |
>>> What happens if you change the type of the argument to >>> >>> std::set<const Volume*> >>> >>> ? If it's a set of constant volumes, that's what the type should >>> express. If you find it difficult to type, use a typedef *or* introduce >>> some kind of 'Volume proxy' and keep that instead of the pointer to >>> Volume. >> >> I will have to look at whether I can do that or not. My guess is that, >> for the most part, I will need non-const Volume*'s. It's a huge code >> base, so a change like that could ripple to a lot of places. > > Well, depending on the domain and the purpose for which the pointers are > collected, it might be OK to const_cast them like that. After all, it is > unlikely that any object of your Volume class is ever created in a > constant memory, so the 'const' here is just a pretense. Keep in mind, > however, that const_cast can be abused. And don't abuse it. If you can > rework your design in such a way that wouldn't call for the use of > 'const_cast' to cast *away* any constness, it could lead to a more > robust system, methinks. > > I wonder (not that you need to explain, just wonder along with me), how > is Volume and, say, Edge derive from the same class. What is common > about them (aside from 'GetVolumes')? Also, can you have nested Volumes? > You know, an egg inside a duck inside a hare hidden in a trunk... Seems > like if your answer is 'no', then a Volume cannot derive from Topology > since you essentially make Topology aware of a type that will be derived > from it, which is usually a no-no... Well, a lot of functionality is common to all element types. For example, every Topology (be it a volume, edge, face, vertex) has functions that can return its unique id, its center point, its bounding vertices, its 'type', its dimension. Every Topology stores another class object that can compute geometry on itself, for example position vector, unitary vectors, etc. So there is a lot of common functionality that is declared as pure virtual or virtual at the base class and some common data members. To answer you other question, nested volumes are not allowed. I do not understand you comment that Volume cannot derive from Topology. I do not see a problem with doing it.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
would you consider this function const? john <gh14tq5@yahoo.com> - 2011-12-14 10:17 -0500
Re: would you consider this function const? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-14 11:19 -0500
Re: would you consider this function const? john <gh14tq5@yahoo.com> - 2011-12-15 08:10 -0500
Re: would you consider this function const? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-15 08:21 -0500
Re: would you consider this function const? john <gh14tq5@yahoo.com> - 2011-12-15 08:44 -0500
Re: would you consider this function const? Leigh Johnston <leigh@i42.co.uk> - 2011-12-15 14:07 +0000
Re: would you consider this function const? Leigh Johnston <leigh@i42.co.uk> - 2011-12-15 14:14 +0000
Re: would you consider this function const? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-15 09:11 -0500
Re: would you consider this function const? john <gh14tq5@yahoo.com> - 2011-12-15 09:30 -0500
Re: would you consider this function const? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-15 10:06 -0500
Re: would you consider this function const? john <gh14tq5@yahoo.com> - 2011-12-15 12:42 -0500
Re: would you consider this function const? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-15 13:32 -0500
Re: would you consider this function const? yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-12-19 18:16 +0000
Re: would you consider this function const? Tobias Müller <troplin@bluewin.ch> - 2011-12-19 19:05 +0000
Re: would you consider this function const? Joshua Maurice <joshuamaurice@gmail.com> - 2011-12-19 14:36 -0800
Re: would you consider this function const? Tobias Müller <troplin@bluewin.ch> - 2011-12-20 06:28 +0000
Re: would you consider this function const? Joshua Maurice <joshuamaurice@gmail.com> - 2011-12-19 23:48 -0800
csiph-web