Skip to content

Instantly share code, notes, and snippets.

@CrazyPython
Last active May 14, 2016 19:27
Show Gist options
  • Save CrazyPython/82eb3322109128f777631c08de18f02a to your computer and use it in GitHub Desktop.
Save CrazyPython/82eb3322109128f777631c08de18f02a to your computer and use it in GitHub Desktop.
Full error for a stackoverflow question
In file included from /Users/james/ClionProjects/United States Computing Olympiad/graphs.cpp:2:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:439:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:628:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1673:31: error: no matching constructor for initialization of 'Vertex'
::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1600:18: note: in instantiation of function template specialization 'std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<int, Vertex>, void *> >::construct<Vertex>' requested here
{__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1453:14: note: in instantiation of function template specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<int, Vertex>, void *> > >::__construct<Vertex>' requested here
{__construct(__has_construct<allocator_type, _Tp*, _Args...>(),
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:1342:20: note: in instantiation of function template specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<int, Vertex>, void *> > >::construct<Vertex>' requested here
__node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second));
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:1365:25: note: in instantiation of member function 'std::__1::unordered_map<int, Vertex, std::__1::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<const int, Vertex> > >::__construct_node_with_key' requested here
__node_holder __h = __construct_node_with_key(__k);
^
/Users/james/ClionProjects/United States Computing Olympiad/graphs.cpp:75:24: note: in instantiation of member function 'std::__1::unordered_map<int, Vertex, std::__1::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<const int, Vertex> > >::operator[]' requested here
return vertices[v];
^
/Users/james/ClionProjects/United States Computing Olympiad/graphs.cpp:14:5: note: candidate constructor not viable: requires single argument 'l', but no arguments were provided
Vertex(const int l) : label(l) { }
^
/Users/james/ClionProjects/United States Computing Olympiad/graphs.cpp:16:5: note: candidate constructor not viable: requires single argument 'other_vertex', but no arguments were provided
Vertex(const Vertex& other_vertex) : label(other_vertex.label), adjacent_vertices(other_vertex.adjacent_vertices){ }
^
/Users/james/ClionProjects/United States Computing Olympiad/graphs.cpp:15:5: note: candidate constructor not viable: requires 2 arguments, but 0 were provided
Vertex(const int l, vector<Vertex> adjacents) : label(l), adjacent_vertices(adjacents) { }
#include <stdio.h>
#include <string>
#include <array>
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Vertex {
public:
int label;
vector<Vertex> adjacent_vertices;
Vertex(const int l) : label(l) { }
Vertex(const int l, vector<Vertex> adjacents) : label(l), adjacent_vertices(adjacents) { }
Vertex(const Vertex& other_vertex) : label(other_vertex.label), adjacent_vertices(other_vertex.adjacent_vertices){ }
};
class Graph {
public:
unordered_map<int, Vertex> vertices;
protected:
Vertex getmake_vertex(const int v) {
if (vertices.find(v) == vertices.end() ) {
// not found, make new vertex
vertices.insert(make_pair(v, Vertex(v)));
}
return vertices[v];
};
};
int main() {
}
Vertex getmake_vertex(const int v) {
if (vertices.find(v) == vertices.end() ) {
// not found, make new vertex
vertices.insert(make_pair(v, Vertex(v)));
}
return vertices[v];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment