home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 33,173 of 33,346   
   Daryle Walker to Daryle Walker   
   Re: Can a (non-static) data member use "   
   20 Aug 13 07:09:24   
   
   From: darylew@googlemail.com   
      
   { Please don't overquote - mod }   
      
   On Tuesday, August 20, 2013 7:14:06 AM UTC-4, Daryle Walker wrote:   
   > I have code like (skipping the base-case specialization):   
   >   
   > template < typename Number, std::size_t Rank >   
   > struct complex_rt {   
   >      using size_type = std::size_t;   
   >      static constexpr size_type rank = Rank;   
   >      using value_type = Number;   
   >      //...   
   >   
   >      template <   
   >          typename    T,   
   >          size_type   R,   
   >          typename ...U,   
   >          typename      = typename std::enable_if<(R < rank - 1u)>::type,   
   >          typename      = typename std::enable_if<((1u + sizeof...( U ))   
   >           <= (1ULL << ( rank - R )))>::type,   
   >          typename      = typename std::enable_if           value_type>::value>::type   
   >      >   
   >      constexpr   
   >      complex_rt( complex_rt const &first, complex_rt const   
   >       &...rest )   
   >          : complex_rt{ 0u, (typename std::remove_extent<   
   >            complex_rt[][1ULL << ( rank - R )]   
   >::type){first,   
   >            rest...} }   
   >      {}   
   >   
   >      //...   
   > };   
   >   
   > The   
   > second argument was originally:   
   >   
   >      complex_rt[1ULL << ( rank - R )]{first, rest...}   
   >   
   > The errors were like unexpected end of an expression right at the   
   > opening array bracket.  I was going to switch to a std::array, but   
   > found out that it won't be constexpr-certified until C++14.  Then I   
   > remember that the code for the array wasn't complaining about using an   
   > array type, but an improper form of the declarator.  So I successfully   
   > tried expressing the array type in conventional C++11 meta-programming   
   > speak.   
   >   
   > Why didn't the direct way work?  Is it a complier deficiency?  (It's   
   > GCC 4.8.1 from MinGW-builds, 32-bit.)  Or is it a defect in the   
   > standard on which type declarations are legal?   
      
   Before anyone else gives answers, I experimented and found out that   
   wrapping the array type directly in parentheses works.   
      
          (complex_rt[1ULL << ( rank - R )]){first, rest...}   
      
   I still don't know if it's a compiler quirk or one in the standard.   
      
   Daryle W.   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca