| 1 | #include <iostream>
|
|---|
| 2 | #include <type_traits>
|
|---|
| 3 |
|
|---|
| 4 | #include <boost/config.hpp>
|
|---|
| 5 | #include <boost/intrusive_ptr.hpp>
|
|---|
| 6 | #include <boost/version.hpp>
|
|---|
| 7 |
|
|---|
| 8 | class S
|
|---|
| 9 | {
|
|---|
| 10 | private:
|
|---|
| 11 | int refcount = 0;
|
|---|
| 12 |
|
|---|
| 13 | private:
|
|---|
| 14 | inline friend void intrusive_ptr_add_ref(S* s)
|
|---|
| 15 | {
|
|---|
| 16 | s->refcount += 1;
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | inline friend void intrusive_ptr_release(S* s)
|
|---|
| 20 | {
|
|---|
| 21 | s->refcount -= 1;
|
|---|
| 22 | if (s->refcount == 0)
|
|---|
| 23 | {
|
|---|
| 24 | delete s;
|
|---|
| 25 | }
|
|---|
| 26 | }
|
|---|
| 27 | };
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | int main()
|
|---|
| 31 | {
|
|---|
| 32 | using S_ptr = boost::intrusive_ptr<S>;
|
|---|
| 33 |
|
|---|
| 34 | {
|
|---|
| 35 | S_ptr p_s(new S);
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | std::cout << std::boolalpha;
|
|---|
| 39 | std::cout << "__cplusplus: " << __cplusplus << '\n';
|
|---|
| 40 | std::cout << "BOOST_VERSION: " << BOOST_VERSION << '\n';
|
|---|
| 41 |
|
|---|
| 42 | std::cout << "std::is_nothrow_move_constructible<S_ptr>: " << std::is_nothrow_move_constructible<S_ptr>::value << '\n';
|
|---|
| 43 |
|
|---|
| 44 | std::cout << "BOOST_NO_CXX11_RVALUE_REFERENCES: " <<
|
|---|
| 45 | #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
|---|
| 46 | "<defined>"
|
|---|
| 47 | #else
|
|---|
| 48 | "<undefined>"
|
|---|
| 49 | #endif
|
|---|
| 50 | << '\n';
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | #if defined(__INTEL_COMPILER)
|
|---|
| 54 | std::cout << "__INTEL_COMPILER: " << __INTEL_COMPILER << '\n';
|
|---|
| 55 | #endif
|
|---|
| 56 |
|
|---|
| 57 | #if defined(BOOST_INTEL_CXX_VERSION)
|
|---|
| 58 | std::cout << "BOOST_INTEL_CXX_VERSION: " << BOOST_INTEL_CXX_VERSION << '\n';
|
|---|
| 59 | #endif
|
|---|
| 60 |
|
|---|
| 61 | #if defined(BOOST_INTEL_GCC_VERSION)
|
|---|
| 62 | std::cout << "BOOST_INTEL_GCC_VERSION: " << BOOST_INTEL_GCC_VERSION << '\n';
|
|---|
| 63 | #endif
|
|---|
| 64 |
|
|---|
| 65 | #if defined(_MSC_VER)
|
|---|
| 66 | std::cout << "_MSC_VER: " << _MSC_VER << '\n';
|
|---|
| 67 | #endif
|
|---|
| 68 | }
|
|---|