c++ - std::queue with different container type depending on runtime data -
i have class needs use std::queue instance var store data. problem std::queue either uses std::deque container type default or 1 needs provide container type @ compile time. container use depends on runtime data of class user, therefore can't specify on compile time. after instanciation of std::queue , providing proper container implementation don't care anymore container itself, use interface of std::queue.
the containers provide std::deque or boost::circular_buffer , both store same type of elements, it's 1 used whenever caller store infinite amount of data , circular _buffer if not.
the way found far custom abstract base class acting common interface 2 derived implementations different std::queue instances. in case have duplicate interface of std::queue annoying.
is there way declare , instanciate std::queue in such way? "std::queue unknown/runtime provided container".
template parameters must known @ compile type. not able change underlying container of queue
@ run time. sort of wrapper or union combines 2 types of queues , use 1 or other @ run time depending on run time condition.
Comments
Post a Comment