Commit 062f62a6 authored by Pádraig Brady's avatar Pádraig Brady Committed by Facebook Github Bot

folly/FixedString: leverage c++14 to support GCC 8

Summary:
gcc8 fails compilation with:
    error: taking address of temporary array
      return {+A{Cs..., Char(0)}, sizeof...(Cs)};
So leverage c++14 to base manipulations on a local array.

Reviewed By: yfeldblum, ericniebler, Orvid

Differential Revision: D9310662

fbshipit-source-id: 0ba375ac0a4cca913e437290bc277c0c6bb8fdc8
parent 35312df9
......@@ -3037,9 +3037,14 @@ constexpr const std::size_t& npos = detail::fixedstring::FixedStringBase::npos;
*/
template <class Char, Char... Cs>
constexpr BasicFixedString<Char, sizeof...(Cs)> operator"" _fs() noexcept {
#if __cplusplus >= 201402L
const Char a[] = {Cs..., Char(0)};
return {+a, sizeof...(Cs)};
#else
using A = const Char[sizeof...(Cs) + 1u];
// The `+` in `+A{etc}` forces the array type to decay to a pointer
return {+A{Cs..., Char(0)}, sizeof...(Cs)};
#endif
}
#pragma GCC diagnostic pop
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment