Skip to content

Instantly share code, notes, and snippets.

@DieHertz
Created March 30, 2014 11:27
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 DieHertz/9871427 to your computer and use it in GitHub Desktop.
Save DieHertz/9871427 to your computer and use it in GitHub Desktop.
#include <cstdlib>
class const_str {
const char* str;
size_t len;
public:
template<size_t N> constexpr const_str(const char (&str)[N]) : str{str}, len{N - 1} {}
constexpr size_t size() const { return len; }
};
constexpr const_str g_c_str = "abc";
template<size_t N> struct int_to_type {};
int main() {
int_to_type<g_c_str.size()>{};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment