c++ - What is wrong with a volatile type deduction in template functions? -
i have template function:
template <typename t> inline void acquire_store(volatile t* ptr, t value) { // ... } when try invoke this:
volatile node* node; acquire_store(&node, static_cast<node*>(nullptr)); the both g++, clang++ compilers this:
deduced conflicting types parameter 't' ('volatile list::node *' vs. 'list::node *')
what correct way invoke template function?
update.
now i'm not sure node's type - maybe, should change node* volatile node;?
i want variable node volatile, not pointed object.
the substitution , deduction not lexically macro. volatile t* not become volatile node** volatile node* volatile*. second volatile comes template. makes t equal volatile node* first parameter.
try free sticking volatile @ beginning, put qhere belongs according actual type. volatile pointer has volatile after star, not before it.
Comments
Post a Comment