aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-16 00:30:08 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-16 00:30:08 +0000
commit40f2054c9e2d3b375e85fe793cef5a6f6c6911b5 (patch)
tree5450a90c6c50bccc8054148d8063f280b1a789bc
parentcae890cf10b6336d9439a298ac103f458f301a6b (diff)
downloadpaludis-40f2054c9e2d3b375e85fe793cef5a6f6c6911b5.tar.gz
paludis-40f2054c9e2d3b375e85fe793cef5a6f6c6911b5.tar.xz
Overload SmartRecord::get to provide a non-const assignable version
-rw-r--r--paludis/util/smart_record.hh.m412
-rw-r--r--paludis/util/smart_record_TEST.cc2
2 files changed, 14 insertions, 0 deletions
diff --git a/paludis/util/smart_record.hh.m4 b/paludis/util/smart_record.hh.m4
index 6fd7f72..ad0c649 100644
--- a/paludis/util/smart_record.hh.m4
+++ b/paludis/util/smart_record.hh.m4
@@ -197,6 +197,12 @@ forloop(`idx', `0', max_record_size, `
return r._v`'idx`';
}
+ static typename GetRecordKeyType<Tag_, `'idx`'>::Type &
+ do_get(RecordBase<Tag_, key_count_> & r)
+ {
+ return r._v`'idx`';
+ }
+
static void
do_set(RecordBase<Tag_, key_count_> & r,
const typename GetRecordKeyType<Tag_, `'idx`'>::Type & v)
@@ -451,6 +457,12 @@ forloop(`idy', `0', decr(idx), `
}
template <typename Tag_::Keys k_>
+ typename GetRecordKeyType<Tag_, k_>::Type & get()
+ {
+ return RecordKeyGetter<Tag_, `'idx`', k_>::do_get(*this);
+ }
+
+ template <typename Tag_::Keys k_>
void set(const typename GetRecordKeyType<Tag_, k_>::Type & v)
{
return RecordKeyGetter<Tag_, `'idx`', k_>::do_set(*this, v);
diff --git a/paludis/util/smart_record_TEST.cc b/paludis/util/smart_record_TEST.cc
index 981bfd5..bc92ffd 100644
--- a/paludis/util/smart_record_TEST.cc
+++ b/paludis/util/smart_record_TEST.cc
@@ -89,6 +89,8 @@ namespace test_cases
TEST_CHECK_EQUAL(p3.get<age>(), 1);
p3.set<age>(2);
TEST_CHECK_EQUAL(p3.get<age>(), 2);
+ p3.get<age>() = 4;
+ TEST_CHECK_EQUAL(p3.get<age>(), 4);
}
} test_simple_record;
}