#include <iostream>
#include <cstring>
using namespace std;

struct string_view
{
	string_view() = default;
	string_view(const string_view& other) = default;
	
	string_view(const string& str)
		: ptr(str.c_str()), size(str.length())
	{}
	
	string_view(const char* str)
		: ptr(str), size(::strlen(str))
	{}
	
	string_view(const char* str, size_t len)
		: ptr(str), size(len)
	{}
	
	// Protection for temporary objects
	string_view(string&& str) = delete;
	
	string_view& operator=(const string_view&) = default; 
	
	const char *ptr = nullptr;
	size_t      size = 0;
};

string get_host()
{
	return "http://h...content-available-to-author-only...d.su";
}

string_view get_schema(string_view uri)
{
	return uri;
}

string_view get_schema2(string url)
{
	string_view v(url);
	return v;
}

const char* get_schema3(string url)
{
	return url.c_str();
}

int main() 
{
	{
		// Compilation error:
		//auto v1 = get_schema(get_host());
		
		//string_view v2;
		//v2 = get_host();
	}
	
	{
		// WA for protection
		auto v1 = get_schema2(get_host());
		auto v2 = get_schema(get_host().c_str());
	}
	
	{
		// Valid usage	
		string str = get_host();
		auto v1 = get_schema(str);
		
		string_view v2 = "hello";
		
		auto v3 = get_schema("http://h...content-available-to-author-only...d.su");
	}
	
	
	
	return 0;
}

