[string.accessors] # 27 Strings library [[strings]](./#strings) ## 27.4 String classes [[string.classes]](string.classes#string.accessors) ### 27.4.3 Class template basic_string [[basic.string]](basic.string#string.accessors) #### 27.4.3.8 String operations [[string.ops]](string.ops#string.accessors) #### 27.4.3.8.1 Accessors [string.accessors] [🔗](#lib:c_str,basic_string) `constexpr const charT* c_str() const noexcept; constexpr const charT* data() const noexcept; ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4297) *Returns*: A pointer p such that p + i == addressof(operator[](i)) for eachi in [0, size()][.](#1.sentence-1) [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4302) *Complexity*: Constant time[.](#2.sentence-1) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4306) *Remarks*: The program shall not modify any of the values stored in the character array; otherwise, the behavior is undefined[.](#3.sentence-1) [🔗](#lib:data,basic_string_) `constexpr charT* data() noexcept; ` [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4317) *Returns*: A pointer p such that p + i == addressof(operator[](i)) for eachi in [0, size()][.](#4.sentence-1) [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4322) *Complexity*: Constant time[.](#5.sentence-1) [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4326) *Remarks*: The program shall not modify the value stored at p + size() to any value other than charT(); otherwise, the behavior is undefined[.](#6.sentence-1) [🔗](#lib:operator_basic_string_view,basic_string) `constexpr operator basic_string_view() const noexcept; ` [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4338) *Effects*: Equivalent to:return basic_string_view(data(), size()); [🔗](#lib:get_allocator,basic_string) `constexpr allocator_type get_allocator() const noexcept; ` [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/strings.tex#L4350) *Returns*: A copy of theAllocator object used to construct the string or, if that allocator has been replaced, a copy of the most recent replacement[.](#8.sentence-1)