ChaiScript/include/chaiscript/utility/static_string.hpp
Jason Turner e07cd88659 Add noexcept where appropriate
This modifies no logic, it simply adds the keyword `noexcept`

I believe this is 100% correct. It calls methods that are not
guaranteed to be `noexcept`, such as `operator[]` but have
no logically way of throwing.
2017-07-22 20:33:30 -06:00

38 lines
773 B
C++

// This file is distributed under the BSD License.
// See "license.txt" for details.
// Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com)
// Copyright 2009-2017, 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>
Static_String(const char (&str)[N]) noexcept
: m_size(N-1), data(&str[0])
{
}
size_t size() const noexcept {
return m_size;
}
const char *c_str() const noexcept {
return data;
}
const size_t m_size;
const char *data = nullptr;
};
}
}
#endif