#include <iostream>
#include <boost/utility/enable_if.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/contains.hpp>
class FooBar
{
public:
FooBar () {}
~FooBar () {}
template <typename T>
typename boost::enable_if <
typename boost::mpl::contains <
boost::mpl::vector<std::string, int>, T>::type,
std::string>::type
operator = (T v)
{
return "some string";
}
};
int
main ()
{
FooBar bar;
bar = 1;
bar = std::string ("foo");
// bar = "bar"; // This will give a compilation error because we have enabled
// our operator only for std::string and int types.
}