aboutsummaryrefslogtreecommitdiff
path: root/build2/function
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-21 11:56:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-21 11:56:00 +0200
commit7a528eab1561b0d0d4ec29f98355fe67025ea632 (patch)
tree28a2061f17e3ee625e8674378227a81a8738a6ec /build2/function
parent3db0756adc641e0a63c4c9f194c4f73cceddd90c (diff)
Add support for derived-to-base function overload resolution
Diffstat (limited to 'build2/function')
-rw-r--r--build2/function31
1 files changed, 24 insertions, 7 deletions
diff --git a/build2/function b/build2/function
index bd91117..c5cde27 100644
--- a/build2/function
+++ b/build2/function
@@ -67,8 +67,9 @@ namespace build2
struct function_overload
{
- const char* name; // Set to point to key by insert() below.
- const char* qual_name; // Qualified name, NULL if none.
+ const char* name; // Set to point to key by insert() below.
+ const char* alt_name; // Alternative name, NULL if none. This is the
+ // qualified name for unqualified or vice verse.
// Arguments.
//
@@ -100,19 +101,19 @@ namespace build2
function_overload () = default;
- function_overload (const char* qn,
+ function_overload (const char* an,
size_t mi, size_t ma, types ts,
function_impl* im)
- : qual_name (qn),
+ : alt_name (an),
arg_min (mi), arg_max (ma), arg_types (move (ts)),
impl (im) {}
template <typename D>
- function_overload (const char* qn,
+ function_overload (const char* an,
size_t mi, size_t ma, types ts,
function_impl* im,
D d)
- : function_overload (qn, mi, ma, move (ts), im)
+ : function_overload (an, mi, ma, move (ts), im)
{
// std::is_pod appears to be broken in VC15.
//
@@ -124,11 +125,15 @@ namespace build2
}
};
+ ostream&
+ operator<< (ostream&, const function_overload&); // Print signature.
+
class function_map
{
public:
using map_type = std::unordered_multimap<string, function_overload>;
using iterator = map_type::iterator;
+ using const_iterator = map_type::const_iterator;
iterator
insert (string name, function_overload);
@@ -137,7 +142,19 @@ namespace build2
erase (iterator i) {map_.erase (i);}
value
- call (const string& name, vector_view<value> args, const location&);
+ call (const string& name, vector_view<value> args, const location&) const;
+
+ iterator
+ begin () {return map_.begin ();}
+
+ iterator
+ end () {return map_.end ();}
+
+ const_iterator
+ begin () const {return map_.begin ();}
+
+ const_iterator
+ end () const {return map_.end ();}
private:
map_type map_;