Merge branch 'develop' into feature/bit

This commit is contained in:
Peter Dimov
2022-09-21 21:41:43 +03:00
6 changed files with 53 additions and 55 deletions

View File

@@ -27,6 +27,10 @@ set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::utility)
boost_test(TYPE run SOURCES sv_conversion_test2.cpp)
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::config Boost::move Boost::smart_ptr)
boost_test(TYPE run SOURCES fclose_deleter_test.cpp)
endif()
add_subdirectory(swap)

View File

@@ -176,7 +176,7 @@ run demangle_test.cpp
run demangled_name_test.cpp
: : : <test-info>always_show_run_output ;
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
run demangled_name_test.cpp : : : <rtti>off <test-info>always_show_run_output : demangled_name_test_no_rtti ;
run scoped_enum.cpp ;
compile-fail scoped_enum_compile_fail_conv_from_int.cpp
@@ -186,8 +186,7 @@ compile-fail scoped_enum_compile_fail_conv_to_int.cpp
run underlying_type.cpp ;
compile fclose_deleter_test.cpp
: <target-os>windows:<define>_CRT_SECURE_NO_WARNINGS <target-os>windows:<define>_CRT_SECURE_NO_DEPRECATE ;
run fclose_deleter_test.cpp : : : <target-os>windows:<define>_CRT_SECURE_NO_WARNINGS <target-os>windows:<define>_CRT_SECURE_NO_DEPRECATE ;
run pointer_traits_pointer_test.cpp ;
run pointer_traits_element_type_test.cpp ;

View File

@@ -16,17 +16,29 @@
#include <cstdio>
#include <cstddef>
#include <boost/config.hpp>
#include <boost/move/unique_ptr.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#if !defined(BOOST_NO_CXX11_SMART_PTR)
#include <memory>
#endif
boost::movelib::unique_ptr< std::FILE, boost::fclose_deleter > make_boost_unique_file(const char* filename)
{
return boost::movelib::unique_ptr< std::FILE, boost::fclose_deleter >(std::fopen(filename, "w"));
}
boost::shared_ptr< std::FILE > make_boost_shared_file(const char* filename)
{
return boost::shared_ptr< std::FILE >(std::fopen(filename, "w"), boost::fclose_deleter());
}
#if !defined(BOOST_NO_CXX11_SMART_PTR)
std::unique_ptr< std::FILE, boost::fclose_deleter > make_unique_file(const char* filename)
std::unique_ptr< std::FILE, boost::fclose_deleter > make_std_unique_file(const char* filename)
{
return std::unique_ptr< std::FILE, boost::fclose_deleter >(std::fopen(filename, "w"));
}
std::shared_ptr< std::FILE > make_shared_file(const char* filename)
std::shared_ptr< std::FILE > make_std_shared_file(const char* filename)
{
return std::shared_ptr< std::FILE >(std::fopen(filename, "w"), boost::fclose_deleter());
}
@@ -43,9 +55,18 @@ int main()
file = NULL;
}
make_boost_unique_file(filename);
make_boost_shared_file(filename);
#if !defined(BOOST_NO_CXX11_SMART_PTR)
make_unique_file(filename);
make_shared_file(filename);
make_std_unique_file(filename);
make_std_shared_file(filename);
#endif
// Test if the deleter can be called on a NULL pointer
boost::shared_ptr< std::FILE >(static_cast< std::FILE* >(NULL), boost::fclose_deleter());
#if !defined(BOOST_NO_CXX11_SMART_PTR)
std::shared_ptr< std::FILE >(static_cast< std::FILE* >(NULL), boost::fclose_deleter());
#endif
std::remove(filename);