difference between data() and c_str() of basic_string
来源:互联网 发布:天干地支计算法 编辑:程序博客网 时间:2024/05/22 10:32
<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()的存在只是为了兼容性吧。
- difference between data() and c_str() of basic_string
- basic_string::c_str() 与 basic_string::data() 区别
- basic_string::c_str() 与 basic_string::data() 区别
- basic_string::c_str() 与 basic_string::data() 区别
- Difference Between Prefetch Abort and Data Abort
- C++_string_basic_string::c_str() 与 basic_string::data() 区别
- Difference between forward and include of RequestDispatcher
- Difference between OnPaint and OnDraw of MFC
- difference of top and left between Javascript and Jquery
- The difference between data references and field symbols
- the difference between data mining and meachine learning
- difference between clear data and clear cache ? Android
- The difference between (()) and ().
- difference between "<" and "<<"
- The difference of overriding between C# and Java
- the difference between ClientID and ID of web control
- String and some of the difference between StringBuffer
- The difference of SE Detail UI between 2.4 and 4.0
- 动态规划
- jQuery方法摘录2
- Flex经验
- RMI@SPRING的常见问题解决
- VMWare SDK 学习与使用 创建虚拟机
- difference between data() and c_str() of basic_string
- EHlib,fastreport,vclskin第三方控件的编译和安装
- 贪心算法
- window.XMLHttpRequest an window.ActivexObject
- VC 6.0 Release下调试程序
- TCP建立连接及断开的几次握手过程
- file lock in the Linux system
- apache 虚拟目录的简单设置
- ARM的除法运算优化策略