Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples: Use modern C++ #81

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from

Conversation

murraycu
Copy link
Contributor

@murraycu 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.

@Belcourt
Copy link
Member

Belcourt commented Nov 5, 2016

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

@murraycu murraycu force-pushed the develop-murrayc-examples-modern-cpp branch 6 times, most recently from f4675cd to 5b82ca3 Compare May 12, 2017 20:44
@jeremy-murphy
Copy link
Contributor

I would love to see Boost.Graph get a modernization, I would actually vote for C++14 at this point.
Since Boost.Graph is not depended on by other libraries in Boost but it has been around for a long time, what would it take for a modernization to be accepted?

@jeking3
Copy link
Contributor

jeking3 commented Aug 22, 2018

@Belcourt why are (were) you disinclined? You rejected the PR but gave no reason for the submitter to allow for more improvement.

@anadon
Copy link
Contributor

anadon commented Aug 31, 2018

I'm helping out with the PR backlog. Looks like you have a large code change. I would like to merge this in around v1.69. The modernization is greatly appreciated, but making some fixes available and then having this change at a later version. There is a very long mailing thread where it looks like the latest when C++03 support will be thought about is 2020, but I'm comfortable telling people now that they should be using a newer system. This can affect other PRs, so lets hold off on merging everything now. This is to let you know and help me prioritize PR's.

@anadon
Copy link
Contributor

anadon commented Oct 15, 2018

Should we actually make this a branch for devel-cpp17?

@murraycu
Copy link
Contributor Author

murraycu commented Nov 1, 2018

I'm helping out with the PR backlog. Looks like you have a large code change. I would like to merge this in around v1.69. The modernization is greatly appreciated, but making some fixes available and then having this change at a later version.
[snip]

@anadon That's encouraging. Thanks. I don't quite understand what you'd like to do and when. Please feel free to request changes or updates from me that would help you to get this merged into the real code base.

@anadon
Copy link
Contributor

anadon commented Nov 1, 2018

@murraycu Can you please rebase this PR on upstream's devel branch?

@murraycu murraycu force-pushed the develop-murrayc-examples-modern-cpp branch from 6bd1dda to dfcd947 Compare November 1, 2018 22:22
@murraycu
Copy link
Contributor Author

murraycu commented Nov 1, 2018

OK. I've rebased on master and force pushed to the develop-murrayc-examples-modern-cpp branch in my fork.

I can't seem to remember how I built this at the time, inside modular-boost, so it might not actually build now.

@anadon
Copy link
Contributor

anadon commented Nov 2, 2018

@murraycu Looks like there are some CI failures. Could you please take a look at those?

@anadon
Copy link
Contributor

anadon commented Nov 5, 2018

2 failures are in the code changes, 2 are from external parameter parsing. Shouldn't be that bad to fix.

@murraycu
Copy link
Contributor Author

murraycu commented Nov 29, 2018

At the moment I can't even build the regular develop branch:

[murrayc@murrayc-ThinkPad-X220 boost (develop *)]$ ./b2 
Performing configuration checks

    - default address-model    : 64-bit
    - default architecture     : x86

Building the Boost C++ Libraries.


    - symlinks supported       : yes
error: at /home/murrayc/checkout/github/boost/tools/build/src/kernel/modules.jam:107
error: Cannot create link boost/pending/property_serialize.hpp to libs/graph/include/boost/pending/property_serialize.hpp.
error: Link previously defined to another file, libs/graph_parallel/include/boost/pending/property_serialize.hpp.

@murraycu murraycu force-pushed the develop-murrayc-examples-modern-cpp branch from dfcd947 to a22ddcc Compare November 29, 2018 13:41
@murraycu murraycu force-pushed the develop-murrayc-examples-modern-cpp branch from a22ddcc to 99b1a6e Compare November 29, 2018 13:42
@murraycu
Copy link
Contributor Author

The remaining build errors in CI are in tests/isomorphism.cpp, and seem to be unrelated to my changes.

@anadon
Copy link
Contributor

anadon commented Dec 4, 2018 via email

// Inspired by:
// https://cplusplusmusings.wordpress.com/2013/04/14/range-based-for-loops-and-pairs-of-iterators/
template <typename T_Pair>
class range_pair
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this class is a good idea, sorry. For starters, it's not how the library is actually used. Secondly, there must be something equivalent in Boost.Range already, presumably iterator_range.

Thirdly, and more importantly, the best thing to do would be to add begin(boost::pair)/end(boost::pair) functions to graph_traits.hpp or some other common file so that boost::pair is automatically treated as a range. If that causes problems, an alternative would be to return iterator_range instead of boost::pair.

Now, that should be done separately from this PR so that this remains entirely about updating examples.

Finally -- the reason I am suddenly interested in this, is we have now effectively dropped support for pre-C++11, so we can actually consider merging!

@murraycu
Copy link
Contributor Author

we have now effectively dropped support for pre-C++11, so we can actually consider merging!

OK. Rebasing this is a bit awkwad after the reformatting in 2019, so I'll make a series of smaller pull requests instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants