Examples: Use modern C++ #81

wants to merge 28 commits into


None yet
2 participants

murraycu commented Nov 2, 2016

These commits change the code in examples/ to use modern C++, specifically C++11. For instance, to use auto to avoid the verbosity of the traits and typedefs.

Even if we don't want to require C++11 for the API itself, maybe it's OK to use it for the example code, to more clearly demonstrate the API. I would understand if you don't want this.

The last commit ("Add and use make_range_pair") is even more debatable: It uses a range_pair utility class to allow use of range-based for loops, but maybe this should actually be a change to the API, or maybe it's something that will be better one day with C++ ranges in C++20.


This comment has been minimized.

Show comment
Hide comment

Belcourt Nov 5, 2016


I'm currently disinclined to apply this PR though I do appreciate your efforts Murray.


Belcourt commented Nov 5, 2016

I'm currently disinclined to apply this PR though I do appreciate your efforts Murray.

murraycu added some commits May 3, 2016

examples: C++11: Use emplace_*().
Use emplace_back() and emplace_front() instead of push_back() and
examples: C++11: Use std::begin() and std::end().
Instead of array + length.
And use initializer lists.
examples: C++11: Remove spaces from around < and > for templates.
This is not necessary in C++11 and it is not a common style.
examples: Remove "using std".
Because it makes the code less clear.
examples: C++11: Add and use make_range_pair().
This could be improved with "structured bindings" if that gets into C++17,
but that alone would still not allow a range-based for loop.

astar_search: Remove unused variable.
To avoid a compiler warning.
examples: Comment-out unused types and variables.
These are meant as documentation, not code, so just leave them
commented out. This lets the build succeed with -Werror.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment