fork(6) download
  1. #include <iostream>
  2. #include <string>
  3. #include <boost/variant.hpp>
  4.  
  5.  
  6. template <typename... Types>
  7. struct my_variant : public boost::variant<Types...>
  8. {
  9. using boost::variant<Types...>::variant;
  10. auto operator=(const char* rhs)
  11. {
  12. return boost::variant<Types...>::operator=(std::string(rhs));
  13. }
  14. };
  15.  
  16. int main() {
  17. my_variant<std::string, void const*> foo;
  18. foo = "bar";
  19. std::cout << foo.which();
  20. return 0;
  21. }
Success #stdin #stdout 0s 3236KB
stdin
Standard input is empty
stdout
Standard output is empty