Created
March 30, 2014 11:27
-
-
Save DieHertz/9871427 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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