Add hb_lidentity(), and rename hb_rvalue() to hb_ridentity()
This commit is contained in:
parent
00195a22ce
commit
c9b287a867
@ -36,17 +36,28 @@
|
||||
|
||||
struct
|
||||
{
|
||||
/* Note. This is dangerous in that if it's passed an rvalue, it returns rvalue-reference. */
|
||||
template <typename T> auto
|
||||
operator () (T&& v) const HB_AUTO_RETURN ( hb_forward<T> (v) )
|
||||
}
|
||||
HB_FUNCOBJ (hb_identity);
|
||||
|
||||
struct
|
||||
{
|
||||
/* Like identity(), but only retains lvalue-references. Rvalues are returned as rvalues. */
|
||||
template <typename T> T&
|
||||
operator () (T& v) const { return v; }
|
||||
|
||||
template <typename T> hb_remove_reference<T>
|
||||
operator () (T&& v) const { return v; }
|
||||
}
|
||||
HB_FUNCOBJ (hb_rvalue);
|
||||
HB_FUNCOBJ (hb_lidentity);
|
||||
struct
|
||||
{
|
||||
/* Like identity(), but always returns rvalue. */
|
||||
template <typename T> hb_remove_reference<T>
|
||||
operator () (T&& v) const { return v; }
|
||||
}
|
||||
HB_FUNCOBJ (hb_ridentity);
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -221,14 +221,14 @@ struct hb_hashmap_t
|
||||
+ hb_array (items, mask ? mask + 1 : 0)
|
||||
| hb_filter (&item_t::is_real)
|
||||
| hb_map (&item_t::key)
|
||||
| hb_map (hb_rvalue)
|
||||
| hb_map (hb_ridentity)
|
||||
)
|
||||
auto values () const HB_AUTO_RETURN
|
||||
(
|
||||
+ hb_array (items, mask ? mask + 1 : 0)
|
||||
| hb_filter (&item_t::is_real)
|
||||
| hb_map (&item_t::value)
|
||||
| hb_map (hb_rvalue)
|
||||
| hb_map (hb_ridentity)
|
||||
)
|
||||
|
||||
protected:
|
||||
|
@ -164,7 +164,7 @@ main (int argc, char **argv)
|
||||
test_iterator_non_default_constructable (hb_enumerate (hb_iter (st)));
|
||||
test_iterator_non_default_constructable (hb_enumerate (hb_iter (st) + 1));
|
||||
test_iterator_non_default_constructable (hb_iter (st) | hb_filter ());
|
||||
test_iterator_non_default_constructable (hb_iter (st) | hb_map (hb_rvalue));
|
||||
test_iterator_non_default_constructable (hb_iter (st) | hb_map (hb_lidentity));
|
||||
|
||||
assert (true == hb_all (st));
|
||||
assert (false == hb_all (st, 42u));
|
||||
|
Loading…
Reference in New Issue
Block a user