fork(5) download
  1. enum IdType {
  2. Book,
  3. Customer
  4. };
  5.  
  6. template <IdType Type>
  7. struct Id {
  8. int m_id;
  9. };
  10.  
  11. using BookId = Id<Book>;
  12. using CustomerId = Id<Customer>;
  13.  
  14. int main()
  15. {
  16. BookId book;
  17. CustomerId cust;
  18. book = cust;
  19. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:18:7: error: no viable overloaded '='
        book = cust;
        ~~~~ ^ ~~~~
prog.cpp:7:8: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Id<Customer aka 1>' to 'const Id<0>' for 1st argument
struct Id {
       ^
prog.cpp:7:8: note: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Id<Customer aka 1>' to 'Id<0>' for 1st argument
struct Id {
       ^
1 error generated.
stdout
Standard output is empty