/** This file is a part of rexy's matrix bot Copyright (C) 2019 rexy712 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ #ifndef RAII_STATIC_STRING_HPP #define RAII_STATIC_STRING_HPP #include "raii/string_base.hpp" namespace raii{ class static_string : public string_base { public: constexpr static_string(void) = default; template constexpr static_string(const char(&str)[N]): string_base(const_cast(str), N){} constexpr static_string(const char* str, size_t len): string_base(const_cast(str), len){} static_string(const char* c): string_base(const_cast(c), strlen(c)){} constexpr static_string(const static_string& s): string_base(s.m_data, s.m_length){} constexpr static_string(static_string&& s): string_base(s.m_data, s.m_length){} ~static_string(void) = default; static_string& operator=(const char* c){ m_data = const_cast(c); m_length = strlen(c); return *this; } static_string& operator=(const static_string& s){ m_data = s.m_data; m_length = s.m_length; return *this; } static_string& operator=(static_string&&) = delete; private: char* _allocate(size_t)const override final{return nullptr;} void _free(char*)const override final{} char* _copy(const char*,size_t)const override final{return nullptr;} }; } namespace{ inline raii::static_string operator"" _ss(const char* str, size_t len){ return raii::static_string(str, len); } } #endif