74 lines
2.5 KiB
C++
74 lines
2.5 KiB
C++
/**
|
|
This file is a part of rexy's general purpose library
|
|
Copyright (C) 2020-2022 rexy712
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU 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 General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef REXY_STRING_VIEW_TPP
|
|
#define REXY_STRING_VIEW_TPP
|
|
|
|
#include "compat/to_address.hpp"
|
|
#include "utility.hpp"
|
|
#include "string_base.hpp"
|
|
|
|
namespace rexy{
|
|
|
|
template<class Char>
|
|
constexpr basic_string_view<Char>::basic_string_view(void)noexcept:
|
|
basic_string_view(nullptr, 0){}
|
|
|
|
template<class Char>
|
|
constexpr basic_string_view<Char>::basic_string_view(const_pointer str, size_type len)noexcept:
|
|
m_data(str), m_length(len){}
|
|
template<class Char>
|
|
constexpr basic_string_view<Char>::basic_string_view(const basic_string_view& s)noexcept:
|
|
m_data(s.m_data), m_length(s.m_length){}
|
|
template<class Char>
|
|
constexpr basic_string_view<Char>::basic_string_view(const string_base<Char>& s)noexcept:
|
|
m_data(s.c_str()), m_length(s.length()){}
|
|
template<class Char>
|
|
constexpr basic_string_view<Char>::basic_string_view(basic_string_view&& s)noexcept:
|
|
m_data(s.m_data), m_length(s.m_length){}
|
|
template<class Char>
|
|
template<class InIter>
|
|
constexpr basic_string_view<Char>::basic_string_view(InIter start, InIter fin)noexcept:
|
|
basic_string_view(compat::to_address(start), fin - start){}
|
|
|
|
template<class Char>
|
|
constexpr basic_string_view<Char>& basic_string_view<Char>::operator=(const basic_string_view& s)noexcept{
|
|
m_data = s.m_data;
|
|
m_length = s.m_length;
|
|
return *this;
|
|
}
|
|
template<class Char>
|
|
constexpr basic_string_view<Char>::basic_string_view(const_pointer c)noexcept:
|
|
basic_string_view(c, strlen(c)){}
|
|
template<class Char>
|
|
constexpr basic_string_view<Char>& basic_string_view<Char>::operator=(const_pointer c)noexcept{
|
|
m_data = c;
|
|
m_length = strlen(c);
|
|
return *this;
|
|
}
|
|
template<class Char>
|
|
constexpr basic_string_view<Char>& basic_string_view<Char>::operator=(basic_string_view&& s)noexcept{
|
|
m_data = s.m_data;
|
|
m_length = s.m_length;
|
|
return *this;
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|