Initial Commit

This commit is contained in:
Jordan Sherer
2018-02-08 21:28:33 -05:00
commit 678c1d3966
14352 changed files with 3176737 additions and 0 deletions
@@ -0,0 +1,96 @@
// Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
// Use, modification and distribution is subject to 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)
// Skeleton and content support for communicators
// This header should be included only after both communicator.hpp and
// skeleton_and_content.hpp have been included.
#ifndef BOOST_MPI_COMMUNICATOR_SC_HPP
#define BOOST_MPI_COMMUNICATOR_SC_HPP
namespace boost { namespace mpi {
template<typename T>
void
communicator::send(int dest, int tag, const skeleton_proxy<T>& proxy) const
{
packed_skeleton_oarchive ar(*this);
ar << proxy.object;
send(dest, tag, ar);
}
template<typename T>
status
communicator::recv(int source, int tag, const skeleton_proxy<T>& proxy) const
{
packed_skeleton_iarchive ar(*this);
status result = recv(source, tag, ar);
ar >> proxy.object;
return result;
}
template<typename T>
status communicator::recv(int source, int tag, skeleton_proxy<T>& proxy) const
{
packed_skeleton_iarchive ar(*this);
status result = recv(source, tag, ar);
ar >> proxy.object;
return result;
}
template<typename T>
request
communicator::isend(int dest, int tag, const skeleton_proxy<T>& proxy) const
{
shared_ptr<packed_skeleton_oarchive>
archive(new packed_skeleton_oarchive(*this));
*archive << proxy.object;
request result = isend(dest, tag, *archive);
result.m_data = archive;
return result;
}
namespace detail {
template<typename T>
struct serialized_irecv_data<const skeleton_proxy<T> >
{
serialized_irecv_data(const communicator& comm, int source, int tag,
skeleton_proxy<T> proxy)
: comm(comm), source(source), tag(tag), isa(comm),
ia(isa.get_skeleton()), proxy(proxy) { }
void deserialize(status& stat)
{
isa >> proxy.object;
stat.m_count = 1;
}
communicator comm;
int source;
int tag;
std::size_t count;
packed_skeleton_iarchive isa;
packed_iarchive& ia;
skeleton_proxy<T> proxy;
};
template<typename T>
struct serialized_irecv_data<skeleton_proxy<T> >
: public serialized_irecv_data<const skeleton_proxy<T> >
{
typedef serialized_irecv_data<const skeleton_proxy<T> > inherited;
serialized_irecv_data(const communicator& comm, int source, int tag,
const skeleton_proxy<T>& proxy)
: inherited(comm, source, tag, proxy) { }
};
}
} } // end namespace boost::mpi
#endif // BOOST_MPI_COMMUNICATOR_SC_HPP
@@ -0,0 +1,27 @@
// -------------------------------------
//
// (C) Copyright Gennaro Prota 2003.
//
// 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)
//
// ------------------------------------------------------
#ifndef BOOST_NON_TYPE_HPP_GP_20030417
#define BOOST_NON_TYPE_HPP_GP_20030417
namespace boost {
// Just a simple "envelope" for non-type template parameters. Useful
// to work around some MSVC deficiencies.
template <typename T, T n>
struct non_type { };
}
#endif // include guard
@@ -0,0 +1,133 @@
// (C) Copyright John Maddock 2007.
// Use, modification and distribution are subject to 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)
//
// This file is machine generated, do not edit by hand
// Unrolled polynomial evaluation using second order Horners rule
#ifndef BOOST_MATH_TOOLS_POLY_EVAL_9_HPP
#define BOOST_MATH_TOOLS_POLY_EVAL_9_HPP
namespace boost{ namespace math{ namespace tools{ namespace detail{
template <class T, class V>
inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V)
{
return static_cast<V>(0);
}
template <class T, class V>
inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V)
{
return static_cast<V>(a[0]);
}
template <class T, class V>
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V)
{
return static_cast<V>(a[1] * x + a[0]);
}
template <class T, class V>
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V)
{
return static_cast<V>((a[2] * x + a[1]) * x + a[0]);
}
template <class T, class V>
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V)
{
return static_cast<V>(((a[3] * x + a[2]) * x + a[1]) * x + a[0]);
}
template <class T, class V>
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V)
{
V x2 = x * x;
V t[2];
t[0] = static_cast<V>(a[4] * x2 + a[2]);
t[1] = static_cast<V>(a[3] * x2 + a[1]);
t[0] *= x2;
t[0] += static_cast<V>(a[0]);
t[1] *= x;
return t[0] + t[1];
}
template <class T, class V>
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V)
{
V x2 = x * x;
V t[2];
t[0] = a[5] * x2 + a[3];
t[1] = a[4] * x2 + a[2];
t[0] *= x2;
t[1] *= x2;
t[0] += static_cast<V>(a[1]);
t[1] += static_cast<V>(a[0]);
t[0] *= x;
return t[0] + t[1];
}
template <class T, class V>
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V)
{
V x2 = x * x;
V t[2];
t[0] = static_cast<V>(a[6] * x2 + a[4]);
t[1] = static_cast<V>(a[5] * x2 + a[3]);
t[0] *= x2;
t[1] *= x2;
t[0] += static_cast<V>(a[2]);
t[1] += static_cast<V>(a[1]);
t[0] *= x2;
t[0] += static_cast<V>(a[0]);
t[1] *= x;
return t[0] + t[1];
}
template <class T, class V>
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V)
{
V x2 = x * x;
V t[2];
t[0] = a[7] * x2 + a[5];
t[1] = a[6] * x2 + a[4];
t[0] *= x2;
t[1] *= x2;
t[0] += static_cast<V>(a[3]);
t[1] += static_cast<V>(a[2]);
t[0] *= x2;
t[1] *= x2;
t[0] += static_cast<V>(a[1]);
t[1] += static_cast<V>(a[0]);
t[0] *= x;
return t[0] + t[1];
}
template <class T, class V>
inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V)
{
V x2 = x * x;
V t[2];
t[0] = static_cast<V>(a[8] * x2 + a[6]);
t[1] = static_cast<V>(a[7] * x2 + a[5]);
t[0] *= x2;
t[1] *= x2;
t[0] += static_cast<V>(a[4]);
t[1] += static_cast<V>(a[3]);
t[0] *= x2;
t[1] *= x2;
t[0] += static_cast<V>(a[2]);
t[1] += static_cast<V>(a[1]);
t[0] *= x2;
t[0] += static_cast<V>(a[0]);
t[1] *= x;
return t[0] + t[1];
}
}}}} // namespaces
#endif // include guard
@@ -0,0 +1,516 @@
/*
* 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)
*
* Copyright (c) 2009 Helge Bahmann
* Copyright (c) 2012 Tim Blechmann
* Copyright (c) 2014 Andrey Semashev
*/
/*!
* \file atomic/detail/ops_gcc_x86.hpp
*
* This header contains implementation of the \c operations template.
*/
#ifndef BOOST_ATOMIC_DETAIL_OPS_GCC_X86_HPP_INCLUDED_
#define BOOST_ATOMIC_DETAIL_OPS_GCC_X86_HPP_INCLUDED_
#include <boost/memory_order.hpp>
#include <boost/atomic/detail/config.hpp>
#include <boost/atomic/detail/storage_type.hpp>
#include <boost/atomic/detail/operations_fwd.hpp>
#include <boost/atomic/capabilities.hpp>
#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B) || defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B)
#include <boost/atomic/detail/ops_gcc_x86_dcas.hpp>
#include <boost/atomic/detail/ops_cas_based.hpp>
#endif
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
#if defined(__x86_64__)
#define BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "rdx"
#else
#define BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "edx"
#endif
namespace boost {
namespace atomics {
namespace detail {
struct gcc_x86_operations_base
{
static BOOST_CONSTEXPR_OR_CONST bool is_always_lock_free = true;
static BOOST_FORCEINLINE void fence_before(memory_order order) BOOST_NOEXCEPT
{
if ((order & memory_order_release) != 0)
__asm__ __volatile__ ("" ::: "memory");
}
static BOOST_FORCEINLINE void fence_after(memory_order order) BOOST_NOEXCEPT
{
if ((order & memory_order_acquire) != 0)
__asm__ __volatile__ ("" ::: "memory");
}
};
template< typename T, typename Derived >
struct gcc_x86_operations :
public gcc_x86_operations_base
{
typedef T storage_type;
static BOOST_FORCEINLINE void store(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
if (order != memory_order_seq_cst)
{
fence_before(order);
storage = v;
fence_after(order);
}
else
{
Derived::exchange(storage, v, order);
}
}
static BOOST_FORCEINLINE storage_type load(storage_type const volatile& storage, memory_order order) BOOST_NOEXCEPT
{
storage_type v = storage;
fence_after(order);
return v;
}
static BOOST_FORCEINLINE storage_type fetch_sub(storage_type volatile& storage, storage_type v, memory_order order) BOOST_NOEXCEPT
{
return Derived::fetch_add(storage, -v, order);
}
static BOOST_FORCEINLINE bool compare_exchange_weak(
storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order success_order, memory_order failure_order) BOOST_NOEXCEPT
{
return Derived::compare_exchange_strong(storage, expected, desired, success_order, failure_order);
}
static BOOST_FORCEINLINE bool test_and_set(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
return !!Derived::exchange(storage, (storage_type)1, order);
}
static BOOST_FORCEINLINE void clear(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
{
store(storage, (storage_type)0, order);
}
static BOOST_FORCEINLINE bool is_lock_free(storage_type const volatile&) BOOST_NOEXCEPT
{
return true;
}
};
template< bool Signed >
struct operations< 1u, Signed > :
public gcc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > >
{
typedef gcc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type;
typedef typename base_type::storage_type storage_type;
typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type;
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
__asm__ __volatile__
(
"lock; xaddb %0, %1"
: "+q" (v), "+m" (storage)
:
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"
);
return v;
}
static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
__asm__ __volatile__
(
"xchgb %0, %1"
: "+q" (v), "+m" (storage)
:
: "memory"
);
return v;
}
static BOOST_FORCEINLINE bool compare_exchange_strong(
storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT
{
storage_type previous = expected;
bool success;
__asm__ __volatile__
(
"lock; cmpxchgb %3, %1\n\t"
"sete %2"
: "+a" (previous), "+m" (storage), "=q" (success)
: "q" (desired)
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"
);
expected = previous;
return success;
}
#define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, argument, result)\
__asm__ __volatile__\
(\
"xor %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER ", %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "\n\t"\
".align 16\n\t"\
"1: movb %[arg], %%dl\n\t"\
op " %%al, %%dl\n\t"\
"lock; cmpxchgb %%dl, %[storage]\n\t"\
"jne 1b"\
: [res] "+a" (result), [storage] "+m" (storage)\
: [arg] "q" (argument)\
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER, "memory"\
)
static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("andb", v, res);
return res;
}
static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("orb", v, res);
return res;
}
static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("xorb", v, res);
return res;
}
#undef BOOST_ATOMIC_DETAIL_CAS_LOOP
};
template< bool Signed >
struct operations< 2u, Signed > :
public gcc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > >
{
typedef gcc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type;
typedef typename base_type::storage_type storage_type;
typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type;
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
__asm__ __volatile__
(
"lock; xaddw %0, %1"
: "+q" (v), "+m" (storage)
:
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"
);
return v;
}
static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
__asm__ __volatile__
(
"xchgw %0, %1"
: "+q" (v), "+m" (storage)
:
: "memory"
);
return v;
}
static BOOST_FORCEINLINE bool compare_exchange_strong(
storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT
{
storage_type previous = expected;
bool success;
__asm__ __volatile__
(
"lock; cmpxchgw %3, %1\n\t"
"sete %2"
: "+a" (previous), "+m" (storage), "=q" (success)
: "q" (desired)
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"
);
expected = previous;
return success;
}
#define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, argument, result)\
__asm__ __volatile__\
(\
"xor %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER ", %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "\n\t"\
".align 16\n\t"\
"1: movw %[arg], %%dx\n\t"\
op " %%ax, %%dx\n\t"\
"lock; cmpxchgw %%dx, %[storage]\n\t"\
"jne 1b"\
: [res] "+a" (result), [storage] "+m" (storage)\
: [arg] "q" (argument)\
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER, "memory"\
)
static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("andw", v, res);
return res;
}
static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("orw", v, res);
return res;
}
static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("xorw", v, res);
return res;
}
#undef BOOST_ATOMIC_DETAIL_CAS_LOOP
};
template< bool Signed >
struct operations< 4u, Signed > :
public gcc_x86_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > >
{
typedef gcc_x86_operations< typename make_storage_type< 4u, Signed >::type, operations< 4u, Signed > > base_type;
typedef typename base_type::storage_type storage_type;
typedef typename make_storage_type< 4u, Signed >::aligned aligned_storage_type;
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
__asm__ __volatile__
(
"lock; xaddl %0, %1"
: "+r" (v), "+m" (storage)
:
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"
);
return v;
}
static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
__asm__ __volatile__
(
"xchgl %0, %1"
: "+r" (v), "+m" (storage)
:
: "memory"
);
return v;
}
static BOOST_FORCEINLINE bool compare_exchange_strong(
storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT
{
storage_type previous = expected;
bool success;
__asm__ __volatile__
(
"lock; cmpxchgl %3, %1\n\t"
"sete %2"
: "+a" (previous), "+m" (storage), "=q" (success)
: "r" (desired)
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"
);
expected = previous;
return success;
}
#define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, argument, result)\
__asm__ __volatile__\
(\
"xor %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER ", %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "\n\t"\
".align 16\n\t"\
"1: movl %[arg], %%edx\n\t"\
op " %%eax, %%edx\n\t"\
"lock; cmpxchgl %%edx, %[storage]\n\t"\
"jne 1b"\
: [res] "+a" (result), [storage] "+m" (storage)\
: [arg] "r" (argument)\
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER, "memory"\
)
static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("andl", v, res);
return res;
}
static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("orl", v, res);
return res;
}
static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("xorl", v, res);
return res;
}
#undef BOOST_ATOMIC_DETAIL_CAS_LOOP
};
#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG8B)
template< bool Signed >
struct operations< 8u, Signed > :
public cas_based_operations< gcc_dcas_x86< Signed > >
{
};
#elif defined(__x86_64__)
template< bool Signed >
struct operations< 8u, Signed > :
public gcc_x86_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > >
{
typedef gcc_x86_operations< typename make_storage_type< 8u, Signed >::type, operations< 8u, Signed > > base_type;
typedef typename base_type::storage_type storage_type;
typedef typename make_storage_type< 8u, Signed >::aligned aligned_storage_type;
static BOOST_FORCEINLINE storage_type fetch_add(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
__asm__ __volatile__
(
"lock; xaddq %0, %1"
: "+r" (v), "+m" (storage)
:
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"
);
return v;
}
static BOOST_FORCEINLINE storage_type exchange(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
__asm__ __volatile__
(
"xchgq %0, %1"
: "+r" (v), "+m" (storage)
:
: "memory"
);
return v;
}
static BOOST_FORCEINLINE bool compare_exchange_strong(
storage_type volatile& storage, storage_type& expected, storage_type desired, memory_order, memory_order) BOOST_NOEXCEPT
{
storage_type previous = expected;
bool success;
__asm__ __volatile__
(
"lock; cmpxchgq %3, %1\n\t"
"sete %2"
: "+a" (previous), "+m" (storage), "=q" (success)
: "r" (desired)
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"
);
expected = previous;
return success;
}
#define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, argument, result)\
__asm__ __volatile__\
(\
"xor %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER ", %%" BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER "\n\t"\
".align 16\n\t"\
"1: movq %[arg], %%rdx\n\t"\
op " %%rax, %%rdx\n\t"\
"lock; cmpxchgq %%rdx, %[storage]\n\t"\
"jne 1b"\
: [res] "+a" (result), [storage] "+m" (storage)\
: [arg] "r" (argument)\
: BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER, "memory"\
)
static BOOST_FORCEINLINE storage_type fetch_and(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("andq", v, res);
return res;
}
static BOOST_FORCEINLINE storage_type fetch_or(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("orq", v, res);
return res;
}
static BOOST_FORCEINLINE storage_type fetch_xor(storage_type volatile& storage, storage_type v, memory_order) BOOST_NOEXCEPT
{
storage_type res = storage;
BOOST_ATOMIC_DETAIL_CAS_LOOP("xorq", v, res);
return res;
}
#undef BOOST_ATOMIC_DETAIL_CAS_LOOP
};
#endif
#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B)
template< bool Signed >
struct operations< 16u, Signed > :
public cas_based_operations< gcc_dcas_x86_64< Signed > >
{
};
#endif // defined(BOOST_ATOMIC_DETAIL_X86_HAS_CMPXCHG16B)
BOOST_FORCEINLINE void thread_fence(memory_order order) BOOST_NOEXCEPT
{
if (order == memory_order_seq_cst)
{
__asm__ __volatile__
(
#if defined(BOOST_ATOMIC_DETAIL_X86_HAS_MFENCE)
"mfence\n"
#else
"lock; addl $0, (%%esp)\n"
#endif
::: "memory"
);
}
else if ((order & (memory_order_acquire | memory_order_release)) != 0)
{
__asm__ __volatile__ ("" ::: "memory");
}
}
BOOST_FORCEINLINE void signal_fence(memory_order order) BOOST_NOEXCEPT
{
if (order != memory_order_relaxed)
__asm__ __volatile__ ("" ::: "memory");
}
} // namespace detail
} // namespace atomics
} // namespace boost
#undef BOOST_ATOMIC_DETAIL_TEMP_CAS_REGISTER
#endif // BOOST_ATOMIC_DETAIL_OPS_GCC_X86_HPP_INCLUDED_
@@ -0,0 +1,735 @@
// Copyright (C) 2003-2004 Jeremy B. Maitin-Shepard.
// Copyright (C) 2005-2011 Daniel James
// 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)
#ifndef BOOST_UNORDERED_DETAIL_EQUIVALENT_HPP_INCLUDED
#define BOOST_UNORDERED_DETAIL_EQUIVALENT_HPP_INCLUDED
#include <boost/config.hpp>
#if defined(BOOST_HAS_PRAGMA_ONCE)
#pragma once
#endif
#include <boost/unordered/detail/extract_key.hpp>
namespace boost { namespace unordered { namespace detail {
template <typename A, typename T> struct grouped_node;
template <typename T> struct grouped_ptr_node;
template <typename Types> struct grouped_table_impl;
template <typename A, typename T>
struct grouped_node :
boost::unordered::detail::value_base<T>
{
typedef typename ::boost::unordered::detail::rebind_wrap<
A, grouped_node<A, T> >::type allocator;
typedef typename ::boost::unordered::detail::
allocator_traits<allocator>::pointer node_pointer;
typedef node_pointer link_pointer;
link_pointer next_;
node_pointer group_prev_;
std::size_t hash_;
grouped_node() :
next_(),
group_prev_(),
hash_(0)
{}
void init(node_pointer self)
{
group_prev_ = self;
}
private:
grouped_node& operator=(grouped_node const&);
};
template <typename T>
struct grouped_ptr_node :
boost::unordered::detail::ptr_bucket
{
typedef T value_type;
typedef boost::unordered::detail::ptr_bucket bucket_base;
typedef grouped_ptr_node<T>* node_pointer;
typedef ptr_bucket* link_pointer;
node_pointer group_prev_;
std::size_t hash_;
boost::unordered::detail::value_base<T> value_base_;
grouped_ptr_node() :
bucket_base(),
group_prev_(0),
hash_(0)
{}
void init(node_pointer self)
{
group_prev_ = self;
}
void* address() { return value_base_.address(); }
value_type& value() { return value_base_.value(); }
value_type* value_ptr() { return value_base_.value_ptr(); }
private:
grouped_ptr_node& operator=(grouped_ptr_node const&);
};
// If the allocator uses raw pointers use grouped_ptr_node
// Otherwise use grouped_node.
template <typename A, typename T, typename NodePtr, typename BucketPtr>
struct pick_grouped_node2
{
typedef boost::unordered::detail::grouped_node<A, T> node;
typedef typename boost::unordered::detail::allocator_traits<
typename boost::unordered::detail::rebind_wrap<A, node>::type
>::pointer node_pointer;
typedef boost::unordered::detail::bucket<node_pointer> bucket;
typedef node_pointer link_pointer;
};
template <typename A, typename T>
struct pick_grouped_node2<A, T,
boost::unordered::detail::grouped_ptr_node<T>*,
boost::unordered::detail::ptr_bucket*>
{
typedef boost::unordered::detail::grouped_ptr_node<T> node;
typedef boost::unordered::detail::ptr_bucket bucket;
typedef bucket* link_pointer;
};
template <typename A, typename T>
struct pick_grouped_node
{
typedef typename boost::remove_const<T>::type nonconst;
typedef boost::unordered::detail::allocator_traits<
typename boost::unordered::detail::rebind_wrap<A,
boost::unordered::detail::grouped_ptr_node<nonconst> >::type
> tentative_node_traits;
typedef boost::unordered::detail::allocator_traits<
typename boost::unordered::detail::rebind_wrap<A,
boost::unordered::detail::ptr_bucket >::type
> tentative_bucket_traits;
typedef pick_grouped_node2<A, nonconst,
typename tentative_node_traits::pointer,
typename tentative_bucket_traits::pointer> pick;
typedef typename pick::node node;
typedef typename pick::bucket bucket;
typedef typename pick::link_pointer link_pointer;
};
template <typename Types>
struct grouped_table_impl : boost::unordered::detail::table<Types>
{
typedef boost::unordered::detail::table<Types> table;
typedef typename table::value_type value_type;
typedef typename table::bucket bucket;
typedef typename table::policy policy;
typedef typename table::node_pointer node_pointer;
typedef typename table::node_allocator node_allocator;
typedef typename table::node_allocator_traits node_allocator_traits;
typedef typename table::bucket_pointer bucket_pointer;
typedef typename table::link_pointer link_pointer;
typedef typename table::hasher hasher;
typedef typename table::key_equal key_equal;
typedef typename table::key_type key_type;
typedef typename table::node_constructor node_constructor;
typedef typename table::node_tmp node_tmp;
typedef typename table::extractor extractor;
typedef typename table::iterator iterator;
typedef typename table::c_iterator c_iterator;
// Constructors
grouped_table_impl(std::size_t n,
hasher const& hf,
key_equal const& eq,
node_allocator const& a)
: table(n, hf, eq, a)
{}
grouped_table_impl(grouped_table_impl const& x)
: table(x, node_allocator_traits::
select_on_container_copy_construction(x.node_alloc()))
{
this->init(x);
}
grouped_table_impl(grouped_table_impl const& x,
node_allocator const& a)
: table(x, a)
{
this->init(x);
}
grouped_table_impl(grouped_table_impl& x,
boost::unordered::detail::move_tag m)
: table(x, m)
{}
grouped_table_impl(grouped_table_impl& x,
node_allocator const& a,
boost::unordered::detail::move_tag m)
: table(x, a, m)
{
this->move_init(x);
}
// Node functions.
static inline node_pointer next_node(link_pointer n) {
return static_cast<node_pointer>(n->next_);
}
static inline node_pointer next_group(node_pointer n) {
return static_cast<node_pointer>(n->group_prev_->next_);
}
// Accessors
template <class Key, class Pred>
node_pointer find_node_impl(
std::size_t key_hash,
Key const& k,
Pred const& eq) const
{
std::size_t bucket_index = this->hash_to_bucket(key_hash);
node_pointer n = this->begin(bucket_index);
for (;;)
{
if (!n) return n;
std::size_t node_hash = n->hash_;
if (key_hash == node_hash)
{
if (eq(k, this->get_key(n->value())))
return n;
}
else
{
if (this->hash_to_bucket(node_hash) != bucket_index)
return node_pointer();
}
n = next_group(n);
}
}
std::size_t count(key_type const& k) const
{
node_pointer n = this->find_node(k);
if (!n) return 0;
std::size_t x = 0;
node_pointer it = n;
do {
it = it->group_prev_;
++x;
} while(it != n);
return x;
}
std::pair<iterator, iterator>
equal_range(key_type const& k) const
{
node_pointer n = this->find_node(k);
return std::make_pair(iterator(n), iterator(n ? next_group(n) : n));
}
// Equality
bool equals(grouped_table_impl const& other) const
{
if(this->size_ != other.size_) return false;
for(node_pointer n1 = this->begin(); n1;)
{
node_pointer n2 = other.find_node(other.get_key(n1->value()));
if (!n2) return false;
node_pointer end1 = next_group(n1);
node_pointer end2 = next_group(n2);
if (!group_equals(n1, end1, n2, end2)) return false;
n1 = end1;
}
return true;
}
static bool group_equals(node_pointer n1, node_pointer end1,
node_pointer n2, node_pointer end2)
{
for(;;)
{
if (n1->value() != n2->value()) break;
n1 = next_node(n1);
n2 = next_node(n2);
if (n1 == end1) return n2 == end2;
if (n2 == end2) return false;
}
for(node_pointer n1a = n1, n2a = n2;;)
{
n1a = next_node(n1a);
n2a = next_node(n2a);
if (n1a == end1)
{
if (n2a == end2) break;
else return false;
}
if (n2a == end2) return false;
}
node_pointer start = n1;
for(;n1 != end1; n1 = next_node(n1))
{
value_type const& v = n1->value();
if (!find(start, n1, v)) {
std::size_t matches = count_equal(n2, end2, v);
if (!matches) return false;
if (matches != 1 + count_equal(next_node(n1), end1, v)) return false;
}
}
return true;
}
static bool find(node_pointer n, node_pointer end, value_type const& v)
{
for(;n != end; n = next_node(n))
if (n->value() == v)
return true;
return false;
}
static std::size_t count_equal(node_pointer n, node_pointer end,
value_type const& v)
{
std::size_t count = 0;
for(;n != end; n = next_node(n))
if (n->value() == v) ++count;
return count;
}
// Emplace/Insert
// Add node 'n' to the group containing 'pos'.
// If 'pos' is the first node in group, add to the end of the group,
// otherwise add before 'pos'.
static inline void add_to_node_group(
node_pointer n,
node_pointer pos)
{
n->next_ = pos->group_prev_->next_;
n->group_prev_ = pos->group_prev_;
pos->group_prev_->next_ = n;
pos->group_prev_ = n;
}
inline node_pointer add_node(
node_pointer n,
std::size_t key_hash,
node_pointer pos)
{
n->hash_ = key_hash;
if (pos) {
this->add_to_node_group(n, pos);
if (n->next_) {
std::size_t next_bucket = this->hash_to_bucket(
next_node(n)->hash_);
if (next_bucket != this->hash_to_bucket(key_hash)) {
this->get_bucket(next_bucket)->next_ = n;
}
}
}
else {
bucket_pointer b = this->get_bucket(
this->hash_to_bucket(key_hash));
if (!b->next_)
{
link_pointer start_node = this->get_previous_start();
if (start_node->next_) {
this->get_bucket(this->hash_to_bucket(
next_node(start_node)->hash_
))->next_ = n;
}
b->next_ = start_node;
n->next_ = start_node->next_;
start_node->next_ = n;
}
else
{
n->next_ = b->next_->next_;
b->next_->next_ = n;
}
}
++this->size_;
return n;
}
inline node_pointer add_using_hint(
node_pointer n,
node_pointer hint)
{
n->hash_ = hint->hash_;
this->add_to_node_group(n, hint);
if (n->next_ != hint && n->next_) {
std::size_t next_bucket = this->hash_to_bucket(
next_node(n)->hash_);
if (next_bucket != this->hash_to_bucket(n->hash_)) {
this->get_bucket(next_bucket)->next_ = n;
}
}
++this->size_;
return n;
}
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
# if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
iterator emplace(boost::unordered::detail::emplace_args1<
boost::unordered::detail::please_ignore_this_overload> const&)
{
BOOST_ASSERT(false);
return iterator();
}
iterator emplace_hint(c_iterator, boost::unordered::detail::emplace_args1<
boost::unordered::detail::please_ignore_this_overload> const&)
{
BOOST_ASSERT(false);
return iterator();
}
# else
iterator emplace(
boost::unordered::detail::please_ignore_this_overload const&)
{
BOOST_ASSERT(false);
return iterator();
}
iterator emplace_hint(c_iterator,
boost::unordered::detail::please_ignore_this_overload const&)
{
BOOST_ASSERT(false);
return iterator();
}
# endif
#endif
template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
iterator emplace(BOOST_UNORDERED_EMPLACE_ARGS)
{
return iterator(emplace_impl(
boost::unordered::detail::func::construct_node_from_args(
this->node_alloc(), BOOST_UNORDERED_EMPLACE_FORWARD)));
}
template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
iterator emplace_hint(c_iterator hint, BOOST_UNORDERED_EMPLACE_ARGS)
{
return iterator(emplace_hint_impl(hint,
boost::unordered::detail::func::construct_node_from_args(
this->node_alloc(), BOOST_UNORDERED_EMPLACE_FORWARD)));
}
iterator emplace_impl(node_pointer n)
{
node_tmp a(n, this->node_alloc());
key_type const& k = this->get_key(a.node_->value());
std::size_t key_hash = this->hash(k);
node_pointer position = this->find_node(key_hash, k);
this->reserve_for_insert(this->size_ + 1);
return iterator(this->add_node(a.release(), key_hash, position));
}
iterator emplace_hint_impl(c_iterator hint, node_pointer n)
{
node_tmp a(n, this->node_alloc());
key_type const& k = this->get_key(a.node_->value());
if (hint.node_ && this->key_eq()(k, this->get_key(*hint))) {
this->reserve_for_insert(this->size_ + 1);
return iterator(this->add_using_hint(a.release(), hint.node_));
}
else {
std::size_t key_hash = this->hash(k);
node_pointer position = this->find_node(key_hash, k);
this->reserve_for_insert(this->size_ + 1);
return iterator(this->add_node(a.release(), key_hash, position));
}
}
void emplace_impl_no_rehash(node_pointer n)
{
node_tmp a(n, this->node_alloc());
key_type const& k = this->get_key(a.node_->value());
std::size_t key_hash = this->hash(k);
node_pointer position = this->find_node(key_hash, k);
this->add_node(a.release(), key_hash, position);
}
////////////////////////////////////////////////////////////////////////
// Insert range methods
// if hash function throws, or inserting > 1 element, basic exception
// safety. Strong otherwise
template <class I>
void insert_range(I i, I j, typename
boost::unordered::detail::enable_if_forward<I, void*>::type = 0)
{
if(i == j) return;
std::size_t distance = static_cast<std::size_t>(std::distance(i, j));
if(distance == 1) {
emplace_impl(
boost::unordered::detail::func::construct_node(
this->node_alloc(), *i));
}
else {
// Only require basic exception safety here
this->reserve_for_insert(this->size_ + distance);
for (; i != j; ++i) {
emplace_impl_no_rehash(
boost::unordered::detail::func::construct_node(
this->node_alloc(), *i));
}
}
}
template <class I>
void insert_range(I i, I j, typename
boost::unordered::detail::disable_if_forward<I, void*>::type = 0)
{
for (; i != j; ++i) {
emplace_impl(
boost::unordered::detail::func::construct_node(
this->node_alloc(), *i));
}
}
////////////////////////////////////////////////////////////////////////
// Erase
//
// no throw
std::size_t erase_key(key_type const& k)
{
if(!this->size_) return 0;
std::size_t key_hash = this->hash(k);
std::size_t bucket_index = this->hash_to_bucket(key_hash);
link_pointer prev = this->get_previous_start(bucket_index);
if (!prev) return 0;
node_pointer first_node;
for (;;)
{
if (!prev->next_) return 0;
first_node = next_node(prev);
std::size_t node_hash = first_node->hash_;
if (this->hash_to_bucket(node_hash) != bucket_index)
return 0;
if (node_hash == key_hash &&
this->key_eq()(k, this->get_key(first_node->value())))
break;
prev = first_node->group_prev_;
}
link_pointer end = first_node->group_prev_->next_;
std::size_t deleted_count = this->delete_nodes(prev, end);
this->fix_bucket(bucket_index, prev);
return deleted_count;
}
iterator erase(c_iterator r)
{
BOOST_ASSERT(r.node_);
node_pointer next = next_node(r.node_);
erase_nodes(r.node_, next);
return iterator(next);
}
iterator erase_range(c_iterator r1, c_iterator r2)
{
if (r1 == r2) return iterator(r2.node_);
erase_nodes(r1.node_, r2.node_);
return iterator(r2.node_);
}
link_pointer erase_nodes(node_pointer i, node_pointer j)
{
std::size_t bucket_index = this->hash_to_bucket(i->hash_);
// Split the groups containing 'i' and 'j'.
// And get the pointer to the node before i while
// we're at it.
link_pointer prev = split_groups(i, j);
// If we don't have a 'prev' it means that i is at the
// beginning of a block, so search through the blocks in the
// same bucket.
if (!prev) {
prev = this->get_previous_start(bucket_index);
while (prev->next_ != i)
prev = next_node(prev)->group_prev_;
}
// Delete the nodes.
do {
link_pointer group_end = next_group(next_node(prev));
this->delete_nodes(prev, group_end);
bucket_index = this->fix_bucket(bucket_index, prev);
} while(prev->next_ != j);
return prev;
}
static link_pointer split_groups(node_pointer i, node_pointer j)
{
node_pointer prev = i->group_prev_;
if (prev->next_ != i) prev = node_pointer();
if (j) {
node_pointer first = j;
while (first != i && first->group_prev_->next_ == first) {
first = first->group_prev_;
}
boost::swap(first->group_prev_, j->group_prev_);
if (first == i) return prev;
}
if (prev) {
node_pointer first = prev;
while (first->group_prev_->next_ == first) {
first = first->group_prev_;
}
boost::swap(first->group_prev_, i->group_prev_);
}
return prev;
}
////////////////////////////////////////////////////////////////////////
// fill_buckets
void copy_buckets(table const& src) {
this->create_buckets(this->bucket_count_);
for (node_pointer n = src.begin(); n;) {
std::size_t key_hash = n->hash_;
node_pointer group_end(next_group(n));
node_pointer pos = this->add_node(
boost::unordered::detail::func::construct_node(
this->node_alloc(), n->value()), key_hash, node_pointer());
for (n = next_node(n); n != group_end; n = next_node(n))
{
this->add_node(
boost::unordered::detail::func::construct_node(
this->node_alloc(), n->value()), key_hash, pos);
}
}
}
void move_buckets(table const& src) {
this->create_buckets(this->bucket_count_);
for (node_pointer n = src.begin(); n;) {
std::size_t key_hash = n->hash_;
node_pointer group_end(next_group(n));
node_pointer pos = this->add_node(
boost::unordered::detail::func::construct_node(
this->node_alloc(), boost::move(n->value())), key_hash, node_pointer());
for (n = next_node(n); n != group_end; n = next_node(n))
{
this->add_node(
boost::unordered::detail::func::construct_node(
this->node_alloc(), boost::move(n->value())), key_hash, pos);
}
}
}
void assign_buckets(table const& src) {
node_holder<node_allocator> holder(*this);
for (node_pointer n = src.begin(); n;) {
std::size_t key_hash = n->hash_;
node_pointer group_end(next_group(n));
node_pointer pos = this->add_node(holder.copy_of(n->value()), key_hash, node_pointer());
for (n = next_node(n); n != group_end; n = next_node(n))
{
this->add_node(holder.copy_of(n->value()), key_hash, pos);
}
}
}
void move_assign_buckets(table& src) {
node_holder<node_allocator> holder(*this);
for (node_pointer n = src.begin(); n;) {
std::size_t key_hash = n->hash_;
node_pointer group_end(next_group(n));
node_pointer pos = this->add_node(holder.move_copy_of(n->value()), key_hash, node_pointer());
for (n = next_node(n); n != group_end; n = next_node(n))
{
this->add_node(holder.move_copy_of(n->value()), key_hash, pos);
}
}
}
// strong otherwise exception safety
void rehash_impl(std::size_t num_buckets)
{
BOOST_ASSERT(this->buckets_);
this->create_buckets(num_buckets);
link_pointer prev = this->get_previous_start();
while (prev->next_)
prev = place_in_bucket(*this, prev, next_node(prev)->group_prev_);
}
// Iterate through the nodes placing them in the correct buckets.
// pre: prev->next_ is not null.
static link_pointer place_in_bucket(table& dst,
link_pointer prev, node_pointer end)
{
bucket_pointer b = dst.get_bucket(dst.hash_to_bucket(end->hash_));
if (!b->next_) {
b->next_ = prev;
return end;
}
else {
link_pointer next = end->next_;
end->next_ = b->next_->next_;
b->next_->next_ = prev->next_;
prev->next_ = next;
return prev;
}
}
};
}}}
#endif
@@ -0,0 +1,162 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SNC_PS3_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SNC_PS3_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/sp_counted_base_gcc_sparc.hpp - g++ on Sparc V8+
//
// Copyright (c) 2006 Piotr Wyderski
// Copyright (c) 2006 Tomas Puverle
// Copyright (c) 2006 Peter Dimov
// Copyright (c) 2011 Emil Dotchevski
//
// 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
//
// Thanks to Michael van der Westhuizen
#include <boost/detail/sp_typeinfo.hpp>
#include <inttypes.h> // uint32_t
namespace boost
{
namespace detail
{
inline uint32_t compare_and_swap( uint32_t * dest_, uint32_t compare_, uint32_t swap_ )
{
return __builtin_cellAtomicCompareAndSwap32(dest_,compare_,swap_);
}
inline uint32_t atomic_fetch_and_add( uint32_t * pw, uint32_t dv )
{
// long r = *pw;
// *pw += dv;
// return r;
for( ;; )
{
uint32_t r = *pw;
if( __builtin_expect((compare_and_swap(pw, r, r + dv) == r), 1) )
{
return r;
}
}
}
inline void atomic_increment( uint32_t * pw )
{
(void) __builtin_cellAtomicIncr32( pw );
}
inline uint32_t atomic_decrement( uint32_t * pw )
{
return __builtin_cellAtomicDecr32( pw );
}
inline uint32_t atomic_conditional_increment( uint32_t * pw )
{
// long r = *pw;
// if( r != 0 ) ++*pw;
// return r;
for( ;; )
{
uint32_t r = *pw;
if( r == 0 )
{
return r;
}
if( __builtin_expect( ( compare_and_swap( pw, r, r + 1 ) == r ), 1 ) )
{
return r;
}
}
}
class sp_counted_base
{
private:
sp_counted_base( sp_counted_base const & );
sp_counted_base & operator= ( sp_counted_base const & );
uint32_t use_count_; // #shared
uint32_t weak_count_; // #weak + (#shared != 0)
public:
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() // nothrow
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
virtual void * get_untyped_deleter() = 0;
void add_ref_copy()
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() // nothrow
{
if( atomic_decrement( &use_count_ ) == 1 )
{
dispose();
weak_release();
}
}
void weak_add_ref() // nothrow
{
atomic_increment( &weak_count_ );
}
void weak_release() // nothrow
{
if( atomic_decrement( &weak_count_ ) == 1 )
{
destroy();
}
}
long use_count() const // nothrow
{
return const_cast< uint32_t const volatile & >( use_count_ );
}
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_COUNTED_BASE_SNC_PS3_HPP_INCLUDED
@@ -0,0 +1,81 @@
#ifndef IARU_REGIONS_HPP__
#define IARU_REGIONS_HPP__
#include <QAbstractListModel>
#include "qt_helpers.hpp"
class QString;
class QVariant;
class QModelIndex;
//
// Class IARURegions - Qt model that implements the list of IARU regions
//
//
// Responsibilities
//
// Provides a single column list model that contains the human
// readable string version of the data region in the display
// role. Also provided is a translatable column header string and
// tool tip string.
//
//
// Collaborations
//
// Implements a concrete sub-class of the QAbstractListModel class.
//
class IARURegions final
: public QAbstractListModel
{
Q_OBJECT
Q_ENUMS (Region)
public:
//
// This enumeration contains the supported regions, to complement
// this an array of human readable strings in the implementation
// (IARURegions.cpp) must be maintained in parallel.
//
enum Region
{
ALL, // matches with all regions
R1,
R2,
R3,
SENTINAL // this must be last
};
Q_ENUM (Region)
explicit IARURegions (QObject * parent = nullptr);
// translate between enumeration and human readable strings
static char const * name (Region);
static Region value (QString const&);
// Implement the QAbstractListModel interface
int rowCount (QModelIndex const& parent = QModelIndex {}) const override
{
return parent.isValid () ? 0 : SENTINAL; // Number of regionss in Region enumeration class
}
QVariant data (QModelIndex const&, int role = Qt::DisplayRole) const override;
QVariant headerData (int section, Qt::Orientation, int = Qt::DisplayRole) const override;
};
// Qt boilerplate to make the IARURegions::region enumeration a type
// that can be streamed and queued as a signal argument as well as
// showing the human readable string when output to debug streams.
#if QT_VERSION < 0x050500
// Qt 5.5 introduces the Q_ENUM macro which automatically registers
// the meta-type
Q_DECLARE_METATYPE (IARURegions::Region);
#endif
#if !defined (QT_NO_DEBUG_STREAM)
ENUM_QDEBUG_OPS_DECL (IARURegions, Region);
#endif
ENUM_QDATASTREAM_OPS_DECL (IARURegions, Region);
ENUM_CONVERSION_OPS_DECL (IARURegions, Region);
#endif
@@ -0,0 +1,13 @@
/*=============================================================================
Copyright (c) 2001-2007 Joel de Guzman
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)
==============================================================================*/
#if !defined(FUSION_INCLUDE_LIST)
#define FUSION_INCLUDE_LIST
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/container/list.hpp>
#endif
@@ -0,0 +1,134 @@
#ifndef GREG_DURATION_HPP___
#define GREG_DURATION_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <boost/date_time/date_duration.hpp>
#include <boost/date_time/int_adapter.hpp>
#include <boost/date_time/special_defs.hpp>
namespace boost {
namespace gregorian {
//!An internal date representation that includes infinities, not a date
typedef boost::date_time::duration_traits_adapted date_duration_rep;
//! Durations in days for gregorian system
/*! \ingroup date_basics
*/
class date_duration :
public boost::date_time::date_duration< date_duration_rep >
{
typedef boost::date_time::date_duration< date_duration_rep > base_type;
public:
typedef base_type::duration_rep duration_rep;
//! Construct from a day count
explicit date_duration(duration_rep day_count = 0) : base_type(day_count) {}
//! construct from special_values
date_duration(date_time::special_values sv) : base_type(sv) {}
//! Copy constructor
date_duration(const date_duration& other) : base_type(static_cast< base_type const& >(other))
{}
//! Construct from another date_duration
date_duration(const base_type& other) : base_type(other)
{}
// Relational operators
// NOTE: Because of date_time::date_duration< T > design choice we don't use Boost.Operators here,
// because we need the class to be a direct base. Either lose EBO, or define operators by hand.
// The latter is more effecient.
bool operator== (const date_duration& rhs) const
{
return base_type::operator== (rhs);
}
bool operator!= (const date_duration& rhs) const
{
return !operator== (rhs);
}
bool operator< (const date_duration& rhs) const
{
return base_type::operator< (rhs);
}
bool operator> (const date_duration& rhs) const
{
return !(base_type::operator< (rhs) || base_type::operator== (rhs));
}
bool operator<= (const date_duration& rhs) const
{
return (base_type::operator< (rhs) || base_type::operator== (rhs));
}
bool operator>= (const date_duration& rhs) const
{
return !base_type::operator< (rhs);
}
//! Subtract another duration -- result is signed
date_duration& operator-= (const date_duration& rhs)
{
base_type::operator-= (rhs);
return *this;
}
friend date_duration operator- (date_duration rhs, date_duration const& lhs)
{
rhs -= lhs;
return rhs;
}
//! Add a duration -- result is signed
date_duration& operator+= (const date_duration& rhs)
{
base_type::operator+= (rhs);
return *this;
}
friend date_duration operator+ (date_duration rhs, date_duration const& lhs)
{
rhs += lhs;
return rhs;
}
//! unary- Allows for dd = -date_duration(2); -> dd == -2
date_duration operator- ()const
{
return date_duration(get_rep() * (-1));
}
//! Division operations on a duration with an integer.
date_duration& operator/= (int divisor)
{
base_type::operator/= (divisor);
return *this;
}
friend date_duration operator/ (date_duration rhs, int lhs)
{
rhs /= lhs;
return rhs;
}
//! Returns the smallest duration -- used by to calculate 'end'
static date_duration unit()
{
return date_duration(base_type::unit().get_rep());
}
};
//! Shorthand for date_duration
typedef date_duration days;
} } //namespace gregorian
#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
#include <boost/date_time/date_duration_types.hpp>
#endif
#endif
@@ -0,0 +1,16 @@
/*
Copyright Rene Rivera 2008-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)
*/
#if !defined(BOOST_PREDEF_LIBRARY_H) || defined(BOOST_PREDEF_INTERNAL_GENERATE_TESTS)
#ifndef BOOST_PREDEF_LIBRARY_H
#define BOOST_PREDEF_LIBRARY_H
#endif
#include <boost/predef/library/c.h>
#include <boost/predef/library/std.h>
#endif
@@ -0,0 +1,73 @@
/*=============================================================================
Copyright (c) 1998-2003 Joel de Guzman
Copyright (c) 2001-2003 Daniel Nuffer
Copyright (c) 2001-2003 Hartmut Kaiser
Copyright (c) 2002-2003 Martin Wille
Copyright (c) 2002 Raghavendra Satish
Copyright (c) 2001 Bruce Florman
http://spirit.sourceforge.net/
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)
=============================================================================*/
#if !defined(BOOST_SPIRIT_CORE_MAIN_HPP)
#define BOOST_SPIRIT_CORE_MAIN_HPP
#include <boost/spirit/home/classic/version.hpp>
#include <boost/spirit/home/classic/debug.hpp>
///////////////////////////////////////////////////////////////////////////////
//
// Spirit.Core includes
//
///////////////////////////////////////////////////////////////////////////////
// Spirit.Core.Kernel
#include <boost/spirit/home/classic/core/config.hpp>
#include <boost/spirit/home/classic/core/nil.hpp>
#include <boost/spirit/home/classic/core/match.hpp>
#include <boost/spirit/home/classic/core/parser.hpp>
// Spirit.Core.Primitives
#include <boost/spirit/home/classic/core/primitives/primitives.hpp>
#include <boost/spirit/home/classic/core/primitives/numerics.hpp>
// Spirit.Core.Scanner
#include <boost/spirit/home/classic/core/scanner/scanner.hpp>
#include <boost/spirit/home/classic/core/scanner/skipper.hpp>
// Spirit.Core.NonTerminal
#include <boost/spirit/home/classic/core/non_terminal/subrule.hpp>
#include <boost/spirit/home/classic/core/non_terminal/rule.hpp>
#include <boost/spirit/home/classic/core/non_terminal/grammar.hpp>
// Spirit.Core.Composite
#include <boost/spirit/home/classic/core/composite/actions.hpp>
#include <boost/spirit/home/classic/core/composite/composite.hpp>
#include <boost/spirit/home/classic/core/composite/directives.hpp>
#include <boost/spirit/home/classic/core/composite/epsilon.hpp>
#include <boost/spirit/home/classic/core/composite/sequence.hpp>
#include <boost/spirit/home/classic/core/composite/sequential_and.hpp>
#include <boost/spirit/home/classic/core/composite/sequential_or.hpp>
#include <boost/spirit/home/classic/core/composite/alternative.hpp>
#include <boost/spirit/home/classic/core/composite/difference.hpp>
#include <boost/spirit/home/classic/core/composite/intersection.hpp>
#include <boost/spirit/home/classic/core/composite/exclusive_or.hpp>
#include <boost/spirit/home/classic/core/composite/kleene_star.hpp>
#include <boost/spirit/home/classic/core/composite/positive.hpp>
#include <boost/spirit/home/classic/core/composite/optional.hpp>
#include <boost/spirit/home/classic/core/composite/list.hpp>
#include <boost/spirit/home/classic/core/composite/no_actions.hpp>
// Deprecated interface includes
#include <boost/spirit/home/classic/actor/assign_actor.hpp>
#include <boost/spirit/home/classic/actor/push_back_actor.hpp>
#if defined(BOOST_SPIRIT_DEBUG)
//////////////////////////////////
#include <boost/spirit/home/classic/debug/parser_names.hpp>
#endif // BOOST_SPIRIT_DEBUG
#endif // BOOST_SPIRIT_CORE_MAIN_HPP
@@ -0,0 +1,45 @@
// Copyright David Abrahams 2006. 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)
#ifndef BOOST_CONCEPT_ASSERT_DWA2006430_HPP
# define BOOST_CONCEPT_ASSERT_DWA2006430_HPP
# include <boost/config.hpp>
# include <boost/detail/workaround.hpp>
// The old protocol used a constraints() member function in concept
// checking classes. If the compiler supports SFINAE, we can detect
// that function and seamlessly support the old concept checking
// classes. In this release, backward compatibility with the old
// concept checking classes is enabled by default, where available.
// The old protocol is deprecated, though, and backward compatibility
// will no longer be the default in the next release.
# if !defined(BOOST_NO_OLD_CONCEPT_SUPPORT) \
&& !defined(BOOST_NO_SFINAE) \
\
&& !(BOOST_WORKAROUND(__GNUC__, == 3) && BOOST_WORKAROUND(__GNUC_MINOR__, < 4))
// Note: gcc-2.96 through 3.3.x have some SFINAE, but no ability to
// check for the presence of particularmember functions.
# define BOOST_OLD_CONCEPT_SUPPORT
# endif
# ifdef BOOST_MSVC
# include <boost/concept/detail/msvc.hpp>
# elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# include <boost/concept/detail/borland.hpp>
# else
# include <boost/concept/detail/general.hpp>
# endif
// Usage, in class or function context:
//
// BOOST_CONCEPT_ASSERT((UnaryFunctionConcept<F,bool,int>));
//
# define BOOST_CONCEPT_ASSERT(ModelInParens) \
BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens)
#endif // BOOST_CONCEPT_ASSERT_DWA2006430_HPP
@@ -0,0 +1,3 @@
1
2
1.0
@@ -0,0 +1,76 @@
program msksim
use, intrinsic :: iso_c_binding
! To change to a new code, edit the following line and the filenames
! that contain the parity check and generator matrices.
parameter (N=198, M=126, K=72) ! M and N are global variables on the C side.
character(50) pchk_file,gen_file
integer(1) codeword(1:N), decoded(1:K), message(1:K)
real*8 lratio(N), rxdata(N)
pchk_file="./jtmode_codes/peg-198-72-irreg-8x3-2x4.pchk"
gen_file="./jtmode_codes/peg-198-72-irreg-8x3-2x4.gen"
rate=real(K)/real(N)
call init_ldpc(trim(pchk_file)//char(0),trim(gen_file)//char(0))
message(1:K/2)=1
message((K/2+1):K)=0
call ldpc_encode(message,codeword)
max_iterations=50
ntrials=1000000
write(*,*) "Eb/N0 ngood nundetected"
do idb = 0, 11
db=idb/2.0-0.5
sigma=1/sqrt( 2*rate*(10**(db/10.0)) )
ngood=0
nue=0
do itrial=1, ntrials
do i=1,N
rxdata(i) = 2.0*(codeword(i)-0.5) + sigma*gran()
enddo
! correct signal normalization is important for this decoder.
rxav=sum(rxdata)/N
rx2av=sum(rxdata*rxdata)/N
rxsig=sqrt(rx2av-rxav*rxav)
rxdata=rxdata/rxsig
! s can be tuned to trade a few tenth's dB of threshold
! for an order of magnitude in UER
do i=1,N
s=0.75
lratio(i)=exp(2.0*rxdata(i)/(s*s))
enddo
call ldpc_decode(lratio, decoded, max_iterations, niterations)
if( niterations .ge. 0 ) then
nueflag=0
do i=1,K
if( message(i) .ne. decoded(i) ) then
nueflag=1
endif
enddo
if( nueflag .eq. 1 ) then
nue=nue+1
else
ngood=ngood+1;
endif
endif
enddo
write(*,"(f4.1,1x,i8,1x,i8)") db,ngood,nue
enddo
end program msksim
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,22 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
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)
This is an auto-generated file. Do not edit!
==============================================================================*/
#if FUSION_MAX_VECTOR_SIZE <= 10
#include <boost/fusion/container/generation/detail/preprocessed/vector_tie10.hpp>
#elif FUSION_MAX_VECTOR_SIZE <= 20
#include <boost/fusion/container/generation/detail/preprocessed/vector_tie20.hpp>
#elif FUSION_MAX_VECTOR_SIZE <= 30
#include <boost/fusion/container/generation/detail/preprocessed/vector_tie30.hpp>
#elif FUSION_MAX_VECTOR_SIZE <= 40
#include <boost/fusion/container/generation/detail/preprocessed/vector_tie40.hpp>
#elif FUSION_MAX_VECTOR_SIZE <= 50
#include <boost/fusion/container/generation/detail/preprocessed/vector_tie50.hpp>
#else
#error "FUSION_MAX_VECTOR_SIZE out of bounds for preprocessed headers"
#endif
@@ -0,0 +1,326 @@
/*=============================================================================
Copyright (c) 2001-2007 Joel de Guzman
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)
==============================================================================*/
template <
typename RT
, typename T0 , typename T1
, typename A0 , typename A1
>
inline
typename detail::expression::function_eval<
detail::function_ptr<
2
, RT
, RT(*)(T0 , T1)
>
, A0 , A1
>::type const
bind(
RT(*f)(T0 , T1)
, A0 const& a0 , A1 const& a1
)
{
typedef detail::function_ptr<
2
, RT
, RT(*)(T0 , T1)
> fp_type;
return
detail::expression::function_eval<
fp_type
, A0 , A1
>::make(
fp_type(f)
, a0 , a1
);
}
template <
typename RT
, typename T0 , typename T1 , typename T2
, typename A0 , typename A1 , typename A2
>
inline
typename detail::expression::function_eval<
detail::function_ptr<
3
, RT
, RT(*)(T0 , T1 , T2)
>
, A0 , A1 , A2
>::type const
bind(
RT(*f)(T0 , T1 , T2)
, A0 const& a0 , A1 const& a1 , A2 const& a2
)
{
typedef detail::function_ptr<
3
, RT
, RT(*)(T0 , T1 , T2)
> fp_type;
return
detail::expression::function_eval<
fp_type
, A0 , A1 , A2
>::make(
fp_type(f)
, a0 , a1 , a2
);
}
template <
typename RT
, typename T0 , typename T1 , typename T2 , typename T3
, typename A0 , typename A1 , typename A2 , typename A3
>
inline
typename detail::expression::function_eval<
detail::function_ptr<
4
, RT
, RT(*)(T0 , T1 , T2 , T3)
>
, A0 , A1 , A2 , A3
>::type const
bind(
RT(*f)(T0 , T1 , T2 , T3)
, A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3
)
{
typedef detail::function_ptr<
4
, RT
, RT(*)(T0 , T1 , T2 , T3)
> fp_type;
return
detail::expression::function_eval<
fp_type
, A0 , A1 , A2 , A3
>::make(
fp_type(f)
, a0 , a1 , a2 , a3
);
}
template <
typename RT
, typename T0 , typename T1 , typename T2 , typename T3 , typename T4
, typename A0 , typename A1 , typename A2 , typename A3 , typename A4
>
inline
typename detail::expression::function_eval<
detail::function_ptr<
5
, RT
, RT(*)(T0 , T1 , T2 , T3 , T4)
>
, A0 , A1 , A2 , A3 , A4
>::type const
bind(
RT(*f)(T0 , T1 , T2 , T3 , T4)
, A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4
)
{
typedef detail::function_ptr<
5
, RT
, RT(*)(T0 , T1 , T2 , T3 , T4)
> fp_type;
return
detail::expression::function_eval<
fp_type
, A0 , A1 , A2 , A3 , A4
>::make(
fp_type(f)
, a0 , a1 , a2 , a3 , a4
);
}
template <
typename RT
, typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5
, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5
>
inline
typename detail::expression::function_eval<
detail::function_ptr<
6
, RT
, RT(*)(T0 , T1 , T2 , T3 , T4 , T5)
>
, A0 , A1 , A2 , A3 , A4 , A5
>::type const
bind(
RT(*f)(T0 , T1 , T2 , T3 , T4 , T5)
, A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5
)
{
typedef detail::function_ptr<
6
, RT
, RT(*)(T0 , T1 , T2 , T3 , T4 , T5)
> fp_type;
return
detail::expression::function_eval<
fp_type
, A0 , A1 , A2 , A3 , A4 , A5
>::make(
fp_type(f)
, a0 , a1 , a2 , a3 , a4 , a5
);
}
template <
typename RT
, typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6
, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6
>
inline
typename detail::expression::function_eval<
detail::function_ptr<
7
, RT
, RT(*)(T0 , T1 , T2 , T3 , T4 , T5 , T6)
>
, A0 , A1 , A2 , A3 , A4 , A5 , A6
>::type const
bind(
RT(*f)(T0 , T1 , T2 , T3 , T4 , T5 , T6)
, A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6
)
{
typedef detail::function_ptr<
7
, RT
, RT(*)(T0 , T1 , T2 , T3 , T4 , T5 , T6)
> fp_type;
return
detail::expression::function_eval<
fp_type
, A0 , A1 , A2 , A3 , A4 , A5 , A6
>::make(
fp_type(f)
, a0 , a1 , a2 , a3 , a4 , a5 , a6
);
}
template <
typename RT
, typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7
, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7
>
inline
typename detail::expression::function_eval<
detail::function_ptr<
8
, RT
, RT(*)(T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7)
>
, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7
>::type const
bind(
RT(*f)(T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7)
, A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7
)
{
typedef detail::function_ptr<
8
, RT
, RT(*)(T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7)
> fp_type;
return
detail::expression::function_eval<
fp_type
, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7
>::make(
fp_type(f)
, a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7
);
}
template <
typename RT
, typename T0 , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8
, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8
>
inline
typename detail::expression::function_eval<
detail::function_ptr<
9
, RT
, RT(*)(T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8)
>
, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8
>::type const
bind(
RT(*f)(T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8)
, A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8
)
{
typedef detail::function_ptr<
9
, RT
, RT(*)(T0 , T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8)
> fp_type;
return
detail::expression::function_eval<
fp_type
, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8
>::make(
fp_type(f)
, a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8
);
}
@@ -0,0 +1,124 @@
// Copyright David Abrahams 2003.
// 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)
#ifndef PURE_VIRTUAL_DWA2003810_HPP
# define PURE_VIRTUAL_DWA2003810_HPP
# include <boost/python/def_visitor.hpp>
# include <boost/python/default_call_policies.hpp>
# include <boost/mpl/push_front.hpp>
# include <boost/mpl/pop_front.hpp>
# include <boost/python/detail/nullary_function_adaptor.hpp>
namespace boost { namespace python {
namespace detail
{
//
// @group Helpers for pure_virtual_visitor. {
//
// Raises a Python RuntimeError reporting that a pure virtual
// function was called.
void BOOST_PYTHON_DECL pure_virtual_called();
// Replace the two front elements of S with T1 and T2
template <class S, class T1, class T2>
struct replace_front2
{
// Metafunction forwarding seemed to confound vc6
typedef typename mpl::push_front<
typename mpl::push_front<
typename mpl::pop_front<
typename mpl::pop_front<
S
>::type
>::type
, T2
>::type
, T1
>::type type;
};
// Given an MPL sequence representing a member function [object]
// signature, returns a new MPL sequence whose return type is
// replaced by void, and whose first argument is replaced by C&.
template <class C, class S>
typename replace_front2<S,void,C&>::type
error_signature(S)
{
typedef typename replace_front2<S,void,C&>::type r;
return r();
}
//
// }
//
//
// A def_visitor which defines a method as usual, then adds a
// corresponding function which raises a "pure virtual called"
// exception unless it's been overridden.
//
template <class PointerToMemberFunction>
struct pure_virtual_visitor
: def_visitor<pure_virtual_visitor<PointerToMemberFunction> >
{
pure_virtual_visitor(PointerToMemberFunction pmf)
: m_pmf(pmf)
{}
private:
friend class python::def_visitor_access;
template <class C_, class Options>
void visit(C_& c, char const* name, Options& options) const
{
// This should probably be a nicer error message
BOOST_STATIC_ASSERT(!Options::has_default_implementation);
// Add the virtual function dispatcher
c.def(
name
, m_pmf
, options.doc()
, options.keywords()
, options.policies()
);
typedef BOOST_DEDUCED_TYPENAME C_::metadata::held_type held_type;
// Add the default implementation which raises the exception
c.def(
name
, make_function(
detail::nullary_function_adaptor<void(*)()>(pure_virtual_called)
, default_call_policies()
, detail::error_signature<held_type>(detail::get_signature(m_pmf))
)
);
}
private: // data members
PointerToMemberFunction m_pmf;
};
}
//
// Passed a pointer to member function, generates a def_visitor which
// creates a method that only dispatches to Python if the function has
// been overridden, either in C++ or in Python, raising a "pure
// virtual called" exception otherwise.
//
template <class PointerToMemberFunction>
detail::pure_virtual_visitor<PointerToMemberFunction>
pure_virtual(PointerToMemberFunction pmf)
{
return detail::pure_virtual_visitor<PointerToMemberFunction>(pmf);
}
}} // namespace boost::python
#endif // PURE_VIRTUAL_DWA2003810_HPP
@@ -0,0 +1,558 @@
// Copyright Aleksey Gurtovoy 2001-2004
//
// 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)
//
// Preprocessed version of "boost/mpl/aux_/full_lambda.hpp" header
// -- DO NOT modify by hand!
namespace boost { namespace mpl {
namespace aux {
template<
bool C1 = false, bool C2 = false, bool C3 = false, bool C4 = false
, bool C5 = false
>
struct lambda_or
: true_
{
};
template<>
struct lambda_or< false,false,false,false,false >
: false_
{
};
} // namespace aux
template<
typename T
, typename Tag
, typename Arity
>
struct lambda
{
typedef false_ is_le;
typedef T result_;
typedef T type;
};
template<
typename T
>
struct is_lambda_expression
: lambda<T>::is_le
{
};
template< int N, typename Tag >
struct lambda< arg<N>,Tag, int_< -1 > >
{
typedef true_ is_le;
typedef mpl::arg<N> result_; // qualified for the sake of MIPSpro 7.41
typedef mpl::protect<result_> type;
};
template<
typename F
, typename Tag
>
struct lambda<
bind0<F>
, Tag
, int_<1>
>
{
typedef false_ is_le;
typedef bind0<
F
> result_;
typedef result_ type;
};
namespace aux {
template<
typename IsLE, typename Tag
, template< typename P1 > class F
, typename L1
>
struct le_result1
{
typedef F<
typename L1::type
> result_;
typedef result_ type;
};
template<
typename Tag
, template< typename P1 > class F
, typename L1
>
struct le_result1< true_,Tag,F,L1 >
{
typedef bind1<
quote1< F,Tag >
, typename L1::result_
> result_;
typedef mpl::protect<result_> type;
};
} // namespace aux
template<
template< typename P1 > class F
, typename T1
, typename Tag
>
struct lambda<
F<T1>
, Tag
, int_<1>
>
{
typedef lambda< T1,Tag > l1;
typedef typename l1::is_le is_le1;
typedef typename aux::lambda_or<
is_le1::value
>::type is_le;
typedef aux::le_result1<
is_le, Tag, F, l1
> le_result_;
typedef typename le_result_::result_ result_;
typedef typename le_result_::type type;
};
template<
typename F, typename T1
, typename Tag
>
struct lambda<
bind1< F,T1 >
, Tag
, int_<2>
>
{
typedef false_ is_le;
typedef bind1<
F
, T1
> result_;
typedef result_ type;
};
namespace aux {
template<
typename IsLE, typename Tag
, template< typename P1, typename P2 > class F
, typename L1, typename L2
>
struct le_result2
{
typedef F<
typename L1::type, typename L2::type
> result_;
typedef result_ type;
};
template<
typename Tag
, template< typename P1, typename P2 > class F
, typename L1, typename L2
>
struct le_result2< true_,Tag,F,L1,L2 >
{
typedef bind2<
quote2< F,Tag >
, typename L1::result_, typename L2::result_
> result_;
typedef mpl::protect<result_> type;
};
} // namespace aux
template<
template< typename P1, typename P2 > class F
, typename T1, typename T2
, typename Tag
>
struct lambda<
F< T1,T2 >
, Tag
, int_<2>
>
{
typedef lambda< T1,Tag > l1;
typedef lambda< T2,Tag > l2;
typedef typename l1::is_le is_le1;
typedef typename l2::is_le is_le2;
typedef typename aux::lambda_or<
is_le1::value, is_le2::value
>::type is_le;
typedef aux::le_result2<
is_le, Tag, F, l1, l2
> le_result_;
typedef typename le_result_::result_ result_;
typedef typename le_result_::type type;
};
template<
typename F, typename T1, typename T2
, typename Tag
>
struct lambda<
bind2< F,T1,T2 >
, Tag
, int_<3>
>
{
typedef false_ is_le;
typedef bind2<
F
, T1, T2
> result_;
typedef result_ type;
};
namespace aux {
template<
typename IsLE, typename Tag
, template< typename P1, typename P2, typename P3 > class F
, typename L1, typename L2, typename L3
>
struct le_result3
{
typedef F<
typename L1::type, typename L2::type, typename L3::type
> result_;
typedef result_ type;
};
template<
typename Tag
, template< typename P1, typename P2, typename P3 > class F
, typename L1, typename L2, typename L3
>
struct le_result3< true_,Tag,F,L1,L2,L3 >
{
typedef bind3<
quote3< F,Tag >
, typename L1::result_, typename L2::result_, typename L3::result_
> result_;
typedef mpl::protect<result_> type;
};
} // namespace aux
template<
template< typename P1, typename P2, typename P3 > class F
, typename T1, typename T2, typename T3
, typename Tag
>
struct lambda<
F< T1,T2,T3 >
, Tag
, int_<3>
>
{
typedef lambda< T1,Tag > l1;
typedef lambda< T2,Tag > l2;
typedef lambda< T3,Tag > l3;
typedef typename l1::is_le is_le1;
typedef typename l2::is_le is_le2;
typedef typename l3::is_le is_le3;
typedef typename aux::lambda_or<
is_le1::value, is_le2::value, is_le3::value
>::type is_le;
typedef aux::le_result3<
is_le, Tag, F, l1, l2, l3
> le_result_;
typedef typename le_result_::result_ result_;
typedef typename le_result_::type type;
};
template<
typename F, typename T1, typename T2, typename T3
, typename Tag
>
struct lambda<
bind3< F,T1,T2,T3 >
, Tag
, int_<4>
>
{
typedef false_ is_le;
typedef bind3<
F
, T1, T2, T3
> result_;
typedef result_ type;
};
namespace aux {
template<
typename IsLE, typename Tag
, template< typename P1, typename P2, typename P3, typename P4 > class F
, typename L1, typename L2, typename L3, typename L4
>
struct le_result4
{
typedef F<
typename L1::type, typename L2::type, typename L3::type
, typename L4::type
> result_;
typedef result_ type;
};
template<
typename Tag
, template< typename P1, typename P2, typename P3, typename P4 > class F
, typename L1, typename L2, typename L3, typename L4
>
struct le_result4< true_,Tag,F,L1,L2,L3,L4 >
{
typedef bind4<
quote4< F,Tag >
, typename L1::result_, typename L2::result_, typename L3::result_
, typename L4::result_
> result_;
typedef mpl::protect<result_> type;
};
} // namespace aux
template<
template< typename P1, typename P2, typename P3, typename P4 > class F
, typename T1, typename T2, typename T3, typename T4
, typename Tag
>
struct lambda<
F< T1,T2,T3,T4 >
, Tag
, int_<4>
>
{
typedef lambda< T1,Tag > l1;
typedef lambda< T2,Tag > l2;
typedef lambda< T3,Tag > l3;
typedef lambda< T4,Tag > l4;
typedef typename l1::is_le is_le1;
typedef typename l2::is_le is_le2;
typedef typename l3::is_le is_le3;
typedef typename l4::is_le is_le4;
typedef typename aux::lambda_or<
is_le1::value, is_le2::value, is_le3::value, is_le4::value
>::type is_le;
typedef aux::le_result4<
is_le, Tag, F, l1, l2, l3, l4
> le_result_;
typedef typename le_result_::result_ result_;
typedef typename le_result_::type type;
};
template<
typename F, typename T1, typename T2, typename T3, typename T4
, typename Tag
>
struct lambda<
bind4< F,T1,T2,T3,T4 >
, Tag
, int_<5>
>
{
typedef false_ is_le;
typedef bind4<
F
, T1, T2, T3, T4
> result_;
typedef result_ type;
};
namespace aux {
template<
typename IsLE, typename Tag
, template< typename P1, typename P2, typename P3, typename P4, typename P5 > class F
, typename L1, typename L2, typename L3, typename L4, typename L5
>
struct le_result5
{
typedef F<
typename L1::type, typename L2::type, typename L3::type
, typename L4::type, typename L5::type
> result_;
typedef result_ type;
};
template<
typename Tag
, template< typename P1, typename P2, typename P3, typename P4, typename P5 > class F
, typename L1, typename L2, typename L3, typename L4, typename L5
>
struct le_result5< true_,Tag,F,L1,L2,L3,L4,L5 >
{
typedef bind5<
quote5< F,Tag >
, typename L1::result_, typename L2::result_, typename L3::result_
, typename L4::result_, typename L5::result_
> result_;
typedef mpl::protect<result_> type;
};
} // namespace aux
template<
template<
typename P1, typename P2, typename P3, typename P4
, typename P5
>
class F
, typename T1, typename T2, typename T3, typename T4, typename T5
, typename Tag
>
struct lambda<
F< T1,T2,T3,T4,T5 >
, Tag
, int_<5>
>
{
typedef lambda< T1,Tag > l1;
typedef lambda< T2,Tag > l2;
typedef lambda< T3,Tag > l3;
typedef lambda< T4,Tag > l4;
typedef lambda< T5,Tag > l5;
typedef typename l1::is_le is_le1;
typedef typename l2::is_le is_le2;
typedef typename l3::is_le is_le3;
typedef typename l4::is_le is_le4;
typedef typename l5::is_le is_le5;
typedef typename aux::lambda_or<
is_le1::value, is_le2::value, is_le3::value, is_le4::value
, is_le5::value
>::type is_le;
typedef aux::le_result5<
is_le, Tag, F, l1, l2, l3, l4, l5
> le_result_;
typedef typename le_result_::result_ result_;
typedef typename le_result_::type type;
};
template<
typename F, typename T1, typename T2, typename T3, typename T4
, typename T5
, typename Tag
>
struct lambda<
bind5< F,T1,T2,T3,T4,T5 >
, Tag
, int_<6>
>
{
typedef false_ is_le;
typedef bind5<
F
, T1, T2, T3, T4, T5
> result_;
typedef result_ type;
};
/// special case for 'protect'
template< typename T, typename Tag >
struct lambda< mpl::protect<T>,Tag, int_<1> >
{
typedef false_ is_le;
typedef mpl::protect<T> result_;
typedef result_ type;
};
/// specializations for the main 'bind' form
template<
typename F, typename T1, typename T2, typename T3, typename T4
, typename T5
, typename Tag
>
struct lambda<
bind< F,T1,T2,T3,T4,T5 >
, Tag
, int_<6>
>
{
typedef false_ is_le;
typedef bind< F,T1,T2,T3,T4,T5 > result_;
typedef result_ type;
};
template<
typename F
, typename Tag1
, typename Tag2
, typename Arity
>
struct lambda<
lambda< F,Tag1,Arity >
, Tag2
, int_<3>
>
{
typedef lambda< F,Tag2 > l1;
typedef lambda< Tag1,Tag2 > l2;
typedef typename l1::is_le is_le;
typedef bind1< quote1<aux::template_arity>, typename l1::result_ > arity_;
typedef lambda< typename if_< is_le,arity_,Arity >::type, Tag2 > l3;
typedef aux::le_result3<is_le, Tag2, mpl::lambda, l1, l2, l3> le_result_;
typedef typename le_result_::result_ result_;
typedef typename le_result_::type type;
};
BOOST_MPL_AUX_NA_SPEC2(2, 3, lambda)
}}
@@ -0,0 +1,399 @@
///////////////////////////////////////////////////////////////
// Copyright 2012 John Maddock. 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_
//
// Comparison operators for cpp_int_backend:
//
#ifndef BOOST_MP_CPP_INT_COMPARISON_HPP
#define BOOST_MP_CPP_INT_COMPARISON_HPP
#include <boost/type_traits/make_unsigned.hpp>
namespace boost{ namespace multiprecision{ namespace backends{
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4018 4389 4996)
#endif
//
// Start with non-trivial cpp_int's:
//
template <unsigned MinBits, unsigned MaxBits, cpp_integer_type SignType, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator> >::value,
bool
>::type
eval_eq(const cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>& a, const cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>& b) BOOST_NOEXCEPT
{
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
return (a.sign() == b.sign())
&& (a.size() == b.size())
&& std::equal(a.limbs(), a.limbs() + a.size(),
stdext::checked_array_iterator<cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>::const_limb_pointer>(b.limbs(), b.size()));
#else
return (a.sign() == b.sign())
&& (a.size() == b.size())
&& std::equal(a.limbs(), a.limbs() + a.size(), b.limbs());
#endif
}
template <unsigned MinBits1, unsigned MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1, unsigned MinBits2, unsigned MaxBits2, cpp_integer_type SignType2, cpp_int_check_type Checked2, class Allocator2>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value
&& !is_trivial_cpp_int<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2> >::value,
bool
>::type
eval_eq(const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& a, const cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>& b) BOOST_NOEXCEPT
{
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
return (a.sign() == b.sign())
&& (a.size() == b.size())
&& std::equal(a.limbs(), a.limbs() + a.size(), stdext::checked_array_iterator<cpp_int_backend<MinBits2, MaxBits2, SignType2, Checked2, Allocator2>::const_limb_pointer>(b.limbs(), b.size()));
#else
return (a.sign() == b.sign())
&& (a.size() == b.size())
&& std::equal(a.limbs(), a.limbs() + a.size(), b.limbs());
#endif
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator> >::value,
bool
>::type eval_eq(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator>& a, limb_type b) BOOST_NOEXCEPT
{
return (a.sign() == false)
&& (a.size() == 1)
&& (*a.limbs() == b);
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator> >::value,
bool
>::type eval_eq(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator>& a, signed_limb_type b) BOOST_NOEXCEPT
{
return (a.sign() == (b < 0))
&& (a.size() == 1)
&& (*a.limbs() == boost::multiprecision::detail::unsigned_abs(b));
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator> >::value,
bool
>::type eval_eq(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator>& a, limb_type b) BOOST_NOEXCEPT
{
return (a.size() == 1)
&& (*a.limbs() == b);
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator> >::value,
bool
>::type eval_eq(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator>& a, signed_limb_type b) BOOST_NOEXCEPT
{
return (b < 0) ? eval_eq(a, cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator>(b)) : eval_eq(a, static_cast<limb_type>(b)); // Use bit pattern of b for comparison
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator> >::value,
bool
>::type eval_lt(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator>& a, limb_type b) BOOST_NOEXCEPT
{
if(a.sign())
return true;
if(a.size() > 1)
return false;
return *a.limbs() < b;
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
inline typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator> >::value,
bool
>::type eval_lt(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator>& a, signed_limb_type b) BOOST_NOEXCEPT
{
if((b == 0) || (a.sign() != (b < 0)))
return a.sign();
if(a.sign())
{
if(a.size() > 1)
return true;
return *a.limbs() > boost::multiprecision::detail::unsigned_abs(b);
}
else
{
if(a.size() > 1)
return false;
return *a.limbs() < boost::multiprecision::detail::unsigned_abs(b);
}
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator> >::value,
bool
>::type eval_lt(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator>& a, limb_type b) BOOST_NOEXCEPT
{
if(a.size() > 1)
return false;
return *a.limbs() < b;
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator> >::value,
bool
>::type eval_lt(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator>& a, signed_limb_type b) BOOST_NOEXCEPT
{
return (b < 0) ? a.compare(b) < 0 : eval_lt(a, static_cast<limb_type>(b)); // Use bit pattern of b for comparison
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator> >::value,
bool
>::type eval_gt(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator>& a, limb_type b) BOOST_NOEXCEPT
{
if(a.sign())
return false;
if(a.size() > 1)
return true;
return *a.limbs() > b;
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
inline typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator> >::value,
bool
>::type eval_gt(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, Allocator>& a, signed_limb_type b) BOOST_NOEXCEPT
{
if(b == 0)
return !a.sign() && ((a.size() > 1) || *a.limbs());
if(a.sign() != (b < 0))
return !a.sign();
if(a.sign())
{
if(a.size() > 1)
return false;
return *a.limbs() < boost::multiprecision::detail::unsigned_abs(b);
}
else
{
if(a.size() > 1)
return true;
return *a.limbs() > boost::multiprecision::detail::unsigned_abs(b);
}
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator> >::value,
bool
>::type eval_gt(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator>& a, limb_type b) BOOST_NOEXCEPT
{
if(a.size() > 1)
return true;
return *a.limbs() > b;
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class Allocator>
BOOST_MP_FORCEINLINE typename enable_if_c<
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator> >::value,
bool
>::type eval_gt(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, Allocator>& a, signed_limb_type b) BOOST_NOEXCEPT
{
return (b < 0) ? a.compare(b) > 0 : eval_gt(a, static_cast<limb_type>(b)); // Use bit pattern of b for comparison.
}
//
// And again for trivial cpp_ints:
//
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void> >::value,
bool
>::value eval_eq(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& a, const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& b) BOOST_NOEXCEPT
{
return (a.sign() == b.sign()) && (*a.limbs() == *b.limbs());
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> >::value,
bool
>::value eval_eq(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& a, const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& b) BOOST_NOEXCEPT
{
return *a.limbs() == *b.limbs();
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class U>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_unsigned<U>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void> >::value,
bool
>::type eval_eq(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& a, U b) BOOST_NOEXCEPT
{
return !a.sign() && (*a.limbs() == b);
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class S>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_signed<S>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void> >::value,
bool
>::type eval_eq(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& a, S b) BOOST_NOEXCEPT
{
return (a.sign() == (b < 0)) && (*a.limbs() == boost::multiprecision::detail::unsigned_abs(b));
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class U>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_unsigned<U>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> >::value,
bool
>::type eval_eq(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& a, U b) BOOST_NOEXCEPT
{
return *a.limbs() == b;
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class S>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_signed<S>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> >::value,
bool
>::type eval_eq(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& a, S b) BOOST_NOEXCEPT
{
typedef typename make_unsigned<S>::type ui_type;
if(b < 0)
{
cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> t(b);
return *a.limbs() == *t.limbs();
}
else
{
return *a.limbs() == static_cast<ui_type>(b);
}
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void> >::value,
bool
>::type eval_lt(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& a, const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& b) BOOST_NOEXCEPT
{
if(a.sign() != b.sign())
return a.sign();
return a.sign() ? *a.limbs() > *b.limbs() : *a.limbs() < *b.limbs();
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> >::value,
bool
>::type eval_lt(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& a, const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& b) BOOST_NOEXCEPT
{
return *a.limbs() < *b.limbs();
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class U>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_unsigned<U>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void> >::value,
bool
>::type eval_lt(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& a, U b) BOOST_NOEXCEPT
{
if(a.sign())
return true;
return *a.limbs() < b;
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class S>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_signed<S>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void> >::value,
bool
>::type eval_lt(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& a, S b) BOOST_NOEXCEPT
{
if(a.sign() != (b < 0))
return a.sign();
return a.sign() ? (*a.limbs() > boost::multiprecision::detail::unsigned_abs(b)) : (*a.limbs() < boost::multiprecision::detail::unsigned_abs(b));
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class U>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_unsigned<U>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> >::value,
bool
>::type eval_lt(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& a, U b) BOOST_NOEXCEPT
{
return *a.limbs() < b;
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class S>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_signed<S>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> >::value,
bool
>::type eval_lt(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& a, S b) BOOST_NOEXCEPT
{
typedef typename make_unsigned<S>::type ui_type;
if(b < 0)
{
cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> t(b);
return *a.limbs() < *t.limbs();
}
else
{
return *a.limbs() < static_cast<ui_type>(b);
}
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void> >::value,
bool
>::type eval_gt(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& a, const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& b) BOOST_NOEXCEPT
{
if(a.sign() != b.sign())
return !a.sign();
return a.sign() ? *a.limbs() < *b.limbs() : *a.limbs() > *b.limbs();
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> >::value,
bool
>::type eval_gt(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& a, const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& b) BOOST_NOEXCEPT
{
return *a.limbs() > *b.limbs();
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class U>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_unsigned<U>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void> >::value,
bool
>::type eval_gt(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& a, U b) BOOST_NOEXCEPT
{
if(a.sign())
return false;
return *a.limbs() > b;
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class S>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_signed<S>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void> >::value,
bool
>::type eval_gt(const cpp_int_backend<MinBits, MaxBits, signed_magnitude, Checked, void>& a, S b) BOOST_NOEXCEPT
{
if(a.sign() != (b < 0))
return !a.sign();
return a.sign() ? (*a.limbs() < boost::multiprecision::detail::unsigned_abs(b)) : (*a.limbs() > boost::multiprecision::detail::unsigned_abs(b));
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class U>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_unsigned<U>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> >::value,
bool
>::type eval_gt(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& a, U b) BOOST_NOEXCEPT
{
return *a.limbs() > b;
}
template <unsigned MinBits, unsigned MaxBits, cpp_int_check_type Checked, class S>
BOOST_MP_FORCEINLINE typename enable_if_c<
is_signed<S>::value && is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> >::value,
bool
>::type eval_gt(const cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void>& a, S b) BOOST_NOEXCEPT
{
typedef typename make_unsigned<S>::type ui_type;
if(b < 0)
{
cpp_int_backend<MinBits, MaxBits, unsigned_magnitude, Checked, void> t(b);
return *a.limbs() > *t.limbs();
}
else
{
return *a.limbs() > static_cast<ui_type>(b);
}
}
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
}}} // namespaces
#endif
@@ -0,0 +1,27 @@
Type 1 Prefixes and Suffixes:
1A 1S 3A 3B6 3B8 3B9 3C 3C0 3D2 3D2C 3D2R 3DA 3V 3W 3X
3Y 3YB 3YP 4J 4L 4S 4U1I 4U1U 4W 4X 5A 5B 5H 5N 5R
5T 5U 5V 5W 5X 5Z 6W 6Y 7O 7P 7Q 7X 8P 8Q 8R
9A 9G 9H 9J 9K 9L 9M2 9M6 9N 9Q 9U 9V 9X 9Y A2
A3 A4 A5 A6 A7 A9 AP BS7 BV BV9 BY C2 C3 C5 C6
C9 CE CE0X CE0Y CE0Z CE9 CM CN CP CT CT3 CU CX CY0 CY9
D2 D4 D6 DL DU E3 E4 EA EA6 EA8 EA9 EI EK EL EP
ER ES ET EU EX EY EZ F FG FH FJ FK FKC FM FO
FOA FOC FOM FP FR FRG FRJ FRT FT5W FT5X FT5Z FW FY M MD
MI MJ MM MU MW H4 H40 HA HB HB0 HC HC8 HH HI HK
HK0A HK0M HL HM HP HR HS HV HZ I IS IS0 J2 J3 J5
J6 J7 J8 JA JDM JDO JT JW JX JY K KG4 KH0 KH1 KH2
KH3 KH4 KH5 KH5K KH6 KH7 KH8 KH9 KL KP1 KP2 KP4 KP5 LA LU
LX LY LZ OA OD OE OH OH0 OJ0 OK OM ON OX OY OZ
P2 P4 PA PJ2 PJ7 PY PY0F PT0S PY0T PZ R1F R1M S0 S2 S5
S7 S9 SM SP ST SU SV SVA SV5 SV9 T2 T30 T31 T32 T33
T5 T7 T8 T9 TA TF TG TI TI9 TJ TK TL TN TR TT
TU TY TZ UA UA2 UA9 UK UN UR V2 V3 V4 V5 V6 V7
V8 VE VK VK0H VK0M VK9C VK9L VK9M VK9N VK9W VK9X VP2E VP2M VP2V VP5
VP6 VP6D VP8 VP8G VP8H VP8O VP8S VP9 VQ9 VR VU VU4 VU7 XE XF4
XT XU XW XX9 XZ YA YB YI YJ YK YL YN YO YS YU
YV YV0 Z2 Z3 ZA ZB ZC4 ZD7 ZD8 ZD9 ZF ZK1N ZK1S ZK2 ZK3
ZL ZL7 ZL8 ZL9 ZP ZS ZS8 KC4 E5
Short-list of Add-on Suffixes: /0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /A /P
@@ -0,0 +1,33 @@
#ifndef BOOST_MPL_LIST_AUX_SIZE_HPP_INCLUDED
#define BOOST_MPL_LIST_AUX_SIZE_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2000-2004
//
// 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)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id$
// $Date$
// $Revision$
#include <boost/mpl/size_fwd.hpp>
#include <boost/mpl/list/aux_/tag.hpp>
namespace boost { namespace mpl {
template<>
struct size_impl< aux::list_tag >
{
template< typename List > struct apply
: List::size
{
};
};
}}
#endif // BOOST_MPL_LIST_AUX_SIZE_HPP_INCLUDED
@@ -0,0 +1,69 @@
/*=============================================================================
Copyright (c) 2005-2012 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
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)
==============================================================================*/
#if !defined(BOOST_PP_IS_ITERATING)
#if !defined(BOOST_FUSION_SEQUENCE_DEQUE_DETAIL_DEQUE_FORWARD_CTOR_04122006_2212)
#define BOOST_FUSION_SEQUENCE_DEQUE_DETAIL_DEQUE_FORWARD_CTOR_04122006_2212
#if defined(BOOST_FUSION_HAS_VARIADIC_DEQUE)
#error "C++03 only! This file should not have been included"
#endif
#define FUSION_DEQUE_FORWARD_CTOR_FORWARD(z, n, _) BOOST_FUSION_FWD_ELEM(T_##n, t##n)
#include <boost/preprocessor/iterate.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#define BOOST_PP_FILENAME_1 \
<boost/fusion/container/deque/detail/cpp03/deque_forward_ctor.hpp>
#define BOOST_PP_ITERATION_LIMITS (2, FUSION_MAX_DEQUE_SIZE)
#include BOOST_PP_ITERATE()
#undef FUSION_DEQUE_FORWARD_CTOR_FORWARD
#endif
#else
#define N BOOST_PP_ITERATION()
#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
FUSION_HASH if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#endif
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
(defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
deque(BOOST_PP_ENUM_BINARY_PARAMS(N, typename detail::call_param<T, >::type t))
: base(detail::deque_keyed_values<BOOST_PP_ENUM_PARAMS(N, T)>::construct(BOOST_PP_ENUM_PARAMS(N, t)))
{}
#endif
#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
FUSION_HASH endif
#endif
#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
FUSION_HASH if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#endif
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
(defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES))
BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
deque(BOOST_PP_ENUM_BINARY_PARAMS(N, T, const& t))
: base(detail::deque_keyed_values<BOOST_PP_ENUM_PARAMS(N, T)>::construct(BOOST_PP_ENUM_PARAMS(N, t)))
{}
template <BOOST_PP_ENUM_PARAMS(N, typename T_)>
BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
deque(BOOST_PP_ENUM_BINARY_PARAMS(N, T_, && t))
: base(detail::deque_keyed_values<BOOST_PP_ENUM_PARAMS(N, T)>::
forward_(BOOST_PP_ENUM(N, FUSION_DEQUE_FORWARD_CTOR_FORWARD, _)))
{}
#endif
#if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
FUSION_HASH endif
#endif
#undef N
#endif
@@ -0,0 +1,87 @@
#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// Copyright (c) 2008 Peter Dimov
//
// 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)
//
#include <boost/smart_ptr/detail/yield_k.hpp>
#if defined( __ia64__ ) && defined( __INTEL_COMPILER )
# include <ia64intrin.h>
#endif
namespace boost
{
namespace detail
{
class spinlock
{
public:
int v_;
public:
bool try_lock()
{
int r = __sync_lock_test_and_set( &v_, 1 );
return r == 0;
}
void lock()
{
for( unsigned k = 0; !try_lock(); ++k )
{
boost::detail::yield( k );
}
}
void unlock()
{
__sync_lock_release( &v_ );
}
public:
class scoped_lock
{
private:
spinlock & sp_;
scoped_lock( scoped_lock const & );
scoped_lock & operator=( scoped_lock const & );
public:
explicit scoped_lock( spinlock & sp ): sp_( sp )
{
sp.lock();
}
~scoped_lock()
{
sp_.unlock();
}
};
};
} // namespace detail
} // namespace boost
#define BOOST_DETAIL_SPINLOCK_INIT {0}
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_SYNC_HPP_INCLUDED