blob: d2fc29c58527e47233744b8d8a9a39d96e8d8a2c (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// file : libbuild2/utility.txx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
namespace build2
{
template <typename I, typename F>
void
append_option_values (cstrings& args, const char* o, I b, I e, F&& get)
{
if (b != e)
{
args.reserve (args.size () + (e - b));
for (; b != e; ++b)
{
args.push_back (o);
args.push_back (get (*b));
}
}
}
template <typename I, typename F>
void
append_option_values (sha256& cs, const char* o, I b, I e, F&& get)
{
for (; b != e; ++b)
{
cs.append (o);
cs.append (get (*b));
}
}
template <typename K>
basic_path<char, K>
relative (const basic_path<char, K>& p)
{
using path = basic_path<char, K>;
const dir_path& b (*relative_base);
if (p.simple () || b.empty ())
return p;
if (p.sub (b))
return p.leaf (b);
if (p.root_directory () == b.root_directory ())
{
path r (p.relative (b));
if (r.string ().size () < p.string ().size ())
return r;
}
return p;
}
}
|