/
BirdLeon
/
ROBLOX2016
Обзор
Документация
Войти
/
BirdLeon
/
ROBLOX2016
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
Library/boost/libs/smart_ptr/test/ip_hash_test2.cpp
67 строк
1 KB
PatoFlamejanteTV
full source code
19 дек 2024, 19:11
19 дек 2024, 19:11
05db15d
Код
Авторство
О чём код?
// Copyright 2011, 2020 Peter Dimov // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt #include <boost/intrusive_ptr.hpp> #include <boost/core/lightweight_test.hpp> #include <boost/config.hpp> #include <functional> #if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) int main() {} #else class base { private: int use_count_; base(base const &); base & operator=(base const &); protected: base(): use_count_(0) { } virtual ~base() { } public: long use_count() const { return use_count_; } inline friend void intrusive_ptr_add_ref(base * p) { ++p->use_count_; } inline friend void intrusive_ptr_release(base * p) { if(--p->use_count_ == 0) delete p; } }; struct X: public base { }; int main() { boost::intrusive_ptr<X> p1, p2( new X ); BOOST_TEST_EQ( std::hash< boost::intrusive_ptr<X> >()( p1 ), std::hash< X* >()( p1.get() ) ); BOOST_TEST_EQ( std::hash< boost::intrusive_ptr<X> >()( p2 ), std::hash< X* >()( p2.get() ) ); return boost::report_errors(); } #endif // #if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)