Skip to content

Commit

Permalink
modernisation: use c++14 where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
timblechmann committed Nov 30, 2023
1 parent f2a9342 commit 0d29fdc
Show file tree
Hide file tree
Showing 31 changed files with 475 additions and 884 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,118 +33,118 @@ jobs:
matrix:
include:
- toolset: gcc-5
cxxstd: "11,14,1z"
cxxstd: "14,1z"
os: ubuntu-22.04
container: ubuntu:16.04
install: g++-5
supported: true
- toolset: gcc-6
cxxstd: "11,14,1z"
cxxstd: "14,1z"
os: ubuntu-22.04
container: ubuntu:16.04
install: g++-6
supported: true
- toolset: gcc-7
cxxstd: "11,14,17"
cxxstd: "14,17"
os: ubuntu-22.04
container: ubuntu:18.04
install: g++-7
supported: true
- toolset: gcc-8
cxxstd: "11,14,17,2a"
cxxstd: "14,17,2a"
os: ubuntu-22.04
container: ubuntu:18.04
install: g++-8
supported: true
- toolset: gcc-9
cxxstd: "11,14,17,2a"
cxxstd: "14,17,2a"
os: ubuntu-22.04
container: ubuntu:18.04
install: g++-9
supported: true
- toolset: gcc-10
cxxstd: "11,14,17,2a"
cxxstd: "14,17,2a"
os: ubuntu-22.04
install: g++-10
supported: true
- toolset: gcc-11
cxxstd: "11,14,17,20"
cxxstd: "14,17,20"
os: ubuntu-22.04
install: g++-11
supported: true
- toolset: gcc-12
cxxstd: "11,14,17,20"
cxxstd: "14,17,20"
os: ubuntu-22.04
install: g++-12
supported: true
- toolset: gcc-13
cxxstd: "11,14,17,20"
cxxstd: "14,17,20"
os: ubuntu-22.04
install: g++-13
supported: true
- toolset: clang
install: clang-9
compiler: clang++-9
cxxstd: "11,14,17"
cxxstd: "14,17"
os: ubuntu-22.04
container: ubuntu:18.04
- toolset: clang
install: clang-10
compiler: clang++-10
cxxstd: "11,14,17,2a"
cxxstd: "14,17,2a"
os: ubuntu-20.04
supported: true
- toolset: clang
install: clang-11
compiler: clang++-11
cxxstd: "11,14,17,2a"
cxxstd: "14,17,2a"
os: ubuntu-20.04
supported: true
- toolset: clang
install: clang-12
compiler: clang++-12
cxxstd: "11,14,17,20"
cxxstd: "14,17,20"
os: ubuntu-22.04
supported: true
- toolset: clang
install: clang-13
compiler: clang++-13
cxxstd: "11,14,17,20"
cxxstd: "14,17,20"
os: ubuntu-22.04
supported: true
- toolset: clang
install: clang-14
compiler: clang++-14
cxxstd: "11,14,17,20"
cxxstd: "14,17,20"
os: ubuntu-22.04
supported: true
- toolset: clang
install: clang-15
compiler: clang++-15
cxxstd: "11,14,17,20"
cxxstd: "14,17,20"
os: ubuntu-22.04
supported: true
# - toolset: clang
# install: clang-16
# compiler: clang++-16
# cxxstd: "11,14,17,20"
# cxxstd: "14,17,20"
# os: ubuntu-22.04
# supported: true

# macos
- description: macos-11
toolset: clang
cxxstd: "11,14,17,2a"
cxxstd: "14,17,2a"
os: macos-11
supported: true
- description: macos-12
toolset: clang
cxxstd: "11,14,17,20"
cxxstd: "14,17,20"
os: macos-11
supported: true
- description: macos-13
toolset: clang
cxxstd: "11,14,17,20"
cxxstd: "14,17,20"
os: macos-11
supported: true

Expand Down Expand Up @@ -275,7 +275,7 @@ jobs:
addrmd: 64
os: windows-2019
- toolset: gcc
cxxstd: "11,14,17,2a"
cxxstd: "14,17,2a"
addrmd: 64
cxxflags: "cxxflags=-Wa,-mbig-obj"
supported: true
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ project(boost_lockfree VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

option(BOOST_LOCKFREE_BUILD_TESTS "Build boost::lockfree tests" ${BUILD_TESTING})

if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

add_library(boost_lockfree INTERFACE)
add_library(Boost::lockfree ALIAS boost_lockfree)
Expand All @@ -33,24 +36,21 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.23)
target_sources(boost_lockfree PUBLIC FILE_SET HEADERS FILES ${Headers} )
endif()

target_compile_features(boost_lockfree INTERFACE cxx_std_14)
set_target_properties( boost_lockfree PROPERTIES CMAKE_CXX_STANDARD_REQUIRED 14)

target_include_directories(boost_lockfree INTERFACE include)

target_link_libraries(boost_lockfree
INTERFACE
Boost::align
Boost::array
Boost::assert
Boost::atomic
Boost::config
Boost::core
Boost::integer
Boost::iterator
Boost::mpl
Boost::parameter
Boost::predef
Boost::static_assert
Boost::tuple
Boost::type_traits
Boost::utility
)

Expand Down
5 changes: 1 addition & 4 deletions doc/lockfree.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,7 @@ problem is the blocking emulation of lock-free atomics, which in the current imp

[section Supported Platforms & Compilers]

_lockfree_ has been tested on the following platforms:

* g++ 4.4, 4.5 and 4.6, linux, x86 & x86_64
* clang++ 3.0, linux, x86 & x86_64
_lockfree_ requires a c++14 compliant compiler

[endsect]

Expand Down
48 changes: 2 additions & 46 deletions include/boost/lockfree/detail/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,7 @@
#ifndef BOOST_LOCKFREE_DETAIL_ATOMIC_HPP
#define BOOST_LOCKFREE_DETAIL_ATOMIC_HPP

#include <boost/config.hpp>

#ifndef BOOST_LOCKFREE_FORCE_STD_ATOMIC

# define BOOST_LOCKFREE_NO_HDR_ATOMIC

// MSVC supports atomic<> from version 2012 onwards.
# if defined( BOOST_MSVC ) && ( BOOST_MSVC >= 1700 )
# undef BOOST_LOCKFREE_NO_HDR_ATOMIC
# endif


// GCC supports atomic<> from version 4.8 onwards.
# if ( BOOST_GCC >= 40800 ) && ( __cplusplus >= 201103L )
# undef BOOST_LOCKFREE_NO_HDR_ATOMIC
# endif


// Apple clang is 2 mayor versions ahead, but in fact 1 minor version behind
# ifdef BOOST_CLANG

# define BOOST_ATOMIC_CLANG_VERSION ( __clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__ )

# if defined( __apple_build_version__ ) && ( BOOST_ATOMIC_CLANG_VERSION >= 60100 ) && ( __cplusplus >= 201103L )
# undef BOOST_LOCKFREE_NO_HDR_ATOMIC
# endif

# if !defined( __apple_build_version__ ) && ( BOOST_ATOMIC_CLANG_VERSION >= 30600 ) && ( __cplusplus >= 201103L )
# undef BOOST_LOCKFREE_NO_HDR_ATOMIC
# endif

# undef BOOST_ATOMIC_CLANG_VERSION

# endif // BOOST_CLANG

// Stdlib should also be checked
# include <boost/config.hpp>
# if defined( BOOST_NO_CXX11_HDR_ATOMIC ) && !defined( BOOST_LOCKFREE_NO_HDR_ATOMIC )
# define BOOST_LOCKFREE_NO_HDR_ATOMIC
# endif

#endif // BOOST_LOCKFREE_FORCE_STD_ATOMIC


#if defined( BOOST_LOCKFREE_NO_HDR_ATOMIC ) || defined( BOOST_LOCKFREE_FORCE_BOOST_ATOMIC )
#if defined( BOOST_LOCKFREE_FORCE_BOOST_ATOMIC )
# include <boost/atomic.hpp>
#else
# include <atomic>
Expand All @@ -60,7 +16,7 @@
namespace boost { namespace lockfree {
namespace detail {

#if defined( BOOST_LOCKFREE_NO_HDR_ATOMIC ) || defined( BOOST_LOCKFREE_FORCE_BOOST_ATOMIC )
#if defined( BOOST_LOCKFREE_FORCE_BOOST_ATOMIC )
using boost::atomic;
using boost::memory_order_acquire;
using boost::memory_order_consume;
Expand Down
32 changes: 3 additions & 29 deletions include/boost/lockfree/detail/copy_payload.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#ifndef BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED
#define BOOST_LOCKFREE_DETAIL_COPY_PAYLOAD_HPP_INCLUDED

#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <type_traits>

#if defined( _MSC_VER )
# pragma warning( push )
Expand Down Expand Up @@ -40,36 +39,11 @@ struct copy_constructible_and_copyable
template < typename T, typename U >
void copy_payload( T& t, U& u )
{
typedef typename boost::mpl::if_< typename boost::is_convertible< T, U >::type,
copy_convertible,
copy_constructible_and_copyable >::type copy_type;
static constexpr bool is_convertible = std::is_convertible< T, U >::value;
typedef std::conditional_t< is_convertible, copy_convertible, copy_constructible_and_copyable > copy_type;
copy_type::copy( t, u );
}

template < typename T >
struct consume_via_copy
{
consume_via_copy( T& out ) :
out_( out )
{}

template < typename U >
void operator()( U& element )
{
copy_payload( element, out_ );
}

T& out_;
};

struct consume_noop
{
template < typename U >
void operator()( const U& )
{}
};


}}} // namespace boost::lockfree::detail

#if defined( _MSC_VER )
Expand Down
Loading

0 comments on commit 0d29fdc

Please sign in to comment.