Skip to content

Instantly share code, notes, and snippets.

@tosik
Created July 12, 2019 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tosik/1a8c415590157e1c789195c3162b267c to your computer and use it in GitHub Desktop.
Save tosik/1a8c415590157e1c789195c3162b267c to your computer and use it in GitHub Desktop.
main.cpp:6:10: error: no viable conversion from 'A<Bar>' to 'A<Foo>'
A<Foo> a = A<Bar>();
^ ~~~~~~~~
main.cpp:3:29: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'A<Bar>' to 'const A<Foo> &' for 1st argument
template <typename T> class A {};
^
main.cpp:3:29: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'A<Bar>' to 'A<Foo> &&' for 1st argument
template <typename T> class A {};
^
1 error generated.
make: *** [all] Error 1
class Foo {};
class Bar : public Foo {};
template <typename T> class A {};
int main() {
A<Foo> a = A<Bar>();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment