aboutsummaryrefslogtreecommitdiff
path: root/libbutl/regex.ixx
blob: 15189fb61634f0dd3c7d14cdf4899f77c739193f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// file      : libbutl/regex.ixx -*- C++ -*-
// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason.
{
  template <typename C>
  inline std::pair<std::basic_string<C>, bool>
  regex_replace_ex (const std::basic_string<C>& s,
                    const std::basic_regex<C>& re,
                    const std::basic_string<C>& fmt,
                    std::regex_constants::match_flag_type flags)
  {
    using namespace std;

    using it = typename basic_string<C>::const_iterator;

    basic_string<C> r;
    bool match (regex_replace_ex (s, re, fmt,
                                  [&r] (it b, it e) {r.append (b, e);},
                                  flags));

    return make_pair (move (r), match);
  }
}