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

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -