鉴于的operator<<
上std::ostream
用于指针的过载到char
存在,并考虑到该标准规定了std::string
类的简介是以下内容,在§21.4:`std :: string :: iterator`保证不是指向char的指针吗?
namespace std {
template<class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT> >
class basic_string {
public:
[...]
typedef implementation-defined iterator;
typedef implementation-defined const_iterator;
[...]
};
}
最后鉴于要求为iterator
和const_iterator
用于Container
概念是,在§23.2/ 4:
和一个指向char
会满足他们;我是否正确地阅读它,它的实现定义是否编译下面的代码?
std::string string = "abc";
std::cout << begin(string);
它不是** _implementation defined_:执行是_not_所需的文件迭代器的类型。但是,实现是_allowed_使用类或指针类型。 –
@DietmarKühl如果迭代器的类型不是实现定义的,那么为什么在'basic_string'的大纲中标记为“* implementation-defined *”? – Shoe
根据您在帖子中已经描述的内容,我会在帖子中对您的问题说“是”,对标题中的问题说“不”。 –