Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. // clang++ -std=c++14 -O0 -g -Wall -fcolor-diagnostics main.cpp
  2.  
  3. #include <string>
  4.  
  5. template <int tag> class string_wrapper final {
  6. public:
  7. explicit string_wrapper(std::string str) : value_(std::move(str)) {}
  8.  
  9. const std::string &str() const noexcept { return value_; }
  10.  
  11. private:
  12. std::string value_;
  13. };
  14.  
  15. enum type_tags { a, b, c };
  16. using type_a = string_wrapper<a>;
  17. using type_b = string_wrapper<b>;
  18. using type_c = string_wrapper<c>;
  19.  
  20. int main() {
  21. auto some_a = type_a("some a");
  22. auto some_b = type_b("some b");
  23. auto some_c = type_c("some c");
  24.  
  25. some_a = some_c; // Does not compile! Check error message
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement