Finish removing runtime string comparisons

* Now virtually all parser string work is done at compile time
 * Continuing the work started by @niXman
This commit is contained in:
Jason Turner
2016-12-02 23:01:57 -07:00
parent 590905f4b3
commit 0dea62dd54
2 changed files with 86 additions and 54 deletions

View File

@@ -0,0 +1,37 @@
// This file is distributed under the BSD License.
// See "license.txt" for details.
// Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com)
// Copyright 2009-2016, Jason Turner (jason@emptycrate.com)
// http://www.chaiscript.com
#ifndef CHAISCRIPT_UTILITY_STATIC_STRING_HPP_
#define CHAISCRIPT_UTILITY_STATIC_STRING_HPP_
namespace chaiscript
{
namespace utility
{
struct Static_String
{
template<size_t N>
constexpr Static_String(const char (&str)[N])
: m_size(N-1), data(&str[0])
{
}
constexpr size_t size() {
return m_size;
}
constexpr const char *c_str() {
return data;
}
const size_t m_size;
const char *data = nullptr;
};
}
}
#endif