1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <regex> 11 12// template <class BidirectionalIterator> 13// class sub_match 14// : public pair<BidirectionalIterator, BidirectionalIterator> 15// { 16// public: 17// typedef BidirectionalIterator iterator; 18// typedef typename iterator_traits<iterator>::value_type value_type; 19// typedef typename iterator_traits<iterator>::difference_type difference_type; 20// typedef basic_string<value_type> string_type; 21// 22// bool matched; 23// ... 24// }; 25 26#include <regex> 27#include <type_traits> 28#include <cassert> 29 30int main() 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 SM sm; 41 sm.first = nullptr; 42 sm.second = nullptr; 43 sm.matched = false; 44 } 45 { 46 typedef std::sub_match<wchar_t*> SM; 47 static_assert((std::is_same<SM::iterator, wchar_t*>::value), ""); 48 static_assert((std::is_same<SM::value_type, wchar_t>::value), ""); 49 static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), ""); 50 static_assert((std::is_same<SM::string_type, std::wstring>::value), ""); 51 static_assert((std::is_convertible<SM*, std::pair<wchar_t*, wchar_t*>*>::value), ""); 52 53 SM sm; 54 sm.first = nullptr; 55 sm.second = nullptr; 56 sm.matched = false; 57 } 58 { 59 static_assert((std::is_same<std::csub_match, std::sub_match<const char*> >::value), ""); 60 static_assert((std::is_same<std::wcsub_match, std::sub_match<const wchar_t*> >::value), ""); 61 static_assert((std::is_same<std::ssub_match, std::sub_match<std::string::const_iterator> >::value), ""); 62 static_assert((std::is_same<std::wssub_match, std::sub_match<std::wstring::const_iterator> >::value), ""); 63 } 64} 65