Esempio n. 1
0
 void swap(message_impl &other) {
   base_type &base_ref(other), &this_ref(*this);
   std::swap(this_ref, base_ref);
   std::swap(status_, other.status_);
   std::swap(status_message_, other.status_message_);
   std::swap(version_, other.version_);
 }
Esempio n. 2
0
 void swap(basic_response & other) {
     message_impl<Tag> & base_ref(other);
     message_impl<Tag> & this_ref(*this);
     this_ref.swap(base_ref);
     std::swap(other.version_, version_);
     std::swap(other.status_, status_);
     std::swap(other.status_message_, status_message_);
 };
Esempio n. 3
0
TEST(Pointer, SRef)
{
    std::stringstream os1;
    util::sref<std::stringstream> sstream_ref(&os1);
    util::sref<std::ostream> base_ref(sstream_ref);
    base_ref->operator<<(2011) << 0 << 2 << 0 << 3;
    ASSERT_EQ("20110203", os1.str());

    std::stringstream os2;
    sstream_ref = util::mkref(os2);
    base_ref = sstream_ref.convert<std::ostream>();
    base_ref->operator<<(12) << 10;
    ASSERT_EQ("1210", os2.str());

    int x = 1;
    int y = 1;
    int const* ax = &x;
    int const* ay = &y;
    ASSERT_EQ(util::mkref(x).cp(), util::mkref(y).cp());
    ASSERT_NE(util::mkref(ax).cp(), util::mkref(ay).cp());
    y = 2;
    ASSERT_LT(util::mkref(x).cp(), util::mkref(y).cp());
    x = 3;
    ASSERT_LT(util::mkref(y).cp(), util::mkref(x).cp());

    ASSERT_TRUE(util::mkref(x).not_nul());
    ASSERT_TRUE(util::mkref(y).not_nul());
    ASSERT_TRUE(util::mkref(ax).not_nul());
    ASSERT_TRUE(util::mkref(ay).not_nul());
    ASSERT_TRUE(util::sref<int const>(nullptr).nul());

    ASSERT_EQ(3, util::mkref(x).cp());
    ASSERT_EQ(2, util::mkref(y).cp());

    std::stringstream os4;
    util::sref<int const> ref(&x);
    os4 << &x;
    ASSERT_EQ(os4.str(), ref.id().str());

    ASSERT_EQ("0", util::sref<int const>(nullptr).id().str());
}
Esempio n. 4
0
 void swap(basic_response& other) {
   base_type& base_ref(other), &this_ref(*this);
   std::swap(this_ref, base_ref);
 };