mirror of
https://github.com/boostorg/detail.git
synced 2025-06-27 21:11:07 +02:00
Compare commits
45 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
4a1d892184 | |||
a4eef8ff7d | |||
c5dc10b3c4 | |||
00e723fba0 | |||
c2192c4caf | |||
097a256c16 | |||
badf2c8a79 | |||
91672171a6 | |||
812c32a5a1 | |||
7dbb57bc82 | |||
7247d512f8 | |||
6a458a381b | |||
c888037399 | |||
8c3a497ec8 | |||
cad13ace57 | |||
3911d7a669 | |||
23850d984a | |||
da8fe765fd | |||
d425f1e5bf | |||
3178938f98 | |||
de4c1b2e9d | |||
770e33343a | |||
a63bc49cfb | |||
472ca5d636 | |||
1588a4a05f | |||
aaf3c4ac98 | |||
816cad7bd8 | |||
d2ce3c5791 | |||
120abc637c | |||
34684d4df2 | |||
20ab8a4e7d | |||
c6024a4ac4 | |||
da0f568852 | |||
18dbae4700 | |||
06946f6607 | |||
3c2c779258 | |||
7c911e570f | |||
96b53f28a8 | |||
7e259580c1 | |||
3d539b76df | |||
e4054d843a | |||
9dcdea9efc | |||
715c05005f | |||
6443246b4b | |||
82bda71faa |
@ -15,9 +15,11 @@
|
||||
|
||||
#include "boost/blank_fwd.hpp"
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
#include <iosfwd> // for std::basic_ostream forward declare
|
||||
|
||||
#include "boost/detail/templated_streams.hpp"
|
||||
#endif // BOOST_NO_IOSTREAM
|
||||
|
||||
#include "boost/mpl/bool.hpp"
|
||||
#include "boost/type_traits/is_empty.hpp"
|
||||
#include "boost/type_traits/is_pod.hpp"
|
||||
@ -85,6 +87,8 @@ inline bool operator>(const blank&, const blank&)
|
||||
|
||||
// streaming support
|
||||
//
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
BOOST_TEMPLATED_STREAM_TEMPLATE(E,T)
|
||||
inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
|
||||
BOOST_TEMPLATED_STREAM(ostream, E,T)& out
|
||||
@ -95,6 +99,8 @@ inline BOOST_TEMPLATED_STREAM(ostream, E,T)& operator<<(
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_IOSTREAM
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_BLANK_HPP
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright 2003-2007 Joaqu<EFBFBD>n M L<EFBFBD>pez Mu<EFBFBD>oz.
|
||||
/* Copyright 2003-2009 Joaquin M Lopez Munoz.
|
||||
* 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)
|
||||
@ -178,12 +178,31 @@ void construct(void* p,const Type& t)
|
||||
new (p) Type(t);
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
|
||||
/* MSVC++ issues spurious warnings about unreferencend formal parameters
|
||||
* in destroy<Type> when Type is a class with trivial dtor.
|
||||
*/
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4100)
|
||||
#endif
|
||||
|
||||
template<typename Type>
|
||||
void destroy(const Type* p)
|
||||
{
|
||||
|
||||
#if BOOST_WORKAROUND(__SUNPRO_CC,BOOST_TESTED_AT(0x590))
|
||||
const_cast<Type*>(p)->~Type();
|
||||
#else
|
||||
p->~Type();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
} /* namespace boost::detail::allocator */
|
||||
|
||||
} /* namespace boost::detail */
|
||||
|
101
include/boost/detail/container_fwd.hpp
Normal file
101
include/boost/detail/container_fwd.hpp
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
#if !defined(BOOST_DETAIL_CONTAINER_FWD_HPP)
|
||||
#define BOOST_DETAIL_CONTAINER_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if defined(BOOST_DETAIL_NO_CONTAINER_FWD) \
|
||||
|| ((defined(__GLIBCPP__) || defined(__GLIBCXX__)) \
|
||||
&& (defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL))) \
|
||||
|| BOOST_WORKAROUND(__BORLANDC__, > 0x551) \
|
||||
|| BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x842)) \
|
||||
|| (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION))
|
||||
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <bitset>
|
||||
#include <string>
|
||||
#include <complex>
|
||||
|
||||
#else
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && \
|
||||
defined(__STL_CONFIG_H)
|
||||
|
||||
#define BOOST_CONTAINER_FWD_BAD_BITSET
|
||||
|
||||
#if !defined(__STL_NON_TYPE_TMPL_PARAM_BUG)
|
||||
#define BOOST_CONTAINER_FWD_BAD_DEQUE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_CONTAINER_FWD_BAD_DEQUE)
|
||||
#include <deque>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_CONTAINER_FWD_BAD_BITSET)
|
||||
#include <bitset>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4099) // struct/class mismatch in fwd declarations
|
||||
#endif
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <class T> class allocator;
|
||||
template <class charT, class traits, class Allocator> class basic_string;
|
||||
|
||||
#if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||
template <class charT> struct string_char_traits;
|
||||
#else
|
||||
template <class charT> struct char_traits;
|
||||
#endif
|
||||
|
||||
template <class T> class complex;
|
||||
}
|
||||
|
||||
// gcc 3.4 and greater
|
||||
namespace std
|
||||
{
|
||||
#if !defined(BOOST_CONTAINER_FWD_BAD_DEQUE)
|
||||
template <class T, class Allocator> class deque;
|
||||
#endif
|
||||
|
||||
template <class T, class Allocator> class list;
|
||||
template <class T, class Allocator> class vector;
|
||||
template <class Key, class T, class Compare, class Allocator> class map;
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
class multimap;
|
||||
template <class Key, class Compare, class Allocator> class set;
|
||||
template <class Key, class Compare, class Allocator> class multiset;
|
||||
|
||||
#if !defined(BOOST_CONTAINER_FWD_BAD_BITSET)
|
||||
template <size_t N> class bitset;
|
||||
#endif
|
||||
template <class T1, class T2> struct pair;
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
// Copyright 2005 Caleb Epstein
|
||||
// Copyright 2006 John Maddock
|
||||
// Copyright 2010 Rene Rivera
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@ -42,15 +43,17 @@
|
||||
# error Unknown machine endianness detected.
|
||||
# endif
|
||||
# define BOOST_BYTE_ORDER __BYTE_ORDER
|
||||
#elif defined(_BIG_ENDIAN)
|
||||
#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) || \
|
||||
defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
|
||||
# define BOOST_BIG_ENDIAN
|
||||
# define BOOST_BYTE_ORDER 4321
|
||||
#elif defined(_LITTLE_ENDIAN)
|
||||
#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) || \
|
||||
defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
|
||||
# define BOOST_LITTLE_ENDIAN
|
||||
# define BOOST_BYTE_ORDER 1234
|
||||
#elif defined(__sparc) || defined(__sparc__) \
|
||||
|| defined(_POWER) || defined(__powerpc__) \
|
||||
|| defined(__ppc__) || defined(__hpux) \
|
||||
|| defined(__ppc__) || defined(__hpux) || defined(__hppa) \
|
||||
|| defined(_MIPSEB) || defined(_POWER) \
|
||||
|| defined(__s390__)
|
||||
# define BOOST_BIG_ENDIAN
|
||||
@ -61,7 +64,7 @@
|
||||
|| defined(_M_ALPHA) || defined(__amd64) \
|
||||
|| defined(__amd64__) || defined(_M_AMD64) \
|
||||
|| defined(__x86_64) || defined(__x86_64__) \
|
||||
|| defined(_M_X64)
|
||||
|| defined(_M_X64) || defined(__bfin__)
|
||||
|
||||
# define BOOST_LITTLE_ENDIAN
|
||||
# define BOOST_BYTE_ORDER 1234
|
||||
|
0
include/boost/detail/indirect_traits.hpp
Executable file → Normal file
0
include/boost/detail/indirect_traits.hpp
Executable file → Normal file
@ -47,13 +47,30 @@ extern "C" long __cdecl InterlockedExchangeAdd( long*, long );
|
||||
# define BOOST_INTERLOCKED_EXCHANGE InterlockedExchange
|
||||
# define BOOST_INTERLOCKED_EXCHANGE_ADD InterlockedExchangeAdd
|
||||
|
||||
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \
|
||||
((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long*)(dest),(long)(exchange),(long)(compare)))
|
||||
# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \
|
||||
((void*)BOOST_INTERLOCKED_EXCHANGE((long*)(dest),(long)(exchange)))
|
||||
|
||||
#elif defined( BOOST_MSVC ) || defined( BOOST_INTEL_WIN )
|
||||
|
||||
#if defined( __CLRCALL_PURE_OR_CDECL )
|
||||
|
||||
extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedIncrement( long volatile * );
|
||||
extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedDecrement( long volatile * );
|
||||
extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedCompareExchange( long volatile *, long, long );
|
||||
extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchange( long volatile *, long );
|
||||
extern "C" long __CLRCALL_PURE_OR_CDECL _InterlockedExchangeAdd( long volatile *, long );
|
||||
|
||||
#else
|
||||
|
||||
extern "C" long __cdecl _InterlockedIncrement( long volatile * );
|
||||
extern "C" long __cdecl _InterlockedDecrement( long volatile * );
|
||||
extern "C" long __cdecl _InterlockedCompareExchange( long volatile *, long, long );
|
||||
extern "C" long __cdecl _InterlockedExchange( long volatile *, long);
|
||||
extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long);
|
||||
extern "C" long __cdecl _InterlockedExchange( long volatile *, long );
|
||||
extern "C" long __cdecl _InterlockedExchangeAdd( long volatile *, long );
|
||||
|
||||
#endif
|
||||
|
||||
# pragma intrinsic( _InterlockedIncrement )
|
||||
# pragma intrinsic( _InterlockedDecrement )
|
||||
@ -87,7 +104,7 @@ extern "C" void* __cdecl _InterlockedExchangePointer( void* volatile *, void* );
|
||||
# define BOOST_INTERLOCKED_EXCHANGE _InterlockedExchange
|
||||
# define BOOST_INTERLOCKED_EXCHANGE_ADD _InterlockedExchangeAdd
|
||||
|
||||
#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ )
|
||||
#elif defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -101,6 +118,11 @@ extern "C" __declspec(dllimport) long __stdcall InterlockedCompareExchange( long
|
||||
extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long );
|
||||
extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long volatile *, long );
|
||||
|
||||
# if defined(_M_IA64) || defined(_M_AMD64)
|
||||
extern "C" __declspec(dllimport) void* __stdcall InterlockedCompareExchangePointer( void* volatile *, void*, void* );
|
||||
extern "C" __declspec(dllimport) void* __stdcall InterlockedExchangePointer( void* volatile *, void* );
|
||||
# endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
@ -111,10 +133,15 @@ extern "C" __declspec(dllimport) long __stdcall InterlockedExchangeAdd( long vol
|
||||
# define BOOST_INTERLOCKED_EXCHANGE ::boost::detail::InterlockedExchange
|
||||
# define BOOST_INTERLOCKED_EXCHANGE_ADD ::boost::detail::InterlockedExchangeAdd
|
||||
|
||||
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \
|
||||
# if defined(_M_IA64) || defined(_M_AMD64)
|
||||
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER ::boost::detail::InterlockedCompareExchangePointer
|
||||
# define BOOST_INTERLOCKED_EXCHANGE_POINTER ::boost::detail::InterlockedExchangePointer
|
||||
# else
|
||||
# define BOOST_INTERLOCKED_COMPARE_EXCHANGE_POINTER(dest,exchange,compare) \
|
||||
((void*)BOOST_INTERLOCKED_COMPARE_EXCHANGE((long volatile*)(dest),(long)(exchange),(long)(compare)))
|
||||
# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \
|
||||
# define BOOST_INTERLOCKED_EXCHANGE_POINTER(dest,exchange) \
|
||||
((void*)BOOST_INTERLOCKED_EXCHANGE((long volatile*)(dest),(long)(exchange)))
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
|
0
include/boost/detail/is_function_ref_tester.hpp
Executable file → Normal file
0
include/boost/detail/is_function_ref_tester.hpp
Executable file → Normal file
12
include/boost/detail/is_incrementable.hpp
Executable file → Normal file
12
include/boost/detail/is_incrementable.hpp
Executable file → Normal file
@ -63,7 +63,12 @@ namespace is_incrementable_
|
||||
tag operator,(tag,int);
|
||||
# define BOOST_comma(a,b) (a,b)
|
||||
# endif
|
||||
|
||||
|
||||
# if defined(BOOST_MSVC)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4913) // Warning about operator,
|
||||
# endif
|
||||
|
||||
// two check overloads help us identify which operator++ was picked
|
||||
char (& check(tag) )[2];
|
||||
|
||||
@ -92,6 +97,11 @@ namespace is_incrementable_
|
||||
, value = sizeof(is_incrementable_::check(BOOST_comma(x++,0))) == 1
|
||||
);
|
||||
};
|
||||
|
||||
# if defined(BOOST_MSVC)
|
||||
# pragma warning(pop)
|
||||
# endif
|
||||
|
||||
}
|
||||
|
||||
# undef BOOST_comma
|
||||
|
0
include/boost/detail/is_xxx.hpp
Executable file → Normal file
0
include/boost/detail/is_xxx.hpp
Executable file → Normal file
@ -10,14 +10,15 @@
|
||||
//
|
||||
// boost/detail/lightweight_test.hpp - lightweight test library
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2002, 2009 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)
|
||||
// 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
|
||||
//
|
||||
// BOOST_TEST(expression)
|
||||
// BOOST_ERROR(message)
|
||||
// BOOST_TEST_EQ(expr1, expr2)
|
||||
//
|
||||
// int boost::report_errors()
|
||||
//
|
||||
@ -49,13 +50,27 @@ inline void error_impl(char const * msg, char const * file, int line, char const
|
||||
++test_errors();
|
||||
}
|
||||
|
||||
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2, char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t == u )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << file << "(" << line << "): test '" << expr1 << " == " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << t << "' != '" << u << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
inline int report_errors()
|
||||
{
|
||||
int errors = detail::test_errors();
|
||||
|
||||
if(errors == 0)
|
||||
if( errors == 0 )
|
||||
{
|
||||
std::cerr << "No errors detected." << std::endl;
|
||||
return 0;
|
||||
@ -71,5 +86,6 @@ inline int report_errors()
|
||||
|
||||
#define BOOST_TEST(expr) ((expr)? (void)0: ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
|
||||
#define BOOST_ERROR(msg) ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
|
||||
#define BOOST_TEST_EQ(expr1,expr2) ( ::boost::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
#endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP_INCLUDED
|
||||
|
135
include/boost/detail/lightweight_thread.hpp
Normal file
135
include/boost/detail/lightweight_thread.hpp
Normal file
@ -0,0 +1,135 @@
|
||||
#ifndef BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
|
||||
#define BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
// boost/detail/lightweight_thread.hpp
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
// 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/config.hpp>
|
||||
#include <memory>
|
||||
#include <cerrno>
|
||||
|
||||
// pthread_create, pthread_join
|
||||
|
||||
#if defined( BOOST_HAS_PTHREADS )
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
|
||||
typedef HANDLE pthread_t;
|
||||
|
||||
int pthread_create( pthread_t * thread, void const *, unsigned (__stdcall * start_routine) (void*), void* arg )
|
||||
{
|
||||
HANDLE h = (HANDLE)_beginthreadex( 0, 0, start_routine, arg, 0, 0 );
|
||||
|
||||
if( h != 0 )
|
||||
{
|
||||
*thread = h;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EAGAIN;
|
||||
}
|
||||
}
|
||||
|
||||
int pthread_join( pthread_t thread, void ** /*value_ptr*/ )
|
||||
{
|
||||
::WaitForSingleObject( thread, INFINITE );
|
||||
::CloseHandle( thread );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// template<class F> int lw_thread_create( pthread_t & pt, F f );
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class lw_abstract_thread
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~lw_abstract_thread() {}
|
||||
virtual void run() = 0;
|
||||
};
|
||||
|
||||
#if defined( BOOST_HAS_PTHREADS )
|
||||
|
||||
extern "C" void * lw_thread_routine( void * pv )
|
||||
{
|
||||
std::auto_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
|
||||
|
||||
pt->run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
unsigned __stdcall lw_thread_routine( void * pv )
|
||||
{
|
||||
std::auto_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
|
||||
|
||||
pt->run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class F> class lw_thread_impl: public lw_abstract_thread
|
||||
{
|
||||
public:
|
||||
|
||||
explicit lw_thread_impl( F f ): f_( f )
|
||||
{
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
f_();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
F f_;
|
||||
};
|
||||
|
||||
template<class F> int lw_thread_create( pthread_t & pt, F f )
|
||||
{
|
||||
std::auto_ptr<lw_abstract_thread> p( new lw_thread_impl<F>( f ) );
|
||||
|
||||
int r = pthread_create( &pt, 0, lw_thread_routine, p.get() );
|
||||
|
||||
if( r == 0 )
|
||||
{
|
||||
p.release();
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
|
@ -13,186 +13,11 @@
|
||||
// Copyright (c) 2003 David Abrahams
|
||||
// Copyright (c) 2003 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)
|
||||
// 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/config.hpp>
|
||||
|
||||
#include <boost/detail/lightweight_mutex.hpp>
|
||||
#include <boost/type_traits/type_with_alignment.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
#include <new> // ::operator new, ::operator delete
|
||||
#include <cstddef> // std::size_t
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<unsigned size, unsigned align_> union freeblock
|
||||
{
|
||||
typedef typename boost::type_with_alignment<align_>::type aligner_type;
|
||||
aligner_type aligner;
|
||||
char bytes[size];
|
||||
freeblock * next;
|
||||
};
|
||||
|
||||
template<unsigned size, unsigned align_> struct allocator_impl
|
||||
{
|
||||
typedef freeblock<size, align_> block;
|
||||
|
||||
// It may seem odd to use such small pages.
|
||||
//
|
||||
// However, on a typical Windows implementation that uses
|
||||
// the OS allocator, "normal size" pages interact with the
|
||||
// "ordinary" operator new, slowing it down dramatically.
|
||||
//
|
||||
// 512 byte pages are handled by the small object allocator,
|
||||
// and don't interfere with ::new.
|
||||
//
|
||||
// The other alternative is to use much bigger pages (1M.)
|
||||
//
|
||||
// It is surprisingly easy to hit pathological behavior by
|
||||
// varying the page size. g++ 2.96 on Red Hat Linux 7.2,
|
||||
// for example, passionately dislikes 496. 512 seems OK.
|
||||
|
||||
#if defined(BOOST_QA_PAGE_SIZE)
|
||||
|
||||
enum { items_per_page = BOOST_QA_PAGE_SIZE / size };
|
||||
|
||||
#else
|
||||
|
||||
enum { items_per_page = 512 / size }; // 1048560 / size
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
|
||||
static lightweight_mutex & mutex()
|
||||
{
|
||||
static lightweight_mutex m;
|
||||
return m;
|
||||
}
|
||||
|
||||
static lightweight_mutex * mutex_init;
|
||||
|
||||
#endif
|
||||
|
||||
static block * free;
|
||||
static block * page;
|
||||
static unsigned last;
|
||||
|
||||
static inline void * alloc()
|
||||
{
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
lightweight_mutex::scoped_lock lock( mutex() );
|
||||
#endif
|
||||
if(block * x = free)
|
||||
{
|
||||
free = x->next;
|
||||
return x;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(last == items_per_page)
|
||||
{
|
||||
// "Listen to me carefully: there is no memory leak"
|
||||
// -- Scott Meyers, Eff C++ 2nd Ed Item 10
|
||||
page = ::new block[items_per_page];
|
||||
last = 0;
|
||||
}
|
||||
|
||||
return &page[last++];
|
||||
}
|
||||
}
|
||||
|
||||
static inline void * alloc(std::size_t n)
|
||||
{
|
||||
if(n != size) // class-specific new called for a derived object
|
||||
{
|
||||
return ::operator new(n);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
lightweight_mutex::scoped_lock lock( mutex() );
|
||||
#endif
|
||||
if(block * x = free)
|
||||
{
|
||||
free = x->next;
|
||||
return x;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(last == items_per_page)
|
||||
{
|
||||
page = ::new block[items_per_page];
|
||||
last = 0;
|
||||
}
|
||||
|
||||
return &page[last++];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void dealloc(void * pv)
|
||||
{
|
||||
if(pv != 0) // 18.4.1.1/13
|
||||
{
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
lightweight_mutex::scoped_lock lock( mutex() );
|
||||
#endif
|
||||
block * pb = static_cast<block *>(pv);
|
||||
pb->next = free;
|
||||
free = pb;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void dealloc(void * pv, std::size_t n)
|
||||
{
|
||||
if(n != size) // class-specific delete called for a derived object
|
||||
{
|
||||
::operator delete(pv);
|
||||
}
|
||||
else if(pv != 0) // 18.4.1.1/13
|
||||
{
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
lightweight_mutex::scoped_lock lock( mutex() );
|
||||
#endif
|
||||
block * pb = static_cast<block *>(pv);
|
||||
pb->next = free;
|
||||
free = pb;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
|
||||
template<unsigned size, unsigned align_>
|
||||
lightweight_mutex * allocator_impl<size, align_>::mutex_init = &allocator_impl<size, align_>::mutex();
|
||||
|
||||
#endif
|
||||
|
||||
template<unsigned size, unsigned align_>
|
||||
freeblock<size, align_> * allocator_impl<size, align_>::free = 0;
|
||||
|
||||
template<unsigned size, unsigned align_>
|
||||
freeblock<size, align_> * allocator_impl<size, align_>::page = 0;
|
||||
|
||||
template<unsigned size, unsigned align_>
|
||||
unsigned allocator_impl<size, align_>::last = allocator_impl<size, align_>::items_per_page;
|
||||
|
||||
template<class T>
|
||||
struct quick_allocator: public allocator_impl< sizeof(T), boost::alignment_of<T>::value >
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace boost
|
||||
#include <boost/smart_ptr/detail/quick_allocator.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
|
||||
|
56
include/boost/detail/scoped_enum_emulation.hpp
Normal file
56
include/boost/detail/scoped_enum_emulation.hpp
Normal file
@ -0,0 +1,56 @@
|
||||
// scoped_enum_emulation.hpp ---------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes, 2009
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
// Generates C++0x scoped enums if the feature is present, otherwise emulates C++0x
|
||||
// scoped enums with C++03 namespaces and enums. The Boost.Config BOOST_NO_SCOPED_ENUMS
|
||||
// macro is used to detect feature support.
|
||||
//
|
||||
// See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf for a
|
||||
// description of the scoped enum feature. Note that the committee changed the name
|
||||
// from strongly typed enum to scoped enum.
|
||||
//
|
||||
// Caution: only the syntax is emulated; the semantics are not emulated and
|
||||
// the syntax emulation doesn't include being able to specify the underlying
|
||||
// representation type.
|
||||
//
|
||||
// The emulation is via struct rather than namespace to allow use within classes.
|
||||
// Thanks to Andrey Semashev for pointing that out.
|
||||
//
|
||||
// Helpful comments and suggestions were also made by Kjell Elster, Phil Endecott,
|
||||
// Joel Falcou, Mathias Gaunard, Felipe Magno de Almeida, Matt Calabrese, Vincente
|
||||
// Botet, and Daniel James.
|
||||
//
|
||||
// Sample usage:
|
||||
//
|
||||
// BOOST_SCOPED_ENUM_START(algae) { green, red, cyan }; BOOST_SCOPED_ENUM_END
|
||||
// ...
|
||||
// BOOST_SCOPED_ENUM(algae) sample( algae::red );
|
||||
// void foo( BOOST_SCOPED_ENUM(algae) color );
|
||||
// ...
|
||||
// sample = algae::green;
|
||||
// foo( algae::cyan );
|
||||
|
||||
#ifndef BOOST_SCOPED_ENUM_EMULATION_HPP
|
||||
#define BOOST_SCOPED_ENUM_EMULATION_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_SCOPED_ENUMS
|
||||
|
||||
# define BOOST_SCOPED_ENUM_START(name) struct name { enum enum_type
|
||||
# define BOOST_SCOPED_ENUM_END };
|
||||
# define BOOST_SCOPED_ENUM(name) name::enum_type
|
||||
|
||||
#else
|
||||
|
||||
# define BOOST_SCOPED_ENUM_START(name) enum class name
|
||||
# define BOOST_SCOPED_ENUM_END
|
||||
# define BOOST_SCOPED_ENUM(name) name
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BOOST_SCOPED_ENUM_EMULATION_HPP
|
@ -1,4 +1,4 @@
|
||||
// Copyright <EFBFBD> 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
|
||||
// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
|
||||
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@ -79,25 +79,18 @@
|
||||
// specialized on those types for this to work.
|
||||
|
||||
#include <locale>
|
||||
// for mbstate_t
|
||||
#include <wchar.h>
|
||||
// for std::size_t
|
||||
#include <cstddef>
|
||||
#include <cwchar> // for mbstate_t
|
||||
#include <cstddef> // for std::size_t
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#if defined(BOOST_NO_STDC_NAMESPACE)
|
||||
namespace std {
|
||||
#if defined(__LIBCOMO__)
|
||||
using ::mbstate_t;
|
||||
#elif defined(BOOST_DINKUMWARE_STDLIB) && !defined(__BORLANDC__)
|
||||
using ::mbstate_t;
|
||||
#elif defined(__SGI_STL_PORT)
|
||||
#elif defined(BOOST_NO_STDC_NAMESPACE)
|
||||
using ::mbstate_t;
|
||||
using ::codecvt;
|
||||
#endif
|
||||
} // namespace std
|
||||
using ::mbstate_t;
|
||||
using ::size_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(__MSL_CPP__) && !defined(__LIBCOMO__)
|
||||
#define BOOST_CODECVT_DO_LENGTH_CONST const
|
||||
|
0
include/boost/indirect_reference.hpp
Executable file → Normal file
0
include/boost/indirect_reference.hpp
Executable file → Normal file
@ -1,43 +0,0 @@
|
||||
// (C) Copyright Jeremy Siek 2000.
|
||||
// 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 header replaces the implementation of ct_if that preceded the
|
||||
// introduction of Boost.MPL with a facade that defers to that reviewed and
|
||||
// accepted library.
|
||||
|
||||
// Author: Ronald Garcia
|
||||
// Date: 20 October, 2006
|
||||
|
||||
|
||||
#ifndef BOOST_CT_IF_HPP
|
||||
#define BOOST_CT_IF_HPP
|
||||
|
||||
|
||||
// A stub implementation in terms of Boost.MPL
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
// true_type and false_type are used by applications of ct_if
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <class A, class B>
|
||||
struct ct_and : boost::mpl::and_<A,B> {};
|
||||
|
||||
template <class A>
|
||||
struct ct_not : mpl::not_<A> {};
|
||||
|
||||
template <bool cond, class A, class B>
|
||||
struct ct_if : mpl::if_c<cond,A,B> {};
|
||||
|
||||
template <class cond, class A, class B>
|
||||
struct ct_if_t : mpl::if_<cond,A,B> {};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_CT_IF_HPP
|
||||
|
@ -1,20 +1,16 @@
|
||||
// -------------------------------------
|
||||
// -----------------------------------------------------------
|
||||
// integer_log2.hpp
|
||||
//
|
||||
// Gives the integer part of the logarithm, in base 2, of a
|
||||
// given number. Behavior is undefined if the argument is <= 0.
|
||||
//
|
||||
//
|
||||
// (C) Copyright Gennaro Prota 2003 - 2004.
|
||||
// Copyright (c) 2003-2004, 2008 Gennaro Prota
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// ------------------------------------------------------
|
||||
//
|
||||
// $Id$
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
#ifndef BOOST_INTEGER_LOG2_HPP_GP_20030301
|
||||
#define BOOST_INTEGER_LOG2_HPP_GP_20030301
|
||||
@ -37,7 +33,7 @@ namespace boost {
|
||||
|
||||
while (x != 1) {
|
||||
|
||||
const T t = x >> n;
|
||||
const T t = static_cast<T>(x >> n);
|
||||
if (t) {
|
||||
result += n;
|
||||
x = t;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
||||
// utf8_codecvt_facet.cpp
|
||||
|
||||
// Copyright <EFBFBD> 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
|
||||
// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
|
||||
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -159,7 +159,7 @@ std::codecvt_base::result utf8_codecvt_facet::do_out(
|
||||
to_next = to - (i+1);
|
||||
return std::codecvt_base::partial;
|
||||
}
|
||||
*from++;
|
||||
++from;
|
||||
}
|
||||
from_next = from;
|
||||
to_next = to;
|
||||
@ -231,9 +231,6 @@ int get_cont_octet_out_count_impl(wchar_t word){
|
||||
return 2;
|
||||
}
|
||||
|
||||
// note the following code will generate on some platforms where
|
||||
// wchar_t is defined as UCS2. The warnings are superfluous as
|
||||
// the specialization is never instantitiated with such compilers.
|
||||
template<>
|
||||
int get_cont_octet_out_count_impl<4>(wchar_t word){
|
||||
if (word < 0x80) {
|
||||
@ -242,7 +239,22 @@ int get_cont_octet_out_count_impl<4>(wchar_t word){
|
||||
if (word < 0x800) {
|
||||
return 1;
|
||||
}
|
||||
if (word < 0x10000) {
|
||||
|
||||
// Note that the following code will generate warnings on some platforms
|
||||
// where wchar_t is defined as UCS2. The warnings are superfluous as the
|
||||
// specialization is never instantitiated with such compilers, but this
|
||||
// can cause problems if warnings are being treated as errors, so we guard
|
||||
// against that. Including <boost/detail/utf8_codecvt_facet.hpp> as we do
|
||||
// should be enough to get WCHAR_MAX defined.
|
||||
#if !defined(WCHAR_MAX)
|
||||
# error WCHAR_MAX not defined!
|
||||
#endif
|
||||
// cope with VC++ 7.1 or earlier having invalid WCHAR_MAX
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1310 // 7.1 or earlier
|
||||
return 2;
|
||||
#elif WCHAR_MAX > 0x10000
|
||||
|
||||
if (word < 0x10000) {
|
||||
return 2;
|
||||
}
|
||||
if (word < 0x200000) {
|
||||
@ -252,6 +264,10 @@ int get_cont_octet_out_count_impl<4>(wchar_t word){
|
||||
return 4;
|
||||
}
|
||||
return 5;
|
||||
|
||||
#else
|
||||
return 2;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace anonymous
|
||||
|
Reference in New Issue
Block a user