mercredi 21 décembre 2016

How to use make_pair to create pair of id and struct (object)?

I was trying to create a pair of id and object like this:

 #include <iostream>
  #include <utility>
  #include <functional>

  struct num{

      double x;
      double y;

  };


  int main(){

      auto tmp = std::make_pair(1, {1.0, 2.0});

 }

I get error as error: no matching function for call to 'make_pair(int, <brace-enclosed initializer list>)'

Is there a proper way to create pair of id and object?

Aucun commentaire:

Enregistrer un commentaire