2
0
mirror of https://github.com/boostorg/log.git synced 2026-01-19 04:22:09 +00:00

Unconditionally use std::unique_ptr.

This commit is contained in:
Andrey Semashev
2025-04-19 18:15:02 +03:00
parent 75f2e8eb6d
commit fea445eaa9
10 changed files with 19 additions and 80 deletions

View File

@@ -132,7 +132,6 @@ set(boost_log_sources
src/bit_tools.hpp
src/code_conversion.cpp
src/stateless_allocator.hpp
src/unique_ptr.hpp
src/core.cpp
src/record_ostream.cpp
src/severity_level.cpp

View File

@@ -17,6 +17,7 @@
#include <cstddef>
#include <new>
#include <chrono>
#include <memory>
#include <vector>
#include <algorithm>
#include <boost/cstdint.hpp>
@@ -44,7 +45,6 @@
#include <boost/log/detail/light_rw_mutex.hpp>
#include <boost/log/detail/thread_id.hpp>
#endif
#include "unique_ptr.hpp"
#include "default_sink.hpp"
#include "stateless_allocator.hpp"
#include "alignment_gap_between.hpp"
@@ -282,7 +282,7 @@ public:
#else
//! Thread-specific data
log::aux::unique_ptr< thread_data > m_thread_data;
std::unique_ptr< thread_data > m_thread_data;
#endif
//! The global state of logging
@@ -427,7 +427,7 @@ private:
BOOST_LOG_EXPR_IF_MT(scoped_write_lock lock(m_mutex);)
if (!m_thread_data.get())
{
log::aux::unique_ptr< thread_data > p(new thread_data());
std::unique_ptr< thread_data > p(new thread_data());
m_thread_data.reset(p.get());
#if defined(BOOST_LOG_USE_COMPILER_TLS)
m_thread_data_cache = p.release();

View File

@@ -14,6 +14,7 @@
*/
#include <boost/log/detail/config.hpp>
#include <memory>
#include <utility>
#include <algorithm>
#include <boost/type_index.hpp>
@@ -27,7 +28,6 @@
#if !defined(BOOST_LOG_NO_THREADS)
#include <boost/thread/tss.hpp>
#endif
#include "unique_ptr.hpp"
#include <boost/log/detail/header.hpp>
namespace boost {
@@ -153,7 +153,7 @@ struct BOOST_SYMBOL_VISIBLE named_scope::impl :
#else
//! Pointer to the scope stack
log::aux::unique_ptr< scope_list > pScopes;
std::unique_ptr< scope_list > pScopes;
#endif
//! The method returns current thread scope stack
@@ -166,7 +166,7 @@ struct BOOST_SYMBOL_VISIBLE named_scope::impl :
#endif
if (!p)
{
log::aux::unique_ptr< scope_list > pNew(new scope_list());
std::unique_ptr< scope_list > pNew(new scope_list());
pScopes.reset(pNew.get());
#if defined(BOOST_LOG_USE_COMPILER_TLS)
pScopesCache = p = pNew.release();

View File

@@ -15,6 +15,7 @@
#include <boost/log/detail/config.hpp>
#include <locale>
#include <memory>
#include <utility>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/detail/singleton.hpp>
@@ -23,7 +24,6 @@
#if !defined(BOOST_LOG_NO_THREADS)
#include <boost/thread/tss.hpp>
#endif
#include "unique_ptr.hpp"
#include <boost/log/detail/header.hpp>
namespace boost {
@@ -75,7 +75,7 @@ class stream_compound_pool :
#if !defined(BOOST_LOG_NO_THREADS)
thread_specific_ptr< stream_compound_pool< CharT > >
#else
log::aux::unique_ptr< stream_compound_pool< CharT > >
std::unique_ptr< stream_compound_pool< CharT > >
#endif
>
{
@@ -86,7 +86,7 @@ class stream_compound_pool :
typedef thread_specific_ptr< this_type > tls_ptr_type;
#else
//! Thread-specific pointer type
typedef log::aux::unique_ptr< this_type > tls_ptr_type;
typedef std::unique_ptr< this_type > tls_ptr_type;
#endif
//! Singleton base type
typedef log::aux::lazy_singleton<
@@ -117,7 +117,7 @@ public:
this_type* p = ptr.get();
if (!p)
{
log::aux::unique_ptr< this_type > pNew(new this_type());
std::unique_ptr< this_type > pNew(new this_type());
ptr.reset(pNew.get());
p = pNew.release();
}

View File

@@ -14,6 +14,7 @@
*/
#include <boost/log/detail/config.hpp>
#include <memory>
#include <boost/cstdint.hpp>
#include <boost/log/sources/severity_feature.hpp>
@@ -22,7 +23,6 @@
#include <boost/log/detail/singleton.hpp>
#include <boost/log/detail/thread_specific.hpp>
#endif
#include "unique_ptr.hpp"
#include <boost/log/detail/header.hpp>
namespace boost {
@@ -61,7 +61,7 @@ BOOST_LOG_API uintmax_t& get_severity_level()
uintmax_t* p = tss.get();
if (BOOST_UNLIKELY(!p))
{
log::aux::unique_ptr< uintmax_t > ptr(new uintmax_t(0));
std::unique_ptr< uintmax_t > ptr(new uintmax_t(0));
tss.set(ptr.get());
p = ptr.release();
boost::this_thread::at_thread_exit([p]() { delete p; });

View File

@@ -18,6 +18,7 @@
#ifndef BOOST_LOG_WITHOUT_SYSLOG
#include <ctime>
#include <memory>
#include <algorithm>
#include <stdexcept>
#include <boost/limits.hpp>
@@ -45,7 +46,6 @@
#if !defined(BOOST_LOG_NO_THREADS)
#include <mutex>
#endif
#include "unique_ptr.hpp"
#ifdef BOOST_LOG_USE_NATIVE_SYSLOG
#include <syslog.h>
@@ -422,7 +422,7 @@ struct syslog_backend::implementation::udp_socket_based :
//! Pointer to the list of sockets
shared_ptr< syslog_udp_service > m_pService;
//! Pointer to the socket being used
log::aux::unique_ptr< syslog_udp_socket > m_pSocket;
std::unique_ptr< syslog_udp_socket > m_pSocket;
//! The target host to send packets to
asio::ip::udp::endpoint m_TargetHost;

View File

@@ -56,7 +56,6 @@
#include <boost/log/attributes/time_traits.hpp>
#include <boost/log/sinks/auto_newline_mode.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include "unique_ptr.hpp"
#if !defined(BOOST_LOG_NO_THREADS)
#include <mutex>

View File

@@ -1,59 +0,0 @@
/*
* Copyright Andrey Semashev 2007 - 2015.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file unique_ptr.hpp
* \author Andrey Semashev
* \date 18.07.2015
*
* \brief This header is the Boost.Log library implementation, see the library documentation
* at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
*/
#ifndef BOOST_LOG_UNIQUE_PTR_HPP_INCLUDED_
#define BOOST_LOG_UNIQUE_PTR_HPP_INCLUDED_
#include <boost/log/detail/config.hpp>
#if !defined(BOOST_NO_CXX11_SMART_PTR)
#include <memory>
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
namespace aux {
using std::unique_ptr;
} // namespace aux
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#else // !defined(BOOST_NO_CXX11_SMART_PTR)
#include <boost/move/unique_ptr.hpp>
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
namespace aux {
using boost::movelib::unique_ptr;
} // namespace aux
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#endif // !defined(BOOST_NO_CXX11_SMART_PTR)
#endif // BOOST_LOG_UNIQUE_PTR_HPP_INCLUDED_

View File

@@ -17,6 +17,7 @@
#ifndef BOOST_LOG_WITHOUT_EVENT_LOG
#include <memory>
#include <string>
#include <vector>
#include <ostream>
@@ -33,7 +34,6 @@
#include <boost/log/utility/formatting_ostream.hpp>
#include <windows.h>
#include <psapi.h>
#include "unique_ptr.hpp"
#include "windows/event_log_registry.hpp"
#include "windows/simple_event_log.h"
#include <boost/log/detail/header.hpp>
@@ -262,7 +262,7 @@ BOOST_LOG_API void basic_simple_event_log_backend< CharT >::construct(
aux::init_event_log_registry(log_name, source_name, reg_mode == event_log::forced, reg_params);
}
log::aux::unique_ptr< implementation > p(new implementation());
std::unique_ptr< implementation > p(new implementation());
const char_type* target_unc = NULL;
if (!target.empty())
@@ -518,7 +518,7 @@ BOOST_LOG_API void basic_event_log_backend< CharT >::construct(
aux::init_event_log_registry(log_name, source_name, reg_mode == event_log::forced, reg_params);
}
log::aux::unique_ptr< implementation > p(new implementation());
std::unique_ptr< implementation > p(new implementation());
const char_type* target_unc = NULL;
if (!target.empty())

View File

@@ -26,6 +26,7 @@
#include <windows.h> // for error codes
#include <cstddef>
#include <limits>
#include <memory>
#include <string>
#include <utility>
#include <boost/assert.hpp>
@@ -34,7 +35,6 @@
#include <boost/memory_order.hpp>
#include <boost/core/snprintf.hpp>
#include <boost/atomic/atomic.hpp>
#include "unique_ptr.hpp"
#include "windows/ipc_sync_wrappers.hpp"
#include <boost/log/detail/header.hpp>
@@ -413,7 +413,7 @@ interprocess_condition_variable::semaphore_info* interprocess_condition_variable
{
// We need to open the semaphore. It is possible that the semaphore does not exist because all processes that had it opened terminated.
// Because of this we also attempt to create it.
boost::log::aux::unique_ptr< semaphore_info > p(new semaphore_info(id));
std::unique_ptr< semaphore_info > p(new semaphore_info(id));
generate_semaphore_name(id);
p->m_semaphore.create_or_open(m_semaphore_name.c_str(), m_perms);