boostorg / mpl

Boost.org mpl module
http://boost.org/libs/mpl
Boost Software License 1.0
51 stars 78 forks source link

Add constexpr to conversion operator for integral constants #1

Closed pfultz2 closed 10 years ago

pfultz2 commented 10 years ago

I added constexpr to conversion operator for integral constants, this will make type traits more closely match the type traits in C++14.

ahmedcharles commented 10 years ago

I would be willing to merge this if it had a test case, like:

constexpr bool b = boost::is_integral(); static_assert(b, "some text");

pfultz2 commented 10 years ago

Alright, I added test cases.

ahmedcharles commented 10 years ago

I pushed this after rebasing it, so I'll close. Thanks for the tests.

gnzlbg commented 10 years ago

Has this been merged to master?

I just sent a fix that should have been already fixed in this patch (see #7).

gnzlbg commented 10 years ago

@robertramey replied on Mar 27

Why is this change necessary? Integral constants don't need to be constant expressions - const (which they already are) is enough. [...]

Integral constants are intended to be used for compile-time computations. Unless they provide a constexpr interface they can't be used within constexpr functions in C++11/14.

I don't see what this change would fix or improve - and it's very hard to anticipate possible surprises.

This allows you to, e.g., fold over a boost::mpl::range_c range inside a constexpr function like this:

fold(boost::mpl::range_c<int, 0, 10>{}, 0, my_constexpr_computation_object{});

Unfortunately, one cannot use lambdas within constexpr functions yet, so it feels a bit C++03.

pfultz2 commented 10 years ago

@gnzlbg It has been merged into develop, but not into master yet.

Also, I believe pull requests should be off of develop, not master branch. (see here) I'm not sure why, it shouldn't matter, but it seems like boost is still new to the git branching model.

gnzlbg commented 10 years ago

@pfultz2 thanks I didn't saw it.

When I update my local git I only update master branches..

If something is unfinished it should be in develop, but this pull-request seems pretty finished, so I don't see the point into merging it on develop and not on master.. I could have benefitted from it a lot today morning.

mclow commented 10 years ago

The general idea is to fix things on develop, let the tests cycle, then merge to master.

gnzlbg commented 10 years ago

@mclow marshall do you know if there is a way to check out the develop branches for every library in modular-boost instead of the master branches?

mclow commented 10 years ago

I believe that git submodule foreach git checkout develop should do it.

gnzlbg commented 10 years ago

@mclow thanks marshall, works like charm.