Opened 8 years ago

#9971 new Patches

Use constexpr for boost::mpl::c_str::value when possible.

Reported by: ytj000@… Owned by: Aleksey Gurtovoy
Milestone: To Be Determined Component: mpl
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

Right now boost::mpl::c_str::value is a static const member variable. I think it is a decent idea to add the constexpr keyword here.

I have a patch for this issue. Here is an example why it is useful:

#include<boost/mpl/string.hpp>
int main() {
    using H = boost::mpl::string<'h'>;
    static_assert(boost::mpl::c_str<H>::value[0] == 'h', "");
}

Without my patch, compiler will complain we could not use c_str::value in constant expression. With my patch, compiler will accept this code.

Tested in clang++ 3.4, CentOS 6.3, but I think GCC should works as well.

Attachments (2)

patch.diff (1.7 KB ) - added by ytj000@… 8 years ago.
Patch
main.cpp (144 bytes ) - added by ytj000@… 8 years ago.
example.cpp

Download all attachments as: .zip

Change History (2)

by ytj000@…, 8 years ago

Attachment: patch.diff added

Patch

by ytj000@…, 8 years ago

Attachment: main.cpp added

example.cpp

Note: See TracTickets for help on using tickets.