腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
1
回答
如何
返回
std
::
string
的
常量
视图
?
c++
、
string
、
string-view
当在C++中进行原型开发和尝试一些概念来创建支持utf8
的
不可变字符串时,我遇到了以下两难境地:
std
::
string
data; //
浏览 15
提问于2017-01-17
得票数 3
3
回答
返回
std
::
string
作为
常量
引用
c++
、
string
、
reference
、
constants
、
stdstring
我对
返回
std
::
string
作为
常量
引用有疑问。class samplepublic: void Set(const
std
::
string
& s) mString = s;} { }在Set函数中,我将
std
::
浏览 0
提问于2012-11-22
得票数 15
回答已采纳
2
回答
重载,const参数,const_cast,const_cast<
string
&>
c++
、
reference
它既不是指向对象
的
指针,也不是对象
的
副本。它就是那个物体。所以我传递一个字符串对象来初始化一个引用s1,所以s1本身就是一个字符串对象,那么它
如何
将一个
string
转换成const
string
&,然后匹配另一个函数呢?
如何
理解函数调用?但是,由于引用本身就是一个对象,所以我使用
的
对象是s1引用
的
初始化对象,而它是一个字符串。从我
的
观点来看,如果您有一个
string
对象,那么您只能匹配
的
非
浏览 1
提问于2018-04-12
得票数 2
1
回答
在MVC设计模式中正确地从
视图
中抽象模型
c++
、
oop
、
model-view-controller
在需要时,GameComponents控件将打包模型,方法是打包所有单独
的
,并将结果
返回
为字符串矩阵。然后将此矩阵传递给
视图
。表示每种类型GameComponent
的
字符串
常量
存储在静态类
常量
中,结构如下: static const
std
::
string
RED; static const <em
浏览 3
提问于2022-06-29
得票数 1
回答已采纳
2
回答
为什么
std
::get<T>其中T是调用constexpr函数失败
的
结果?
c++
、
c++17
我
的
问题是这段代码到底是
如何
工作
的
:constexpr int i = 0;现在,如果我编写以下代码,它将失败:
std
::cout
浏览 14
提问于2019-11-01
得票数 0
回答已采纳
1
回答
operator[]重载C++
c++
、
overloading
、
operator-keyword
因此,我必须为我正在编写
的
类编写两个版本
的
括号运算符。我有点不确定这两个版本实际上有什么不同,以及当调用它们时,它们将
如何
区分。我目前已经写了一个只
返回
索引处
的
字符串。 我
的
问题是,有一个
常量
和一个非
浏览 2
提问于2013-04-24
得票数 1
3
回答
我应该
如何
处理c++中
的
字符串参数?
c++
、
string
、
arguments
假设我想要写一个这样
的
函数: ...perform magic...return result;但是,我也希望能够这样调用它:但是,我不能这样做,因为const char[4]不是const
string
那么,处理字符串参数
的
正确方法是什么呢?
浏览 2
提问于2012-06-30
得票数 0
回答已采纳
5
回答
返回
"const
std
::
string
&“并进行错误检查
的
方法
c++
我正在写一个函数,我想
返回
"const
std
::
string
&“。让我们来看一下代码。class Apublic: { {; // how to get around this line. return list[0];protected:
浏览 2
提问于2011-02-17
得票数 1
回答已采纳
4
回答
对临时对象成员
的
常量
引用
c++
、
c++11
、
reference
、
constants
、
language-lawyer
常量
引用延长了从函数
返回
的
临时对象
的
生命周期,这是C++
的
,但对从函数
返回
的
临时对象
的
成员使用
常量
引用是否可以接受?示例:{ return {
std
::to_
string
(
浏览 37
提问于2016-07-06
得票数 19
回答已采纳
10
回答
如何
返回
std
::
string
.c_str()
c++
、
string
、
pointers
、
c++11
、
return
我有一个
返回
常量
char指针
的
方法。它利用一个
std
::
string
并最终
返回
它
的
c_str()字符指针。const char * returnCharPtr()
std
::
string
someString; } 我收到来自COVERITY工具
的
报告,上面的用法不是很好。我用谷歌搜
浏览 0
提问于2014-03-11
得票数 37
2
回答
C++在函数声明中与符号
的
右边及其他任何地方
的
联系
c++
这是:其含义与此相同:1.)但如果我这么做会怎么样:这是否意味着参数本身
的
地址是常数?2.)此外,如果我这样做会发生什么: void foo(const
std
::
string
const& ba
浏览 5
提问于2017-04-21
得票数 0
回答已采纳
2
回答
`=`为新
的
std
::
string
分配了什么?
c++
、
stdstring
我想要写一个方法,它应该修剪一个
std
::
string
的
正在进行和尾随
的
空格。例如,如果方法获得"HELLO ",则应该
返回
“HELLO”。注意,
返回
字符串之间是一个空格,这一点很重要。这是我
的
方法
的
签名:我
的
方法是将
浏览 3
提问于2020-10-21
得票数 1
回答已采纳
12
回答
返回
对对象
的
常量
引用而不是副本
c++
、
constants
在重构一些代码时,我遇到了一些
返回
std
::
string
的
getter方法。例如,类似于以下内容:{
std
::
string
name_;
std
::
string
name() }当然,getter
返回
一个const
std
::
string
&会更好?当前方法
返
浏览 2
提问于2008-09-25
得票数 73
回答已采纳
1
回答
c++11:完美转发中
的
不变性
c++
、
c++11
我创建了一个函数来检测参数
的
常量
和l(R)值。template<class T>
std
::
string
return
std
::
string
type&) { return
std
::
string
(
std
::is_const<T>::val
浏览 0
提问于2012-04-27
得票数 3
回答已采纳
2
回答
有没有办法在
std
::remove_if迭代器上使用
std
::
string
_view?
c++
、
iterator
、
c++17
、
string-view
我希望使用迭代器有效地修剪一个已经创建
的
std
::
string
_view,由于使用了
std
::remove_if(),而迭代器没有指向修剪过
的
字符。,
std
::remove_if()不能将不可移动
的
迭代器作为参数。我想到
的
唯一解决办法是将
std
::
string
_view转换为
std
::
string
,然后使用迭代器。)但是这有点不符合使用
std
::<
浏览 7
提问于2022-01-21
得票数 2
2
回答
正确设计C++中多个
常量
的
项目
c++
、
constants
在当前
的
项目中,我们当前处理
常量
的
方式存在问题。为了总结它,假设我们有不同
的
操作类型,定义为const::
string
const
std
::
string
actionTypeY这通常通过
std
::unordered_map实现,将操作类型链接到我们需要
的
任何属性: const
std
浏览 0
提问于2018-09-04
得票数 0
9
回答
std
::
string
常量
的
正确成语?
c++
、
string
、
constants
我有一个表示DB对象
的
映射。我想从中得到“众所周知”
的
价值观。 ...当然,最好有一个常数
std
::
string
(当然,与刚刚获取对象
的
磁盘IO相比,它可能是一个很小
的
开销,但我认为这仍然是一个有效
的
问题)。那么,对于
std
::
string
常
浏览 5
提问于2010-02-22
得票数 26
回答已采纳
2
回答
类,包含
std
::
string
的
常量
。
c++
、
string
、
static
、
constants
我想要创建一个类,包含我所有的
常量
(
string
,int,double,属于自己
的
类)--我尝试过这样做,它在Java中一直适用于我: static const
std
::
string
shallowWaterPath = "E:\\Development\\C++\\Material\\terrain\\deep_sea.tga"; static cons
浏览 11
提问于2017-06-12
得票数 0
回答已采纳
3
回答
移动语义并
返回
常量
值
c++
、
c++11
、
constants
、
return-value
、
move-semantics
将所有内容作为"const“值
返回
。像这样..。take_s(make_s());make_s().mutating_member_function();structc_str_proxy { c_str_proxy(
std
::
string
&&s) :
浏览 1
提问于2011-08-21
得票数 4
回答已采纳
1
回答
在堆栈上创建
的
对象地址是
如何
临时
的
c++
我遇到了问题,我想知道为什么在方法堆栈上创建
的
非常数字符串
的
地址在请求其地址时
返回
常量
指针。我已经复制了这里使用
的
代码示例。void myfunc(
string
*& val) // Do stuff to the
string
pointer{ myfunc(&s); // ...
浏览 1
提问于2015-05-26
得票数 0
回答已采纳
点击加载更多
热门
标签
更多标签
云服务器
ICP备案
对象存储
实时音视频
云点播
活动推荐
运营活动
广告
关闭
领券