| 1 |
//===----------------------------------------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// <regex> |
| 10 |
|
| 11 |
// template <class BidirectionalIterator> |
| 12 |
// class sub_match |
| 13 |
// : public pair<BidirectionalIterator, BidirectionalIterator> |
| 14 |
// { |
| 15 |
// public: |
| 16 |
// typedef BidirectionalIterator iterator; |
| 17 |
// typedef typename iterator_traits<iterator>::value_type value_type; |
| 18 |
// typedef typename iterator_traits<iterator>::difference_type difference_type; |
| 19 |
// typedef basic_string<value_type> string_type; |
| 20 |
// |
| 21 |
// bool matched; |
| 22 |
// ... |
| 23 |
// }; |
| 24 |
|
| 25 |
#include <regex> |
| 26 |
#include <type_traits> |
| 27 |
#include <cassert> |
| 28 |
#include "test_macros.h" |
| 29 |
|
| 30 |
int main(int, char**) |
| 31 |
{ |
| 32 |
{ |
| 33 |
typedef std::sub_match<char*> SM; |
| 34 |
static_assert((std::is_same<SM::iterator, char*>::value), ""); |
| 35 |
static_assert((std::is_same<SM::value_type, char>::value), ""); |
| 36 |
static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), ""); |
| 37 |
static_assert((std::is_same<SM::string_type, std::string>::value), ""); |
| 38 |
static_assert((std::is_convertible<SM*, std::pair<char*, char*>*>::value), ""); |
| 39 |
|
| 40 |
static_assert((std::is_same<std::csub_match, std::sub_match<const char*> >::value), ""); |
| 41 |
static_assert((std::is_same<std::ssub_match, std::sub_match<std::string::const_iterator> >::value), ""); |
| 42 |
|
| 43 |
SM sm; |
| 44 |
sm.first = nullptr; |
| 45 |
sm.second = nullptr; |
| 46 |
sm.matched = false; |
| 47 |
} |
| 48 |
|
| 49 |
#ifndef TEST_HAS_NO_WIDE_CHARACTERS |
| 50 |
{ |
| 51 |
typedef std::sub_match<wchar_t*> SM; |
| 52 |
static_assert((std::is_same<SM::iterator, wchar_t*>::value), ""); |
| 53 |
static_assert((std::is_same<SM::value_type, wchar_t>::value), ""); |
| 54 |
static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), ""); |
| 55 |
static_assert((std::is_same<SM::string_type, std::wstring>::value), ""); |
| 56 |
static_assert((std::is_convertible<SM*, std::pair<wchar_t*, wchar_t*>*>::value), ""); |
| 57 |
|
| 58 |
static_assert((std::is_same<std::wcsub_match, std::sub_match<const wchar_t*> >::value), ""); |
| 59 |
static_assert((std::is_same<std::wssub_match, std::sub_match<std::wstring::const_iterator> >::value), ""); |
| 60 |
|
| 61 |
SM sm; |
| 62 |
sm.first = nullptr; |
| 63 |
sm.second = nullptr; |
| 64 |
sm.matched = false; |
| 65 |
} |
| 66 |
#endif |
| 67 |
|
| 68 |
return 0; |
| 69 |
} |