diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-09-11 11:01:03 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-09-11 11:01:03 +0200 |
commit | 3e0ec6220c1bcc32f45ffd26c08b99af556a8101 (patch) | |
tree | cbae1d7d731ce2f449e3563490aa689c577fba22 /cutl | |
parent | 2da617e92758c20c9abfd37122864a22e287f896 (diff) |
Return reference to newly set value from compiler::context::set()
Diffstat (limited to 'cutl')
-rw-r--r-- | cutl/compiler/context.hxx | 6 | ||||
-rw-r--r-- | cutl/compiler/context.txx | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/cutl/compiler/context.hxx b/cutl/compiler/context.hxx index c8e35e6..6a861e4 100644 --- a/cutl/compiler/context.hxx +++ b/cutl/compiler/context.hxx @@ -88,14 +88,14 @@ namespace cutl get (std::string const& key, X const& default_value) const; template <typename X> - void + X& set (char const* key, X const& value) { - set<X> (std::string (key), value); + return set<X> (std::string (key), value); } template <typename X> - void + X& set (std::string const& key, X const& value); void diff --git a/cutl/compiler/context.txx b/cutl/compiler/context.txx index 6c69d0a..2518019 100644 --- a/cutl/compiler/context.txx +++ b/cutl/compiler/context.txx @@ -65,7 +65,7 @@ namespace cutl } template <typename X> - void context:: + X& context:: set (std::string const& key, X const& value) { try @@ -73,8 +73,12 @@ namespace cutl std::pair<map::iterator, bool> r ( map_.insert (map::value_type (key, value))); + X& x (r.first->second. template value<X> ()); + if (!r.second) - r.first->second. template value<X> () = value; + x = value; + + return x; } catch (container::any::typing const&) { |