libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

types.pass.cpp (2535B)


      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 #include "test_macros.h"
     30 
     31 int main()
     32 {
     33     {
     34         typedef std::sub_match<char*> SM;
     35         static_assert((std::is_same<SM::iterator, char*>::value), "");
     36         static_assert((std::is_same<SM::value_type, char>::value), "");
     37         static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), "");
     38         static_assert((std::is_same<SM::string_type, std::string>::value), "");
     39         static_assert((std::is_convertible<SM*, std::pair<char*, char*>*>::value), "");
     40 
     41         SM sm;
     42         sm.first = nullptr;
     43         sm.second = nullptr;
     44         sm.matched = false;
     45     }
     46     {
     47         typedef std::sub_match<wchar_t*> SM;
     48         static_assert((std::is_same<SM::iterator, wchar_t*>::value), "");
     49         static_assert((std::is_same<SM::value_type, wchar_t>::value), "");
     50         static_assert((std::is_same<SM::difference_type, std::ptrdiff_t>::value), "");
     51         static_assert((std::is_same<SM::string_type, std::wstring>::value), "");
     52         static_assert((std::is_convertible<SM*, std::pair<wchar_t*, wchar_t*>*>::value), "");
     53 
     54         SM sm;
     55         sm.first = nullptr;
     56         sm.second = nullptr;
     57         sm.matched = false;
     58     }
     59     {
     60         static_assert((std::is_same<std::csub_match, std::sub_match<const char*> >::value), "");
     61         static_assert((std::is_same<std::wcsub_match, std::sub_match<const wchar_t*> >::value), "");
     62         static_assert((std::is_same<std::ssub_match, std::sub_match<std::string::const_iterator> >::value), "");
     63         static_assert((std::is_same<std::wssub_match, std::sub_match<std::wstring::const_iterator> >::value), "");
     64     }
     65 }