#include "stdafx.h"
#include <iostream>
#include <vector>
#include <map>
template <typename T>
auto Copy(T c)
{
std::vector<decltype(c.begin()->first)> lc;
//Copying
return lc;
}
int main()
{
std::map<int, int> map;
Copy(map);
return 0;
}
In the above code I am trying declare a vector
from the datatype of keys of map
but I am getting following error -
"The C++ Standard forbids containers of const elements allocator<const T> is ill-formed."
How can I achieve my motive. Please guide.
Aucun commentaire:
Enregistrer un commentaire