http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59867

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Comment on attachment 31880
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31880
Template string literal works somehow strange in this example

>#include <iostream>
>using namespace std;
>
>// constant
>template <class T, T x>
>struct meta_value {
>       typedef meta_value type;
>       typedef T value_type;
>       static const T value = x;
>};
>
>// array
>template <class T, T... data>
>struct meta_array {
>       typedef meta_array type;
>       typedef T item_type;
>};
>
>// static array -> runtime array conversion utility
>template <class T>
>struct array_gen;
>
>template <class T, T... xs>
>struct array_gen<meta_array<T, xs...>> {
>       static const T value[sizeof...(xs)];
>};
>
>template <class T, T... xs>
>const T array_gen<meta_array<T, xs...>>::value[sizeof...(xs)] = { xs... };
>
>// static string
>template <class T, T... xs>
>constexpr meta_array<T, xs...> operator "" _s() {
>       static_assert(sizeof...(xs) == 3, "What's wrong with you?");
>       //static_assert(sizeof...(xs) != 3, "What's wrong with you?");
>       return meta_array<T, xs...>();
>}
>
>int main() {
>       const char (& xs)[2] = array_gen<decltype("123"_s)>::value;
>       for (auto & x : xs) cout << x << endl;
>}

Reply via email to