Timeline for Binary search as a generic algorithm
Current License: CC BY-SA 3.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 20, 2014 at 13:07 | comment | added | ruds | Interesting point about the proxy classes. | |
Aug 20, 2014 at 12:49 | comment | added | Nobody moving away from SE |
@ruds: decltype(*begin) could not do what is intended (see stackoverflow.com/a/15560972/760746). If you write a custom iterator you have to specialize std::iterator_traits anyway or your iterator won't be compatible with the stdlib's algorithms.
|
|
Aug 20, 2014 at 12:45 | comment | added | ruds |
Nice review! I think you can do even better than the using statement: decltype(*begin) . I think it's easier to read and it works even for custom iterators that haven't defined a specialization of std::iterator_traits .
|
|
Aug 20, 2014 at 12:43 | history | edited | Nobody moving away from SE | CC BY-SA 3.0 |
Changed wording
|
Aug 20, 2014 at 12:34 | comment | added | Nobody moving away from SE |
As I explained the using declaration is more powerful than a typedef (it can be templated and it works more like a function when used for template meta functions). I would recommend that you update your compiler to a more C++11 compliant one if you really want to learn and use C++11.
|
|
Aug 20, 2014 at 12:32 | comment | added | Nils | Yes I know VS2012 lacks of some support, but why using using instead of typedef? I do not se how this is better. | |
Aug 20, 2014 at 12:31 | comment | added | Nobody moving away from SE | @Nils: I have extended the list. There is no such thing as "no real code". Either it is code or it isn't. Having exceptions for "non real" code opens the door for letting this behavior creep into your daily practice ("nah this is just a quick hack, no real code") until it gets into production and trips you up there. | |
Aug 20, 2014 at 12:29 | history | edited | Nobody moving away from SE | CC BY-SA 3.0 |
added 1814 characters in body
|
Aug 20, 2014 at 12:28 | comment | added | Nils | Agreed with everything except the last point: This is just a simple example no real code. | |
Aug 20, 2014 at 12:11 | history | answered | Nobody moving away from SE | CC BY-SA 3.0 |