Skip to content

Instantly share code, notes, and snippets.

@vinniefalco
Created January 20, 2020 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinniefalco/769c92afe592f681fcb31d63c3391de2 to your computer and use it in GitHub Desktop.
Save vinniefalco/769c92afe592f681fcb31d63c3391de2 to your computer and use it in GitHub Desktop.
namespace url {
class basic_value
{
char* s_;
public:
// construct a URL from a string.
// the string is copied.
basic_value( string_view s );
// return the hostname
string_view
encoded_hostname() const noexcept;
protected:
virtual
char*
reserve(
char* buffer,
std::size_t n) = 0;
};
template<class Allocator>
class dynamic_value : public basic_value
{
Allocator a_;
...
};
template<std::size_t N>
class static_value : public basic_value
{
char buf_[N+1]; // for the null
};
using value = basic_value<std::allocator<char>>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment