4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
15 #if __cplusplus >= 201103L && defined(LYX_USE_STD_REGEX)
18 # define match_partial _Match_partial
20 // inheriting 'private' to see which functions are used and if there are
21 // other ECMAScrip defaults
22 class regex : private std::regex
26 regex(const regex& rhs) : std::regex(rhs) {}
28 regex(T t) : std::regex(t, std::regex_constants::grep) {}
30 void assign(T t) { std::regex::assign(t, std::regex_constants::grep); }
31 template<class T, class V>
32 void assign(T t, V v) { std::regex::assign(t, v); }
33 const std::regex& toStd() const { return *this; }
36 bool regex_match(T t, const regex& r) { return std::regex_match(t, r.toStd()); }
37 template<class T, class V>
38 bool regex_match(T t, V v, const regex& r) { return std::regex_match(t, v, r.toStd()); }
39 template<class T, class V, class U, class H>
40 bool regex_match(T t, V v, H h, const regex& r, U u) { return std::regex_match(t, v, h, r.toStd(), u); }
41 template<class T, class V>
42 std::string regex_replace(T t, const regex& r, V v) { return std::regex_replace(t, r.toStd(), v); }
43 //template<class T, class V, class U, class H>
44 //std::string regex_replace(T t, V v, U u, const regex& r, H h) { return std::regex_replace(t, v, u, r.toStd(), h); }
46 bool regex_search(T t, const regex& r) { return std::regex_search(t, r.toStd()); }
47 template<class T, class V>
48 bool regex_search(T t, V v, const regex& r) { return std::regex_search(t, v, r.toStd()); }
49 template<class T, class V, class U>
50 bool regex_search(T t, V v, U u, const regex& r) { return std::regex_search(t, v, u, r.toStd()); }
52 struct sregex_iterator : std::sregex_iterator
55 template<class T, class V>
56 sregex_iterator(T t, V v, const regex& r) : std::sregex_iterator(t, v, r.toStd()) {}
60 // <regex> in gcc is unusable in versions less than 4.9.0
61 // see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53631
62 // TODO no match_partial in std, how to replace?
66 using LR_NS::regex_match;
67 using LR_NS::sregex_iterator;
71 # include <boost/regex.hpp>
75 using LR_NS::regex_match;
76 using LR_NS::sregex_iterator;
82 using LR_NS::regex_replace;
83 using LR_NS::basic_regex;
84 using LR_NS::regex_error;
85 using LR_NS::regex_search;
86 using LR_NS::match_results;
88 namespace regex_constants
90 using namespace LR_NS::regex_constants;
91 using LR_NS::regex_constants::match_flag_type;