Tuesday, March 27, 2018

c++11 - Strange declaration with using in C++



On a piece of code in a previous question in stackoverflow I saw this, strange to me, declaration with using:



template  
class A

{
public:
...
using const_buffer_t = const char(&)[SIZE];
...
};


Could someone please address the following questions:





  1. What type it represents?

  2. Where do we need such kind of declarations?


Answer



That's a type alias, a new syntax available since c++11.



What you're actually doing is typedefing the type of an array



const_buffer_t 



will be an array of const char with length = SIZE


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...