252. missing casts/C-style casts used in iostreams

Section: 31.8 [string.streams] Status: CD1 Submitter: Martin Sebor Opened: 2000-07-28 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [string.streams].

View all issues with CD1 status.

Discussion:

27.7.2.2, p1 uses a C-style cast rather than the more appropriate const_cast<> in the Returns clause for basic_istringstream<>::rdbuf(). The same C-style cast is being used in 27.7.3.2, p1, D.7.2.2, p1, and D.7.3.2, p1, and perhaps elsewhere. 27.7.6, p1 and D.7.2.2, p1 are missing the cast altogether.

C-style casts have not been deprecated, so the first part of this issue is stylistic rather than a matter of correctness.

Proposed resolution:

In 27.7.2.2, p1 replace

  -1- Returns: (basic_stringbuf<charT,traits,Allocator>*)&sb.

with

  -1- Returns: const_cast<basic_stringbuf<charT,traits,Allocator>*>(&sb).

In 27.7.3.2, p1 replace

  -1- Returns: (basic_stringbuf<charT,traits,Allocator>*)&sb.

with

  -1- Returns: const_cast<basic_stringbuf<charT,traits,Allocator>*>(&sb).

In 27.7.6, p1, replace

  -1- Returns: &sb

with

  -1- Returns: const_cast<basic_stringbuf<charT,traits,Allocator>*>(&sb).

In D.7.2.2, p1 replace

  -2- Returns: &sb. 

with

  -2- Returns: const_cast<strstreambuf*>(&sb).