From 8c783c48fa85045a13573395a83fca765e26a291 Mon Sep 17 00:00:00 2001 From: rexy712 Date: Fri, 17 Jul 2020 14:39:06 -0700 Subject: [PATCH] Add c_str function to strings. Mainly just an aesthetic change for me --- include/rexy/cx/string.hpp | 6 ++++++ include/rexy/string_base.hpp | 2 ++ 2 files changed, 8 insertions(+) diff --git a/include/rexy/cx/string.hpp b/include/rexy/cx/string.hpp index f2fba4a..ec973ac 100644 --- a/include/rexy/cx/string.hpp +++ b/include/rexy/cx/string.hpp @@ -105,6 +105,12 @@ namespace rexy::cx{ constexpr size_t capacity(void)const noexcept{ return max_size; } + constexpr char* c_str(void)noexcept{ + return m_data; + } + constexpr const char* c_str(void)const noexcept{ + return m_data; + } constexpr char* get(void)noexcept{ return m_data; } diff --git a/include/rexy/string_base.hpp b/include/rexy/string_base.hpp index 515fd00..bb2a9a4 100644 --- a/include/rexy/string_base.hpp +++ b/include/rexy/string_base.hpp @@ -61,6 +61,8 @@ namespace rexy{ constexpr size_t length(void)const noexcept{return m_length;} constexpr size_t capacity(void)const noexcept{return m_cap;} //direct access to managed pointer + constexpr char* c_str(void)noexcept{return m_data;} + constexpr const char* c_str(void)const noexcept{return m_data;} constexpr char* get(void)noexcept{return m_data;} constexpr const char* get(void)const noexcept{return m_data;} constexpr operator char*(void)noexcept{return m_data;}