Reputation: 1321
I am going through 'The C++ Programming Language, 4th Edition'. In
1.2.2 Type checking
section, there is a sentence that says
"Outside of low-level sections of code (hopefully isolated by type-safe interfaces), code that interfaces to code obeying different language conventions (e.g., an operating system call interface), and the implementations of fundamental abstractions (e.g., string and vector), there is now little need for type-unsafe code."
I understand that low-level sections of code and operating system call interfaces can be type-unsafe but how are string and vector type-unsafe? or am I understanding it wrongly?
Upvotes: 2
Views: 264
Reputation: 238361
How are string or vector type unsafe?
They aren't type-unsafe interfaces. As your quote states, their implementations may use type-unsafe code.
To go into more detail, their implementations need to separate the allocation of storage, and the creation of the elements, which is inherently unsafe to do.
Upvotes: 2