Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #11625 > unrolled thread
| Started by | Jayden Shui <jayden.shui@gmail.com> |
|---|---|
| First post | 2011-11-19 14:37 -0800 |
| Last post | 2011-11-22 01:09 -0800 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.c++
Any way to bind an object with an integer Jayden Shui <jayden.shui@gmail.com> - 2011-11-19 14:37 -0800
Re: Any way to bind an object with an integer Victor Bazarov <v.bazarov@comcast.invalid> - 2011-11-21 12:04 -0500
Re: Any way to bind an object with an integer XeCycle <xecycle@gmail.com> - 2011-11-22 12:04 +0800
Re: Any way to bind an object with an integer SG <s.gesemann@gmail.com> - 2011-11-22 01:09 -0800
| From | Jayden Shui <jayden.shui@gmail.com> |
|---|---|
| Date | 2011-11-19 14:37 -0800 |
| Subject | Any way to bind an object with an integer |
| Message-ID | <54106ae2-c52c-4e83-aabf-5c34ba415019@m19g2000yqh.googlegroups.com> |
Hello All, I think usually we require to bind an object with a data, such as an integer. From this object, we can easily and quickly get its bound integer. std::map requires the object to be compared. Any other way to do it? Thank you very much for your kind help! Best regards, Jayden
[toc] | [next] | [standalone]
| From | Victor Bazarov <v.bazarov@comcast.invalid> |
|---|---|
| Date | 2011-11-21 12:04 -0500 |
| Message-ID | <jae0aa$7hc$1@dont-email.me> |
| In reply to | #11625 |
On 11/19/2011 5:37 PM, Jayden Shui wrote: > I think usually we require to bind an object with a data, such as an > integer. From this object, we can easily and quickly get its bound > integer. std::map requires the object to be compared. Any other way to > do it? A derived class that adds an integer as a data member? You disclose too little of the requirements to recommend anything specific... V -- I do not respond to top-posted replies, please don't ask
[toc] | [prev] | [next] | [standalone]
| From | XeCycle <xecycle@gmail.com> |
|---|---|
| Date | 2011-11-22 12:04 +0800 |
| Message-ID | <87aa7oby53.fsf@gmail.com> |
| In reply to | #11625 |
Jayden Shui <jayden.shui@gmail.com> writes: > Hello All, > > I think usually we require to bind an object with a data, such as an > integer. From this object, we can easily and quickly get its bound > integer. std::map requires the object to be compared. Any other way to > do it? Pointer to objects are always comparable. If you don't mind equal objects bound to different integers, this should work for you. -- Carl Lei (XeCycle) Department of Physics, Shanghai Jiao Tong University OpenPGP public key: 7795E591 Fingerprint: 1FB6 7F1F D45D F681 C845 27F7 8D71 8EC4 7795 E591
[toc] | [prev] | [next] | [standalone]
| From | SG <s.gesemann@gmail.com> |
|---|---|
| Date | 2011-11-22 01:09 -0800 |
| Message-ID | <5b76571e-4cb1-48e7-b3a4-ec76c4d4d748@14g2000yqo.googlegroups.com> |
| In reply to | #11625 |
On 19 Nov., 23:37, Jayden Shui wrote: > > I think usually we require to bind an object with a data, such as an > integer. From this object, we can easily and quickly get its bound > integer. What do you mean by "bind" and "bound" in this context? > std::map requires the object to be compared. It requires the key type to be comparable somehow, yes. Either using the default predicate -- std::less<key_type> -- or with a custom predicate. As long as this binary predicate represents a strict weak ordering you'll be fine. > Any other way to do it? What is "it" ? Cheers! SG
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web