jeudi 1 février 2018

construct unique_ptr with c++11

I have some code:

#include <string>
#include <memory>
#include <queue>

template <typename T>
class MyQueue {
  public:
  MyQueue() {
    q_(new std::queue<T>);
  }

  private:
  std::unique_ptr<std::queue<T>> q_; 
};

int main() {
  MyQueue<std::string> queue;
  return 0;
}

When I compile with g++ (-std=c++11) I get an output that indicates that I am not constructing my unique_ptr properly. What is the 'proper' way to construct such a unique_ptr?

Aucun commentaire:

Enregistrer un commentaire