constexpr Initializer list of string views

Viewed 286

I'm trying to make a constexpr initializer list of some string constants. I think this should be possible in C++17, but I can't get it to compile in MSVC.

#include <string_view>

using namespace std::literals::string_view_literals;

const constexpr std::initializer_list<std::string_view> some_strings{
    "asdf"sv
};

This gives the following error message:

error C2131: expression did not evaluate to a constant
note: failure was caused by non-constant arguments or reference to a non-constant symbol
note: see usage of '$S1'

I can't figure out which part would be non-constexpr:

  • std::string_view's operator"" is constexpr
  • std::initializer_list's constructor is constexpr as well

Any ideas? Is this possibly just a bug in visual studio? What is '$S1' referenced in the error message?

EDIT: Visual Studio 15.8.9

1 Answers
Related