blob: d3c57a54af00f2c2e1cc1fc67a074ca551e94080 (
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
|
// file : build2/config/utility.txx -*- C++ -*-
// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#include <build2/scope>
namespace build2
{
namespace config
{
template <typename T>
pair<reference_wrapper<const value>, bool>
required (scope& root, const variable& var, const T& def_value, bool ovr)
{
using result = pair<reference_wrapper<const value>, bool>;
if (auto l = root[var])
{
if (l.belongs (*global_scope))
return result (root.assign (var) = *l, true);
if (!ovr || l.belongs (root))
return result (*l, false);
}
return result (root.assign (var) = def_value, true);
}
}
}
|