Bug 65211 - Bad: iostream::traits_type is ambiguous
Summary: Bad: iostream::traits_type is ambiguous
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libstdc++
Version: 7.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-05-20 12:41 UTC by Need Real Name
Modified: 2007-04-18 16:42 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2004-10-01 15:13:00 UTC
Embargoed:


Attachments (Terms of Use)

Description Need Real Name 2002-05-20 12:41:17 UTC
Description of Problem:

When I try to compile following code:

// ... skipped
 typedef STD basic_iostream<Char,It> Iostr;
 Iostr::traits_type * some = (It*)0;
// ... skipped

Compiler tells me that member `traits_type' is ambiguous and candidates are
placed in basic_ostream and basic_istream.

I know that
C++ standard 27.6.1.1 & 27.6.2.1 describes public types of classes 
basic_istream & basic_ostream such as:
 .......
public:
// Types (inherited from basic_ios (27.4.4)):
    typedef charT  char_type;
    typedef typename traits::int_type int_type;
    typedef typename traits::pos_type       pos_type;
    typedef typename traits::off_type       off_type;
    typedef traits traits_type;
.....

but I believe that these typedefs can be placed in basic_ios only. 
Version-Release number of selected component (if applicable):


How Reproducible:
Try to compile source code which contains refference to iostream::traits_type

Steps to Reproduce:
1.  Try to compile source code which contains refference to iostream::traits_type
2. 
3. 

Actual Results:
request for member `traits_type' is ambiguous
/usr/include/g++-v3/bits/std_ostream.h:54: candidates are: typedef struct 
   std::char_traits<char> std::basic_ostream<char, std::char_traits<char> 
   >::traits_type
/usr/include/g++-v3/bits/std_istream.h:54:                 typedef struct 
   std::char_traits<char> std::basic_istream<char, std::char_traits<char> 
   >::traits_type

Expected Results:
Code should be compiled without any errors.

Additional Information:

Comment 1 Benjamin Kosnik 2004-10-01 15:13:00 UTC
Dunno what's up with this bug, report itself is ambiguous. Please
reopen and provide source to your problem if you feel this is still an
active issue.

This works with gcc-3.3.x and gcc-3.4.x:


#include <iostream>

int main()
{
  typedef std::basic_iostream<char, std::char_traits<char> > Iostr;
  Iostr::traits_type* some = NULL;
}



Note You need to log in before you can comment on or make changes to this bug.