<THE C++ PROGRAMMING LANGUAGE> writes: In other words, data() produces an array of characters, whereas c_str() produces a C-style string.
以下是cygwin(basic_string.h ISO C++ 14882: 21 Strings library)与M$ Vs2005(xstring.h)分别对data()和c_str()的实现,由代码可知,data()与c_str()功能已经完全相同了。
、
// VS2005
由VS2005的代码可知,data()调用c_str(),c_str()调用_Myptr(),很显然,如果编译器没有做优化处理的话,
data()的效率要比c_str()慢一点。
而cygwin的代码中,两个函数实现是相同的,因此不存在效率差异。
通过两者对与data()与c_str()的实现方法不同点可以看出两者的设计观点不同。
VS2005是为了能够保证data()与c_str()得功能一致,而cygwin则仍然保持了data()与c_str()的独立性。
或许data()的存在只是为了兼容性吧。
分享到:
相关推荐
很好的东西,简述PLMN和PSTN的区别,大家看看就知道了。
Difference between HBase and RDBMS
state 50 differences between marketing and sales
举个栗子(Difference between str and repr?): >>> import datetime >>> today = datetime.datetime.now() >>> str(today) '2020-03-28 11:06:49.580643' >>> repr(today) 'datetime.datetime(2020, 3, 28, 11, 6...
MAKING A WORLD OF DIFFERENCE 这是我的英文自传。我决定把整本书从收费的Amazon转换成免费分享。昨晚修改格式后(内 容丝毫未变)。任何一本书不可能没有错误,如果您看到错误,请留言,一定修改。谢谢! 这本英文...
What's the difference between TAF and FCF
This is the advanced level of econometrics and financial econometrics with some basic theory and heavy applications. Here, our focuses are on the SKILLS of analyzing real data using advanced ...
sva classical q&a Qi1)What is callback ? (Qi2)What is factory pattern ?...(Qi3)Explain the difference between data types logic and reg and wire . (Qi4)What is the need of clocking blocks ?
Difference between E and V version of att7022
Calculate sum of square difference between manipulated image and different resaved version compressed at different JPEG quality. Tampered region is detected by resaving the image at a multitude of ...
show the difference of set
FX2 and FX2LP 系列的区别 cy7c68013A开发套餐
Data collection at ultra high-frequency on financial markets requires the manipulation of complex databases, and possibly the correction of errors present in the data. The New York Stock Exchange is ...
If so, then having the right tools makes a critical difference, and will be a great investment as you grow your data science expertise. The book starts by highlighting the importance of data ...
Difference Between VMWare ESX and VMWare ESXi
4)And compare the results between these two algorithms and the difference of selection processes. 5)Write down the report in which there should be the execution results of the program. ...
Summary: <br/>Symptom: This is an explanation of differences between TYPE and LIKE additions <br/>Additional key words: Data types, data objects, ABAP type concept, Dictionary ...
Temporal Difference Variational Auto-Encoder_序列生成模型+VAE1
The Finite Difference Time Domain Method for Electromagnetics With MATLAB Simulations Atef Elsherbeni and Veysel Demir Chapter 11
This date class consists of lots of function like calculation of age, difference between two dates, Adding number to a date and subtracting and also checking whether the date is valid or not and so on