This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.

### 1180. Missing `string_type` member typedef in class `sub_match`

Section: 30.8.2 [re.submatch.members] Status: C++11 Submitter: Daniel Krügler Opened: 2009-07-25 Last modified: 2016-01-28

Priority: Not Prioritized

View all issues with C++11 status.

Discussion:

The definition of class template `sub_match` is strongly dependent on the type `basic_string<value_type>`, both in interface and effects, but does not provide a corresponding typedef `string_type`, as e.g. class `match_results` does, which looks like an oversight to me that should be fixed.

[ 2009-11-15 Moved to Tentatively Ready after 5 positive votes on c++std-lib. ]

Proposed resolution:

1. In the class template `sub_match` synopsis 30.8 [re.submatch]/1 change as indicated:

   >     template <class BidirectionalIterator>
   >     class sub_match : public std::pair<BidirectionalIterator, BidirectionalIterator> {
   >     public:
   >       typedef typename iterator_traits<BidirectionalIterator>::value_type value_type;
   >       typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
   >       typedef BidirectionalIterator iterator;
   >       typedef basic_string<value_type> string_type;

   >       bool matched;

   >       difference_type length() const;
   >       operator basic_string<value_type>string_type() const;
   >       basic_string<value_type>string_type str() const;
   >       int compare(const sub_match& s) const;
   >       int compare(const basic_string<value_type>string_type& s) const;
   >       int compare(const value_type* s) const;
   >     };

2. In 30.8.2 [re.submatch.members]/2 change as indicated:

   >     operator basic_string<value_type>string_type() const;

   > > Returns: `matched ? basic_string<value_type> string_type(first, second) : basic_string<value_type> string_type()`.

3. In 30.8.2 [re.submatch.members]/3 change as indicated:

   >     basic_string<value_type>string_type str() const;

   > > Returns: `matched ? basic_string<value_type> string_type(first, second) : basic_string<value_type> string_type()`.

4. In 30.8.2 [re.submatch.members]/5 change as indicated:

   >     int compare(const basic_string<value_type>string_type& s) const;