Creating URL with Builder pattern
Include the required headers

You use std::string extensively, but you don't include &lt;string&gt;. This is allowed to work (any standard header is allowed to act as if it includes any or all others), but it's not required to work (and didn't, for me).

Use the proper defaults

Right now, your code defaults to https on port 440, but the normal default for https is port 443. I'd tend to include the port in the result if and only if it's explicitly specified. Otherwise, it's probably better to let the browser sort out the port, since most know quite a few more than your code does.

Fluent Interface

I'm not particularly excited about fluent interfaces in general, but if you're going to use one, I'd prefer to get rid of the set on the beginnings of most of the setters. If you have something like:

auto uri = builder().scheme(HTTPS).domain("www.google.com").build();


...you don't really need a set on the beginning of each to make it apparent what you intend.

Consider unique types for the parts of a URL/URI

I tend to wonder whether we wouldn't be better served by a set of tiny classes, one for each type of element in a URL, with each able to (for example) insert itself to a stream, with the url class basically just a set of those. At least for some of the obvious cases, I'd also at least consider using overloaded operators instead of named functions. For example, a fairly minimalist version might look something like this:

struct protocol {
    enum prot { http, https } p_;

    protocol(prot p) : p_(p) {}

    friend std::ostream &amp;operator&lt;&lt;(std::ostream &amp;os, protocol const &amp;p) {
        switch (p.p_) {
        case http: return os &lt;&lt; "http://";
        case https: return os &lt;&lt; "https://";
        }
    }
};

struct query {
    std::string k;
    std::string v;
};

class queries {
    std::vector&lt;query&gt; queries_;
public:
    void add(query const &amp;q) { queries_.push_back(q); }

    friend std::ostream &amp;operator&lt;&lt;(std::ostream &amp;os, queries const &amp;q) {
        std::string sep = "?";
        for (auto const &amp; f : q.queries_) {
            os &lt;&lt; sep &lt;&lt; f.k &lt;&lt; "=" &lt;&lt; f.v;
            sep = "&amp;";
        }
        return os;
    }
};

class path {
    std::vector&lt;std::string&gt; components;
public:
    void add(std::string const &amp;path) {
        components.push_back(path);
    }

    friend std::ostream &amp;operator &lt;&lt; (std::ostream &amp;os, path const &amp;p) {
        for (auto const &amp; s : p.components)
            os &lt;&lt; s &lt;&lt; "/";
        return os;
    }
};

class url {
    protocol prot_;
    path path_;
    queries q_;
public:
    url(protocol::prot p) : prot_(p) {}

    url &amp;operator/(std::string const &amp;p) { path_.add(p); return *this; }
    url &amp;operator&amp;(query const &amp;q) { q_.add(q); return *this; }

    friend std::ostream &amp;operator&lt;&lt;(std::ostream &amp;os, url const &amp;u) {
        return os &lt;&lt; u.prot_ &lt;&lt; u.path_ &lt;&lt; u.q_;
    }
};

int main() {
    url u = url(protocol::http) / "www.youtube.com" / "watch" &amp; query{"v", "tpnrd0xGRsw"};
    std::cout &lt;&lt; u;
}


Note how url's operator&lt;&lt; (roughly equivalent to your build) is now almost trivially simple--and if we add in types for a fragment, port, user name, and so on, it'll remain almost equally trivial, because most of the complexity will be delegated to each of those classes instead of being crammed together into the one giant "build" that knows everything about a URL and how all the pieces need to be delimited and such. Instead, it needs to know the order of the components in a URL, but that's about it. All the details of how to write each piece are delegated to the type for that piece (most of which are individually pretty trivial too).

More syntactic sugar

After some further thought, I've decided that a little more syntactic sugar probably won't rot our teeth too badly. It might be worth adding a couple of tiny functions like this:

url http() { return url(protocol::http); }
url https() { return url(protocol::https); }


This way we can generate a url something like this:

url u = https() / "www.youtube.com" / "watch" &amp; query{"v", "tpnrd0xGRsw"};


Seems a tad cleaner to me, anyway.