title: const char* as argument for constexpr constructor
body: <p>I am trying to make a custom string class that involves a constexpr constructor that allows counted initialization at compile time. Unfortunately, the problem of not being able to overload a constexpr constructor/function with a non-constexpr function/constructor seems to be getting in the way.</p>
  <p>This isn't a problem if the struct is meant to stay as that literal its entire lifetime, or if the struct is never meant to be constructed with a non literal value. But the goal of this struct is if it is made using a literal or any kind of constexpr value, it is counted at compile time and initialized as a const string. But, if it is initialized using some non constexpr value, or it is changed after being initialized with a constexpr value, it allocates itself and stops acting like a literal.</p>
  <p>This problem can be solved using 2 different structs, but I would like to try not doing that, for the fun of it. But C++ really doesn't seem to want me to.</p>
  <p>Here is the string struct as of now:</p>
  <pre><code>typedef unsigned int u32;
  
  struct string{
      u32 count;
      u32 space;
      
      char* str;
      const char* literal;
      
      string(){
          count = 0;
          space = 0;
          str   = 0;
      }
      
      template&lt;u32 N&gt; constexpr inline 
      string(const char (&amp;s)[N]) : 
      literal(s), 
      str((char*)s),
      count(N-1), 
      space(0) {}
      
      string(const char* s){
          count  = strlen(s);
          space = RoundUpTo(count+1, 4);
          str = (char*)calloc(space, sizeof(char));
          memcpy(str, s, count* sizeof(char));
      }
  };
  </code></pre>
  <p>when the overloaded non-constexpr constructor is included it always prefers to use it regardless of if its given a literal or not, except when given a <code>const char[N]</code>.</p>
  <p>My next attempt was to just remove the overloaded function, but the issue this now causes is I can't use a variable of type <code>const char*</code> to initialize a string, only <code>const char[N]</code>. This makes sense I guess, but I'm hoping there's someway around this.</p>
  <p>In essence, all I want is to be able to put a char literal into a string struct, without counting its characters at runtime.</p>