79436447

Date: 2025-02-13 14:13:52
Score: 0.5
Natty:
Report link
using         ptr_arr_using = int(*)[];  // pointer to array <-- answer
typedef int (*ptr_arr_typedef)[];        // pointer to array
typedef int  *arr_ptr_typedef [];        // array   of pointers
using         arr_ptr_using = int*[];    // array   of pointers

#include <type_traits>
static_assert( std::is_same_v<arr_ptr_using, arr_ptr_typedef>); // array   of pointers
static_assert( std::is_same_v<ptr_arr_using, ptr_arr_typedef>); // pointer to array

static_assert(!std::is_same_v<arr_ptr_using, ptr_arr_using  >); // arr_ptr != ptr_arr

What hinted me to this

An example "alias template" from https://en.cppreference.com/w/cpp/language/type_alias

template<class T> using ptr = T*;
using ptr_arr_using_template = ptr<int[]>; // then IDE showed `int(*)[]` hint

Aid Material

"The Clockwise/Spiral Rule" by David Anderson https://c-faq.com/decl/spiral.anderson.html

Will explain how to "parse complex declarations in your head". This time C typedef is slightly more readable vs C++ using since it helps to locate the parsing entry point faster (by typename).

So () brackets control the order of things during the declaration process.

Overkill example:

const int *volatile(*const(*const volatile)[1])[2]
// cv*->[1]->с*->[2]->v*=>cT // T=int
Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Starts with a question (0.5): What
  • Low reputation (1):
Posted by: int main