Wrapping a std::string for use in a boost::variant

212 Views Asked by At

I wish to have a boost::variant which contains a range of different types including std::string and my own class called Path. Path is effectively a string itself, at least at the time being, but it is a very different concept in terms of the application itself and when visiting it I will be doing very different this with this string. Now of course I cant simply typedef Path as a std::string, so what is the best way to define my Path class?

UPDATE

Here is my solution:

struct Path
{
    Path()
    {
    }

    Path(std::string& _value): value(_value)
    {
    }

    Path(const char* _value): value(_value)
    {
    }

    bool operator==(const Path& right) const
    {
        return value==right.value;
    }

    bool operator!=(const Path& right) const
    {
        return value!=right.value;  
    }

    bool operator<(const Path& right) const
    {
        return value<right.value;
    }

    std::string value;
};
0

There are 0 best solutions below