Using void pointers for unknown return types in a linked list c++ -


i'm trying implement linked list , values held each node need not same type. i've used void pointer store value, issue i'm having retrieving value node. want write single function contains switch statement cast value appropriate type, i'm not sure how handle unknown return type other using void pointer.

is there way around this, or perhaps more efficient way handle unknown data types?

  1. you don't use void* unless you're 100% sure you're doing.
  2. you don't use t* pointers value
  3. you don't use raw pointers @ all, appropriate idioms dynamic memory management facilities of c++ standard library.
  4. you use standard linked-list implementation: std::list.

"is there way around this, or perhaps more efficient way handle unknown data types?"

yes there's boost::any or boost::variant mentioned, though these aren't c++ standard types.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -