Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
core.stdcpp.string
D header file for interaction with C++ std::string.
License:
Distributed under the
Boost Software License 1.0.
(See accompanying file LICENSE)
Authors:
Guillaume Chatelet
Manu Evans
Source core/stdcpp/string.d
- enum DefaultConstruct
Default
; - Constructor argument for default construction
- struct
char_traits
(CharT); - Character traits classes specify character properties and provide specific semantics for certain operations on characters and sequences of characters.
- struct
basic_string
(T, Traits = char_traits!T, Alloc = allocator!T); - D language counterpart to C++ std::basic_string.
- enum size_type
npos
; - alias
size_type
= size_t; - alias
difference_type
= ptrdiff_t; - alias
value_type
= T; - alias
traits_type
= Traits; - alias
allocator_type
= Alloc; - alias
pointer
= value_type*; - alias
const_pointer
= const(value_type)*; - alias
toString
= as_array; - this();
- MSVC allocates on default initialisation in debug, which can't be modelled by D struct
- alias
length
= size; - alias
opDollar
= length; - const nothrow @trusted bool
empty
(); - const pure nothrow @nogc @safe size_t[2]
opSlice
(size_t dim : 0)(size_tstart
, size_tend
); - inout pure nothrow @nogc ref @safe inout(T)
opIndex
(size_tindex
); - inout pure nothrow @nogc @safe inout(T)[]
opIndex
(size_t[2]slice
); - inout pure nothrow @nogc @safe inout(T)[]
opIndex
(); - const pure nothrow @safe bool
opEquals
(ref scope const basic_strings
);
const pure nothrow @safe boolopEquals
(scope const T[]s
); - Two basic_strings are equal if they represent the same sequence of code units.
- const pure nothrow @safe int
opCmp
(ref scope const basic_stringrhs
);
const pure nothrow @safe intopCmp
(scope const T[]rhs
); - Performs lexicographical comparison.
- const pure nothrow @nogc @safe size_t
toHash
(); - Hash to allow basic_strings to be used as keys for built-in associative arrays. The result will generally not be the same as C++ std::hash<std::basic_string<T>>.
- void
clear
(); - @trusted void
resize
(size_typen
, Tc
= T(0)); - inout nothrow ref @safe inout(T)
front
(); - inout nothrow ref @safe inout(T)
back
(); - const nothrow @safe const(T)*
c_str
(); - ref basic_string
opAssign
()(auto ref basic_stringstr
); - ref basic_string
opAssign
(const(T)[]str
); - ref basic_string
opAssign
(Tc
); - ref basic_string
opIndexAssign
(Tc
, size_tindex
); - ref basic_string
opIndexAssign
(Tc
, size_t[2]slice
); - ref basic_string
opIndexAssign
(const(T)[]str
, size_t[2]slice
); - ref basic_string
opIndexAssign
(Tc
); - ref basic_string
opIndexAssign
(const(T)[]str
); - ref basic_string
opIndexOpAssign
(string op)(Tc
, size_tindex
); - ref basic_string
opIndexOpAssign
(string op)(Tc
, size_t[2]slice
); - ref basic_string
opIndexOpAssign
(string op)(const(T)[]str
, size_t[2]slice
); - ref basic_string
opIndexOpAssign
(string op)(Tc
); - ref basic_string
opIndexOpAssign
(string op)(const(T)[]str
); - ref basic_string
append
(Tc
); - ref basic_string
opOpAssign
(string op : "~")(const(T)[]str
); - ref basic_string
opOpAssign
(string op : "~")(Tc
); - ref basic_string
insert
(size_typepos
, ref const(basic_string)str
); - ref @trusted basic_string
insert
(size_typepos
, ref const(basic_string)str
, size_typesubpos
, size_typesublen
); - ref basic_string
insert
(S : size_type)(Spos
, const(T)*s
); - ref basic_string
insert
(size_typepos
, const(T)[]s
); - ref basic_string
erase
(size_typepos
= 0); - ref basic_string
erase
(size_typepos
, size_typelen
); - ref basic_string
replace
()(size_typepos
, size_typelen
, auto ref basic_stringstr
); - ref basic_string
replace
()(size_typepos
, size_typelen
, auto ref basic_stringstr
, size_typesubpos
, size_typesublen
= npos); - ref basic_string
replace
(size_typepos
, size_typelen
, const(value_type)[]s
); - ref basic_string
replace
(S : size_type)(Spos
, size_typelen
, const(value_type)*s
); - @trusted void
push_back
(Tc
); - void
pop_back
(); - this(DefaultConstruct);
- this(const(T)[]
str
); - this(const(T)[]
str
, ref const(allocator_type)al
); - inout ref inout(Alloc)
get_allocator
(); - const nothrow @safe size_type
max_size
(); - const nothrow @safe size_type
size
(); - const nothrow @safe size_type
capacity
(); - inout @safe inout(T)*
data
(); - inout nothrow scope @trusted inout(T)[]
as_array
() return; - inout nothrow ref @trusted inout(T)
at
(size_typei
); - ref basic_string
assign
(const(T)[]str
); - ref basic_string
assign
(const ref basic_stringstr
); - ref basic_string
append
(const(T)[]str
); - ref basic_string
append
(size_typen
, Tc
); - void
reserve
(size_type_Newcap
= 0); - void
shrink_to_fit
(); - ref basic_string
insert
(size_typepos
, const(T)*s
, size_typen
); - ref basic_string
insert
(size_typepos
, size_typen
, Tc
); - ref basic_string
replace
(size_typepos
, size_typelen
, const(T)*s
, size_typeslen
); - ref basic_string
replace
(size_type_Off
, size_type_N0
, size_type_Count
, T_Ch
); - void
swap
(ref basic_string_Right
);
Copyright © 1999-2024 by the D Language Foundation | Page generated by
Ddoc on Sun Nov 17 01:07:08 2024