typedef boolean (*Item_Function)();

What does this mean? any help is much appreciated thank you

 
  typedef boolean (*Item_Function)();
The line declares an alias named Item_Function for the type boolean (*)(), which is the type of a pointer to a function returning boolean and accepting no arguments.
Last edited on
Thank you.I somehow used to see typedef identifier in simpler form.This definition confused me.
Function pointers have a complicated syntax, that's why this seems more complicated than usual.
It need not be complicated; the type alias can be declared using syntax that is quite simple.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// using type alias declaration
using function_type = bool() ; // type is: 'nullary function returning bool' (1)
using ptr_function_t = function_type* ; // type is: pointer to such a function (2)

// using typedef declaration
typedef bool function_type() ; // redeclares (1)
typedef function_type* ptr_function_t ; // redeclares (2)

bool my_function() ;

const ptr_function_t pfn = &my_function ; // use the type alias

// using type deduction
const auto pfn2 = &my_function ;
using ptr_function_t = decltype(&my_function) ; // redeclares (2)
typedef decltype(&my_function) ptr_function_t ; // redeclares (2) 
Topic archived. No new replies allowed.