0

I have declared a class template:

template <typename DeallocFunction, typename CryptoObject>
class CryptoDeallocator
{
    uint32_t (*DeallocFunc)(CryptoObject*);
    CryptoObject *ObjectToDealloc;
public:
    CryptoDeallocator(DeallocFunction i_p_func, CryptoObject *i_st_CryptoObject)
    {
        DeallocFunc = i_p_func;
        ObjectToDealloc = i_st_CryptoObject;
    }
    ~CryptoDeallocator()
    {
        if ((ObjectToDealloc != NULL) && (DeallocFunc != NULL))
        {
            DeallocFunc(ObjectToDealloc);
        }
    }
};

Elsewhere in my code, I have a function defined that has the following prototype:

uint32_t nrf_crypto_ecc_private_key_free(nrf_crypto_ecc_private_key_t * p_private_key);

I try to create an instance of my CryptoDeallocator class using:

nrf_crypto_ecc_private_key_t st_OwnPrivateKey;
CryptoDeallocator<uint32_t(*nrf_crypto_ecc_private_key_free)(nrf_crypto_ecc_private_key_t*), nrf_crypto_ecc_private_key_t> st_CryptoDeallocator(nrf_crypto_ecc_private_key_free, &st_OwnPrivateKey);

but I get a compilation error in IAR: Error[Pe018]: expected a ")".

What is the proper syntax I should be using to instantiate a CryptoDeallocator class object?

Keron
  • 167
  • 8

1 Answers1

0

When creating an instance of the class, use the decltype specifier:

CryptoDeallocator<decltype(nrf_crypto_ecc_private_key_free), nrf_crypto_ecc_private_key_t> st_CryptoDeallocator(nrf_crypto_ecc_private_key_free, &st_OwnPrivateKey);
Keron
  • 167
  • 8