ARMmbed / core-util

DEPRECATED: Mbed 3 utilities library
Other
12 stars 17 forks source link

FunctionPointer - error: forming pointer to reference type #33

Open headlessme opened 8 years ago

headlessme commented 8 years ago

Should FunctionPointer work with reference types as its template arguments?

For example:

typedef mbed::util::FunctionPointer3<void, SomeClass&, uint32_t, SomeOtherClass&> my_function_ptr_t;

used like this:

my_function_ptr_t callback(this, &AwesomeClass::doAwesomeness);
doSomethingWithCallback(callback);

gives an error like:

/yotta_modules/core-util/core-util/FunctionPointer.h:363:9: error: forming pointer to reference type 'SomeOtherClass&'
         arg_struct(const A1 *b1, const A2 *b2, const A3* b3) {
         ^

@bremoran @autopulated

bremoran commented 8 years ago

The problem here is that function pointer uses pointers to pull arguments through a va_args funciton. I use pointers there because references cannot traverse va_args lists. Unfortunately, this creates a bit of a limitation.

If we use C++11, the use of variadic macros will make it possible to remove this limitation.

rainierwolfcastle commented 8 years ago

ARM Internal Ref: IOTSFW-977