Skip to content

Instantly share code, notes, and snippets.

@xtofl
xtofl / _main.cpp
Last active October 20, 2017 07:36
intuitive string-to-type conversion in C++ using user defined conversion; use `int i = val("22");`
#include "headers.h"
struct Val_t {
const std::string_view s;
template<typename T>
operator T() const { return S<T>::cast(s); }
// can't have partial function specialization,
// hence we use an intermediate structure