From 21cf4091a9071f5db6d881fabcab7add047af10d Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 22 May 2001 18:58:21 +0000 Subject: [PATCH 001/109] Smart pointer and utility changes related to adding checked_delere and checked_array_delete [SVN r10189] --- checked_delete_test.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 checked_delete_test.cpp diff --git a/checked_delete_test.cpp b/checked_delete_test.cpp new file mode 100644 index 0000000..f9107c8 --- /dev/null +++ b/checked_delete_test.cpp @@ -0,0 +1,31 @@ +// Boost checked_delete test program ---------------------------------------// + +// (C) Copyright Beman Dawes 2001. Permission to copy, use, modify, sell +// and distribute this software is granted provided this copyright +// notice appears in all copies. This software is provided "as is" without +// express or implied warranty, and with no claim as to its suitability for +// any purpose. + +// See http://www.boost.org for most recent version including documentation. + +// Revision History +// 21 May 01 Initial version (Beman Dawes) + +#include // for checked_delete + +// This program demonstrates compiler errors when trying to delete an +// incomplete type. + +namespace +{ + class Incomplete; +} + +int main() +{ + Incomplete * p; + boost::checked_delete(p); // should cause compile time error + Incomplete ** pa; + boost::checked_array_delete(pa); // should cause compile time error + return 0; +} // main From 7c5387626b874ee33617d066af8394c45b872c49 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 23 Aug 2001 18:42:16 +0000 Subject: [PATCH 002/109] initial commit [SVN r10914] --- include/boost/ref.hpp | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 include/boost/ref.hpp diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp new file mode 100644 index 0000000..f8ab454 --- /dev/null +++ b/include/boost/ref.hpp @@ -0,0 +1,55 @@ +#ifndef BOOST_REF_HPP_INCLUDED +#define BOOST_REF_HPP_INCLUDED + +#if _MSC_VER >= 1020 +#pragma once +#endif + +// +// ref.hpp - ref/cref, useful helper functions +// +// Version 1.00.0003 (2001-08-22) +// +// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +// See http://www.boost.org/libs/bind/ref.html for documentation. +// + +namespace boost +{ + +template class reference_wrapper +{ +public: + + explicit reference_wrapper(T & t): t_(t) {} + + operator T & () const { return t_; } + + T & get() const { return t_; } + +private: + + T & t_; + + reference_wrapper & operator= (reference_wrapper const &); +}; + +template inline reference_wrapper ref(T & t) +{ + return reference_wrapper(t); +} + +template inline reference_wrapper cref(T const & t) +{ + return reference_wrapper(t); +} + +} // namespace boost + +#endif // #ifndef BOOST_REF_HPP_INCLUDED From 9884fdb1bc4874da7da1e930d651139d2a0a021d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 23 Aug 2001 19:05:21 +0000 Subject: [PATCH 003/109] Tabs converted to spaces. [SVN r10916] --- include/boost/ref.hpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index f8ab454..39ce4e3 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -6,18 +6,18 @@ #endif // -// ref.hpp - ref/cref, useful helper functions +// ref.hpp - ref/cref, useful helper functions // -// Version 1.00.0003 (2001-08-22) +// Version 1.00.0003 (2001-08-22) // -// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. // -// See http://www.boost.org/libs/bind/ref.html for documentation. +// See http://www.boost.org/libs/bind/ref.html for documentation. // namespace boost @@ -27,27 +27,27 @@ template class reference_wrapper { public: - explicit reference_wrapper(T & t): t_(t) {} + explicit reference_wrapper(T & t): t_(t) {} - operator T & () const { return t_; } + operator T & () const { return t_; } - T & get() const { return t_; } + T & get() const { return t_; } private: - T & t_; + T & t_; - reference_wrapper & operator= (reference_wrapper const &); + reference_wrapper & operator= (reference_wrapper const &); }; template inline reference_wrapper ref(T & t) { - return reference_wrapper(t); + return reference_wrapper(t); } template inline reference_wrapper cref(T const & t) { - return reference_wrapper(t); + return reference_wrapper(t); } } // namespace boost From 853f2daae5874d5005945632cd445e899cf0607a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 10 Nov 2001 19:18:58 +0000 Subject: [PATCH 004/109] __stdcall support added. [SVN r11649] --- include/boost/ref.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 39ce4e3..b35fb0f 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -1,16 +1,15 @@ #ifndef BOOST_REF_HPP_INCLUDED #define BOOST_REF_HPP_INCLUDED -#if _MSC_VER >= 1020 +#if _MSC_VER+0 >= 1020 #pragma once #endif // // ref.hpp - ref/cref, useful helper functions // -// Version 1.00.0003 (2001-08-22) -// // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 2001 Peter Dimov // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. From d198eecb615b555c0d20b5038f3c5dcc26397b48 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Nov 2001 13:56:05 +0000 Subject: [PATCH 005/109] Fixed a bug w/ adaptable function objects + nested binds, made ref<> return const [SVN r11670] --- include/boost/ref.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index b35fb0f..29f8930 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -39,12 +39,18 @@ private: reference_wrapper & operator= (reference_wrapper const &); }; -template inline reference_wrapper ref(T & t) +#if defined(__BORLANDC__) && (__BORLANDC__ <= 0x551) +#define BOOST_REF_CONST +#else +#define BOOST_REF_CONST const +#endif + +template inline reference_wrapper BOOST_REF_CONST ref(T & t) { return reference_wrapper(t); } -template inline reference_wrapper cref(T const & t) +template inline reference_wrapper BOOST_REF_CONST cref(T const & t) { return reference_wrapper(t); } From 54963bff325bbbc44030f4732b96a27b712f58ec Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 14 Nov 2001 14:40:29 +0000 Subject: [PATCH 006/109] #undef BOOST_REF_CONST added [SVN r11674] --- include/boost/ref.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 29f8930..8ba1cfe 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -55,6 +55,8 @@ template inline reference_wrapper BOOST_REF_CONST cref(T const return reference_wrapper(t); } +#undef BOOST_REF_CONST + } // namespace boost #endif // #ifndef BOOST_REF_HPP_INCLUDED From d25904e4d5dd09f62e82dc3f44b93abdaf6b2289 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 22 Jan 2002 13:38:52 +0000 Subject: [PATCH 007/109] Smart pointer enhancements, initial commit [SVN r12439] --- include/boost/checked_delete.hpp | 73 ++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 include/boost/checked_delete.hpp diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp new file mode 100644 index 0000000..ad11d58 --- /dev/null +++ b/include/boost/checked_delete.hpp @@ -0,0 +1,73 @@ +#ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED +#define BOOST_CHECKED_DELETE_HPP_INCLUDED + +#if _MSC_VER >= 1020 +#pragma once +#endif + +// +// boost/checked_delete.hpp +// +// Copyright (c) 1999, 2000, 2001, 2002 boost.org +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// + +namespace boost +{ + +// verify that types are complete for increased safety + +template< typename T > inline void checked_delete(T * x) +{ + typedef char type_must_be_complete[sizeof(T)]; + delete x; +} + +template< typename T > inline void checked_array_delete(T * x) +{ + typedef char type_must_be_complete[sizeof(T)]; + delete [] x; +} + +template struct checked_deleter +{ + typedef void result_type; + typedef T * argument_type; + + void operator()(T * x) + { + checked_delete(x); + } +}; + +// checked_deleter is needed by shared_ptr::reset(0) + +template<> struct checked_deleter +{ + typedef void result_type; + typedef void * argument_type; + + void operator()(void * x) + { + ::operator delete(x); // avoid g++ warning + } +}; + +template struct checked_array_deleter +{ + typedef void result_type; + typedef T * argument_type; + + void operator()(T * x) + { + checked_array_delete(x); + } +}; + +} // namespace boost + +#endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED From 42d2ad8f07273dc405815a3722ba03088d06a4a1 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 23 Jan 2002 21:19:14 +0000 Subject: [PATCH 008/109] added is_reference_wrapper<>, unwrap_reference<> [SVN r12470] --- include/boost/ref.hpp | 101 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 91 insertions(+), 10 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 8ba1cfe..b6b4704 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -1,9 +1,9 @@ #ifndef BOOST_REF_HPP_INCLUDED -#define BOOST_REF_HPP_INCLUDED +# define BOOST_REF_HPP_INCLUDED -#if _MSC_VER+0 >= 1020 -#pragma once -#endif +# if _MSC_VER+0 >= 1020 +# pragma once +# endif // // ref.hpp - ref/cref, useful helper functions @@ -25,6 +25,7 @@ namespace boost template class reference_wrapper { public: + typedef T type; explicit reference_wrapper(T & t): t_(t) {} @@ -39,11 +40,11 @@ private: reference_wrapper & operator= (reference_wrapper const &); }; -#if defined(__BORLANDC__) && (__BORLANDC__ <= 0x551) -#define BOOST_REF_CONST -#else -#define BOOST_REF_CONST const -#endif +# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x551) +# define BOOST_REF_CONST +# else +# define BOOST_REF_CONST const +# endif template inline reference_wrapper BOOST_REF_CONST ref(T & t) { @@ -55,7 +56,87 @@ template inline reference_wrapper BOOST_REF_CONST cref(T const return reference_wrapper(t); } -#undef BOOST_REF_CONST +# undef BOOST_REF_CONST + +# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +template +class is_reference_wrapper +{ + public: + BOOST_STATIC_CONSTANT(bool, value = false); +}; + +template +class is_reference_wrapper > +{ + public: + BOOST_STATIC_CONSTANT(bool, value = true); +}; + +template +class unwrap_reference +{ + public: + typedef T type; +}; + +template +class unwrap_reference > +{ + public: + typedef T type; +}; +# else // no partial specialization +namespace detail +{ + typedef char (&yes_reference_wrapper_t)[1]; + typedef char (&no_reference_wrapper_t)[2]; + + no_reference_wrapper_t is_reference_wrapper_test(...); + + template + yes_reference_wrapper_t is_reference_wrapper_test(reference_wrapper*); + + template + struct reference_unwrapper + { + template + struct apply + { + typedef T type; + }; + }; + + template<> + struct reference_unwrapper + { + template + struct apply + { + typedef typename T::type type; + }; + }; +} + +template +class is_reference_wrapper +{ + public: + static T* t; + BOOST_STATIC_CONSTANT( + bool, value = ( + sizeof(detail::is_reference_wrapper_test(t)) + == sizeof(detail::yes_reference_wrapper_t))); +}; + +template +class unwrap_reference + : public detail::reference_unwrapper< + is_reference_wrapper::value + >::template apply +{}; + +# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION } // namespace boost From 47c046fa8e149f79e4e4358950be00cdf97a8100 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 24 Jan 2002 13:28:08 +0000 Subject: [PATCH 009/109] Modified is_reference_wrapper<> to work for reference types. [SVN r12475] --- include/boost/ref.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index b6b4704..a13558b 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -87,6 +87,14 @@ class unwrap_reference > typedef T type; }; # else // no partial specialization + +} // namespace boost + +#include + +namespace boost +{ + namespace detail { typedef char (&yes_reference_wrapper_t)[1]; @@ -95,7 +103,7 @@ namespace detail no_reference_wrapper_t is_reference_wrapper_test(...); template - yes_reference_wrapper_t is_reference_wrapper_test(reference_wrapper*); + yes_reference_wrapper_t is_reference_wrapper_test(type< reference_wrapper >); template struct reference_unwrapper @@ -122,10 +130,9 @@ template class is_reference_wrapper { public: - static T* t; BOOST_STATIC_CONSTANT( bool, value = ( - sizeof(detail::is_reference_wrapper_test(t)) + sizeof(detail::is_reference_wrapper_test(type())) == sizeof(detail::yes_reference_wrapper_t))); }; From f77ace87d39a09f9ca1655d82a158a835dcdd5d4 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 24 Jan 2002 16:52:06 +0000 Subject: [PATCH 010/109] initial checkin [SVN r12481] --- ref_test.cpp | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 ref_test.cpp diff --git a/ref_test.cpp b/ref_test.cpp new file mode 100644 index 0000000..24f9e98 --- /dev/null +++ b/ref_test.cpp @@ -0,0 +1,124 @@ +#if defined(_MSC_VER) && !defined(__ICL) +# pragma warning(disable: 4786) // identifier truncated in debug info +# pragma warning(disable: 4710) // function not inlined +# pragma warning(disable: 4711) // function selected for automatic inline expansion +# pragma warning(disable: 4514) // unreferenced inline removed +#endif + +#include +#include +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +# pragma warning(push, 3) +#endif + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +# pragma warning(pop) +#endif + + +#define BOOST_INCLUDE_MAIN +#include + +namespace { +using namespace boost; + +template +struct wrapper +{ + // Used to verify implicit conversion + static T* get_pointer(T& x) + { + return &x; + } + + static T const* get_const_pointer(T const& x) + { + return &x; + } + + static void check_type_typedef(...) + { + BOOST_ERROR("expected a reference_wrapper argument"); + } + + template + static void check_type_typedef(boost::reference_wrapper) + { + typedef typename boost::reference_wrapper::type type_typedef; + BOOST_TEST((boost::is_same::value)); + } + + template + static T* passthru(Arg x) + { + check_type_typedef(x); + return get_pointer(x); + } + + template + static T const* cref_passthru(Arg x) + { + check_type_typedef(x); + return get_const_pointer(x); + } + + template + static void test_unwrapped(Arg x) + { + typedef typename unwrap_reference::type unwrapped; + BOOST_TEST((is_same::value)); + } + + template struct select {}; + typedef select constant; + typedef select non_constant; + + static void cref_test(T x, constant) {} + + static void cref_test(T x, non_constant) + { + BOOST_TEST(is_reference_wrapper >::value); + BOOST_TEST(cref_passthru(cref(x)) == &x); + BOOST_TEST(&cref(x).get() == &x); + } + + BOOST_STATIC_CONSTANT( + bool, t_is_constant = boost::is_const::value); + + static void test(T x) + { + BOOST_TEST(passthru(ref(x)) == &x); + + BOOST_TEST((is_same::type,T>::value)); + + BOOST_TEST(&ref(x).get() == &x); + + typedef reference_wrapper wrapped; + BOOST_TEST(is_reference_wrapper::value); + + typedef typename unwrap_reference::type unwrapped_wrapper; + BOOST_TEST((is_same::value)); + + typedef typename unwrap_reference::type unwrapped_self; + BOOST_TEST((is_same::value)); + + cref_test(x, select()); + } +}; + +} // namespace unnamed + +int test_main(int, char * []) +{ + wrapper::test(1); + wrapper::test(1); + BOOST_TEST(!is_reference_wrapper::value); + BOOST_TEST(!is_reference_wrapper::value); + BOOST_TEST(!is_reference_wrapper::value); + BOOST_TEST(!is_reference_wrapper::value); + return 0; +} From b22469f950fd701b945a87b1327d8a6e0db0c4de Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 24 Jan 2002 16:55:41 +0000 Subject: [PATCH 011/109] added missing #include of boost/config.hpp [SVN r12483] --- include/boost/ref.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index a13558b..ff5394c 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -5,6 +5,8 @@ # pragma once # endif +# include + // // ref.hpp - ref/cref, useful helper functions // From 1c3cd876d623dd2665fab95d49321b756ee13a42 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Sun, 27 Jan 2002 13:02:27 +0000 Subject: [PATCH 012/109] made 'reference_wrapper' Assignable [SVN r12520] --- include/boost/ref.hpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index ff5394c..cf85e64 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -29,17 +29,15 @@ template class reference_wrapper public: typedef T type; - explicit reference_wrapper(T & t): t_(t) {} + explicit reference_wrapper(T& t): t_(&t) {} - operator T & () const { return t_; } + operator T& () const { return *t_; } - T & get() const { return t_; } + T& get() const { return *t_; } private: - T & t_; - - reference_wrapper & operator= (reference_wrapper const &); + T* t_; }; # if defined(__BORLANDC__) && (__BORLANDC__ <= 0x551) From 50141f41a392ff617aedb9aea8f51fef8ab83523 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Sun, 27 Jan 2002 13:07:20 +0000 Subject: [PATCH 013/109] compile-time ref.hpp header test, initial checkin [SVN r12522] --- ref_ct_test.cpp | 128 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 ref_ct_test.cpp diff --git a/ref_ct_test.cpp b/ref_ct_test.cpp new file mode 100644 index 0000000..97fecc3 --- /dev/null +++ b/ref_ct_test.cpp @@ -0,0 +1,128 @@ +//----------------------------------------------------------------------------- +// ref_ct_test.cpp - compile-time test for "boost/ref.hpp" header content +// See http://www.boost.org for updates, documentation, and revision history. +//----------------------------------------------------------------------------- +// +// Copyright (c) 2002 +// Aleksey Gurtovoy +// +// Permission to use, copy, modify, distribute and sell this software +// and its documentation for any purpose is hereby granted without fee, +// provided that the above copyright notice appears in all copies and +// that both the copyright notice and this permission notice appear in +// supporting documentation. No representations are made about the +// suitability of this software for any purpose. It is provided "as is" +// without express or implied warranty. + +#include +#include +#include + +namespace { + +template< typename T, typename U > +void ref_test(boost::reference_wrapper) +{ + typedef typename boost::reference_wrapper::type type; + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); +} + +template< typename T > +void assignable_test(T x) +{ + x = x; +} + +template< bool R, typename T > +void is_reference_wrapper_test(T) +{ + BOOST_STATIC_ASSERT(boost::is_reference_wrapper::value == R); +} + +template< typename R, typename Ref > +void cxx_reference_test(Ref) +{ + BOOST_STATIC_ASSERT((boost::is_same::value)); +} + +template< typename R, typename Ref > +void unwrap_reference_test(Ref) +{ + typedef typename boost::unwrap_reference::type type; + BOOST_STATIC_ASSERT((boost::is_same::value)); +} + +} // namespace + +int main() +{ + int i = 0; + int& ri = i; + + int const ci = 0; + int const& rci = ci; + + // 'ref/cref' functions test + ref_test(boost::ref(i)); + ref_test(boost::ref(ri)); + ref_test(boost::ref(ci)); + ref_test(boost::ref(rci)); + + ref_test(boost::cref(i)); + ref_test(boost::cref(ri)); + ref_test(boost::cref(ci)); + ref_test(boost::cref(rci)); + + // test 'assignable' requirement + assignable_test(boost::ref(i)); + assignable_test(boost::ref(ri)); + assignable_test(boost::cref(i)); + assignable_test(boost::cref(ci)); + assignable_test(boost::cref(rci)); + + // 'is_reference_wrapper' test + is_reference_wrapper_test(boost::ref(i)); + is_reference_wrapper_test(boost::ref(ri)); + is_reference_wrapper_test(boost::cref(i)); + is_reference_wrapper_test(boost::cref(ci)); + is_reference_wrapper_test(boost::cref(rci)); + + is_reference_wrapper_test(i); + is_reference_wrapper_test(ri); + is_reference_wrapper_test(ci); + is_reference_wrapper_test(rci); + + // ordinary references/function template arguments deduction test + cxx_reference_test(i); + cxx_reference_test(ri); + cxx_reference_test(ci); + cxx_reference_test(rci); + + cxx_reference_test(i); + cxx_reference_test(ri); + cxx_reference_test(i); + cxx_reference_test(ri); + cxx_reference_test(ci); + cxx_reference_test(rci); + + // 'unwrap_reference' test + unwrap_reference_test(boost::ref(i)); + unwrap_reference_test(boost::ref(ri)); + unwrap_reference_test(boost::cref(i)); + unwrap_reference_test(boost::cref(ci)); + unwrap_reference_test(boost::cref(rci)); + + unwrap_reference_test(i); + unwrap_reference_test(ri); + unwrap_reference_test(ci); + unwrap_reference_test(rci); + unwrap_reference_test(i); + unwrap_reference_test(ri); + unwrap_reference_test(i); + unwrap_reference_test(ri); + unwrap_reference_test(ci); + unwrap_reference_test(rci); + + return 0; +} From 4dce6be6748ec505b66e55250ad7cddeb92a9384 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Sun, 27 Jan 2002 13:32:37 +0000 Subject: [PATCH 014/109] ref_ct_test.cpp [SVN r12524] --- ref_ct_test.cpp | 128 ------------------------------------------------ ref_test.cpp | 68 ++++--------------------- 2 files changed, 9 insertions(+), 187 deletions(-) delete mode 100644 ref_ct_test.cpp diff --git a/ref_ct_test.cpp b/ref_ct_test.cpp deleted file mode 100644 index 97fecc3..0000000 --- a/ref_ct_test.cpp +++ /dev/null @@ -1,128 +0,0 @@ -//----------------------------------------------------------------------------- -// ref_ct_test.cpp - compile-time test for "boost/ref.hpp" header content -// See http://www.boost.org for updates, documentation, and revision history. -//----------------------------------------------------------------------------- -// -// Copyright (c) 2002 -// Aleksey Gurtovoy -// -// Permission to use, copy, modify, distribute and sell this software -// and its documentation for any purpose is hereby granted without fee, -// provided that the above copyright notice appears in all copies and -// that both the copyright notice and this permission notice appear in -// supporting documentation. No representations are made about the -// suitability of this software for any purpose. It is provided "as is" -// without express or implied warranty. - -#include -#include -#include - -namespace { - -template< typename T, typename U > -void ref_test(boost::reference_wrapper) -{ - typedef typename boost::reference_wrapper::type type; - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); -} - -template< typename T > -void assignable_test(T x) -{ - x = x; -} - -template< bool R, typename T > -void is_reference_wrapper_test(T) -{ - BOOST_STATIC_ASSERT(boost::is_reference_wrapper::value == R); -} - -template< typename R, typename Ref > -void cxx_reference_test(Ref) -{ - BOOST_STATIC_ASSERT((boost::is_same::value)); -} - -template< typename R, typename Ref > -void unwrap_reference_test(Ref) -{ - typedef typename boost::unwrap_reference::type type; - BOOST_STATIC_ASSERT((boost::is_same::value)); -} - -} // namespace - -int main() -{ - int i = 0; - int& ri = i; - - int const ci = 0; - int const& rci = ci; - - // 'ref/cref' functions test - ref_test(boost::ref(i)); - ref_test(boost::ref(ri)); - ref_test(boost::ref(ci)); - ref_test(boost::ref(rci)); - - ref_test(boost::cref(i)); - ref_test(boost::cref(ri)); - ref_test(boost::cref(ci)); - ref_test(boost::cref(rci)); - - // test 'assignable' requirement - assignable_test(boost::ref(i)); - assignable_test(boost::ref(ri)); - assignable_test(boost::cref(i)); - assignable_test(boost::cref(ci)); - assignable_test(boost::cref(rci)); - - // 'is_reference_wrapper' test - is_reference_wrapper_test(boost::ref(i)); - is_reference_wrapper_test(boost::ref(ri)); - is_reference_wrapper_test(boost::cref(i)); - is_reference_wrapper_test(boost::cref(ci)); - is_reference_wrapper_test(boost::cref(rci)); - - is_reference_wrapper_test(i); - is_reference_wrapper_test(ri); - is_reference_wrapper_test(ci); - is_reference_wrapper_test(rci); - - // ordinary references/function template arguments deduction test - cxx_reference_test(i); - cxx_reference_test(ri); - cxx_reference_test(ci); - cxx_reference_test(rci); - - cxx_reference_test(i); - cxx_reference_test(ri); - cxx_reference_test(i); - cxx_reference_test(ri); - cxx_reference_test(ci); - cxx_reference_test(rci); - - // 'unwrap_reference' test - unwrap_reference_test(boost::ref(i)); - unwrap_reference_test(boost::ref(ri)); - unwrap_reference_test(boost::cref(i)); - unwrap_reference_test(boost::cref(ci)); - unwrap_reference_test(boost::cref(rci)); - - unwrap_reference_test(i); - unwrap_reference_test(ri); - unwrap_reference_test(ci); - unwrap_reference_test(rci); - unwrap_reference_test(i); - unwrap_reference_test(ri); - unwrap_reference_test(i); - unwrap_reference_test(ri); - unwrap_reference_test(ci); - unwrap_reference_test(rci); - - return 0; -} diff --git a/ref_test.cpp b/ref_test.cpp index 24f9e98..1cfb5dd 100644 --- a/ref_test.cpp +++ b/ref_test.cpp @@ -1,3 +1,7 @@ + +// run-time test for "boost/ref.hpp" header content +// see 'ref_ct_test.cpp' for compile-time part + #if defined(_MSC_VER) && !defined(__ICL) # pragma warning(disable: 4786) // identifier truncated in debug info # pragma warning(disable: 4710) // function not inlined @@ -6,8 +10,6 @@ #endif #include -#include -#include #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) # pragma warning(push, 3) @@ -27,7 +29,7 @@ namespace { using namespace boost; template -struct wrapper +struct ref_wrapper { // Used to verify implicit conversion static T* get_pointer(T& x) @@ -40,73 +42,25 @@ struct wrapper return &x; } - static void check_type_typedef(...) - { - BOOST_ERROR("expected a reference_wrapper argument"); - } - - template - static void check_type_typedef(boost::reference_wrapper) - { - typedef typename boost::reference_wrapper::type type_typedef; - BOOST_TEST((boost::is_same::value)); - } - template static T* passthru(Arg x) { - check_type_typedef(x); return get_pointer(x); } template static T const* cref_passthru(Arg x) { - check_type_typedef(x); return get_const_pointer(x); } - template - static void test_unwrapped(Arg x) - { - typedef typename unwrap_reference::type unwrapped; - BOOST_TEST((is_same::value)); - } - - template struct select {}; - typedef select constant; - typedef select non_constant; - - static void cref_test(T x, constant) {} - - static void cref_test(T x, non_constant) - { - BOOST_TEST(is_reference_wrapper >::value); - BOOST_TEST(cref_passthru(cref(x)) == &x); - BOOST_TEST(&cref(x).get() == &x); - } - - BOOST_STATIC_CONSTANT( - bool, t_is_constant = boost::is_const::value); - static void test(T x) { BOOST_TEST(passthru(ref(x)) == &x); - - BOOST_TEST((is_same::type,T>::value)); - BOOST_TEST(&ref(x).get() == &x); - typedef reference_wrapper wrapped; - BOOST_TEST(is_reference_wrapper::value); - - typedef typename unwrap_reference::type unwrapped_wrapper; - BOOST_TEST((is_same::value)); - - typedef typename unwrap_reference::type unwrapped_self; - BOOST_TEST((is_same::value)); - - cref_test(x, select()); + BOOST_TEST(cref_passthru(cref(x)) == &x); + BOOST_TEST(&cref(x).get() == &x); } }; @@ -114,11 +68,7 @@ struct wrapper int test_main(int, char * []) { - wrapper::test(1); - wrapper::test(1); - BOOST_TEST(!is_reference_wrapper::value); - BOOST_TEST(!is_reference_wrapper::value); - BOOST_TEST(!is_reference_wrapper::value); - BOOST_TEST(!is_reference_wrapper::value); + ref_wrapper::test(1); + ref_wrapper::test(1); return 0; } From 6c35fd5ecab82c87df6db62a17f30aaee6c12474 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Sun, 27 Jan 2002 13:39:06 +0000 Subject: [PATCH 015/109] compile-time ref.hpp header test, initial checkin [SVN r12525] --- ref_ct_test.cpp | 115 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 ref_ct_test.cpp diff --git a/ref_ct_test.cpp b/ref_ct_test.cpp new file mode 100644 index 0000000..d9af429 --- /dev/null +++ b/ref_ct_test.cpp @@ -0,0 +1,115 @@ +// compile-time test for "boost/ref.hpp" header content +// see 'ref_test.cpp' for run-time part + +#include +#include +#include + +namespace { + +template< typename T, typename U > +void ref_test(boost::reference_wrapper) +{ + typedef typename boost::reference_wrapper::type type; + BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::is_same::value)); +} + +template< typename T > +void assignable_test(T x) +{ + x = x; +} + +template< bool R, typename T > +void is_reference_wrapper_test(T) +{ + BOOST_STATIC_ASSERT(boost::is_reference_wrapper::value == R); +} + +template< typename R, typename Ref > +void cxx_reference_test(Ref) +{ + BOOST_STATIC_ASSERT((boost::is_same::value)); +} + +template< typename R, typename Ref > +void unwrap_reference_test(Ref) +{ + typedef typename boost::unwrap_reference::type type; + BOOST_STATIC_ASSERT((boost::is_same::value)); +} + +} // namespace + +int main() +{ + int i = 0; + int& ri = i; + + int const ci = 0; + int const& rci = ci; + + // 'ref/cref' functions test + ref_test(boost::ref(i)); + ref_test(boost::ref(ri)); + ref_test(boost::ref(ci)); + ref_test(boost::ref(rci)); + + ref_test(boost::cref(i)); + ref_test(boost::cref(ri)); + ref_test(boost::cref(ci)); + ref_test(boost::cref(rci)); + + // test 'assignable' requirement + assignable_test(boost::ref(i)); + assignable_test(boost::ref(ri)); + assignable_test(boost::cref(i)); + assignable_test(boost::cref(ci)); + assignable_test(boost::cref(rci)); + + // 'is_reference_wrapper' test + is_reference_wrapper_test(boost::ref(i)); + is_reference_wrapper_test(boost::ref(ri)); + is_reference_wrapper_test(boost::cref(i)); + is_reference_wrapper_test(boost::cref(ci)); + is_reference_wrapper_test(boost::cref(rci)); + + is_reference_wrapper_test(i); + is_reference_wrapper_test(ri); + is_reference_wrapper_test(ci); + is_reference_wrapper_test(rci); + + // ordinary references/function template arguments deduction test + cxx_reference_test(i); + cxx_reference_test(ri); + cxx_reference_test(ci); + cxx_reference_test(rci); + + cxx_reference_test(i); + cxx_reference_test(ri); + cxx_reference_test(i); + cxx_reference_test(ri); + cxx_reference_test(ci); + cxx_reference_test(rci); + + // 'unwrap_reference' test + unwrap_reference_test(boost::ref(i)); + unwrap_reference_test(boost::ref(ri)); + unwrap_reference_test(boost::cref(i)); + unwrap_reference_test(boost::cref(ci)); + unwrap_reference_test(boost::cref(rci)); + + unwrap_reference_test(i); + unwrap_reference_test(ri); + unwrap_reference_test(ci); + unwrap_reference_test(rci); + unwrap_reference_test(i); + unwrap_reference_test(ri); + unwrap_reference_test(i); + unwrap_reference_test(ri); + unwrap_reference_test(ci); + unwrap_reference_test(rci); + + return 0; +} From 32e43f35e2775f9679ff2bedc5452081f04f9899 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 15 Feb 2002 13:31:58 +0000 Subject: [PATCH 016/109] Added a default constructor to shared_count and shared_ptr for incomplete types (void). [SVN r12815] --- include/boost/checked_delete.hpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index ad11d58..abb2ce0 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -44,19 +44,6 @@ template struct checked_deleter } }; -// checked_deleter is needed by shared_ptr::reset(0) - -template<> struct checked_deleter -{ - typedef void result_type; - typedef void * argument_type; - - void operator()(void * x) - { - ::operator delete(x); // avoid g++ warning - } -}; - template struct checked_array_deleter { typedef void result_type; From 0fb3e5888180afe2edfba6ce11e289cfd82c5503 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 9 Mar 2002 20:34:06 +0000 Subject: [PATCH 017/109] Added Copyright [SVN r13145] --- include/boost/ref.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index cf85e64..9a93fb2 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -12,6 +12,7 @@ // // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2001 Peter Dimov +// Copyright (C) 2002 David Abrahams // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. From 7cc6436afc6f9877d636d29d4caecb1b7869d431 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 31 Mar 2002 00:24:00 +0000 Subject: [PATCH 018/109] boost/ref.hpp: - Added get_pointer method to return a pointer (instead of a reference) libs/bind/ref.html: - Document get_pointer [SVN r13322] --- include/boost/ref.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 9a93fb2..c7e23ca 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -36,6 +36,8 @@ public: T& get() const { return *t_; } + T* get_pointer() const { return t_; } + private: T* t_; From 380e34f2be84a28962ee3fd24c9de80977b53f03 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 10 Apr 2002 03:31:18 +0000 Subject: [PATCH 019/109] boost/utility.hpp: - Include boost/utility/addressof.hpp boost/utility/addressof.hpp: - addressof() implementation libs/utility/utility.htm: - Document addressof libs/utility/addressof_test.cpp: - Test addressof() [SVN r13414] --- addressof_test.cpp | 46 +++++++++++++++++++++++++ include/boost/utility/addressof.hpp | 53 +++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 addressof_test.cpp create mode 100644 include/boost/utility/addressof.hpp diff --git a/addressof_test.cpp b/addressof_test.cpp new file mode 100644 index 0000000..62d988c --- /dev/null +++ b/addressof_test.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2002 Brad King (brad.king@kitware.com) +// Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#define BOOST_INCLUDE_MAIN +#include +#include + +struct useless_type {}; + +class nonaddressable { +public: + void dummy(); // Silence GCC warning: all member of class are private + +private: + useless_type operator&() const; +}; + +int test_main(int, char*[]) +{ + nonaddressable* px = new nonaddressable(); + + nonaddressable& x = *px; + BOOST_TEST(boost::addressof(x) == px); + + const nonaddressable& cx = *px; + BOOST_TEST(boost::addressof(cx) == static_cast(px)); + + volatile nonaddressable& vx = *px; + BOOST_TEST(boost::addressof(vx) == static_cast(px)); + + const volatile nonaddressable& cvx = *px; + BOOST_TEST(boost::addressof(cvx) == static_cast(px)); + + return 0; +} diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp new file mode 100644 index 0000000..ee997ff --- /dev/null +++ b/include/boost/utility/addressof.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2002 Brad King (brad.king@kitware.com) +// Doug Gregor (gregod@cs.rpi.edu) +// +// Permission to copy, use, sell and distribute this software is granted +// provided this copyright notice appears in all copies. +// Permission to modify the code and to distribute modified code is granted +// provided this copyright notice appears in all copies, and a notice +// that the code was modified is included with the copyright notice. +// +// This software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. + +// For more information, see http://www.boost.org + +#ifndef BOOST_UTILITY_ADDRESSOF_HPP +#define BOOST_UTILITY_ADDRESSOF_HPP + +namespace boost { + +template +inline T* addressof(T& v) +{ + struct addressof_helper {}; + return reinterpret_cast(&reinterpret_cast(v)); +} + +template +inline const T* addressof(const T& v) +{ + struct addressof_helper {}; + return reinterpret_cast( + &reinterpret_cast(v)); +} + +template +inline volatile T* addressof(volatile T& v) +{ + struct addressof_helper {}; + return reinterpret_cast( + &reinterpret_cast(v)); +} + +template +inline const volatile T* addressof(const volatile T& v) +{ + struct addressof_helper {}; + return reinterpret_cast( + &reinterpret_cast(v)); +} + +} + +#endif // BOOST_UTILITY_ADDRESSOF_HPP From 7c48c7ad2833d7085179284082396ca74ab5ab96 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 10 Apr 2002 03:36:17 +0000 Subject: [PATCH 020/109] ref.hpp: - Use addressof() instead of & operator [SVN r13416] --- include/boost/ref.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index c7e23ca..e45dd17 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -6,6 +6,7 @@ # endif # include +# include // // ref.hpp - ref/cref, useful helper functions @@ -30,7 +31,7 @@ template class reference_wrapper public: typedef T type; - explicit reference_wrapper(T& t): t_(&t) {} + explicit reference_wrapper(T& t): t_(addressof(t)) {} operator T& () const { return *t_; } From a5db30a747c3395798b74aa36bb27b8ac0819a1a Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 10 Apr 2002 04:00:22 +0000 Subject: [PATCH 021/109] Make local classes nonlocal to silence annoying warnings from Borland C++ [SVN r13418] --- include/boost/utility/addressof.hpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index ee997ff..11a9fd3 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -17,35 +17,36 @@ namespace boost { +namespace detail { + struct addressof_helper {}; +} + template inline T* addressof(T& v) { - struct addressof_helper {}; - return reinterpret_cast(&reinterpret_cast(v)); + return reinterpret_cast( + &reinterpret_cast(v)); } template inline const T* addressof(const T& v) { - struct addressof_helper {}; return reinterpret_cast( - &reinterpret_cast(v)); + &reinterpret_cast(v)); } template inline volatile T* addressof(volatile T& v) { - struct addressof_helper {}; return reinterpret_cast( - &reinterpret_cast(v)); + &reinterpret_cast(v)); } template inline const volatile T* addressof(const volatile T& v) { - struct addressof_helper {}; return reinterpret_cast( - &reinterpret_cast(v)); + &reinterpret_cast(v)); } } From 49938f88e8a02848aac0ecb873e9764267e21374 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 10 Apr 2002 09:48:30 +0000 Subject: [PATCH 022/109] Roll back addressof() patch temporarily [SVN r13428] --- include/boost/ref.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index e45dd17..c7e23ca 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -6,7 +6,6 @@ # endif # include -# include // // ref.hpp - ref/cref, useful helper functions @@ -31,7 +30,7 @@ template class reference_wrapper public: typedef T type; - explicit reference_wrapper(T& t): t_(addressof(t)) {} + explicit reference_wrapper(T& t): t_(&t) {} operator T& () const { return *t_; } From 72c113f7956f6d3952bfec1ffa2f1cfeda211aa3 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 10 Apr 2002 14:47:32 +0000 Subject: [PATCH 023/109] addressof.hpp: - Peter Dimov suggested a fix to deal with those evil cv-qualifiers [SVN r13431] --- include/boost/utility/addressof.hpp | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 11a9fd3..22da536 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -17,36 +17,11 @@ namespace boost { -namespace detail { - struct addressof_helper {}; -} - template inline T* addressof(T& v) { return reinterpret_cast( - &reinterpret_cast(v)); -} - -template -inline const T* addressof(const T& v) -{ - return reinterpret_cast( - &reinterpret_cast(v)); -} - -template -inline volatile T* addressof(volatile T& v) -{ - return reinterpret_cast( - &reinterpret_cast(v)); -} - -template -inline const volatile T* addressof(const volatile T& v) -{ - return reinterpret_cast( - &reinterpret_cast(v)); + &const_cast(reinterpret_cast(v))); } } From bb94cb5a5d4fcd43c6676a91ce4cd01fe299b1b0 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 10 Apr 2002 17:01:35 +0000 Subject: [PATCH 024/109] Roll addressof() patch back in! [SVN r13433] --- include/boost/ref.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index c7e23ca..e45dd17 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -6,6 +6,7 @@ # endif # include +# include // // ref.hpp - ref/cref, useful helper functions @@ -30,7 +31,7 @@ template class reference_wrapper public: typedef T type; - explicit reference_wrapper(T& t): t_(&t) {} + explicit reference_wrapper(T& t): t_(addressof(t)) {} operator T& () const { return *t_; } From 5185b371af16c525e2a5a1bf2be264dd28b671fc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 13 Apr 2002 13:19:57 +0000 Subject: [PATCH 025/109] MSVC fixes. [SVN r13476] --- include/boost/ref.hpp | 10 +++++++++- include/boost/utility/addressof.hpp | 8 +++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index e45dd17..9a6fbc5 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -12,7 +12,7 @@ // ref.hpp - ref/cref, useful helper functions // // Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) -// Copyright (C) 2001 Peter Dimov +// Copyright (C) 2001, 2002 Peter Dimov // Copyright (C) 2002 David Abrahams // // Permission to copy, use, modify, sell and distribute this software @@ -31,8 +31,16 @@ template class reference_wrapper public: typedef T type; +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) + + explicit reference_wrapper(T& t): t_(&t) {} + +#else + explicit reference_wrapper(T& t): t_(addressof(t)) {} +#endif + operator T& () const { return *t_; } T& get() const { return *t_; } diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 22da536..a434b8e 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -1,5 +1,6 @@ // Copyright (C) 2002 Brad King (brad.king@kitware.com) // Doug Gregor (gregod@cs.rpi.edu) +// Peter Dimov // // Permission to copy, use, sell and distribute this software is granted // provided this copyright notice appears in all copies. @@ -17,11 +18,12 @@ namespace boost { -template -inline T* addressof(T& v) +// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov) + +template T* addressof(T& v) { return reinterpret_cast( - &const_cast(reinterpret_cast(v))); + &const_cast(reinterpret_cast(v))); } } From dbfe562a3f3a2604890c971ac8380bf9f9b87afe Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 4 May 2002 10:55:15 +0000 Subject: [PATCH 026/109] Borland C++ Builder 6 fixes [SVN r13659] --- include/boost/ref.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 9a6fbc5..60a834b 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -52,7 +52,7 @@ private: T* t_; }; -# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x551) +# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x560) # define BOOST_REF_CONST # else # define BOOST_REF_CONST const From 6e498682d19a33f06dcf42e1d37c1dc0528ed737 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 25 Aug 2002 11:57:37 +0000 Subject: [PATCH 027/109] Misc Kylix fixes [SVN r15086] --- include/boost/ref.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 60a834b..a8d996c 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -52,7 +52,7 @@ private: T* t_; }; -# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x560) +# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x570) # define BOOST_REF_CONST # else # define BOOST_REF_CONST const From 41354ce3a1f09ed57f79e1cc8c37fec697aa8bf8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 23 Oct 2002 13:55:18 +0000 Subject: [PATCH 028/109] Changed typename to class; some libraries helpfully #define typename [SVN r15970] --- include/boost/checked_delete.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index abb2ce0..9e42d9c 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -21,13 +21,13 @@ namespace boost // verify that types are complete for increased safety -template< typename T > inline void checked_delete(T * x) +template inline void checked_delete(T * x) { typedef char type_must_be_complete[sizeof(T)]; delete x; } -template< typename T > inline void checked_array_delete(T * x) +template inline void checked_array_delete(T * x) { typedef char type_must_be_complete[sizeof(T)]; delete [] x; From c5fdd6e9519feecb894d19e76293f5c539d1f361 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 14 Nov 2002 14:53:32 +0000 Subject: [PATCH 029/109] checked_delete.hpp documentation added. [SVN r16238] --- checked_delete.html | 124 +++++++++++++++++++++++++++++++ include/boost/checked_delete.hpp | 3 + 2 files changed, 127 insertions(+) create mode 100644 checked_delete.html diff --git a/checked_delete.html b/checked_delete.html new file mode 100644 index 0000000..bd7753e --- /dev/null +++ b/checked_delete.html @@ -0,0 +1,124 @@ + + + + Boost: checked_delete.hpp documentation + + + + + + + + + + + +
+ c++boost.gif (8819 bytes) + +

checked_delete.hpp

+
 
+

+ The header <boost/checked_delete.hpp> defines two + function templates, checked_delete and checked_array_delete, + and two class templates, checked_deleter and checked_array_deleter. +

+

The C++ Standard allows, in 5.3.5/5, pointers to incomplete class types to + be deleted with a delete-expression. When the class has a non-trivial + destructor, or a class-specific operator delete, the behavior is undefined. + Some compilers issue a warning when an incomplete type is deleted, but + unfortunately, not all do, and programmers sometimes ignore or disable + warnings.

+

A particularly troublesome case is when a smart pointer's destructor, such as + boost::scoped_ptr<T>::~scoped_ptr, is instantiated with an + incomplete type. This can often lead to silent, hard to track failures.

+

The supplied function and class templates can be used to prevent these problems, + as they require a complete type, and cause a compilation error otherwise.

+

Synopsis

+
+namespace boost
+{
+
+template<class T> void checked_delete(T * p);
+template<class T> void checked_array_delete(T * p);
+template<class T> struct checked_deleter;
+template<class T> struct checked_array_deleter;
+
+}
+
+

checked_delete

+

template<class T> void checked_delete(T * p);

+
+

+ Requires: T must be a complete type. The expression delete p + must be well-formed. +

+

+ Effects: delete p; +

+
+

checked_array_delete

+

template<class T> void checked_array_delete(T + * p);

+
+

+ Requires: T must be a complete type. The expression delete [] p + must be well-formed. +

+

+ Effects: delete [] p; +

+
+

checked_deleter

+
+template<class T> struct checked_deleter
+{
+    typedef void result_type;
+    typedef T * argument_type;
+    void operator()(T * p);
+};
+
+

void checked_deleter<T>::operator()(T * p);

+
+

+ Requires: T must be a complete type. The expression delete p + must be well-formed. +

+

+ Effects: delete p; +

+
+

checked_array_deleter

+
+template<class T> struct checked_array_deleter
+{
+    typedef void result_type;
+    typedef T * argument_type;
+    void operator()(T * p);
+};
+
+

void checked_array_deleter<T>::operator()(T * p);

+
+

+ Requires: T must be a complete type. The expression delete [] p + must be well-formed. +

+

+ Effects: delete [] p; +

+
+

Acknowledgements

+

+ The function templates checked_delete and checked_array_delete + were originally part of <boost/utility.hpp>, and the + documentation acknowledged Beman Dawes, Dave Abrahams, Vladimir Prus, + Rainer Deyke, John Maddock, and others as contributors. +

+

+
+ Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell + and distribute this document is granted provided this copyright notice appears + in all copies. This document is provided "as is" without express or implied + warranty, and with no claim as to its suitability for any purpose.

+ + diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index 9e42d9c..bf689c9 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -9,12 +9,15 @@ // boost/checked_delete.hpp // // Copyright (c) 1999, 2000, 2001, 2002 boost.org +// Copyright (c) 2002 Peter Dimov // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // +// http://www.boost.org/libs/utility/checked_delete.html +// namespace boost { From c54b0184bbacbe7732abf6ff16f9efda28854261 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Mon, 23 Dec 2002 02:43:12 +0000 Subject: [PATCH 030/109] Add /libs/lib-name to comment [SVN r16685] --- include/boost/checked_delete.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index bf689c9..223b4b5 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -16,7 +16,7 @@ // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // -// http://www.boost.org/libs/utility/checked_delete.html +// See http://www.boost.org/libs/utility/checked_delete.html for documentation. // namespace boost From 9db43ee00f54d2081c68a73b4aa7f6c893609114 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 8 Jan 2003 17:21:10 +0000 Subject: [PATCH 031/109] Workaround VC7 bug which strips const from nested classes [SVN r16797] --- include/boost/utility/addressof.hpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index a434b8e..de8dfe5 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -14,13 +14,25 @@ // For more information, see http://www.boost.org #ifndef BOOST_UTILITY_ADDRESSOF_HPP -#define BOOST_UTILITY_ADDRESSOF_HPP +# define BOOST_UTILITY_ADDRESSOF_HPP + +# include +# include +# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) +# include +# endif namespace boost { // Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov) -template T* addressof(T& v) +// VC7 strips const from nested classes unless we add indirection here +# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) +template typename add_pointer::type +# else +template T* +# endif +addressof(T& v) { return reinterpret_cast( &const_cast(reinterpret_cast(v))); From 3bbcb3aff216446ada8818bda469688653487ad6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 14 Feb 2003 16:20:01 +0000 Subject: [PATCH 032/109] Made operator()s const. [SVN r17411] --- checked_delete.html | 22 +++++++++++----------- include/boost/checked_delete.hpp | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/checked_delete.html b/checked_delete.html index bd7753e..4af2ae7 100644 --- a/checked_delete.html +++ b/checked_delete.html @@ -23,8 +23,8 @@ function templates, checked_delete and checked_array_delete, and two class templates, checked_deleter and checked_array_deleter.

-

The C++ Standard allows, in 5.3.5/5, pointers to incomplete class types to - be deleted with a delete-expression. When the class has a non-trivial +

The C++ Standard allows, in 5.3.5/5, pointers to incomplete class types to be + deleted with a delete-expression. When the class has a non-trivial destructor, or a class-specific operator delete, the behavior is undefined. Some compilers issue a warning when an incomplete type is deleted, but unfortunately, not all do, and programmers sometimes ignore or disable @@ -75,10 +75,10 @@ template<class T> struct checked_deleter { typedef void result_type; typedef T * argument_type; - void operator()(T * p); + void operator()(T * p) const; }; -

void checked_deleter<T>::operator()(T * p);

+

void checked_deleter<T>::operator()(T * p) const;

Requires: T must be a complete type. The expression delete p @@ -94,10 +94,10 @@ template<class T> struct checked_array_deleter { typedef void result_type; typedef T * argument_type; - void operator()(T * p); + void operator()(T * p) const; }; -

void checked_array_deleter<T>::operator()(T * p);

+

void checked_array_deleter<T>::operator()(T * p) const;

Requires: T must be a complete type. The expression delete [] p @@ -111,14 +111,14 @@ template<class T> struct checked_array_deleter

The function templates checked_delete and checked_array_delete were originally part of <boost/utility.hpp>, and the - documentation acknowledged Beman Dawes, Dave Abrahams, Vladimir Prus, - Rainer Deyke, John Maddock, and others as contributors. + documentation acknowledged Beman Dawes, Dave Abrahams, Vladimir Prus, Rainer + Deyke, John Maddock, and others as contributors.


- Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell - and distribute this document is granted provided this copyright notice appears - in all copies. This document is provided "as is" without express or implied + Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell and + distribute this document is granted provided this copyright notice appears in + all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.

diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index 223b4b5..aa8a7a5 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -9,7 +9,7 @@ // boost/checked_delete.hpp // // Copyright (c) 1999, 2000, 2001, 2002 boost.org -// Copyright (c) 2002 Peter Dimov +// Copyright (c) 2002, 2003 Peter Dimov // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. @@ -41,7 +41,7 @@ template struct checked_deleter typedef void result_type; typedef T * argument_type; - void operator()(T * x) + void operator()(T * x) const { checked_delete(x); } @@ -52,7 +52,7 @@ template struct checked_array_deleter typedef void result_type; typedef T * argument_type; - void operator()(T * x) + void operator()(T * x) const { checked_array_delete(x); } From 3c00d03d37641463eea90f74d77d3c29b1ada4d8 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Mon, 17 Feb 2003 06:20:57 +0000 Subject: [PATCH 033/109] split utility.hpp header [SVN r17472] --- checked_delete_test.cpp | 2 +- include/boost/noncopyable.hpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 include/boost/noncopyable.hpp diff --git a/checked_delete_test.cpp b/checked_delete_test.cpp index f9107c8..161b49f 100644 --- a/checked_delete_test.cpp +++ b/checked_delete_test.cpp @@ -11,7 +11,7 @@ // Revision History // 21 May 01 Initial version (Beman Dawes) -#include // for checked_delete +#include // for checked_delete // This program demonstrates compiler errors when trying to delete an // incomplete type. diff --git a/include/boost/noncopyable.hpp b/include/boost/noncopyable.hpp new file mode 100644 index 0000000..e2c8399 --- /dev/null +++ b/include/boost/noncopyable.hpp @@ -0,0 +1,33 @@ +// Boost noncopyable.hpp header file --------------------------------------// + +// (C) Copyright Boost.org 1999-2003. Permission to copy, use, modify, sell +// and distribute this software is granted provided this copyright +// notice appears in all copies. This software is provided "as is" without +// express or implied warranty, and with no claim as to its suitability for +// any purpose. + +// See http://www.boost.org/libs/utility for documentation. + +#ifndef BOOST_NONCOPYABLE_HPP_INCLUDED +#define BOOST_NONCOPYABLE_HPP_INCLUDED + +namespace boost { + +// Private copy constructor and copy assignment ensure classes derived from +// class noncopyable cannot be copied. + +// Contributed by Dave Abrahams + +class noncopyable +{ + protected: + noncopyable() {} + ~noncopyable() {} + private: // emphasize the following members are private + noncopyable( const noncopyable& ); + const noncopyable& operator=( const noncopyable& ); +}; + +} // namespace boost + +#endif // BOOST_NONCOPYABLE_HPP_INCLUDED From dc49e072032a6d77051bca9f796a5cd79dc5ac2f Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 25 Feb 2003 00:57:33 +0000 Subject: [PATCH 034/109] fix metafunctions for MPL [SVN r17621] --- include/boost/ref.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index a8d996c..c8a46c3 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -7,6 +7,7 @@ # include # include +# include // // ref.hpp - ref/cref, useful helper functions @@ -73,16 +74,14 @@ template inline reference_wrapper BOOST_REF_CONST cref(T const # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template class is_reference_wrapper + : public mpl::false_c { - public: - BOOST_STATIC_CONSTANT(bool, value = false); }; template class is_reference_wrapper > + : public mpl::true_c { - public: - BOOST_STATIC_CONSTANT(bool, value = true); }; template @@ -144,8 +143,10 @@ class is_reference_wrapper public: BOOST_STATIC_CONSTANT( bool, value = ( - sizeof(detail::is_reference_wrapper_test(type())) + sizeof(detail::is_reference_wrapper_test(type())) == sizeof(detail::yes_reference_wrapper_t))); + + typedef ::boost::mpl::bool_c type; }; template From d1b6b6a41c2d67bb44283b5830f575ec383cc5f3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 25 Feb 2003 13:00:22 +0000 Subject: [PATCH 035/109] Qualified checked_delete calls to prevent ADL (reported by Daniel Frey) [SVN r17636] --- include/boost/checked_delete.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index aa8a7a5..92a3d0a 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -43,7 +43,7 @@ template struct checked_deleter void operator()(T * x) const { - checked_delete(x); + boost::checked_delete(x); } }; @@ -54,7 +54,7 @@ template struct checked_array_deleter void operator()(T * x) const { - checked_array_delete(x); + boost::checked_array_delete(x); } }; From e1296cf76b51e6412449698d0c768e01f0ade51a Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Tue, 25 Feb 2003 23:11:41 +0000 Subject: [PATCH 036/109] MPL names/directory structure refactoring [SVN r17651] --- include/boost/ref.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index c8a46c3..52f01cd 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -7,7 +7,7 @@ # include # include -# include +# include // // ref.hpp - ref/cref, useful helper functions @@ -74,13 +74,13 @@ template inline reference_wrapper BOOST_REF_CONST cref(T const # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template class is_reference_wrapper - : public mpl::false_c + : public mpl::false_ { }; template class is_reference_wrapper > - : public mpl::true_c + : public mpl::true_ { }; @@ -146,7 +146,7 @@ class is_reference_wrapper sizeof(detail::is_reference_wrapper_test(type())) == sizeof(detail::yes_reference_wrapper_t))); - typedef ::boost::mpl::bool_c type; + typedef ::boost::mpl::bool_ type; }; template From 5da17fb9ef8fe537b05aac0d60a7a09c02b7f3d6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 12 Jun 2003 17:09:24 +0000 Subject: [PATCH 037/109] -Wundef fixes. [SVN r18788] --- include/boost/checked_delete.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index 92a3d0a..f2300dd 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -1,8 +1,8 @@ #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED #define BOOST_CHECKED_DELETE_HPP_INCLUDED -#if _MSC_VER >= 1020 -#pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once #endif // From 82aa7bfcbc140a8dbfdc2c86643df1977ccdb17c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 16 Jul 2003 10:53:06 +0000 Subject: [PATCH 038/109] Fixed Intel 7 issue (reported by Daniel Frey) [SVN r19145] --- checked_delete_test.cpp | 5 ++--- include/boost/checked_delete.hpp | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/checked_delete_test.cpp b/checked_delete_test.cpp index 161b49f..f5c799e 100644 --- a/checked_delete_test.cpp +++ b/checked_delete_test.cpp @@ -23,9 +23,8 @@ namespace int main() { - Incomplete * p; + Incomplete * p = 0; boost::checked_delete(p); // should cause compile time error - Incomplete ** pa; - boost::checked_array_delete(pa); // should cause compile time error + boost::checked_array_delete(p); // should cause compile time error return 0; } // main diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index f2300dd..3f7ca47 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -26,13 +26,14 @@ namespace boost template inline void checked_delete(T * x) { - typedef char type_must_be_complete[sizeof(T)]; + // Intel 7 accepts sizeof(incomplete) as 0 in system headers + typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; delete x; } template inline void checked_array_delete(T * x) { - typedef char type_must_be_complete[sizeof(T)]; + typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; delete [] x; } @@ -43,6 +44,7 @@ template struct checked_deleter void operator()(T * x) const { + // boost:: disables ADL boost::checked_delete(x); } }; From e6d3d3dbb188bd5d6aac6e97c7609efa3494e282 Mon Sep 17 00:00:00 2001 From: Daniel Frey Date: Sat, 16 Aug 2003 01:05:43 +0000 Subject: [PATCH 039/109] Fix for Metrowerks CW [SVN r19626] --- include/boost/checked_delete.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index 3f7ca47..480c041 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -10,6 +10,8 @@ // // Copyright (c) 1999, 2000, 2001, 2002 boost.org // Copyright (c) 2002, 2003 Peter Dimov +// Copyright (c) 2003 Daniel Frey +// Copyright (c) 2003 Howard Hinnant // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. @@ -26,14 +28,16 @@ namespace boost template inline void checked_delete(T * x) { - // Intel 7 accepts sizeof(incomplete) as 0 in system headers + // intentionally complex - simplification causes regressions typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; + (void) sizeof(type_must_be_complete); delete x; } template inline void checked_array_delete(T * x) { typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; + (void) sizeof(type_must_be_complete); delete [] x; } From 621c828e124af93843cd3a9bf3c10aeead083bc9 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 12 Sep 2003 17:09:29 +0000 Subject: [PATCH 040/109] Change license message to reference Boost Software License [SVN r20038] --- checked_delete_test.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/checked_delete_test.cpp b/checked_delete_test.cpp index f5c799e..1ffc1fd 100644 --- a/checked_delete_test.cpp +++ b/checked_delete_test.cpp @@ -1,12 +1,9 @@ // Boost checked_delete test program ---------------------------------------// -// (C) Copyright Beman Dawes 2001. Permission to copy, use, modify, sell -// and distribute this software is granted provided this copyright -// notice appears in all copies. This software is provided "as is" without -// express or implied warranty, and with no claim as to its suitability for -// any purpose. +// Copyright Beman Dawes 2001. +// See accompanying license for terms and conditions of use. -// See http://www.boost.org for most recent version including documentation. +// See http://www.boost.org/libs/utility for documentation. // Revision History // 21 May 01 Initial version (Beman Dawes) From 5a900e5817665aedf90921336afcbab39ed91208 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 28 Nov 2003 15:35:21 +0000 Subject: [PATCH 041/109] _MSC_VER use clarified. [SVN r20992] --- include/boost/checked_delete.hpp | 2 ++ include/boost/ref.hpp | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index 480c041..d7f5212 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -1,6 +1,8 @@ #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED #define BOOST_CHECKED_DELETE_HPP_INCLUDED +// MS compatible compilers support #pragma once + #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 52f01cd..8ff5725 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -1,13 +1,15 @@ #ifndef BOOST_REF_HPP_INCLUDED -# define BOOST_REF_HPP_INCLUDED +#define BOOST_REF_HPP_INCLUDED -# if _MSC_VER+0 >= 1020 -# pragma once -# endif +// MS compatible compilers support #pragma once -# include -# include -# include +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +#include +#include +#include // // ref.hpp - ref/cref, useful helper functions From ceedace2e3b415c3ac0fc95fe0ad1fa752201a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20J=C3=A4rvi?= Date: Tue, 2 Dec 2003 21:41:15 +0000 Subject: [PATCH 042/109] Added enable_if library [SVN r21090] --- enable_if.html | 417 ++++++++++++++++++++++++++++ include/boost/utility/enable_if.hpp | 69 +++++ 2 files changed, 486 insertions(+) create mode 100644 enable_if.html create mode 100644 include/boost/utility/enable_if.hpp diff --git a/enable_if.html b/enable_if.html new file mode 100644 index 0000000..349189e --- /dev/null +++ b/enable_if.html @@ -0,0 +1,417 @@ + + +enable_if + + + + + + + + + + +
+
+ + +

+enable_if

+
+
+Copyright 2003 Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine.
+
+ + +

1  Introduction

+ + +The enable_if family of templates is a set of tools to allow a function template or a class template specialization +to include or exclude itself from a set of matching functions or specializations +based on properties of its template arguments. +For example, one can define function templates that +are only enabled for, and thus only match, an arbitrary set of types +defined by a traits class. The enable_if templates can also be +applied to enable class template specializations. Applications of +enable_if are discussed in length +in [1] and [2].
+
+ + +

1.1  Synopsis

+ + +
+namespace boost {
+  template <class Cond, class T = void> struct enable_if;
+  template <class Cond, class T = void> struct disable_if;
+  template <class Cond, class T> struct lazy_enable_if;
+  template <class Cond, class T> struct lazy_disable_if;
+
+  template <bool B, class T = void> struct enable_if_c;
+  template <bool B, class T = void> struct disable_if_c;
+  template <bool B, class T> struct lazy_enable_if_c;
+  template <bool B, class T> struct lazy_disable_if_c;
+}
+
+ + +

1.2  Background

+ + +Sensible operation of template function overloading in C++ relies +on the SFINAE (substitution-failure-is-not-an-error) +principle [3]: if an invalid argument +or return type is formed during the instantiation of a function +template, the instantiation is removed from the overload resolution +set instead of causing a compilation error. The following example, +taken from [1], +demonstrates why this is important: +
+
+int negate(int i) { return -i; }
+
+template <class F>
+typename F::result_type negate(const F& f) { return -f(); }
+
+
+Suppose the compiler encounters the call negate(1). The first +definition is obviously a better match, but the compiler must +nevertheless consider (and instantiate the prototypes) of both +definitions to find this out. Instantiating the latter definition with +F as int would result in: +
+
+int::result_type negate(const int&);
+
+
+where the return type is invalid. If this was an error, adding an unrelated function template +(that was never called) could break otherwise valid code. +Due to the SFINAE principle the above example is not, however, erroneous. +The latter definition of negate is simply removed from the overload resolution set.
+
+The enable_if templates are tools for controlled creation of the SFINAE +conditions.
+
+ + +

2  The enable_if templates

+ + +The names of the enable_if templates have three parts: an optional lazy_ tag, +either enable_if or disable_if, and an optional _c tag. +All eight combinations of these parts are supported. +The meaning of the lazy_ tag is described in Section 3.3. +The second part of the name indicates whether a true condition argument should +enable or disable the current overload. +The third part of the name indicates whether the condition argument is a bool value +(_c suffix), or a type containing a static bool constant named value (no suffix). +The latter version interoperates with Boost.MPL.
+
+The definitions of enable_if_c and enable_if are as follows (we use enable_if templates +unqualified but they are in the boost namespace). +
+
+template <bool B, class T = void>
+struct enable_if_c {
+  typedef T type;
+};
+
+template <class T>
+struct enable_if_c<false, T> {};
+
+template <class Cond, class T = void>
+struct enable_if : public enable_if_c<Cond::value, T> {};
+
+
+An instantiation of the enable_if_c template with the parameter +B as true contains a member type type, defined +to be T. If B is +false, no such member is defined. Thus +enable_if_c<B, T>::type is either a valid or an invalid type +expression, depending on the value of B. +When valid, enable_if_c<B, T>::type equals T. +The enable_if_c template can thus be used for controlling when functions are considered for +overload resolution and when they are not. +For example, the following function is defined for all arithmetic types (according to the +classification of the Boost type_traits library): +
+
+template <class T>
+typename enable_if_c<boost::is_arithmetic<T>::value, T>::type 
+foo(T t) { return t; }
+
+
+The disable_if_c template is provided as well, and has the +same functionality as enable_if_c except for the negated condition. The following +function is enabled for all non-arithmetic types. +
+
+template <class T>
+typename disable_if_c<boost::is_arithmetic<T>::value, T>::type 
+bar(T t) { return t; }
+
+
+For easier syntax in some cases and interoperation with Boost.MPL we provide versions of +the enable_if templates taking any type with a bool member constant named +value as the condition argument. +The MPL bool_, and_, or_, and not_ templates are likely to be +useful for creating such types. Also, the traits classes in the Boost.Type_traits library +follow this convention. +For example, the above example function foo can be alternatively written as: +
+
+template <class T>
+typename enable_if<boost::is_arithmetic<T>, T>::type 
+foo(T t) { return t; }
+
+
+ + +

3  Using enable_if

+ + +The enable_if templates are defined in +boost/utility/enable_if.hpp, which is included by boost/utility.hpp.
+
+The enable_if template can be used either as the return type, or as an +extra argument. For example, the foo function in the previous section could also be written +as: +
+
+template <class T>
+T foo(T t, typename enable_if<boost::is_arithmetic<T> >::type* dummy = 0); 
+
+
Hence, an extra parameter of type void* is added, but it is given +a default value to keep the parameter hidden from client code. +Note that the second template argument was not given to enable_if, as the default +void gives the desired behavior.
+
+Whether to write the enabler as an argument or within the return type is +largely a matter of taste, but for certain functions, only one +alternative is possible: +
  • +Operators have a fixed number of arguments, thus enable_if must be used in the return type. +
  • Constructors and destructors do not have a return type; an extra argument is the only option. +
  • There does not seem to be a way to specify an enabler for a conversion operator. Converting constructors, +however, can have enablers as extra default arguments. +
+ + +

3.1  Enabling template class specializations

+ + +Class template specializations can be enabled or disabled with enable_if. +One extra template parameter needs to be added for the enabler expressions. +This parameter has the default value void. +For example: +
+
+template <class T, class Enable = void> 
+class A { ... };
+
+template <class T>
+class A<T, typename enable_if<is_integral<T> >::type> { ... };
+
+template <class T>
+class A<T, typename enable_if<is_float<T> >::type> { ... };
+
+
Instantiating A with any integral type matches the first specialization, +whereas any floating point type matches the second one. All other types +match the primary template. +The condition can be any compile-time boolean expression that depends on the +template arguments of the class. +Note that again, the second argument to enable_if is not needed; the default (void) +is the correct value.
+
+ + +

3.2  Overlapping enabler conditions

+ + +Once the compiler has examined the enabling conditions and included the +function into the overload resolution set, normal C++ overload resolution +rules are used to select the best matching function. +In particular, there is no ordering between enabling conditions. +Function templates with enabling conditions that are not mutually exclusive can +lead to ambiguities. For example: +
+
+template <class T>
+typename enable_if<boost::is_integral<T>, void>::type 
+foo(T t) {}
+
+template <class T>
+typename enable_if<boost::is_arithmetic<T>, void>::type 
+foo(T t) {}
+
+
+All integral types are also arithmetic. Therefore, say, for the call foo(1), +both conditions are true and both functions are thus in the overload resolution set. +They are both equally good matches and thus ambiguous. +Of course, more than one enabling condition can be simultaneously true as long as +other arguments disambiguate the functions.
+
+The above discussion applies to using enable_if in class template +partial specializations as well.
+
+ + +

3.3  Lazy enable_if

+ + +In some cases it is necessary to avoid instantiating part of a +function signature unless an enabling condition is true. For example: +
+
+template <class T, class U> class mult_traits;
+
+template <class T, class U>
+typename enable_if<is_multipliable<T, U>, typename mult_traits<T, U>::type>::type
+operator*(const T& t, const U& u) { ... }
+
+
Assume the class template mult_traits is a traits class defining +the resulting type of a multiplication operator. The is_multipliable traits +class specifies for which types to enable the operator. Whenever +is_multipliable<A, B>::value is true for some types A and B, +then mult_traits<A, B>::type is defined.
+
+Now, trying to invoke (some other overload) of operator* with, say, operand types C and D +for which is_multipliable<C, D>::value is false +and mult_traits<C, D>::type is not defined is an error on some compilers. +The SFINAE principle is not applied because +the invalid type occurs as an argument to another template. The lazy_enable_if +and lazy_disable_if templates (and their _c versions) can be used in such +situations: +
+
+template<class T, class U>
+typename lazy_enable_if<is_multipliable<T, U>, mult_traits<T, U> >::type
+operator*(const T& t, const U& u) { ... }
+
+
The second argument of lazy_enable_if must be a class type +that defines a nested type named type whenever the first +parameter (the condition) is true.
+
+ + +
Note
+ +Referring to one member type or static constant in a traits class +causes all of the members (type and static constant) of that +specialization to be instantiated. Therefore, if your traits classes +can sometimes contain invalid types, you should use two distinct +templates for describing the conditions and the type mappings. In the +above example, is_multipliable<T, U>::value defines when +mult_traits<T, U>::type is valid.
+
+ + +

3.4  Compiler workarounds

+ + +Some compilers flag functions as ambiguous if the only distinguishing factor is a different +condition in an enabler (even though the functions could never be ambiguous). For example, +some compilers (e.g. GCC 3.2) diagnose the following two functions as ambiguous: +
+
+template <class T>
+typename enable_if<boost::is_arithmetic<T>, T>::type 
+foo(T t);
+
+template <class T>
+typename disable_if<boost::is_arithmetic<T>, T>::type 
+foo(T t);
+
+
Two workarounds can be applied: +
  • +Use an extra dummy parameter which disambiguates the functions. Use a default value for +it to hide the parameter from the caller. For example: +
    +
    +template <class T> struct dummy { dummy(int) {} };
    +
    +template <class T>
    +typename enable_if<boost::is_arithmetic<T>, T>::type 
    +foo(T t, dummy<0> = 0);
    +
    +template <class T>
    +typename disable_if<boost::is_arithmetic<T>, T>::type 
    +foo(T t, dummy<1> = 0);
    +

    +
    +
  • Define the functions in different namespaces and bring them into a common +namespace with using declarations: +
    +
    +namespace A {
    +  template <class T>
    +  typename enable_if<boost::is_arithmetic<T>, T>::type 
    +  foo(T t);
    +}
    +
    +namespace B {
    +  template <class T>
    +  typename disable_if<boost::is_arithmetic<T>, T>::type 
    +  foo(T t);
    +}
    +
    +using A::foo;
    +using B::foo;
    +
    +
    +Note that the second workaround above cannot be used for member +templates. On the other hand, operators do not accept extra arguments, +which makes the first workaround unusable. As the net effect, +neither of the workarounds are of assistance for templated operators that +need to be defined as member functions (assignment and +subscript operators). +
+ + +

4  Acknowledgements

+ +We are grateful to Howard Hinnant, Jason Shirk, Paul Mensonides, and Richard +Smith whose findings have influenced the library.
+
+ + +

References

+
[1]
+Jaakko Järvi, Jeremiah Willcock, Howard Hinnant, and Andrew Lumsdaine. +Function overloading based on arbitrary properties of types. +C/C++ Users Journal, 21(6):25--32, June 2003.
+
+
[2]
+Jaakko Järvi, Jeremiah Willcock, and Andrew Lumsdaine. +Concept-controlled polymorphism. +In Frank Pfennig and Yannis Smaragdakis, editors, Generative + Programming and Component Engineering, volume 2830 of LNCS, pages + 228--244. Springer Verlag, September 2003.
+
+
[3]
+David Vandevoorde and Nicolai M. Josuttis. +C++ Templates: The Complete Guide. +Addison-Wesley, 2002.
+ + + + + +
+ +Contributed by:
+Jaakko Järvi, Jeremiah Willcock and Andrew Lumsdaine
+{jajarvi|jewillco|lums}@osl.iu.edu
+Indiana University
+Open Systems Lab + + + +
+
This document was translated from LATEX by +HEVEA. +
+ + diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp new file mode 100644 index 0000000..c1f217d --- /dev/null +++ b/include/boost/utility/enable_if.hpp @@ -0,0 +1,69 @@ +// Boost enable_if library + +// Copyright 2003 © The Trustees of Indiana University. + +// 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) + +// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Jeremiah Willcock (jewillco at osl.iu.edu) +// Andrew Lumsdaine (lums at osl.iu.edu) + + +#ifndef BOOST_UTILITY_ENABLE_IF_HPP +#define BOOST_UTILITY_ENABLE_IF_HPP + +namespace boost +{ + + template + struct enable_if_c { + typedef T type; + }; + + template + struct enable_if_c {}; + + template + struct enable_if : public enable_if_c {}; + + template + struct lazy_enable_if_c { + typedef typename T::type type; + }; + + template + struct lazy_enable_if_c {}; + + template + struct lazy_enable_if : public lazy_enable_if_c {}; + + + template + struct disable_if_c { + typedef T type; + }; + + template + struct disable_if_c {}; + + template + struct disable_if : public disable_if_c {}; + + template + struct lazy_disable_if_c { + typedef typename T::type type; + }; + + template + struct lazy_disable_if_c {}; + + template + struct lazy_disable_if : public lazy_disable_if_c {}; + + + +} // namespace boost + +#endif From d72a328c8e836a40f15cb34dd6408a67a5388313 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Wed, 3 Dec 2003 14:36:38 +0000 Subject: [PATCH 043/109] fix broken link to logo [SVN r21122] --- enable_if.html | 65 ++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/enable_if.html b/enable_if.html index 349189e..eb485c5 100644 --- a/enable_if.html +++ b/enable_if.html @@ -4,7 +4,7 @@ enable_if - + @@ -17,7 +17,7 @@

-enable_if

+enable_if

Copyright 2003 Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine.
@@ -42,8 +42,7 @@ in [1] and&n

1.1  Synopsis

-
-namespace boost {
+
namespace boost {
   template <class Cond, class T = void> struct enable_if;
   template <class Cond, class T = void> struct disable_if;
   template <class Cond, class T> struct lazy_enable_if;
@@ -68,9 +67,7 @@ template, the instantiation is removed from the overload resolution
 set instead of causing a compilation error. The following example, 
 taken from [1],
 demonstrates why this is important:
-
-
-int negate(int i) { return -i; }
+
int negate(int i) { return -i; }
 
 template <class F>
 typename F::result_type negate(const F& f) { return -f(); }
@@ -81,9 +78,7 @@ definition is obviously a better match, but the compiler must
 nevertheless consider (and instantiate the prototypes) of both
 definitions to find this out. Instantiating the latter definition with
 F as int would result in:
-
-
-int::result_type negate(const int&);
+
int::result_type negate(const int&);
 
 
where the return type is invalid. If this was an error, adding an unrelated function template @@ -111,9 +106,7 @@ The latter version interoperates with Boost.MPL.

The definitions of enable_if_c and enable_if are as follows (we use enable_if templates unqualified but they are in the boost namespace). -
-
-template <bool B, class T = void>
+
template <bool B, class T = void>
 struct enable_if_c {
   typedef T type;
 };
@@ -136,9 +129,7 @@ The enable_if_c template can thus be used for controlling when function
 overload resolution and when they are not. 
 For example, the following function is defined for all arithmetic types (according to the
 classification of the Boost type_traits library):
-
-
-template <class T>
+
template <class T>
 typename enable_if_c<boost::is_arithmetic<T>::value, T>::type 
 foo(T t) { return t; }
 
@@ -146,9 +137,7 @@ foo(T t) { return t; }
 The disable_if_c template is provided as well, and has the
 same functionality as enable_if_c except for the negated condition. The following
 function is enabled for all non-arithmetic types.
-
-
-template <class T>
+
template <class T>
 typename disable_if_c<boost::is_arithmetic<T>::value, T>::type 
 bar(T t) { return t; }
 
@@ -160,9 +149,7 @@ The MPL bool_, and_, or_, and not_ templates
 useful for creating such types. Also, the traits classes in the Boost.Type_traits library 
 follow this convention. 
 For example, the above example function foo can be alternatively written as:
-
-
-template <class T>
+
template <class T>
 typename enable_if<boost::is_arithmetic<T>, T>::type 
 foo(T t) { return t; }
 
@@ -178,9 +165,7 @@ The enable_if templates are defined in
 The enable_if template can be used either as the return type, or as an 
 extra argument. For example, the foo function in the previous section could also be written
 as:
-
-
-template <class T>
+
template <class T>
 T foo(T t, typename enable_if<boost::is_arithmetic<T> >::type* dummy = 0); 
 
 
Hence, an extra parameter of type void* is added, but it is given @@ -206,9 +191,7 @@ Class template specializations can be enabled or disabled with enable_ifvoid. For example: -
-
-template <class T, class Enable = void> 
+
template <class T, class Enable = void> 
 class A { ... };
 
 template <class T>
@@ -236,9 +219,7 @@ rules are used to select the best matching function.
 In particular, there is no ordering between enabling conditions.
 Function templates with enabling conditions that are not mutually exclusive can 
 lead to ambiguities. For example:
-
-
-template <class T>
+
template <class T>
 typename enable_if<boost::is_integral<T>, void>::type 
 foo(T t) {}
 
@@ -263,9 +244,7 @@ partial specializations as well.
In some cases it is necessary to avoid instantiating part of a function signature unless an enabling condition is true. For example: -
-
-template <class T, class U> class mult_traits;
+
template <class T, class U> class mult_traits;
 
 template <class T, class U>
 typename enable_if<is_multipliable<T, U>, typename mult_traits<T, U>::type>::type
@@ -284,9 +263,7 @@ The SFINAE principle is not applied because
 the invalid type occurs as an argument to another template. The lazy_enable_if 
 and lazy_disable_if templates (and their _c versions) can be used in such
 situations:
-
-
-template<class T, class U>
+
template<class T, class U>
 typename lazy_enable_if<is_multipliable<T, U>, mult_traits<T, U> >::type
 operator*(const T& t, const U& u) { ... }
 
@@ -314,9 +291,7 @@ above example, is_multipliable<T, U>::value defines when
 Some compilers flag functions as ambiguous if the only distinguishing factor is a different 
 condition in an enabler (even though the functions could never be ambiguous). For example,
 some compilers (e.g. GCC 3.2) diagnose the following two functions as ambiguous:
-
-
-template <class T>
+
template <class T>
 typename enable_if<boost::is_arithmetic<T>, T>::type 
 foo(T t);
 
@@ -328,9 +303,7 @@ foo(T t);
 
  • Use an extra dummy parameter which disambiguates the functions. Use a default value for it to hide the parameter from the caller. For example: -
    -
    -template <class T> struct dummy { dummy(int) {} };
    +
    template <class T> struct dummy { dummy(int) {} };
     
     template <class T>
     typename enable_if<boost::is_arithmetic<T>, T>::type 
    @@ -343,9 +316,7 @@ foo(T t, dummy<1> = 0);
     
  • Define the functions in different namespaces and bring them into a common namespace with using declarations: -
    -
    -namespace A {
    +
    namespace A {
       template <class T>
       typename enable_if<boost::is_arithmetic<T>, T>::type 
       foo(T t);
    @@ -414,4 +385,4 @@ Open Systems Lab
     HEVEA.
     
- + \ No newline at end of file From 834a592f44368f645283d6fb767ef296592d7180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20J=C3=A4rvi?= Date: Fri, 5 Dec 2003 16:31:38 +0000 Subject: [PATCH 044/109] guarded enable_if definitions with BOOST_NO_SFINAE [SVN r21149] --- include/boost/utility/enable_if.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp index c1f217d..0498d36 100644 --- a/include/boost/utility/enable_if.hpp +++ b/include/boost/utility/enable_if.hpp @@ -14,6 +14,13 @@ #ifndef BOOST_UTILITY_ENABLE_IF_HPP #define BOOST_UTILITY_ENABLE_IF_HPP +#include + +// Even the definition of enable_if causes problems on some compilers, +// so it's macroed out for all compilers that do not support SFINAE + +#ifndef BOOST_NO_SFINAE + namespace boost { @@ -62,8 +69,8 @@ namespace boost template struct lazy_disable_if : public lazy_disable_if_c {}; - - } // namespace boost +#endif // BOOST_NO_SFINAE + #endif From 22e7bff2af669c877a4f497f020dbbf98ae884aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20J=C3=A4rvi?= Date: Fri, 5 Dec 2003 21:38:43 +0000 Subject: [PATCH 045/109] added dummy versions of enable_if templates for platforms that have BOOST_NO_SFINAE defined [SVN r21154] --- include/boost/utility/enable_if.hpp | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp index 0498d36..df126c1 100644 --- a/include/boost/utility/enable_if.hpp +++ b/include/boost/utility/enable_if.hpp @@ -15,6 +15,7 @@ #define BOOST_UTILITY_ENABLE_IF_HPP #include +#include // Even the definition of enable_if causes problems on some compilers, // so it's macroed out for all compilers that do not support SFINAE @@ -71,6 +72,46 @@ namespace boost } // namespace boost +#else + +namespace boost { + + BOOST_STATIC_CONSTANT(bool, enable_if_does_not_work_on_this_compiler = false); + + template + struct enable_if_c + { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + + template + struct disable_if_c + { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + + template + struct lazy_enable_if_c + { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + + template + struct lazy_disable_if_c + { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + + template + struct enable_if + { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + + template + struct disable_if + { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + + template + struct lazy_enable_if + { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + + template + struct lazy_disable_if + { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + +} // namespace boost + #endif // BOOST_NO_SFINAE #endif From cdbc1a2db5d785f95cdf7fe368ec54942668d549 Mon Sep 17 00:00:00 2001 From: Eric Friedman Date: Sat, 6 Dec 2003 03:57:54 +0000 Subject: [PATCH 046/109] Improved workarounds. [SVN r21157] --- include/boost/utility/enable_if.hpp | 56 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp index df126c1..c8b54c4 100644 --- a/include/boost/utility/enable_if.hpp +++ b/include/boost/utility/enable_if.hpp @@ -14,8 +14,7 @@ #ifndef BOOST_UTILITY_ENABLE_IF_HPP #define BOOST_UTILITY_ENABLE_IF_HPP -#include -#include +#include "boost/config.hpp" // Even the definition of enable_if causes problems on some compilers, // so it's macroed out for all compilers that do not support SFINAE @@ -76,39 +75,42 @@ namespace boost namespace boost { - BOOST_STATIC_CONSTANT(bool, enable_if_does_not_work_on_this_compiler = false); + namespace detail { typedef void enable_if_default_T; } - template - struct enable_if_c - { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + template + struct enable_if_does_not_work_on_this_compiler; - template - struct disable_if_c - { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + template + struct enable_if_c : enable_if_does_not_work_on_this_compiler + { }; - template - struct lazy_enable_if_c - { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + template + struct disable_if_c : enable_if_does_not_work_on_this_compiler + { }; - template - struct lazy_disable_if_c - { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + template + struct lazy_enable_if_c : enable_if_does_not_work_on_this_compiler + { }; - template - struct enable_if - { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + template + struct lazy_disable_if_c : enable_if_does_not_work_on_this_compiler + { }; - template - struct disable_if - { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + template + struct enable_if : enable_if_does_not_work_on_this_compiler + { }; - template - struct lazy_enable_if - { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + template + struct disable_if : enable_if_does_not_work_on_this_compiler + { }; - template - struct lazy_disable_if - { BOOST_STATIC_ASSERT(enable_if_does_not_work_on_this_compiler); }; + template + struct lazy_enable_if : enable_if_does_not_work_on_this_compiler + { }; + + template + struct lazy_disable_if : enable_if_does_not_work_on_this_compiler + { }; } // namespace boost From 7a1400291d5839e8bd4303e4dd12c5ef3cb92cb5 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 7 Jan 2004 14:07:21 +0000 Subject: [PATCH 047/109] pro9 workarounds; some ADL protection for is_xxx [SVN r21529] --- include/boost/ref.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 8ff5725..fb7497b 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -40,7 +40,7 @@ public: #else - explicit reference_wrapper(T& t): t_(addressof(t)) {} + explicit reference_wrapper(T& t): t_(boost::addressof(t)) {} #endif From 9a8dbe4d6a8b5539c9a3f4964d99c85baf5e6261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20J=C3=A4rvi?= Date: Thu, 6 May 2004 22:38:34 +0000 Subject: [PATCH 048/109] fixed a typo [SVN r22754] --- enable_if.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enable_if.html b/enable_if.html index eb485c5..085fcd9 100644 --- a/enable_if.html +++ b/enable_if.html @@ -303,7 +303,7 @@ foo(T t);
  • Use an extra dummy parameter which disambiguates the functions. Use a default value for it to hide the parameter from the caller. For example: -
    template <class T> struct dummy { dummy(int) {} };
    +
    template <int> struct dummy { dummy(int) {} };
     
     template <class T>
     typename enable_if<boost::is_arithmetic<T>, T>::type 
    
    From d3a1203215412f557c8dcd0e1b81dd9576af76e9 Mon Sep 17 00:00:00 2001
    From: Douglas Gregor 
    Date: Sun, 25 Jul 2004 02:29:29 +0000
    Subject: [PATCH 049/109] Doug Gregor -> Douglas Gregor
    
    [SVN r24016]
    ---
     include/boost/utility/addressof.hpp | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp
    index de8dfe5..a5a1425 100644
    --- a/include/boost/utility/addressof.hpp
    +++ b/include/boost/utility/addressof.hpp
    @@ -1,5 +1,5 @@
     // Copyright (C) 2002 Brad King (brad.king@kitware.com) 
    -//                    Doug Gregor (gregod@cs.rpi.edu)
    +//                    Douglas Gregor (gregod@cs.rpi.edu)
     //                    Peter Dimov
     //
     // Permission to copy, use, sell and distribute this software is granted
    
    From 98d2bfcd22847e6e684195212e8e618da5114c36 Mon Sep 17 00:00:00 2001
    From: Douglas Gregor 
    Date: Sun, 25 Jul 2004 19:13:06 +0000
    Subject: [PATCH 050/109] License update
    
    [SVN r24048]
    ---
     addressof_test.cpp | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/addressof_test.cpp b/addressof_test.cpp
    index 62d988c..eacb985 100644
    --- a/addressof_test.cpp
    +++ b/addressof_test.cpp
    @@ -1,5 +1,5 @@
     // Copyright (C) 2002 Brad King (brad.king@kitware.com) 
    -//                    Doug Gregor (gregod@cs.rpi.edu)
    +//                    Douglas Gregor (gregod@cs.rpi.edu)
     //
     // Permission to copy, use, sell and distribute this software is granted
     // provided this copyright notice appears in all copies.
    
    From 766a85b678e292d4da338adca0c632e7498ba0a0 Mon Sep 17 00:00:00 2001
    From: Douglas Gregor 
    Date: Mon, 26 Jul 2004 00:32:12 +0000
    Subject: [PATCH 051/109] Converted to Boost Software License, Version 1.0
    
    [SVN r24055]
    ---
     include/boost/ref.hpp | 7 +++----
     1 file changed, 3 insertions(+), 4 deletions(-)
    
    diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp
    index fb7497b..65d5d10 100644
    --- a/include/boost/ref.hpp
    +++ b/include/boost/ref.hpp
    @@ -18,10 +18,9 @@
     //  Copyright (C) 2001, 2002 Peter Dimov
     //  Copyright (C) 2002 David Abrahams
     //
    -//  Permission to copy, use, modify, sell and distribute this software
    -//  is granted provided this copyright notice appears in all copies.
    -//  This software is provided "as is" without express or implied
    -//  warranty, and with no claim as to its suitability for any purpose.
    +// 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/bind/ref.html for documentation.
     //
    
    From 24b1179772bb2d12142981e9bc4a505797b63926 Mon Sep 17 00:00:00 2001
    From: Douglas Gregor 
    Date: Tue, 27 Jul 2004 03:43:34 +0000
    Subject: [PATCH 052/109] Converted to Boost Software License, Version 1.0
    
    [SVN r24096]
    ---
     include/boost/utility/addressof.hpp | 11 +++--------
     1 file changed, 3 insertions(+), 8 deletions(-)
    
    diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp
    index a5a1425..603ea60 100644
    --- a/include/boost/utility/addressof.hpp
    +++ b/include/boost/utility/addressof.hpp
    @@ -2,14 +2,9 @@
     //                    Douglas Gregor (gregod@cs.rpi.edu)
     //                    Peter Dimov
     //
    -// Permission to copy, use, sell and distribute this software is granted
    -// provided this copyright notice appears in all copies.
    -// Permission to modify the code and to distribute modified code is granted
    -// provided this copyright notice appears in all copies, and a notice
    -// that the code was modified is included with the copyright notice.
    -//
    -// This software is provided "as is" without express or implied warranty,
    -// and with no claim as to its suitability for any purpose.
    +// 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)
     
     // For more information, see http://www.boost.org
     
    
    From 08f9a57f05f8ca5b5d9cd0766fd52b45a8064887 Mon Sep 17 00:00:00 2001
    From: Douglas Gregor 
    Date: Fri, 30 Jul 2004 01:47:08 +0000
    Subject: [PATCH 053/109] License update
    
    [SVN r24175]
    ---
     addressof_test.cpp | 11 +++--------
     1 file changed, 3 insertions(+), 8 deletions(-)
    
    diff --git a/addressof_test.cpp b/addressof_test.cpp
    index eacb985..60f2e23 100644
    --- a/addressof_test.cpp
    +++ b/addressof_test.cpp
    @@ -1,14 +1,9 @@
     // Copyright (C) 2002 Brad King (brad.king@kitware.com) 
     //                    Douglas Gregor (gregod@cs.rpi.edu)
     //
    -// Permission to copy, use, sell and distribute this software is granted
    -// provided this copyright notice appears in all copies.
    -// Permission to modify the code and to distribute modified code is granted
    -// provided this copyright notice appears in all copies, and a notice
    -// that the code was modified is included with the copyright notice.
    -//
    -// This software is provided "as is" without express or implied warranty,
    -// and with no claim as to its suitability for any purpose.
    +// 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)
     
     // For more information, see http://www.boost.org
     
    
    From f88c9efb86922fcc0e634d9664bb88e3d68290be Mon Sep 17 00:00:00 2001
    From: John Maddock 
    Date: Tue, 10 Aug 2004 10:34:20 +0000
    Subject: [PATCH 054/109] Updated Beman Dawes' licence statement to use the new
     prefered form of words.
    
    [SVN r24370]
    ---
     checked_delete_test.cpp | 5 +++--
     1 file changed, 3 insertions(+), 2 deletions(-)
    
    diff --git a/checked_delete_test.cpp b/checked_delete_test.cpp
    index 1ffc1fd..41fdc9a 100644
    --- a/checked_delete_test.cpp
    +++ b/checked_delete_test.cpp
    @@ -1,7 +1,8 @@
     //  Boost checked_delete test program  ---------------------------------------//
     
    -//  Copyright Beman Dawes 2001.
    -//  See accompanying license for terms and conditions of use.
    +//  Copyright Beman Dawes 2001.  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/utility for documentation.
     
    
    From 7bd4d002afa813bac174f44c445930d4fa7a2946 Mon Sep 17 00:00:00 2001
    From: John Maddock 
    Date: Tue, 10 Aug 2004 12:53:34 +0000
    Subject: [PATCH 055/109] Removed Boost.org copyrights and replaced with
     originating authors copyright instead.
    
    [SVN r24372]
    ---
     include/boost/noncopyable.hpp | 8 +++-----
     1 file changed, 3 insertions(+), 5 deletions(-)
    
    diff --git a/include/boost/noncopyable.hpp b/include/boost/noncopyable.hpp
    index e2c8399..ce05cfa 100644
    --- a/include/boost/noncopyable.hpp
    +++ b/include/boost/noncopyable.hpp
    @@ -1,10 +1,8 @@
     //  Boost noncopyable.hpp header file  --------------------------------------//
     
    -//  (C) Copyright Boost.org 1999-2003. Permission to copy, use, modify, sell
    -//  and distribute this software is granted provided this copyright
    -//  notice appears in all copies. This software is provided "as is" without
    -//  express or implied warranty, and with no claim as to its suitability for
    -//  any purpose.
    +//  (C) Copyright Beman Dawes 1999-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)
     
     //  See http://www.boost.org/libs/utility for documentation.
     
    
    From f4d0abf98ba7842871840760054d4b9a53dd226c Mon Sep 17 00:00:00 2001
    From: John Maddock 
    Date: Wed, 11 Aug 2004 10:59:33 +0000
    Subject: [PATCH 056/109] Removed boost.org copyright assignments, and reverted
     to orginal author (as based on cvs history).
    
    [SVN r24402]
    ---
     include/boost/checked_delete.hpp | 1 -
     1 file changed, 1 deletion(-)
    
    diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp
    index d7f5212..8d39d5c 100644
    --- a/include/boost/checked_delete.hpp
    +++ b/include/boost/checked_delete.hpp
    @@ -10,7 +10,6 @@
     //
     //  boost/checked_delete.hpp
     //
    -//  Copyright (c) 1999, 2000, 2001, 2002 boost.org
     //  Copyright (c) 2002, 2003 Peter Dimov
     //  Copyright (c) 2003 Daniel Frey
     //  Copyright (c) 2003 Howard Hinnant
    
    From 4f521dc58c5c7486b1a9551eddff9d4803e1d673 Mon Sep 17 00:00:00 2001
    From: Douglas Gregor 
    Date: Thu, 12 Aug 2004 17:13:07 +0000
    Subject: [PATCH 057/109] Moved to BSL
    
    [SVN r24446]
    ---
     include/boost/checked_delete.hpp | 7 +++----
     1 file changed, 3 insertions(+), 4 deletions(-)
    
    diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp
    index 8d39d5c..9bb84e8 100644
    --- a/include/boost/checked_delete.hpp
    +++ b/include/boost/checked_delete.hpp
    @@ -14,10 +14,9 @@
     //  Copyright (c) 2003 Daniel Frey
     //  Copyright (c) 2003 Howard Hinnant
     //
    -//  Permission to copy, use, modify, sell and distribute this software
    -//  is granted provided this copyright notice appears in all copies.
    -//  This software is provided "as is" without express or implied
    -//  warranty, and with no claim as to its suitability for any purpose.
    +//  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/utility/checked_delete.html for documentation.
     //
    
    From d712f4afd1a528010cc87ce4995ccc9f6ff533a5 Mon Sep 17 00:00:00 2001
    From: Dave Abrahams 
    Date: Wed, 18 Aug 2004 17:01:11 +0000
    Subject: [PATCH 058/109] ADL protection
    
    [SVN r24564]
    ---
     include/boost/noncopyable.hpp | 21 +++++++++++++--------
     1 file changed, 13 insertions(+), 8 deletions(-)
    
    diff --git a/include/boost/noncopyable.hpp b/include/boost/noncopyable.hpp
    index ce05cfa..7770bdb 100644
    --- a/include/boost/noncopyable.hpp
    +++ b/include/boost/noncopyable.hpp
    @@ -16,15 +16,20 @@ namespace boost {
     
     //  Contributed by Dave Abrahams
     
    -class noncopyable
    +namespace noncopyable_  // protection from unintended ADL
     {
    - protected:
    -    noncopyable() {}
    -    ~noncopyable() {}
    - private:  // emphasize the following members are private
    -    noncopyable( const noncopyable& );
    -    const noncopyable& operator=( const noncopyable& );
    -};
    +  class noncopyable
    +  {
    +   protected:
    +      noncopyable() {}
    +      ~noncopyable() {}
    +   private:  // emphasize the following members are private
    +      noncopyable( const noncopyable& );
    +      const noncopyable& operator=( const noncopyable& );
    +  };
    +}
    +
    +typedef noncopyable_::noncopyable noncopyable;
     
     } // namespace boost
     
    
    From 9d5fc9ece70fd77e97818be948f59aa133b9390b Mon Sep 17 00:00:00 2001
    From: Dave Abrahams 
    Date: Thu, 19 Aug 2004 13:12:35 +0000
    Subject: [PATCH 059/109] ADL protection
    
    [SVN r24595]
    ---
     include/boost/noncopyable.hpp | 2 --
     1 file changed, 2 deletions(-)
    
    diff --git a/include/boost/noncopyable.hpp b/include/boost/noncopyable.hpp
    index 7770bdb..019413e 100644
    --- a/include/boost/noncopyable.hpp
    +++ b/include/boost/noncopyable.hpp
    @@ -29,8 +29,6 @@ namespace noncopyable_  // protection from unintended ADL
       };
     }
     
    -typedef noncopyable_::noncopyable noncopyable;
    -
     } // namespace boost
     
     #endif  // BOOST_NONCOPYABLE_HPP_INCLUDED
    
    From 3e2cb017b04199917a30831294c0fe0f7bdd55b3 Mon Sep 17 00:00:00 2001
    From: Dave Abrahams 
    Date: Fri, 20 Aug 2004 17:17:06 +0000
    Subject: [PATCH 060/109] fix noncopyable, finally
    
    [SVN r24618]
    ---
     include/boost/noncopyable.hpp | 2 ++
     1 file changed, 2 insertions(+)
    
    diff --git a/include/boost/noncopyable.hpp b/include/boost/noncopyable.hpp
    index 019413e..7770bdb 100644
    --- a/include/boost/noncopyable.hpp
    +++ b/include/boost/noncopyable.hpp
    @@ -29,6 +29,8 @@ namespace noncopyable_  // protection from unintended ADL
       };
     }
     
    +typedef noncopyable_::noncopyable noncopyable;
    +
     } // namespace boost
     
     #endif  // BOOST_NONCOPYABLE_HPP_INCLUDED
    
    From c1de42016b35c9ac15e54781457c0f0a6395071e Mon Sep 17 00:00:00 2001
    From: Dave Abrahams 
    Date: Mon, 30 Aug 2004 01:31:40 +0000
    Subject: [PATCH 061/109] added copyright/license
    
    [SVN r24814]
    ---
     ref_ct_test.cpp | 5 +++++
     ref_test.cpp    | 4 ++++
     2 files changed, 9 insertions(+)
    
    diff --git a/ref_ct_test.cpp b/ref_ct_test.cpp
    index d9af429..f072537 100644
    --- a/ref_ct_test.cpp
    +++ b/ref_ct_test.cpp
    @@ -1,3 +1,8 @@
    +// Copyright David Abrahams and Aleksey Gurtovoy
    +// 2002-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)
    +
     // compile-time test for "boost/ref.hpp" header content
     // see 'ref_test.cpp' for run-time part
     
    diff --git a/ref_test.cpp b/ref_test.cpp
    index 1cfb5dd..ef4775f 100644
    --- a/ref_test.cpp
    +++ b/ref_test.cpp
    @@ -1,3 +1,7 @@
    +// Copyright David Abrahams and Aleksey Gurtovoy
    +// 2002-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)
     
     // run-time test for "boost/ref.hpp" header content
     // see 'ref_ct_test.cpp' for compile-time part
    
    From 7a0964bfa3e13ce80a915413ca807b88bd8f1b07 Mon Sep 17 00:00:00 2001
    From: Aleksey Gurtovoy 
    Date: Tue, 5 Oct 2004 15:45:52 +0000
    Subject: [PATCH 062/109] c++boost.gif -> boost.png replacement
    
    [SVN r25573]
    ---
     checked_delete.html | 2 +-
     enable_if.html      | 2 +-
     2 files changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/checked_delete.html b/checked_delete.html
    index 4af2ae7..20ffef0 100644
    --- a/checked_delete.html
    +++ b/checked_delete.html
    @@ -8,7 +8,7 @@
     		
    - c++boost.gif (8819 bytes) + boost.png (6897 bytes)

    checked_delete.hpp

    diff --git a/enable_if.html b/enable_if.html index 085fcd9..7a00225 100644 --- a/enable_if.html +++ b/enable_if.html @@ -17,7 +17,7 @@

    -enable_if

    +enable_if

    Copyright 2003 Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine.
    From d778ba1a08c37d01b644d78624759e95ffa92f12 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Sun, 28 Nov 2004 03:35:12 +0000 Subject: [PATCH 063/109] merge RC_1_32_0 fixes [SVN r26328] --- include/boost/ref.hpp | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 65d5d10..3745e7c 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -73,18 +73,13 @@ template inline reference_wrapper BOOST_REF_CONST cref(T const # undef BOOST_REF_CONST # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template class is_reference_wrapper : public mpl::false_ { }; -template -class is_reference_wrapper > - : public mpl::true_ -{ -}; - template class unwrap_reference { @@ -92,12 +87,30 @@ class unwrap_reference typedef T type; }; -template -class unwrap_reference > -{ - public: - typedef T type; -}; +# define AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(X) \ +template \ +class is_reference_wrapper< X > \ + : public mpl::true_ \ +{ \ +}; \ +\ +template \ +class unwrap_reference< X > \ +{ \ + public: \ + typedef T type; \ +}; \ +/**/ + +AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper) +#if !defined(BOOST_NO_CV_SPECIALIZATIONS) +AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper const) +AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper volatile) +AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper const volatile) +#endif + +# undef AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF + # else // no partial specialization } // namespace boost From 220080e288648dd84b80b52674221d6040c91409 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Sun, 28 Nov 2004 04:44:21 +0000 Subject: [PATCH 064/109] merge RC_1_32_0 fixes [SVN r26333] --- enable_if.html | 2 +- ref_ct_test.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/enable_if.html b/enable_if.html index 7a00225..2b6ac0a 100644 --- a/enable_if.html +++ b/enable_if.html @@ -128,7 +128,7 @@ When valid, enable_if_c<B, T>::type equals T. The enable_if_c template can thus be used for controlling when functions are considered for overload resolution and when they are not. For example, the following function is defined for all arithmetic types (according to the -classification of the Boost type_traits library): +classification of the Boost type_traits library):
    template <class T>
     typename enable_if_c<boost::is_arithmetic<T>::value, T>::type 
     foo(T t) { return t; }
    diff --git a/ref_ct_test.cpp b/ref_ct_test.cpp
    index f072537..a3b5eea 100644
    --- a/ref_ct_test.cpp
    +++ b/ref_ct_test.cpp
    @@ -7,8 +7,12 @@
     // see 'ref_test.cpp' for run-time part
     
     #include 
    -#include 
    +#include 
    +#include 
     #include 
    +#include 
    +
    +#include 
     
     namespace {
     
    @@ -35,13 +39,23 @@ void is_reference_wrapper_test(T)
     template< typename R, typename Ref >
     void cxx_reference_test(Ref)
     {
    +#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
    +    typedef typename boost::remove_const::type ref;
    +    BOOST_STATIC_ASSERT((boost::is_same::value));
    +#else
         BOOST_STATIC_ASSERT((boost::is_same::value));
    +#endif
     }
     
     template< typename R, typename Ref >
     void unwrap_reference_test(Ref)
     {
    +#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
    +    typedef typename boost::remove_const::type ref;
    +    typedef typename boost::unwrap_reference::type type;
    +#else
         typedef typename boost::unwrap_reference::type type;
    +#endif
         BOOST_STATIC_ASSERT((boost::is_same::value));
     }
     
    
    From f27b153b75b92e9b5f34f4922a43ff78417e7b3c Mon Sep 17 00:00:00 2001
    From: Stefan Slapeta 
    Date: Thu, 3 Feb 2005 13:48:49 +0000
    Subject: [PATCH 065/109] replaced BOOST_TEST
    
    [SVN r27054]
    ---
     addressof_test.cpp | 8 ++++----
     ref_test.cpp       | 8 ++++----
     2 files changed, 8 insertions(+), 8 deletions(-)
    
    diff --git a/addressof_test.cpp b/addressof_test.cpp
    index 60f2e23..2630f27 100644
    --- a/addressof_test.cpp
    +++ b/addressof_test.cpp
    @@ -26,16 +26,16 @@ int test_main(int, char*[])
       nonaddressable* px = new nonaddressable();
     
       nonaddressable& x = *px;
    -  BOOST_TEST(boost::addressof(x) == px);
    +  BOOST_CHECK(boost::addressof(x) == px);
     
       const nonaddressable& cx = *px;
    -  BOOST_TEST(boost::addressof(cx) == static_cast(px));
    +  BOOST_CHECK(boost::addressof(cx) == static_cast(px));
     
       volatile nonaddressable& vx = *px;
    -  BOOST_TEST(boost::addressof(vx) == static_cast(px));
    +  BOOST_CHECK(boost::addressof(vx) == static_cast(px));
     
       const volatile nonaddressable& cvx = *px;
    -  BOOST_TEST(boost::addressof(cvx) == static_cast(px));
    +  BOOST_CHECK(boost::addressof(cvx) == static_cast(px));
       
       return 0;
     }
    diff --git a/ref_test.cpp b/ref_test.cpp
    index ef4775f..63fc9e5 100644
    --- a/ref_test.cpp
    +++ b/ref_test.cpp
    @@ -60,11 +60,11 @@ struct ref_wrapper
     
         static void test(T x)
         {
    -        BOOST_TEST(passthru(ref(x)) == &x);
    -        BOOST_TEST(&ref(x).get() == &x);
    +        BOOST_CHECK(passthru(ref(x)) == &x);
    +        BOOST_CHECK(&ref(x).get() == &x);
     
    -        BOOST_TEST(cref_passthru(cref(x)) == &x);
    -        BOOST_TEST(&cref(x).get() == &x);
    +        BOOST_CHECK(cref_passthru(cref(x)) == &x);
    +        BOOST_CHECK(&cref(x).get() == &x);
         }
     };
     
    
    From c52d81a792db2d3b98bfdf35745f8a2042722264 Mon Sep 17 00:00:00 2001
    From: Eric Niebler 
    Date: Mon, 14 Mar 2005 23:03:42 +0000
    Subject: [PATCH 066/109] work-around for Borland addressof(array) bug and
     associated tests
    
    [SVN r27656]
    ---
     addressof_test.cpp                  | 10 +++++++++-
     include/boost/utility/addressof.hpp | 16 ++++++++++++++++
     2 files changed, 25 insertions(+), 1 deletion(-)
    
    diff --git a/addressof_test.cpp b/addressof_test.cpp
    index 2630f27..51294bd 100644
    --- a/addressof_test.cpp
    +++ b/addressof_test.cpp
    @@ -36,6 +36,14 @@ int test_main(int, char*[])
     
       const volatile nonaddressable& cvx = *px;
       BOOST_CHECK(boost::addressof(cvx) == static_cast(px));
    -  
    +
    +  int nrg[3] = {1,2,3};
    +  int (*pnrg)[3] = &nrg;
    +  BOOST_CHECK(boost::addressof(nrg) == pnrg);
    +
    +  int const cnrg[3] = {1,2,3};
    +  int const (*pcnrg)[3] = &cnrg;
    +  BOOST_CHECK(boost::addressof(cnrg) == pcnrg);
    +
       return 0;
     }
    diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp
    index 603ea60..6d97fca 100644
    --- a/include/boost/utility/addressof.hpp
    +++ b/include/boost/utility/addressof.hpp
    @@ -33,6 +33,22 @@ addressof(T& v)
            &const_cast(reinterpret_cast(v)));
     }
     
    +// Borland doesn't like casting an array reference to a char reference
    +// but these overloads work around the problem.
    +# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
    +template
    +T (*addressof(T (&t)[N]))[N]
    +{
    +   return reinterpret_cast(&t);
    +}
    +
    +template
    +const T (*addressof(const T (&t)[N]))[N]
    +{
    +   return reinterpret_cast(&t);
    +}
    +# endif
    +
     }
     
     #endif // BOOST_UTILITY_ADDRESSOF_HPP
    
    From 6de0794761fb9c01568d36341dade6b5d9ae0814 Mon Sep 17 00:00:00 2001
    From: Peter Dimov 
    Date: Wed, 16 Mar 2005 22:02:22 +0000
    Subject: [PATCH 067/109] Removed type_traits include, added more tests
    
    [SVN r27712]
    ---
     addressof_test.cpp                  | 99 +++++++++++++++++++++--------
     include/boost/utility/addressof.hpp | 12 ++--
     2 files changed, 80 insertions(+), 31 deletions(-)
    
    diff --git a/addressof_test.cpp b/addressof_test.cpp
    index 51294bd..9619cc3 100644
    --- a/addressof_test.cpp
    +++ b/addressof_test.cpp
    @@ -7,43 +7,88 @@
     
     // For more information, see http://www.boost.org
     
    -#define BOOST_INCLUDE_MAIN
    -#include 
    -#include 
    +
    +#include 
    +
    +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
    +#pragma warning(push, 3)
    +#endif
    +
    +#include 
    +
    +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
    +#pragma warning(pop)
    +#endif
    +
    +#include 
    +
    +template void scalar_test( T * = 0 )
    +{
    +    T* px = new T();
    +
    +    T& x = *px;
    +    BOOST_TEST( boost::addressof(x) == px );
    +
    +    const T& cx = *px;
    +    const T* pcx = boost::addressof(cx);
    +    BOOST_TEST( pcx == px );
    +
    +    volatile T& vx = *px;
    +    volatile T* pvx = boost::addressof(vx);
    +    BOOST_TEST( pvx == px );
    +
    +    const volatile T& cvx = *px;
    +    const volatile T* pcvx = boost::addressof(cvx);
    +    BOOST_TEST( pcvx == px );
    +
    +    delete px;
    +}
    +
    +template void array_test( T * = 0 )
    +{
    +    T nrg[3] = {1,2,3};
    +    T (*pnrg)[3] = &nrg;
    +    BOOST_TEST( boost::addressof(nrg) == pnrg );
    +
    +    T const cnrg[3] = {1,2,3};
    +    T const (*pcnrg)[3] = &cnrg;
    +    BOOST_TEST( boost::addressof(cnrg) == pcnrg );
    +}
    +
    +struct addressable
    +{
    +    addressable( int = 0 )
    +    {
    +    }
    +};
     
     struct useless_type {};
     
     class nonaddressable {
     public:
    -  void dummy(); // Silence GCC warning: all member of class are private
    +
    +    nonaddressable( int = 0 )
    +    {
    +    }
    +
    +    void dummy(); // Silence GCC warning: all member of class are private
     
     private:
    -  useless_type operator&() const;
    +
    +    useless_type operator&() const;
     };
     
    -int test_main(int, char*[])
    +int main()
     {
    -  nonaddressable* px = new nonaddressable();
    +    scalar_test();
    +    scalar_test();
    +    scalar_test();
    +    scalar_test();
     
    -  nonaddressable& x = *px;
    -  BOOST_CHECK(boost::addressof(x) == px);
    +    array_test();
    +    array_test();
    +    array_test();
    +    array_test();
     
    -  const nonaddressable& cx = *px;
    -  BOOST_CHECK(boost::addressof(cx) == static_cast(px));
    -
    -  volatile nonaddressable& vx = *px;
    -  BOOST_CHECK(boost::addressof(vx) == static_cast(px));
    -
    -  const volatile nonaddressable& cvx = *px;
    -  BOOST_CHECK(boost::addressof(cvx) == static_cast(px));
    -
    -  int nrg[3] = {1,2,3};
    -  int (*pnrg)[3] = &nrg;
    -  BOOST_CHECK(boost::addressof(nrg) == pnrg);
    -
    -  int const cnrg[3] = {1,2,3};
    -  int const (*pcnrg)[3] = &cnrg;
    -  BOOST_CHECK(boost::addressof(cnrg) == pcnrg);
    -
    -  return 0;
    +    return boost::report_errors();
     }
    diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp
    index 6d97fca..7629488 100644
    --- a/include/boost/utility/addressof.hpp
    +++ b/include/boost/utility/addressof.hpp
    @@ -13,9 +13,6 @@
     
     # include 
     # include 
    -# if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
    -#  include 
    -# endif
     
     namespace boost {
     
    @@ -23,7 +20,14 @@ namespace boost {
     
     // VC7 strips const from nested classes unless we add indirection here
     # if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
    -template  typename add_pointer::type
    +
    +template struct _addp
    +{
    +    typedef T * type;
    +};
    +    
    +template  typename _addp::type
    +
     # else
     template  T*
     # endif
    
    From f7508e647b74b8926a01a02589981d00927a439c Mon Sep 17 00:00:00 2001
    From: Peter Dimov 
    Date: Sun, 25 Sep 2005 21:54:19 +0000
    Subject: [PATCH 068/109] Made the Boost logo link to the home page
    
    [SVN r31112]
    ---
     checked_delete.html | 5 ++---
     1 file changed, 2 insertions(+), 3 deletions(-)
    
    diff --git a/checked_delete.html b/checked_delete.html
    index 20ffef0..c123fd5 100644
    --- a/checked_delete.html
    +++ b/checked_delete.html
    @@ -7,10 +7,9 @@
     	
     		
    -				
    -				
    
    From 06d5bbef08dae2fce9e0a1bf308a02626178881b Mon Sep 17 00:00:00 2001
    From: Peter Dimov 
    Date: Mon, 27 Feb 2006 21:57:38 +0000
    Subject: [PATCH 069/109] Borland 5.81 fix (Alisdair Meredith)
    
    [SVN r33161]
    ---
     include/boost/ref.hpp | 5 +++--
     1 file changed, 3 insertions(+), 2 deletions(-)
    
    diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp
    index 3745e7c..ab09ae7 100644
    --- a/include/boost/ref.hpp
    +++ b/include/boost/ref.hpp
    @@ -10,6 +10,7 @@
     #include 
     #include 
     #include 
    +#include 
     
     //
     //  ref.hpp - ref/cref, useful helper functions
    @@ -33,7 +34,7 @@ template class reference_wrapper
     public:
         typedef T type;
     
    -#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
    +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 )
     
         explicit reference_wrapper(T& t): t_(&t) {}
     
    @@ -54,7 +55,7 @@ private:
         T* t_;
     };
     
    -# if defined(__BORLANDC__) && (__BORLANDC__ <= 0x570)
    +# if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
     #  define BOOST_REF_CONST
     # else
     #  define BOOST_REF_CONST const
    
    From e49f04d1795bdb44d633bf9ee8f1ca80415901a5 Mon Sep 17 00:00:00 2001
    From: Peter Dimov 
    Date: Thu, 9 Nov 2006 20:34:33 +0000
    Subject: [PATCH 070/109] License/copyright edits
    
    [SVN r35958]
    ---
     checked_delete.html | 7 +++----
     1 file changed, 3 insertions(+), 4 deletions(-)
    
    diff --git a/checked_delete.html b/checked_delete.html
    index c123fd5..33b5bcb 100644
    --- a/checked_delete.html
    +++ b/checked_delete.html
    @@ -115,9 +115,8 @@ template<class T> struct checked_array_deleter
     		


    - Copyright © 2002 by Peter Dimov. Permission to copy, use, modify, sell and - distribute this document is granted provided this copyright notice appears in - all copies. This document is provided "as is" without express or implied - warranty, and with no claim as to its suitability for any purpose.

    + Copyright © 2002 by 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.

    From 69c8e3144b2dfc9189bde80131824c4b1e39b974 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 15 Mar 2008 18:41:51 +0000 Subject: [PATCH 071/109] Fix some inspection report issues. [SVN r43633] --- enable_if.html | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/enable_if.html b/enable_if.html index 2b6ac0a..a17a290 100644 --- a/enable_if.html +++ b/enable_if.html @@ -366,17 +366,18 @@ David Vandevoorde and Nicolai M. Josuttis. C++ Templates: The Complete Guide. Addison-Wesley, 2002. - - - - -
    - -Contributed by:
    -Jaakko Järvi, Jeremiah Willcock and Andrew Lumsdaine
    +
    +

    Copyright Jaakko Järvi, Jeremiah Willcock and Andrew Lumsdaine
    {jajarvi|jewillco|lums}@osl.iu.edu
    Indiana University
    -Open Systems Lab +Open Systems Lab
    +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 +). +

    From be620e23a3a5ff5f560896377dd97594d5078de5 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 2 Apr 2008 01:42:32 +0000 Subject: [PATCH 072/109] Replaced all occurrences of non-ASCII copyright symbol with '(c)' for people using non-ASCII code pages [SVN r43992] --- include/boost/utility/enable_if.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp index c8b54c4..d77d108 100644 --- a/include/boost/utility/enable_if.hpp +++ b/include/boost/utility/enable_if.hpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at From f2bc4dc7311b280070c30a0ab622a5f56eed1e5c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 21 Apr 2008 21:42:29 +0000 Subject: [PATCH 073/109] Fix #1846. [SVN r44705] --- include/boost/utility/addressof.hpp | 43 ++++++++++++++++------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 7629488..8e0a586 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -1,6 +1,7 @@ // Copyright (C) 2002 Brad King (brad.king@kitware.com) // Douglas Gregor (gregod@cs.rpi.edu) -// Peter Dimov +// +// Copyright (C) 2002, 2008 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -14,27 +15,31 @@ # include # include -namespace boost { - -// Do not make addressof() inline. Breaks MSVC 7. (Peter Dimov) - -// VC7 strips const from nested classes unless we add indirection here -# if BOOST_WORKAROUND(BOOST_MSVC, == 1300) - -template struct _addp +namespace boost { - typedef T * type; + +namespace detail +{ + +template struct addressof_impl +{ + static inline T * f( T & v, long ) + { + return reinterpret_cast( + &const_cast(reinterpret_cast(v))); + } + + static inline T * f( T * v, int ) + { + return v; + } }; - -template typename _addp::type -# else -template T* -# endif -addressof(T& v) +} // namespace detail + +template T * addressof( T & v ) { - return reinterpret_cast( - &const_cast(reinterpret_cast(v))); + return boost::detail::addressof_impl::f( v, 0 ); } // Borland doesn't like casting an array reference to a char reference @@ -53,6 +58,6 @@ const T (*addressof(const T (&t)[N]))[N] } # endif -} +} // namespace boost #endif // BOOST_UTILITY_ADDRESSOF_HPP From 2af0215fddb995dd6c6cf0bc44499adac176755a Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sat, 28 Jun 2008 13:45:21 +0000 Subject: [PATCH 074/109] =?UTF-8?q?With=20his=20kind=20permission,=20chang?= =?UTF-8?q?e=20Jaakko=20"J=C3=A4rvi"=20to=20"Jarvi"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [SVN r46808] --- include/boost/ref.hpp | 2 +- include/boost/utility/enable_if.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index ab09ae7..330ca65 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -15,7 +15,7 @@ // // ref.hpp - ref/cref, useful helper functions // -// Copyright (C) 1999, 2000 Jaakko Järvi (jaakko.jarvi@cs.utu.fi) +// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) // Copyright (C) 2001, 2002 Peter Dimov // Copyright (C) 2002 David Abrahams // diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp index d77d108..d292c6a 100644 --- a/include/boost/utility/enable_if.hpp +++ b/include/boost/utility/enable_if.hpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) From 0f0591c3e72236d772b2c5308abfe0074b97950e Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Thu, 10 Jul 2008 19:28:49 +0000 Subject: [PATCH 075/109] Added unwrap_ref. [SVN r47295] --- include/boost/ref.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 330ca65..9c996ab 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -173,6 +173,12 @@ class unwrap_reference # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +template inline typename unwrap_reference::type& +unwrap_ref(T& t) +{ + return t; +} + } // namespace boost #endif // #ifndef BOOST_REF_HPP_INCLUDED From 8991da4fabd6ab1677766d5296e3e757baac5878 Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Thu, 10 Jul 2008 19:29:02 +0000 Subject: [PATCH 076/109] Added tests for unwrap_ref. [SVN r47296] --- ref_test.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/ref_test.cpp b/ref_test.cpp index 63fc9e5..93468ee 100644 --- a/ref_test.cpp +++ b/ref_test.cpp @@ -68,11 +68,53 @@ struct ref_wrapper } }; +struct copy_counter { + static int count_; + copy_counter(copy_counter const& other) { + ++count_; + } + copy_counter() {} + static void reset() { count_ = 0; } + static int count() { return copy_counter::count_; } +}; + +int copy_counter::count_ = 0; + } // namespace unnamed +template +void do_unwrap(T t) { + + /* typename unwrap_reference::type& lt = */ + unwrap_ref(t); + +} + +void unwrap_test() { + + int i = 3; + const int ci = 2; + + do_unwrap(i); + do_unwrap(ci); + do_unwrap(ref(i)); + do_unwrap(cref(ci)); + do_unwrap(ref(ci)); + + copy_counter cc; + BOOST_CHECK(cc.count() == 0); + + do_unwrap(cc); + do_unwrap(ref(cc)); + do_unwrap(cref(cc)); + + BOOST_CHECK(cc.count() == 1); +} + int test_main(int, char * []) { ref_wrapper::test(1); ref_wrapper::test(1); + unwrap_test(); return 0; } From 5b2149af82e27728c1fd89c4a814eafb6e3abfe0 Mon Sep 17 00:00:00 2001 From: Ronald Garcia Date: Thu, 10 Jul 2008 23:01:26 +0000 Subject: [PATCH 077/109] Added an anonymous unwrapping test. [SVN r47297] --- ref_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ref_test.cpp b/ref_test.cpp index 93468ee..d4237b4 100644 --- a/ref_test.cpp +++ b/ref_test.cpp @@ -109,6 +109,7 @@ void unwrap_test() { do_unwrap(cref(cc)); BOOST_CHECK(cc.count() == 1); + BOOST_CHECK(unwrap_ref(ref(cc)).count() == 1); } int test_main(int, char * []) From e45f2cd9d3fac5fba24b3b7324075edfdf43aab4 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 1 Mar 2009 17:04:14 +0000 Subject: [PATCH 078/109] Refs #2128 (fixed in trunk.) [SVN r51512] --- include/boost/ref.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 9c996ab..6058d69 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -179,6 +179,11 @@ unwrap_ref(T& t) return t; } +template inline T* get_pointer( reference_wrapper const & r ) +{ + return r.get_pointer(); +} + } // namespace boost #endif // #ifndef BOOST_REF_HPP_INCLUDED From 2f4e34a658e7562968abdf831800eaf0c4b577c8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 20 Mar 2009 17:14:00 +0000 Subject: [PATCH 079/109] Attempt to fix addressof in trunk to handle classes with conversion operators. Refs #2878. [SVN r51872] --- addressof_fn_test.cpp | 76 +++++++++++++++++++++++ addressof_test2.cpp | 95 +++++++++++++++++++++++++++++ include/boost/utility/addressof.hpp | 16 +++++ 3 files changed, 187 insertions(+) create mode 100644 addressof_fn_test.cpp create mode 100644 addressof_test2.cpp diff --git a/addressof_fn_test.cpp b/addressof_fn_test.cpp new file mode 100644 index 0000000..0d043bf --- /dev/null +++ b/addressof_fn_test.cpp @@ -0,0 +1,76 @@ +#include + +#if defined(BOOST_MSVC) +#pragma warning(disable: 4786) // identifier truncated in debug info +#pragma warning(disable: 4710) // function not inlined +#pragma warning(disable: 4711) // function selected for automatic inline expansion +#pragma warning(disable: 4514) // unreferenced inline removed +#endif + +// addressof_fn_test.cpp: addressof( f ) +// +// Copyright (c) 2008, 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 + +#include +#include + + +void f0() +{ +} + +void f1(int) +{ +} + +void f2(int, int) +{ +} + +void f3(int, int, int) +{ +} + +void f4(int, int, int, int) +{ +} + +void f5(int, int, int, int, int) +{ +} + +void f6(int, int, int, int, int, int) +{ +} + +void f7(int, int, int, int, int, int, int) +{ +} + +void f8(int, int, int, int, int, int, int, int) +{ +} + +void f9(int, int, int, int, int, int, int, int, int) +{ +} + +int main() +{ + BOOST_TEST( boost::addressof( f0 ) == &f0 ); + BOOST_TEST( boost::addressof( f1 ) == &f1 ); + BOOST_TEST( boost::addressof( f2 ) == &f2 ); + BOOST_TEST( boost::addressof( f3 ) == &f3 ); + BOOST_TEST( boost::addressof( f4 ) == &f4 ); + BOOST_TEST( boost::addressof( f5 ) == &f5 ); + BOOST_TEST( boost::addressof( f6 ) == &f6 ); + BOOST_TEST( boost::addressof( f7 ) == &f7 ); + BOOST_TEST( boost::addressof( f8 ) == &f8 ); + BOOST_TEST( boost::addressof( f9 ) == &f9 ); + + return boost::report_errors(); +} diff --git a/addressof_test2.cpp b/addressof_test2.cpp new file mode 100644 index 0000000..b1c36f8 --- /dev/null +++ b/addressof_test2.cpp @@ -0,0 +1,95 @@ +// Copyright (C) 2002 Brad King (brad.king@kitware.com) +// Douglas Gregor (gregod@cs.rpi.edu) +// +// Copyright 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) + +// For more information, see http://www.boost.org + + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(push, 3) +#endif + +#include + +#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) +#pragma warning(pop) +#endif + +#include + +template void scalar_test( T * = 0 ) +{ + T* px = new T(); + + T& x = *px; + BOOST_TEST( boost::addressof(x) == px ); + + const T& cx = *px; + const T* pcx = boost::addressof(cx); + BOOST_TEST( pcx == px ); + + volatile T& vx = *px; + volatile T* pvx = boost::addressof(vx); + BOOST_TEST( pvx == px ); + + const volatile T& cvx = *px; + const volatile T* pcvx = boost::addressof(cvx); + BOOST_TEST( pcvx == px ); + + delete px; +} + +template void array_test( T * = 0 ) +{ + T nrg[3] = {1,2,3}; + T (*pnrg)[3] = &nrg; + BOOST_TEST( boost::addressof(nrg) == pnrg ); + + T const cnrg[3] = {1,2,3}; + T const (*pcnrg)[3] = &cnrg; + BOOST_TEST( boost::addressof(cnrg) == pcnrg ); +} + +class convertible { +public: + + convertible( int = 0 ) + { + } + + template operator U () const + { + return U(); + } +}; + +class convertible2 { +public: + + convertible2( int = 0 ) + { + } + + operator convertible2* () const + { + return 0; + } +}; + +int main() +{ + scalar_test(); + scalar_test(); + + array_test(); + array_test(); + + return boost::report_errors(); +} diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 8e0a586..f0da384 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -21,6 +21,14 @@ namespace boost namespace detail { +template struct addr_impl_ref +{ + T & v_; + + inline addr_impl_ref( T & v ): v_( v ) {} + inline operator T& () const { return v_; } +}; + template struct addressof_impl { static inline T * f( T & v, long ) @@ -39,7 +47,15 @@ template struct addressof_impl template T * addressof( T & v ) { +#if BOOST_WORKAROUND( __BORLANDC__, < 0x560 ) + return boost::detail::addressof_impl::f( v, 0 ); + +#else + + return boost::detail::addressof_impl::f( boost::detail::addr_impl_ref( v ), 0 ); + +#endif } // Borland doesn't like casting an array reference to a char reference From 31caf21d8b97d08c6866f81d73cace5c975a2c31 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 21 Mar 2009 20:20:37 +0000 Subject: [PATCH 080/109] Disable new addressof code for all Borland versions. Refs #2878. [SVN r51891] --- include/boost/utility/addressof.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index f0da384..48602be 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -47,7 +47,7 @@ template struct addressof_impl template T * addressof( T & v ) { -#if BOOST_WORKAROUND( __BORLANDC__, < 0x560 ) +#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) return boost::detail::addressof_impl::f( v, 0 ); From dc33c13d86a43b97881b17d4956e7c7b26ede9a5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 26 Mar 2009 00:06:47 +0000 Subject: [PATCH 081/109] Try to fix array addressof failures on Sun C++. [SVN r51977] --- include/boost/utility/addressof.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 48602be..2ebaefb 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -47,7 +47,7 @@ template struct addressof_impl template T * addressof( T & v ) { -#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) return boost::detail::addressof_impl::f( v, 0 ); @@ -58,9 +58,18 @@ template T * addressof( T & v ) #endif } +#if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) ) + +template T (*addressof(T (&t)[N]))[N] +{ + return &t; +} + +#endif + // Borland doesn't like casting an array reference to a char reference // but these overloads work around the problem. -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) template T (*addressof(T (&t)[N]))[N] { @@ -72,7 +81,7 @@ const T (*addressof(const T (&t)[N]))[N] { return reinterpret_cast(&t); } -# endif +#endif } // namespace boost From 00e75d78e7e2aa57abb82405688c1aa6a0c4306b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 26 Mar 2009 13:05:05 +0000 Subject: [PATCH 082/109] Try the Sun workaround with int instead of size_t. [SVN r51986] --- include/boost/utility/addressof.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 2ebaefb..bea9a01 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -60,7 +60,7 @@ template T * addressof( T & v ) #if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) ) -template T (*addressof(T (&t)[N]))[N] +template T (*addressof(T (&t)[N]))[N] { return &t; } From 868403700d425cacdcf4f3ff3822ccf76cda18c5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 27 Mar 2009 12:50:09 +0000 Subject: [PATCH 083/109] Another try at the Sun workaround. [SVN r52010] --- include/boost/utility/addressof.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index bea9a01..ac42a51 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -60,7 +60,18 @@ template T * addressof( T & v ) #if defined( __SUNPRO_CC ) && BOOST_WORKAROUND( __SUNPRO_CC, BOOST_TESTED_AT( 0x590 ) ) -template T (*addressof(T (&t)[N]))[N] +namespace detail +{ + +template struct addressof_addp +{ + typedef T * type; +}; + +} // namespace detail + +template< class T, std::size_t N > +typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] ) { return &t; } From 4a2d4813b3907f8c2c2392f8302c4a17290162e0 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Thu, 7 May 2009 17:47:08 +0000 Subject: [PATCH 084/109] eliminate noisy warning on msvc, fixes #2993 [SVN r52837] --- include/boost/utility/addressof.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index ac42a51..95cd92f 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -27,6 +27,9 @@ template struct addr_impl_ref inline addr_impl_ref( T & v ): v_( v ) {} inline operator T& () const { return v_; } + +private: + addr_impl_ref & operator=(const addr_impl_ref &); }; template struct addressof_impl From 5dd164b0bc5c9b2f0e6e8eb73ce5a2cc3492e8a8 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sun, 8 Nov 2009 18:53:59 +0000 Subject: [PATCH 085/109] Suppress/fix some msvc and gcc compiler warnings. [SVN r57494] --- ref_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ref_test.cpp b/ref_test.cpp index d4237b4..71481fa 100644 --- a/ref_test.cpp +++ b/ref_test.cpp @@ -70,7 +70,7 @@ struct ref_wrapper struct copy_counter { static int count_; - copy_counter(copy_counter const& other) { + copy_counter(copy_counter const& /*other*/) { ++count_; } copy_counter() {} From 72835cf1aceec9176a407c4633a1cc2c6949a9b7 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Wed, 13 Apr 2011 02:30:39 +0000 Subject: [PATCH 086/109] Applied doc patches from Matt Calabrese [SVN r71221] --- enable_if.html | 111 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 93 insertions(+), 18 deletions(-) diff --git a/enable_if.html b/enable_if.html index a17a290..8ea33bb 100644 --- a/enable_if.html +++ b/enable_if.html @@ -21,6 +21,7 @@

    Copyright 2003 Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine.
    +Copyright 2011 Matt Calabrese.

    @@ -81,7 +82,7 @@ definitions to find this out. Instantiating the latter definition with
    int::result_type negate(const int&);
     
     
    -where the return type is invalid. If this was an error, adding an unrelated function template +where the return type is invalid. If this were an error, adding an unrelated function template (that was never called) could break otherwise valid code. Due to the SFINAE principle the above example is not, however, erroneous. The latter definition of negate is simply removed from the overload resolution set.
    @@ -154,6 +155,7 @@ typename enable_if<boost::is_arithmetic<T>, T>::type foo(T t) { return t; } +

    3  Using enable_if

    @@ -162,8 +164,19 @@ foo(T t) { return t; } The enable_if templates are defined in boost/utility/enable_if.hpp, which is included by boost/utility.hpp.

    -The enable_if template can be used either as the return type, or as an -extra argument. For example, the foo function in the previous section could also be written +With respect to function templates, enable_if can be used in multiple different ways: + +
      +
    • As the return type of an instantiatied function +
    • As an extra parameter of an instantiated function +
    • As an extra template parameter (useful only in a compiler that supports C++0x default +arguments for function template parameters, see Enabling function +templates in C++0x for details) +
    + +In the previous section, the return type form of enable_if was shown. As an example +of using the form of enable_if that works via an extra function parameter, the +foo function in the previous section could also be written as:
    template <class T>
     T foo(T t, typename enable_if<boost::is_arithmetic<T> >::type* dummy = 0); 
    @@ -173,18 +186,80 @@ a default value to keep the parameter hidden from client code.
     Note that the second template argument was not given to enable_if, as the default 
     void gives the desired behavior.

    -Whether to write the enabler as an argument or within the return type is -largely a matter of taste, but for certain functions, only one -alternative is possible: +Which way to write the enabler is largely a matter of taste, but for certain functions, only a +subset of the options is possible:
    • -Operators have a fixed number of arguments, thus enable_if must be used in the return type. -
    • Constructors and destructors do not have a return type; an extra argument is the only option. -
    • There does not seem to be a way to specify an enabler for a conversion operator. Converting constructors, -however, can have enablers as extra default arguments. +Many operators have a fixed number of arguments, thus enable_if must be used either in the +return type or in an extra template parameter. +
    • Functions that have a variadic parameter list must use either the return type form or an extra +template parameter. +
    • Constructors do not have a return type so you must use either an extra function parameter or an +extra template parameter. +
    • Constructors that have a variadic parameter list must an extra template parameter. +
    • Conversion operators can only be written with an extra template parameter.
    + + + +

    3.1  Enabling function templates in C++0x

    + +In a compiler which supports C++0x default arguments for function template parameters, you can +enable and disable function templates by adding an additional template parameter. This approach +works in all situations where you would use either the return type form of enable_if or +the function parameter form, including operators, constructors, variadic function templates, and +even overloaded conversion operations. + +As an example: + +
    #include <boost/type_traits/is_arithmetic.hpp>
    +#include <boost/type_traits/is_pointer.hpp>
    +#include <boost/utility/enable_if.hpp>
    +
    +class test
    +{
    +public:
    +  // A constructor that works for any argument list of size 10
    +  template< class... T
    +          , typename boost::enable_if_c< sizeof...( T ) == 10, int >::type = 0
    +          >
    +  test( T&&... );
    +
    +  // A conversion operation that can convert to any arithmetic type
    +  template< class T
    +          , typename boost::enable_if< boost::is_arithmetic< T >, int >::type = 0
    +          >
    +  operator T() const;
    +
    +  // A conversion operation that can convert to any pointer type
    +  template< class T
    +          , typename boost::enable_if< boost::is_pointer< T >, int >::type = 0
    +          >
    +  operator T() const;
    +};
    +
    +int main()
    +{
    +  // Works
    +  test test_( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
    +
    +  // Fails as expected
    +  test fail_construction( 1, 2, 3, 4, 5 );
    +
    +  // Works by calling the conversion operator enabled for arithmetic types
    +  int arithmetic_object = test_;
    +
    +  // Works by calling the conversion operator enabled for pointer types
    +  int* pointer_object = test_;
    +
    +  // Fails as expected
    +  struct {} fail_conversion = test_;
    +}
    +
    +
    + -

    3.1  Enabling template class specializations

    +

    3.2  Enabling template class specializations

    Class template specializations can be enabled or disabled with enable_if. @@ -210,7 +285,7 @@ is the correct value.

    -

    3.2  Overlapping enabler conditions

    +

    3.3  Overlapping enabler conditions

    Once the compiler has examined the enabling conditions and included the @@ -239,7 +314,7 @@ partial specializations as well.

    -

    3.3  Lazy enable_if

    +

    3.4  Lazy enable_if

    In some cases it is necessary to avoid instantiating part of a @@ -285,7 +360,7 @@ above example, is_multipliable<T, U>::value defines when
    -

    3.4  Compiler workarounds

    +

    3.5  Compiler workarounds

    Some compilers flag functions as ambiguous if the only distinguishing factor is a different @@ -367,9 +442,9 @@ David Vandevoorde and Nicolai M. Josuttis. Addison-Wesley, 2002.
    -

    Copyright Jaakko Järvi, Jeremiah Willcock and Andrew Lumsdaine
    -{jajarvi|jewillco|lums}@osl.iu.edu
    -Indiana University
    +

    Copyright Jaakko Järvi*, Jeremiah Willcock*, Andrew Lumsdaine*, Matt Calabrese
    +{jajarvi|jewillco|lums}@osl.iu.edu, rivorus@gmail.com
    +*Indiana University
    Open Systems Lab
    Use, modification and distribution are subject to the Boost Software License, Version 1.0. @@ -386,4 +461,4 @@ or copy at HEVEA. - \ No newline at end of file + From 86bfb22ec047a71719379dd9d77f565f45d5c161 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Thu, 14 Mar 2013 17:48:06 +0000 Subject: [PATCH 087/109] Utility: address_of take care of #7079. [SVN r83429] --- include/boost/utility/addressof.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 95cd92f..ecb7776 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2002 Brad King (brad.king@kitware.com) +// Copyright (C) 2002 Brad King (brad.king@kitware.com) // Douglas Gregor (gregod@cs.rpi.edu) // // Copyright (C) 2002, 2008 Peter Dimov @@ -50,7 +50,7 @@ template struct addressof_impl template T * addressof( T & v ) { -#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) +#if (defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) ) || defined( __SUNPRO_CC ) return boost::detail::addressof_impl::f( v, 0 ); From f8aa53fe714e5d80f112bbdea99d5ba37f230d4b Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Wed, 10 Apr 2013 17:16:02 +0000 Subject: [PATCH 088/109] Utility/noncopyable: Make use of =delete #6578. [SVN r83833] --- include/boost/noncopyable.hpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/include/boost/noncopyable.hpp b/include/boost/noncopyable.hpp index 7770bdb..eb8e2e7 100644 --- a/include/boost/noncopyable.hpp +++ b/include/boost/noncopyable.hpp @@ -9,6 +9,8 @@ #ifndef BOOST_NONCOPYABLE_HPP_INCLUDED #define BOOST_NONCOPYABLE_HPP_INCLUDED +#include + namespace boost { // Private copy constructor and copy assignment ensure classes derived from @@ -21,11 +23,21 @@ namespace noncopyable_ // protection from unintended ADL class noncopyable { protected: - noncopyable() {} +#ifndef BOOST_NO_DEFAULTED_FUNCTIONS + BOOST_CONSTEXPR noncopyable() = default; + ~noncopyable() = default; +#else + noncopyable() {} ~noncopyable() {} - private: // emphasize the following members are private +#endif +#ifndef BOOST_NO_DELETED_FUNCTIONS + noncopyable( const noncopyable& ) = delete; + noncopyable& operator=( const noncopyable& ) = delete; +#else + private: // emphasize the following members are private noncopyable( const noncopyable& ); - const noncopyable& operator=( const noncopyable& ); + noncopyable& operator=( const noncopyable& ); +#endif }; } From da934c4ecf17c033e2588a6c56695458d418aec3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 26 Sep 2013 13:02:51 +0000 Subject: [PATCH 089/109] Remove obsolete MSVC check from pragma guard git grep -h -B1 "^#\s*pragma once" | grep -v pragma | sort | uniq is now clean. [SVN r85952] --- include/boost/checked_delete.hpp | 2 +- include/boost/ref.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index 9bb84e8..80f936a 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 6058d69..90d033c 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif From 999b417ae2fc2a0b07dc3d42e6758e3d33779651 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 30 Sep 2013 00:19:48 +0000 Subject: [PATCH 090/109] Ref: Remove obsolete MSVC version check. [SVN r86031] --- include/boost/ref.hpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 90d033c..cf68764 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -34,16 +34,8 @@ template class reference_wrapper public: typedef T type; -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) - - explicit reference_wrapper(T& t): t_(&t) {} - -#else - explicit reference_wrapper(T& t): t_(boost::addressof(t)) {} -#endif - operator T& () const { return *t_; } T& get() const { return *t_; } From 5c4b2ffc396e3c8217d45700cf080e1b7dad200c Mon Sep 17 00:00:00 2001 From: Joel Falcou Date: Tue, 1 Oct 2013 15:02:28 +0000 Subject: [PATCH 091/109] Fix #9169 - Add BOOST_FORCEINLINE on boost::ref for performance issue [SVN r86124] --- include/boost/ref.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index cf68764..cd186f9 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -30,17 +30,17 @@ namespace boost { template class reference_wrapper -{ +{ public: typedef T type; - explicit reference_wrapper(T& t): t_(boost::addressof(t)) {} + BOOST_FORCEINLINE explicit reference_wrapper(T& t): t_(boost::addressof(t)) {} - operator T& () const { return *t_; } + BOOST_FORCEINLINE operator T& () const { return *t_; } - T& get() const { return *t_; } + BOOST_FORCEINLINE T& get() const { return *t_; } - T* get_pointer() const { return t_; } + BOOST_FORCEINLINE T* get_pointer() const { return t_; } private: @@ -53,12 +53,12 @@ private: # define BOOST_REF_CONST const # endif -template inline reference_wrapper BOOST_REF_CONST ref(T & t) -{ +template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST ref(T & t) +{ return reference_wrapper(t); } -template inline reference_wrapper BOOST_REF_CONST cref(T const & t) +template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST cref(T const & t) { return reference_wrapper(t); } @@ -117,7 +117,7 @@ namespace detail { typedef char (&yes_reference_wrapper_t)[1]; typedef char (&no_reference_wrapper_t)[2]; - + no_reference_wrapper_t is_reference_wrapper_test(...); template @@ -152,7 +152,7 @@ class is_reference_wrapper bool, value = ( sizeof(detail::is_reference_wrapper_test(type())) == sizeof(detail::yes_reference_wrapper_t))); - + typedef ::boost::mpl::bool_ type; }; @@ -165,13 +165,13 @@ class unwrap_reference # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -template inline typename unwrap_reference::type& +template BOOST_FORCEINLINE typename unwrap_reference::type& unwrap_ref(T& t) { return t; } -template inline T* get_pointer( reference_wrapper const & r ) +template BOOST_FORCEINLINE T* get_pointer( reference_wrapper const & r ) { return r.get_pointer(); } From 000e6d6f04c3d96913abd6a359374943624c5bcf Mon Sep 17 00:00:00 2001 From: Joel Falcou Date: Tue, 1 Oct 2013 15:05:39 +0000 Subject: [PATCH 092/109] Fix #9170 - Add BOOST_FORCEINLINE in address_of for performance issues [SVN r86125] --- include/boost/utility/addressof.hpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index ecb7776..2b637df 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -25,8 +25,8 @@ template struct addr_impl_ref { T & v_; - inline addr_impl_ref( T & v ): v_( v ) {} - inline operator T& () const { return v_; } + BOOST_FORCEINLINE addr_impl_ref( T & v ): v_( v ) {} + BOOST_FORCEINLINE operator T& () const { return v_; } private: addr_impl_ref & operator=(const addr_impl_ref &); @@ -34,13 +34,13 @@ private: template struct addressof_impl { - static inline T * f( T & v, long ) + static BOOST_FORCEINLINE T * f( T & v, long ) { return reinterpret_cast( &const_cast(reinterpret_cast(v))); } - static inline T * f( T * v, int ) + static BOOST_FORCEINLINE T * f( T * v, int ) { return v; } @@ -48,7 +48,9 @@ template struct addressof_impl } // namespace detail -template T * addressof( T & v ) +template +BOOST_FORCEINLINE +T * addressof( T & v ) { #if (defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x610 ) ) ) || defined( __SUNPRO_CC ) @@ -74,6 +76,7 @@ template struct addressof_addp } // namespace detail template< class T, std::size_t N > +BOOST_FORCEINLINE typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] ) { return &t; @@ -85,12 +88,14 @@ typename detail::addressof_addp< T[N] >::type addressof( T (&t)[N] ) // but these overloads work around the problem. #if defined( __BORLANDC__ ) && BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) template +BOOST_FORCEINLINE T (*addressof(T (&t)[N]))[N] { return reinterpret_cast(&t); } template +BOOST_FORCEINLINE const T (*addressof(const T (&t)[N]))[N] { return reinterpret_cast(&t); From aeaf9ecf8a1305baa83eaefc327b2cfa9c8522d1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 11 Oct 2013 23:17:48 +0000 Subject: [PATCH 093/109] Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Process #ifndef...#else...#endif blocks. [SVN r86245] --- include/boost/ref.hpp | 61 ------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index cd186f9..eae86f8 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -65,7 +65,6 @@ template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST # undef BOOST_REF_CONST -# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template class is_reference_wrapper @@ -104,66 +103,6 @@ AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF(reference_wrapper const volatile) # undef AUX_REFERENCE_WRAPPER_METAFUNCTIONS_DEF -# else // no partial specialization - -} // namespace boost - -#include - -namespace boost -{ - -namespace detail -{ - typedef char (&yes_reference_wrapper_t)[1]; - typedef char (&no_reference_wrapper_t)[2]; - - no_reference_wrapper_t is_reference_wrapper_test(...); - - template - yes_reference_wrapper_t is_reference_wrapper_test(type< reference_wrapper >); - - template - struct reference_unwrapper - { - template - struct apply - { - typedef T type; - }; - }; - - template<> - struct reference_unwrapper - { - template - struct apply - { - typedef typename T::type type; - }; - }; -} - -template -class is_reference_wrapper -{ - public: - BOOST_STATIC_CONSTANT( - bool, value = ( - sizeof(detail::is_reference_wrapper_test(type())) - == sizeof(detail::yes_reference_wrapper_t))); - - typedef ::boost::mpl::bool_ type; -}; - -template -class unwrap_reference - : public detail::reference_unwrapper< - is_reference_wrapper::value - >::template apply -{}; - -# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template BOOST_FORCEINLINE typename unwrap_reference::type& unwrap_ref(T& t) From afefe89832c291b89d24ed99a9af282ea5efa4b3 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Fri, 25 Oct 2013 02:46:04 +0000 Subject: [PATCH 094/109] Fixed duplicate anchors [SVN r86423] --- enable_if.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/enable_if.html b/enable_if.html index 8ea33bb..9988f3a 100644 --- a/enable_if.html +++ b/enable_if.html @@ -201,7 +201,7 @@ extra template parameter. -

    3.1  Enabling function templates in C++0x

    +

    3.1  Enabling function templates in C++0x

    In a compiler which supports C++0x default arguments for function template parameters, you can enable and disable function templates by adding an additional template parameter. This approach @@ -416,7 +416,7 @@ subscript operators). -

    4  Acknowledgements

    +

    4  Acknowledgements

    We are grateful to Howard Hinnant, Jason Shirk, Paul Mensonides, and Richard Smith whose findings have influenced the library.
    From a608977aefa3048ad50c41f776124f1d32097d55 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 11 Dec 2013 00:13:48 +0200 Subject: [PATCH 095/109] Revert "Remove obsolete MSVC check from pragma guard" This reverts commit 1fd5883b345a3c230daaad8ee93af5bc8f3209d5. --- include/boost/checked_delete.hpp | 2 +- include/boost/ref.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index 80f936a..9bb84e8 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index eae86f8..e31b167 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -3,7 +3,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif From 1c98320b6eae91f33e409a4909693711357578e8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 11 Dec 2013 00:46:10 +0200 Subject: [PATCH 096/109] Revert "Ref: Remove obsolete MSVC version check." This reverts commit adf57817ec09cb8edd6032a30da6daec3edbe23f. Conflicts: include/boost/ref.hpp --- include/boost/ref.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index e31b167..8169149 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -34,8 +34,16 @@ template class reference_wrapper public: typedef T type; +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) + + explicit reference_wrapper(T& t): t_(&t) {} + +#else + BOOST_FORCEINLINE explicit reference_wrapper(T& t): t_(boost::addressof(t)) {} +#endif + BOOST_FORCEINLINE operator T& () const { return *t_; } BOOST_FORCEINLINE T& get() const { return *t_; } From 779e2b30def02f414906a02f0b6c12ff97ca5efb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 11 Dec 2013 01:57:20 +0200 Subject: [PATCH 097/109] Fix addressof for nullptr_t values. Fixes #5487. --- addressof_np_test.cpp | 50 +++++++++++++++++++++++++ include/boost/utility/addressof.hpp | 57 ++++++++++++++++++++++++++++- 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 addressof_np_test.cpp diff --git a/addressof_np_test.cpp b/addressof_np_test.cpp new file mode 100644 index 0000000..9e155d4 --- /dev/null +++ b/addressof_np_test.cpp @@ -0,0 +1,50 @@ +// +// Copyright 2013 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 +#include +#include + +#if defined( BOOST_NO_CXX11_NULLPTR ) + +void nullptr_test() +{ +} + +#else + +void nullptr_test() +{ + { + auto x = nullptr; + BOOST_TEST( boost::addressof(x) == &x ); + } + + { + auto const x = nullptr; + BOOST_TEST( boost::addressof(x) == &x ); + } + + { + auto volatile x = nullptr; + BOOST_TEST( boost::addressof(x) == &x ); + } + + { + auto const volatile x = nullptr; + BOOST_TEST( boost::addressof(x) == &x ); + } +} + +#endif + +int main() +{ + nullptr_test(); + return boost::report_errors(); +} diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 2b637df..ef5639f 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -1,7 +1,7 @@ // Copyright (C) 2002 Brad King (brad.king@kitware.com) // Douglas Gregor (gregod@cs.rpi.edu) // -// Copyright (C) 2002, 2008 Peter Dimov +// Copyright (C) 2002, 2008, 2013 Peter Dimov // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -14,6 +14,7 @@ # include # include +# include namespace boost { @@ -46,6 +47,60 @@ template struct addressof_impl } }; +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +#if defined( __clang__ ) && !defined( _LIBCPP_VERSION ) && !defined( BOOST_NO_CXX11_DECLTYPE ) + + typedef decltype(nullptr) addr_nullptr_t; + +#else + + typedef std::nullptr_t addr_nullptr_t; + +#endif + +template<> struct addressof_impl< addr_nullptr_t > +{ + typedef addr_nullptr_t T; + + static BOOST_FORCEINLINE T * f( T & v, int ) + { + return &v; + } +}; + +template<> struct addressof_impl< addr_nullptr_t const > +{ + typedef addr_nullptr_t const T; + + static BOOST_FORCEINLINE T * f( T & v, int ) + { + return &v; + } +}; + +template<> struct addressof_impl< addr_nullptr_t volatile > +{ + typedef addr_nullptr_t volatile T; + + static BOOST_FORCEINLINE T * f( T & v, int ) + { + return &v; + } +}; + +template<> struct addressof_impl< addr_nullptr_t const volatile > +{ + typedef addr_nullptr_t const volatile T; + + static BOOST_FORCEINLINE T * f( T & v, int ) + { + return &v; + } +}; + +#endif + } // namespace detail template From ebd6aff12ace6b7d9ef894b30074e7e87f7cc383 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 11 Dec 2013 23:28:13 +0200 Subject: [PATCH 098/109] Revert incorrect reversion of adf57817ec09cb8edd6032a30da6daec3edbe23f --- include/boost/ref.hpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index 8169149..e31b167 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -34,16 +34,8 @@ template class reference_wrapper public: typedef T type; -#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1300 ) - - explicit reference_wrapper(T& t): t_(&t) {} - -#else - BOOST_FORCEINLINE explicit reference_wrapper(T& t): t_(boost::addressof(t)) {} -#endif - BOOST_FORCEINLINE operator T& () const { return *t_; } BOOST_FORCEINLINE T& get() const { return *t_; } From 4d1902031363f2739a0516a27e27f4017f558a49 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 10 Apr 2014 00:27:41 +0400 Subject: [PATCH 099/109] Fix compilation with gcc 4.5 in C++11 mode Gcc 4.5 does not allow non-public defaulted functions, so fall back to the C++03 version. Also replaced the deprecated macros with the new ones and adjusted formatting. --- include/boost/noncopyable.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/boost/noncopyable.hpp b/include/boost/noncopyable.hpp index eb8e2e7..50eb966 100644 --- a/include/boost/noncopyable.hpp +++ b/include/boost/noncopyable.hpp @@ -22,19 +22,19 @@ namespace noncopyable_ // protection from unintended ADL { class noncopyable { - protected: -#ifndef BOOST_NO_DEFAULTED_FUNCTIONS - BOOST_CONSTEXPR noncopyable() = default; - ~noncopyable() = default; + protected: +#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS) + BOOST_CONSTEXPR noncopyable() = default; + ~noncopyable() = default; #else - noncopyable() {} + noncopyable() {} ~noncopyable() {} #endif -#ifndef BOOST_NO_DELETED_FUNCTIONS - noncopyable( const noncopyable& ) = delete; - noncopyable& operator=( const noncopyable& ) = delete; +#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) + noncopyable( const noncopyable& ) = delete; + noncopyable& operator=( const noncopyable& ) = delete; #else - private: // emphasize the following members are private + private: // emphasize the following members are private noncopyable( const noncopyable& ); noncopyable& operator=( const noncopyable& ); #endif From 7ec17497c773d61cf677b9da76ee1eaa59f0c383 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Sun, 10 Oct 2004 16:15:58 +0000 Subject: [PATCH 100/109] move enable_if tests into their own subdirectory [SVN r25649] --- enable_if/test/Jamfile | 33 +++++++ enable_if/test/constructors.cpp | 62 ++++++++++++ enable_if/test/dummy_arg_disambiguation.cpp | 46 +++++++++ enable_if/test/lazy.cpp | 82 ++++++++++++++++ enable_if/test/lazy_test.cpp | 100 ++++++++++++++++++++ enable_if/test/member_templates.cpp | 43 +++++++++ enable_if/test/namespace_disambiguation.cpp | 47 +++++++++ enable_if/test/no_disambiguation.cpp | 43 +++++++++ enable_if/test/partial_specializations.cpp | 67 +++++++++++++ 9 files changed, 523 insertions(+) create mode 100644 enable_if/test/Jamfile create mode 100644 enable_if/test/constructors.cpp create mode 100644 enable_if/test/dummy_arg_disambiguation.cpp create mode 100644 enable_if/test/lazy.cpp create mode 100644 enable_if/test/lazy_test.cpp create mode 100644 enable_if/test/member_templates.cpp create mode 100644 enable_if/test/namespace_disambiguation.cpp create mode 100644 enable_if/test/no_disambiguation.cpp create mode 100644 enable_if/test/partial_specializations.cpp diff --git a/enable_if/test/Jamfile b/enable_if/test/Jamfile new file mode 100644 index 0000000..f2e5ee3 --- /dev/null +++ b/enable_if/test/Jamfile @@ -0,0 +1,33 @@ +# 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) + +# For more information, see http://www.boost.org/ + +subproject libs/utility/enable_if/test ; + +# bring in rules for testing +import testing ; + +# Make tests run by default. +DEPENDS all : test ; + +{ + local test_monitor = @boost/libs/test/build/boost_test_exec_monitor ; + + # look in BOOST_ROOT for sources first, just in this Jamfile + local SEARCH_SOURCE = $(BOOST_ROOT) $(SEARCH_SOURCE) ; + + test-suite utility/enable_if + : + [ run libs/utility/enable_if/test/constructors.cpp $(test_monitor) ] + [ run libs/utility/enable_if/test/dummy_arg_disambiguation.cpp $(test_monitor) ] + [ run libs/utility/enable_if/test/lazy.cpp $(test_monitor) ] + [ run libs/utility/enable_if/test/lazy_test.cpp $(test_monitor) ] + [ run libs/utility/enable_if/test/member_templates.cpp $(test_monitor) ] + [ run libs/utility/enable_if/test/namespace_disambiguation.cpp $(test_monitor) ] + [ run libs/utility/enable_if/test/no_disambiguation.cpp $(test_monitor) ] + [ run libs/utility/enable_if/test/partial_specializations.cpp $(test_monitor) ] + ; +} diff --git a/enable_if/test/constructors.cpp b/enable_if/test/constructors.cpp new file mode 100644 index 0000000..557b2f0 --- /dev/null +++ b/enable_if/test/constructors.cpp @@ -0,0 +1,62 @@ +// Boost enable_if library + +// Copyright 2003 © The Trustees of Indiana University. + +// 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) + +// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Jeremiah Willcock (jewillco at osl.iu.edu) +// Andrew Lumsdaine (lums at osl.iu.edu) + +#include + +#include +#include + +using boost::enable_if; +using boost::disable_if; +using boost::is_arithmetic; + +struct container { + bool my_value; + + template + container(const T&, const typename enable_if, T>::type * = 0): + my_value(true) {} + + template + container(const T&, const typename disable_if, T>::type * = 0): + my_value(false) {} +}; + +// example from Howard Hinnant (tests enable_if template members of a templated class) +template +struct xstring +{ + template + xstring(It begin, It end, typename + disable_if >::type* = 0) + : data(end-begin) {} + + int data; +}; + + +int test_main(int, char*[]) +{ + + BOOST_CHECK(container(1).my_value); + BOOST_CHECK(container(1.0).my_value); + + BOOST_CHECK(!container("1").my_value); + BOOST_CHECK(!container(static_cast(0)).my_value); + + char sa[] = "123456"; + BOOST_CHECK(xstring(sa, sa+6).data == 6); + + + return 0; +} + diff --git a/enable_if/test/dummy_arg_disambiguation.cpp b/enable_if/test/dummy_arg_disambiguation.cpp new file mode 100644 index 0000000..bb9f733 --- /dev/null +++ b/enable_if/test/dummy_arg_disambiguation.cpp @@ -0,0 +1,46 @@ +// Boost enable_if library + +// Copyright 2003 © The Trustees of Indiana University. + +// 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) + +// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Jeremiah Willcock (jewillco at osl.iu.edu) +// Andrew Lumsdaine (lums at osl.iu.edu) + +#include + +#include +#include + +using boost::enable_if; +using boost::disable_if; +using boost::is_arithmetic; + +template struct dummy { + dummy(int) {}; +}; + +template +typename enable_if, bool>::type +arithmetic_object(T t, dummy<0> = 0) { return true; } + +template +typename disable_if, bool>::type +arithmetic_object(T t, dummy<1> = 0) { return false; } + + +int test_main(int, char*[]) +{ + + BOOST_CHECK(arithmetic_object(1)); + BOOST_CHECK(arithmetic_object(1.0)); + + BOOST_CHECK(!arithmetic_object("1")); + BOOST_CHECK(!arithmetic_object(static_cast(0))); + + return 0; +} + diff --git a/enable_if/test/lazy.cpp b/enable_if/test/lazy.cpp new file mode 100644 index 0000000..6e7d650 --- /dev/null +++ b/enable_if/test/lazy.cpp @@ -0,0 +1,82 @@ +// Boost enable_if library + +// Copyright 2003 © The Trustees of Indiana University. + +// 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) + +// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Jeremiah Willcock (jewillco at osl.iu.edu) +// Andrew Lumsdaine (lums at osl.iu.edu) + +#include + +#include +#include + +using boost::enable_if_c; +using boost::lazy_enable_if_c; + +// This class provides a reduced example of a traits class for +// computing the result of multiplying two types. The member typedef +// 'type' in this traits class defines the return type of this +// operator. The return type member is invalid unless both arguments +// for mult_traits are values that mult_traits expects (ints in this +// case). This kind of situation may arise if a traits class only +// makes sense for some set of types, not all C++ types. + +template struct is_int { + BOOST_STATIC_CONSTANT(bool, value = (boost::is_same::value)); +}; + +template +struct mult_traits { + typedef typename T::does_not_exist type; +}; + +template <> +struct mult_traits { + typedef int type; +}; + + +// Next, a forwarding function mult() is defined. It is enabled only +// when both arguments are of type int. The first version, using +// non-lazy enable_if_c does not work. + +#if 0 +template +typename enable_if_c< + is_int::value && is_int::value, + typename mult_traits::type +>::type +mult(const T& x, const U& y) {return x * y;} +#endif + +// A correct version uses lazy_enable_if_c. +// This template removes compiler errors from invalid code used as an +// argument to enable_if_c. + +#if 1 +template +typename lazy_enable_if_c< + is_int::value && is_int::value, + mult_traits +>::type +mult(const T& x, const U& y) {return x * y;} +#endif + +double mult(int i, double d) { return (double)i * d; } + +int test_main(int, char*[]) +{ + + + BOOST_CHECK(mult(1, 2) == 2); + + BOOST_CHECK(mult(1, 3.0) == 3.0); + + return 0; +} + diff --git a/enable_if/test/lazy_test.cpp b/enable_if/test/lazy_test.cpp new file mode 100644 index 0000000..d52d01e --- /dev/null +++ b/enable_if/test/lazy_test.cpp @@ -0,0 +1,100 @@ +// Boost enable_if library + +// Copyright 2003 © The Trustees of Indiana University. + +// 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) + +// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Jeremiah Willcock (jewillco at osl.iu.edu) +// Andrew Lumsdaine (lums at osl.iu.edu) + +// Testing all variations of lazy_enable_if. + +#include +#include + +#include +#include + +using boost::lazy_enable_if; +using boost::lazy_disable_if; + +using boost::lazy_enable_if_c; +using boost::lazy_disable_if_c; + + +template +struct is_int_or_double { + BOOST_STATIC_CONSTANT(bool, + value = (boost::is_same::value || + boost::is_same::value)); +}; + +template +struct some_traits { + typedef typename T::does_not_exist type; +}; + +template <> +struct some_traits { + typedef bool type; +}; + +template <> +struct some_traits { + typedef bool type; +}; + +template +struct make_bool { + typedef bool type; +}; + +template <> +struct make_bool {}; + +template <> +struct make_bool {}; + +namespace A { + + template + typename lazy_enable_if, some_traits >::type + foo(T t) { return true; } + + template + typename lazy_enable_if_c::value, some_traits >::type + foo2(T t) { return true; } +} + +namespace B { + template + typename lazy_disable_if, make_bool >::type + foo(T t) { return false; } + + template + typename lazy_disable_if_c::value, make_bool >::type + foo2(T t) { return false; } +} + +int test_main(int, char*[]) +{ + using namespace A; + using namespace B; + BOOST_CHECK(foo(1)); + BOOST_CHECK(foo(1.0)); + + BOOST_CHECK(!foo("1")); + BOOST_CHECK(!foo(static_cast(0))); + + BOOST_CHECK(foo2(1)); + BOOST_CHECK(foo2(1.0)); + + BOOST_CHECK(!foo2("1")); + BOOST_CHECK(!foo2(static_cast(0))); + + return 0; +} + diff --git a/enable_if/test/member_templates.cpp b/enable_if/test/member_templates.cpp new file mode 100644 index 0000000..23dd173 --- /dev/null +++ b/enable_if/test/member_templates.cpp @@ -0,0 +1,43 @@ +// Boost enable_if library + +// Copyright 2003 © The Trustees of Indiana University. + +// 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) + +// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Jeremiah Willcock (jewillco at osl.iu.edu) +// Andrew Lumsdaine (lums at osl.iu.edu) + +#include + +#include +#include + +using boost::enable_if; +using boost::disable_if; +using boost::is_arithmetic; + +struct container { + template + typename enable_if, bool>::type + arithmetic_object(const T&, const int* /* disambiguate */ = 0) {return true;} + + template + typename disable_if, bool>::type + arithmetic_object(const T&) {return false;} +}; + +int test_main(int, char*[]) +{ + + BOOST_CHECK(container().arithmetic_object(1)); + BOOST_CHECK(container().arithmetic_object(1.0)); + + BOOST_CHECK(!container().arithmetic_object("1")); + BOOST_CHECK(!container().arithmetic_object(static_cast(0))); + + return 0; +} + diff --git a/enable_if/test/namespace_disambiguation.cpp b/enable_if/test/namespace_disambiguation.cpp new file mode 100644 index 0000000..90a98a1 --- /dev/null +++ b/enable_if/test/namespace_disambiguation.cpp @@ -0,0 +1,47 @@ +// Boost enable_if library + +// Copyright 2003 © The Trustees of Indiana University. + +// 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) + +// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Jeremiah Willcock (jewillco at osl.iu.edu) +// Andrew Lumsdaine (lums at osl.iu.edu) + +#include +#include + +#include +#include + +using boost::enable_if; +using boost::mpl::not_; +using boost::is_arithmetic; + +namespace A { + template + typename enable_if, bool>::type + arithmetic_object(T t) { return true; } +} + +namespace B { + template + typename enable_if >, bool>::type + arithmetic_object(T t) { return false; } +} + +int test_main(int, char*[]) +{ + using namespace A; + using namespace B; + BOOST_CHECK(arithmetic_object(1)); + BOOST_CHECK(arithmetic_object(1.0)); + + BOOST_CHECK(!arithmetic_object("1")); + BOOST_CHECK(!arithmetic_object(static_cast(0))); + + return 0; +} + diff --git a/enable_if/test/no_disambiguation.cpp b/enable_if/test/no_disambiguation.cpp new file mode 100644 index 0000000..f4936e8 --- /dev/null +++ b/enable_if/test/no_disambiguation.cpp @@ -0,0 +1,43 @@ +// Boost enable_if library + +// Copyright 2003 © The Trustees of Indiana University. + +// 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) + +// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Jeremiah Willcock (jewillco at osl.iu.edu) +// Andrew Lumsdaine (lums at osl.iu.edu) + +#include +#include + +#include +#include + +using boost::mpl::not_; +using boost::enable_if; +using boost::is_arithmetic; + +template +typename enable_if, bool>::type +arithmetic_object(T t) { return true; } + +template +typename enable_if >, bool>::type +arithmetic_object(T t) { return false; } + + +int test_main(int, char*[]) +{ + + BOOST_CHECK(arithmetic_object(1)); + BOOST_CHECK(arithmetic_object(1.0)); + + BOOST_CHECK(!arithmetic_object("1")); + BOOST_CHECK(!arithmetic_object(static_cast(0))); + + return 0; +} + diff --git a/enable_if/test/partial_specializations.cpp b/enable_if/test/partial_specializations.cpp new file mode 100644 index 0000000..3dce799 --- /dev/null +++ b/enable_if/test/partial_specializations.cpp @@ -0,0 +1,67 @@ +// Boost enable_if library + +// Copyright 2003 © The Trustees of Indiana University. + +// 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) + +// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Jeremiah Willcock (jewillco at osl.iu.edu) +// Andrew Lumsdaine (lums at osl.iu.edu) + +#include + +#include +#include + +using boost::enable_if_c; +using boost::disable_if_c; +using boost::enable_if; +using boost::disable_if; +using boost::is_arithmetic; + +template +struct tester; + +template +struct tester::value>::type> { + BOOST_STATIC_CONSTANT(bool, value = true); +}; + +template +struct tester::value>::type> { + BOOST_STATIC_CONSTANT(bool, value = false); +}; + +template +struct tester2; + +template +struct tester2 >::type> { + BOOST_STATIC_CONSTANT(bool, value = true); +}; + +template +struct tester2 >::type> { + BOOST_STATIC_CONSTANT(bool, value = false); +}; + +int test_main(int, char*[]) +{ + + BOOST_CHECK(tester::value); + BOOST_CHECK(tester::value); + + BOOST_CHECK(!tester::value); + BOOST_CHECK(!tester::value); + + BOOST_CHECK(tester2::value); + BOOST_CHECK(tester2::value); + + BOOST_CHECK(!tester2::value); + BOOST_CHECK(!tester2::value); + + return 0; +} + From 395da5e7c997df95cd84394a1fe4406552674b0e Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 14 Apr 2005 13:15:46 +0000 Subject: [PATCH 101/109] Add V2 Jamfile [SVN r28246] --- enable_if/test/Jamfile.v2 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 enable_if/test/Jamfile.v2 diff --git a/enable_if/test/Jamfile.v2 b/enable_if/test/Jamfile.v2 new file mode 100644 index 0000000..77a8798 --- /dev/null +++ b/enable_if/test/Jamfile.v2 @@ -0,0 +1,23 @@ +# 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) + +# For more information, see http://www.boost.org/ + +project + : requirements /boost/test//boost_test_exec_monitor + ; + +test-suite utility/enable_if + : + [ run constructors.cpp ] + [ run dummy_arg_disambiguation.cpp ] + [ run lazy.cpp ] + [ run lazy_test.cpp ] + [ run member_templates.cpp ] + [ run namespace_disambiguation.cpp ] + [ run no_disambiguation.cpp ] + [ run partial_specializations.cpp ] + ; + From d3ce7aa91c2f0cbb85787f6dd4b377d2430cf0c2 Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Sun, 4 Dec 2005 18:47:02 +0000 Subject: [PATCH 102/109] Attempted portability fix for Sun compilers [SVN r31904] --- enable_if/test/lazy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enable_if/test/lazy.cpp b/enable_if/test/lazy.cpp index 6e7d650..d766fc9 100644 --- a/enable_if/test/lazy.cpp +++ b/enable_if/test/lazy.cpp @@ -61,7 +61,7 @@ mult(const T& x, const U& y) {return x * y;} #if 1 template typename lazy_enable_if_c< - is_int::value && is_int::value, + is_int::value & is_int::value, mult_traits >::type mult(const T& x, const U& y) {return x * y;} From fd5c46ad76c6c009d3861c45acf75e57b2469516 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 8 Aug 2007 19:02:26 +0000 Subject: [PATCH 103/109] Remove V1 Jamfiles [SVN r38516] --- enable_if/test/Jamfile | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 enable_if/test/Jamfile diff --git a/enable_if/test/Jamfile b/enable_if/test/Jamfile deleted file mode 100644 index f2e5ee3..0000000 --- a/enable_if/test/Jamfile +++ /dev/null @@ -1,33 +0,0 @@ -# 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) - -# For more information, see http://www.boost.org/ - -subproject libs/utility/enable_if/test ; - -# bring in rules for testing -import testing ; - -# Make tests run by default. -DEPENDS all : test ; - -{ - local test_monitor = @boost/libs/test/build/boost_test_exec_monitor ; - - # look in BOOST_ROOT for sources first, just in this Jamfile - local SEARCH_SOURCE = $(BOOST_ROOT) $(SEARCH_SOURCE) ; - - test-suite utility/enable_if - : - [ run libs/utility/enable_if/test/constructors.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/dummy_arg_disambiguation.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/lazy.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/lazy_test.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/member_templates.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/namespace_disambiguation.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/no_disambiguation.cpp $(test_monitor) ] - [ run libs/utility/enable_if/test/partial_specializations.cpp $(test_monitor) ] - ; -} From 605b5112e194edf5a96a51faa50de8a0447d57ae Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 2 Apr 2008 01:42:32 +0000 Subject: [PATCH 104/109] Replaced all occurrences of non-ASCII copyright symbol with '(c)' for people using non-ASCII code pages [SVN r43992] --- enable_if/test/constructors.cpp | 2 +- enable_if/test/dummy_arg_disambiguation.cpp | 2 +- enable_if/test/lazy.cpp | 2 +- enable_if/test/lazy_test.cpp | 2 +- enable_if/test/member_templates.cpp | 2 +- enable_if/test/namespace_disambiguation.cpp | 2 +- enable_if/test/no_disambiguation.cpp | 2 +- enable_if/test/partial_specializations.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/enable_if/test/constructors.cpp b/enable_if/test/constructors.cpp index 557b2f0..889133d 100644 --- a/enable_if/test/constructors.cpp +++ b/enable_if/test/constructors.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/dummy_arg_disambiguation.cpp b/enable_if/test/dummy_arg_disambiguation.cpp index bb9f733..90275e9 100644 --- a/enable_if/test/dummy_arg_disambiguation.cpp +++ b/enable_if/test/dummy_arg_disambiguation.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/lazy.cpp b/enable_if/test/lazy.cpp index d766fc9..117ec41 100644 --- a/enable_if/test/lazy.cpp +++ b/enable_if/test/lazy.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/lazy_test.cpp b/enable_if/test/lazy_test.cpp index d52d01e..10bb60c 100644 --- a/enable_if/test/lazy_test.cpp +++ b/enable_if/test/lazy_test.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/member_templates.cpp b/enable_if/test/member_templates.cpp index 23dd173..f7c00a0 100644 --- a/enable_if/test/member_templates.cpp +++ b/enable_if/test/member_templates.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/namespace_disambiguation.cpp b/enable_if/test/namespace_disambiguation.cpp index 90a98a1..a53d3a7 100644 --- a/enable_if/test/namespace_disambiguation.cpp +++ b/enable_if/test/namespace_disambiguation.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/no_disambiguation.cpp b/enable_if/test/no_disambiguation.cpp index f4936e8..122d600 100644 --- a/enable_if/test/no_disambiguation.cpp +++ b/enable_if/test/no_disambiguation.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at diff --git a/enable_if/test/partial_specializations.cpp b/enable_if/test/partial_specializations.cpp index 3dce799..5c322ae 100644 --- a/enable_if/test/partial_specializations.cpp +++ b/enable_if/test/partial_specializations.cpp @@ -1,6 +1,6 @@ // Boost enable_if library -// Copyright 2003 © The Trustees of Indiana University. +// Copyright 2003 (c) The Trustees of Indiana University. // Use, modification, and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at From fb6ec0ef3a3723ce24f57b8921ab049470e6ffff Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sat, 28 Jun 2008 13:45:21 +0000 Subject: [PATCH 105/109] =?UTF-8?q?With=20his=20kind=20permission,=20chang?= =?UTF-8?q?e=20Jaakko=20"J=C3=A4rvi"=20to=20"Jarvi"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [SVN r46808] --- enable_if/test/constructors.cpp | 2 +- enable_if/test/dummy_arg_disambiguation.cpp | 2 +- enable_if/test/lazy.cpp | 2 +- enable_if/test/lazy_test.cpp | 2 +- enable_if/test/member_templates.cpp | 2 +- enable_if/test/namespace_disambiguation.cpp | 2 +- enable_if/test/no_disambiguation.cpp | 2 +- enable_if/test/partial_specializations.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/enable_if/test/constructors.cpp b/enable_if/test/constructors.cpp index 889133d..0d465de 100644 --- a/enable_if/test/constructors.cpp +++ b/enable_if/test/constructors.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/dummy_arg_disambiguation.cpp b/enable_if/test/dummy_arg_disambiguation.cpp index 90275e9..60dfdfd 100644 --- a/enable_if/test/dummy_arg_disambiguation.cpp +++ b/enable_if/test/dummy_arg_disambiguation.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/lazy.cpp b/enable_if/test/lazy.cpp index 117ec41..f04111e 100644 --- a/enable_if/test/lazy.cpp +++ b/enable_if/test/lazy.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/lazy_test.cpp b/enable_if/test/lazy_test.cpp index 10bb60c..9ec5324 100644 --- a/enable_if/test/lazy_test.cpp +++ b/enable_if/test/lazy_test.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/member_templates.cpp b/enable_if/test/member_templates.cpp index f7c00a0..55e2d80 100644 --- a/enable_if/test/member_templates.cpp +++ b/enable_if/test/member_templates.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/namespace_disambiguation.cpp b/enable_if/test/namespace_disambiguation.cpp index a53d3a7..45d4f0a 100644 --- a/enable_if/test/namespace_disambiguation.cpp +++ b/enable_if/test/namespace_disambiguation.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/no_disambiguation.cpp b/enable_if/test/no_disambiguation.cpp index 122d600..e2416ed 100644 --- a/enable_if/test/no_disambiguation.cpp +++ b/enable_if/test/no_disambiguation.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) diff --git a/enable_if/test/partial_specializations.cpp b/enable_if/test/partial_specializations.cpp index 5c322ae..1d4db99 100644 --- a/enable_if/test/partial_specializations.cpp +++ b/enable_if/test/partial_specializations.cpp @@ -6,7 +6,7 @@ // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -// Authors: Jaakko Järvi (jajarvi at osl.iu.edu) +// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) From 5dd86f3ac4bd4c3e9d65d219bbd2947d1bfbfa28 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 1 Jun 2014 01:31:54 +0300 Subject: [PATCH 106/109] Move and rename test files. --- enable_if/test/Jamfile.v2 | 23 ------------------- .../addressof_fn_test.cpp | 0 .../addressof_np_test.cpp | 0 addressof_test.cpp => test/addressof_test.cpp | 0 .../addressof_test2.cpp | 0 .../checked_delete_test.cpp | 0 .../eif_constructors.cpp | 0 .../eif_dummy_arg_disambiguation.cpp | 0 enable_if/test/lazy.cpp => test/eif_lazy.cpp | 0 .../lazy_test.cpp => test/eif_lazy_test.cpp | 0 .../eif_member_templates.cpp | 0 .../eif_namespace_disambiguation.cpp | 0 .../eif_no_disambiguation.cpp | 0 .../eif_partial_specializations.cpp | 0 ref_ct_test.cpp => test/ref_ct_test.cpp | 0 ref_test.cpp => test/ref_test.cpp | 0 16 files changed, 23 deletions(-) delete mode 100644 enable_if/test/Jamfile.v2 rename addressof_fn_test.cpp => test/addressof_fn_test.cpp (100%) rename addressof_np_test.cpp => test/addressof_np_test.cpp (100%) rename addressof_test.cpp => test/addressof_test.cpp (100%) rename addressof_test2.cpp => test/addressof_test2.cpp (100%) rename checked_delete_test.cpp => test/checked_delete_test.cpp (100%) rename enable_if/test/constructors.cpp => test/eif_constructors.cpp (100%) rename enable_if/test/dummy_arg_disambiguation.cpp => test/eif_dummy_arg_disambiguation.cpp (100%) rename enable_if/test/lazy.cpp => test/eif_lazy.cpp (100%) rename enable_if/test/lazy_test.cpp => test/eif_lazy_test.cpp (100%) rename enable_if/test/member_templates.cpp => test/eif_member_templates.cpp (100%) rename enable_if/test/namespace_disambiguation.cpp => test/eif_namespace_disambiguation.cpp (100%) rename enable_if/test/no_disambiguation.cpp => test/eif_no_disambiguation.cpp (100%) rename enable_if/test/partial_specializations.cpp => test/eif_partial_specializations.cpp (100%) rename ref_ct_test.cpp => test/ref_ct_test.cpp (100%) rename ref_test.cpp => test/ref_test.cpp (100%) diff --git a/enable_if/test/Jamfile.v2 b/enable_if/test/Jamfile.v2 deleted file mode 100644 index 77a8798..0000000 --- a/enable_if/test/Jamfile.v2 +++ /dev/null @@ -1,23 +0,0 @@ -# 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) - -# For more information, see http://www.boost.org/ - -project - : requirements /boost/test//boost_test_exec_monitor - ; - -test-suite utility/enable_if - : - [ run constructors.cpp ] - [ run dummy_arg_disambiguation.cpp ] - [ run lazy.cpp ] - [ run lazy_test.cpp ] - [ run member_templates.cpp ] - [ run namespace_disambiguation.cpp ] - [ run no_disambiguation.cpp ] - [ run partial_specializations.cpp ] - ; - diff --git a/addressof_fn_test.cpp b/test/addressof_fn_test.cpp similarity index 100% rename from addressof_fn_test.cpp rename to test/addressof_fn_test.cpp diff --git a/addressof_np_test.cpp b/test/addressof_np_test.cpp similarity index 100% rename from addressof_np_test.cpp rename to test/addressof_np_test.cpp diff --git a/addressof_test.cpp b/test/addressof_test.cpp similarity index 100% rename from addressof_test.cpp rename to test/addressof_test.cpp diff --git a/addressof_test2.cpp b/test/addressof_test2.cpp similarity index 100% rename from addressof_test2.cpp rename to test/addressof_test2.cpp diff --git a/checked_delete_test.cpp b/test/checked_delete_test.cpp similarity index 100% rename from checked_delete_test.cpp rename to test/checked_delete_test.cpp diff --git a/enable_if/test/constructors.cpp b/test/eif_constructors.cpp similarity index 100% rename from enable_if/test/constructors.cpp rename to test/eif_constructors.cpp diff --git a/enable_if/test/dummy_arg_disambiguation.cpp b/test/eif_dummy_arg_disambiguation.cpp similarity index 100% rename from enable_if/test/dummy_arg_disambiguation.cpp rename to test/eif_dummy_arg_disambiguation.cpp diff --git a/enable_if/test/lazy.cpp b/test/eif_lazy.cpp similarity index 100% rename from enable_if/test/lazy.cpp rename to test/eif_lazy.cpp diff --git a/enable_if/test/lazy_test.cpp b/test/eif_lazy_test.cpp similarity index 100% rename from enable_if/test/lazy_test.cpp rename to test/eif_lazy_test.cpp diff --git a/enable_if/test/member_templates.cpp b/test/eif_member_templates.cpp similarity index 100% rename from enable_if/test/member_templates.cpp rename to test/eif_member_templates.cpp diff --git a/enable_if/test/namespace_disambiguation.cpp b/test/eif_namespace_disambiguation.cpp similarity index 100% rename from enable_if/test/namespace_disambiguation.cpp rename to test/eif_namespace_disambiguation.cpp diff --git a/enable_if/test/no_disambiguation.cpp b/test/eif_no_disambiguation.cpp similarity index 100% rename from enable_if/test/no_disambiguation.cpp rename to test/eif_no_disambiguation.cpp diff --git a/enable_if/test/partial_specializations.cpp b/test/eif_partial_specializations.cpp similarity index 100% rename from enable_if/test/partial_specializations.cpp rename to test/eif_partial_specializations.cpp diff --git a/ref_ct_test.cpp b/test/ref_ct_test.cpp similarity index 100% rename from ref_ct_test.cpp rename to test/ref_ct_test.cpp diff --git a/ref_test.cpp b/test/ref_test.cpp similarity index 100% rename from ref_test.cpp rename to test/ref_test.cpp From f032781796a74a1713bc134248350f00f5cc80ba Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 1 Jun 2014 01:48:14 +0300 Subject: [PATCH 107/109] Add Jamfile.v2; make ref_test use lightweight_test.hpp. --- test/Jamfile.v2 | 21 ++++++++++ ...elete_test.cpp => checked_delete_fail.cpp} | 0 test/ref_test.cpp | 40 +++++-------------- 3 files changed, 31 insertions(+), 30 deletions(-) create mode 100644 test/Jamfile.v2 rename test/{checked_delete_test.cpp => checked_delete_fail.cpp} (100%) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 new file mode 100644 index 0000000..ed6e7e4 --- /dev/null +++ b/test/Jamfile.v2 @@ -0,0 +1,21 @@ +# Boost.Core Library test Jamfile +# +# Copyright (c) 2014 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 + +# bring in rules for testing +import testing ; + +test-suite "core" + : + [ run addressof_test.cpp ] + [ run addressof_test2.cpp ] + [ run addressof_np_test.cpp ] + [ run addressof_fn_test.cpp ] + [ compile-fail checked_delete_fail.cpp ] + [ compile ref_ct_test.cpp ] + [ run ref_test.cpp ] + ; diff --git a/test/checked_delete_test.cpp b/test/checked_delete_fail.cpp similarity index 100% rename from test/checked_delete_test.cpp rename to test/checked_delete_fail.cpp diff --git a/test/ref_test.cpp b/test/ref_test.cpp index 71481fa..a8f5bd7 100644 --- a/test/ref_test.cpp +++ b/test/ref_test.cpp @@ -6,28 +6,8 @@ // run-time test for "boost/ref.hpp" header content // see 'ref_ct_test.cpp' for compile-time part -#if defined(_MSC_VER) && !defined(__ICL) -# pragma warning(disable: 4786) // identifier truncated in debug info -# pragma warning(disable: 4710) // function not inlined -# pragma warning(disable: 4711) // function selected for automatic inline expansion -# pragma warning(disable: 4514) // unreferenced inline removed -#endif - #include - -#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) -# pragma warning(push, 3) -#endif - -#include - -#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) -# pragma warning(pop) -#endif - - -#define BOOST_INCLUDE_MAIN -#include +#include namespace { using namespace boost; @@ -60,11 +40,11 @@ struct ref_wrapper static void test(T x) { - BOOST_CHECK(passthru(ref(x)) == &x); - BOOST_CHECK(&ref(x).get() == &x); + BOOST_TEST(passthru(ref(x)) == &x); + BOOST_TEST(&ref(x).get() == &x); - BOOST_CHECK(cref_passthru(cref(x)) == &x); - BOOST_CHECK(&cref(x).get() == &x); + BOOST_TEST(cref_passthru(cref(x)) == &x); + BOOST_TEST(&cref(x).get() == &x); } }; @@ -102,20 +82,20 @@ void unwrap_test() { do_unwrap(ref(ci)); copy_counter cc; - BOOST_CHECK(cc.count() == 0); + BOOST_TEST(cc.count() == 0); do_unwrap(cc); do_unwrap(ref(cc)); do_unwrap(cref(cc)); - BOOST_CHECK(cc.count() == 1); - BOOST_CHECK(unwrap_ref(ref(cc)).count() == 1); + BOOST_TEST(cc.count() == 1); + BOOST_TEST(unwrap_ref(ref(cc)).count() == 1); } -int test_main(int, char * []) +int main() { ref_wrapper::test(1); ref_wrapper::test(1); unwrap_test(); - return 0; + return boost::report_errors(); } From ba9f0e47a1aefefb46542ddf0224f5e1e5f233a8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 1 Jun 2014 01:51:40 +0300 Subject: [PATCH 108/109] Remove unnecessary includes and workarounds from ref_ct_test. --- test/ref_ct_test.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/ref_ct_test.cpp b/test/ref_ct_test.cpp index a3b5eea..34a79d2 100644 --- a/test/ref_ct_test.cpp +++ b/test/ref_ct_test.cpp @@ -8,12 +8,9 @@ #include #include -#include #include #include -#include - namespace { template< typename T, typename U > @@ -39,23 +36,13 @@ void is_reference_wrapper_test(T) template< typename R, typename Ref > void cxx_reference_test(Ref) { -#if BOOST_WORKAROUND(__BORLANDC__, < 0x600) - typedef typename boost::remove_const::type ref; - BOOST_STATIC_ASSERT((boost::is_same::value)); -#else BOOST_STATIC_ASSERT((boost::is_same::value)); -#endif } template< typename R, typename Ref > void unwrap_reference_test(Ref) { -#if BOOST_WORKAROUND(__BORLANDC__, < 0x600) - typedef typename boost::remove_const::type ref; - typedef typename boost::unwrap_reference::type type; -#else typedef typename boost::unwrap_reference::type type; -#endif BOOST_STATIC_ASSERT((boost::is_same::value)); } From 927f98189d860cb954aadcd5bba57d29c480f191 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 1 Jun 2014 02:10:28 +0300 Subject: [PATCH 109/109] Update enable_if tests to use lightweight_test, add to Jamfile. --- test/Jamfile.v2 | 11 +++++++++++ test/eif_constructors.cpp | 17 ++++++++--------- test/eif_dummy_arg_disambiguation.cpp | 15 +++++++-------- test/eif_lazy.cpp | 11 +++++------ test/eif_lazy_test.cpp | 24 +++++++++++------------- test/eif_member_templates.cpp | 15 +++++++-------- test/eif_namespace_disambiguation.cpp | 14 +++++++------- test/eif_no_disambiguation.cpp | 14 +++++++------- test/eif_partial_specializations.cpp | 23 +++++++++++------------ 9 files changed, 74 insertions(+), 70 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ed6e7e4..74fd336 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -15,7 +15,18 @@ test-suite "core" [ run addressof_test2.cpp ] [ run addressof_np_test.cpp ] [ run addressof_fn_test.cpp ] + [ compile-fail checked_delete_fail.cpp ] + [ compile ref_ct_test.cpp ] [ run ref_test.cpp ] + + [ run eif_constructors.cpp ] + [ run eif_dummy_arg_disambiguation.cpp ] + [ run eif_lazy.cpp ] + [ run eif_lazy_test.cpp ] + [ run eif_member_templates.cpp ] + [ run eif_namespace_disambiguation.cpp ] + [ run eif_no_disambiguation.cpp ] + [ run eif_partial_specializations.cpp ] ; diff --git a/test/eif_constructors.cpp b/test/eif_constructors.cpp index 0d465de..ea82b40 100644 --- a/test/eif_constructors.cpp +++ b/test/eif_constructors.cpp @@ -10,10 +10,9 @@ // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) -#include - #include #include +#include using boost::enable_if; using boost::disable_if; @@ -44,19 +43,19 @@ struct xstring }; -int test_main(int, char*[]) +int main() { - BOOST_CHECK(container(1).my_value); - BOOST_CHECK(container(1.0).my_value); + BOOST_TEST(container(1).my_value); + BOOST_TEST(container(1.0).my_value); - BOOST_CHECK(!container("1").my_value); - BOOST_CHECK(!container(static_cast(0)).my_value); + BOOST_TEST(!container("1").my_value); + BOOST_TEST(!container(static_cast(0)).my_value); char sa[] = "123456"; - BOOST_CHECK(xstring(sa, sa+6).data == 6); + BOOST_TEST(xstring(sa, sa+6).data == 6); - return 0; + return boost::report_errors(); } diff --git a/test/eif_dummy_arg_disambiguation.cpp b/test/eif_dummy_arg_disambiguation.cpp index 60dfdfd..e72b158 100644 --- a/test/eif_dummy_arg_disambiguation.cpp +++ b/test/eif_dummy_arg_disambiguation.cpp @@ -10,10 +10,9 @@ // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) -#include - #include #include +#include using boost::enable_if; using boost::disable_if; @@ -32,15 +31,15 @@ typename disable_if, bool>::type arithmetic_object(T t, dummy<1> = 0) { return false; } -int test_main(int, char*[]) +int main() { - BOOST_CHECK(arithmetic_object(1)); - BOOST_CHECK(arithmetic_object(1.0)); + BOOST_TEST(arithmetic_object(1)); + BOOST_TEST(arithmetic_object(1.0)); - BOOST_CHECK(!arithmetic_object("1")); - BOOST_CHECK(!arithmetic_object(static_cast(0))); + BOOST_TEST(!arithmetic_object("1")); + BOOST_TEST(!arithmetic_object(static_cast(0))); - return 0; + return boost::report_errors(); } diff --git a/test/eif_lazy.cpp b/test/eif_lazy.cpp index f04111e..029eca5 100644 --- a/test/eif_lazy.cpp +++ b/test/eif_lazy.cpp @@ -10,10 +10,9 @@ // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) -#include - #include #include +#include using boost::enable_if_c; using boost::lazy_enable_if_c; @@ -69,14 +68,14 @@ mult(const T& x, const U& y) {return x * y;} double mult(int i, double d) { return (double)i * d; } -int test_main(int, char*[]) +int main() { - BOOST_CHECK(mult(1, 2) == 2); + BOOST_TEST(mult(1, 2) == 2); - BOOST_CHECK(mult(1, 3.0) == 3.0); + BOOST_TEST(mult(1, 3.0) == 3.0); - return 0; + return boost::report_errors(); } diff --git a/test/eif_lazy_test.cpp b/test/eif_lazy_test.cpp index 9ec5324..6077759 100644 --- a/test/eif_lazy_test.cpp +++ b/test/eif_lazy_test.cpp @@ -12,11 +12,9 @@ // Testing all variations of lazy_enable_if. -#include -#include - #include #include +#include using boost::lazy_enable_if; using boost::lazy_disable_if; @@ -79,22 +77,22 @@ namespace B { foo2(T t) { return false; } } -int test_main(int, char*[]) +int main() { using namespace A; using namespace B; - BOOST_CHECK(foo(1)); - BOOST_CHECK(foo(1.0)); + BOOST_TEST(foo(1)); + BOOST_TEST(foo(1.0)); - BOOST_CHECK(!foo("1")); - BOOST_CHECK(!foo(static_cast(0))); + BOOST_TEST(!foo("1")); + BOOST_TEST(!foo(static_cast(0))); - BOOST_CHECK(foo2(1)); - BOOST_CHECK(foo2(1.0)); + BOOST_TEST(foo2(1)); + BOOST_TEST(foo2(1.0)); - BOOST_CHECK(!foo2("1")); - BOOST_CHECK(!foo2(static_cast(0))); + BOOST_TEST(!foo2("1")); + BOOST_TEST(!foo2(static_cast(0))); - return 0; + return boost::report_errors(); } diff --git a/test/eif_member_templates.cpp b/test/eif_member_templates.cpp index 55e2d80..2f1eeb2 100644 --- a/test/eif_member_templates.cpp +++ b/test/eif_member_templates.cpp @@ -10,10 +10,9 @@ // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) -#include - #include #include +#include using boost::enable_if; using boost::disable_if; @@ -29,15 +28,15 @@ struct container { arithmetic_object(const T&) {return false;} }; -int test_main(int, char*[]) +int main() { - BOOST_CHECK(container().arithmetic_object(1)); - BOOST_CHECK(container().arithmetic_object(1.0)); + BOOST_TEST(container().arithmetic_object(1)); + BOOST_TEST(container().arithmetic_object(1.0)); - BOOST_CHECK(!container().arithmetic_object("1")); - BOOST_CHECK(!container().arithmetic_object(static_cast(0))); + BOOST_TEST(!container().arithmetic_object("1")); + BOOST_TEST(!container().arithmetic_object(static_cast(0))); - return 0; + return boost::report_errors(); } diff --git a/test/eif_namespace_disambiguation.cpp b/test/eif_namespace_disambiguation.cpp index 45d4f0a..2a090cc 100644 --- a/test/eif_namespace_disambiguation.cpp +++ b/test/eif_namespace_disambiguation.cpp @@ -10,11 +10,11 @@ // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) -#include #include #include #include +#include using boost::enable_if; using boost::mpl::not_; @@ -32,16 +32,16 @@ namespace B { arithmetic_object(T t) { return false; } } -int test_main(int, char*[]) +int main() { using namespace A; using namespace B; - BOOST_CHECK(arithmetic_object(1)); - BOOST_CHECK(arithmetic_object(1.0)); + BOOST_TEST(arithmetic_object(1)); + BOOST_TEST(arithmetic_object(1.0)); - BOOST_CHECK(!arithmetic_object("1")); - BOOST_CHECK(!arithmetic_object(static_cast(0))); + BOOST_TEST(!arithmetic_object("1")); + BOOST_TEST(!arithmetic_object(static_cast(0))); - return 0; + return boost::report_errors(); } diff --git a/test/eif_no_disambiguation.cpp b/test/eif_no_disambiguation.cpp index e2416ed..d2ecbd9 100644 --- a/test/eif_no_disambiguation.cpp +++ b/test/eif_no_disambiguation.cpp @@ -10,11 +10,11 @@ // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) -#include #include #include #include +#include using boost::mpl::not_; using boost::enable_if; @@ -29,15 +29,15 @@ typename enable_if >, bool>::type arithmetic_object(T t) { return false; } -int test_main(int, char*[]) +int main() { - BOOST_CHECK(arithmetic_object(1)); - BOOST_CHECK(arithmetic_object(1.0)); + BOOST_TEST(arithmetic_object(1)); + BOOST_TEST(arithmetic_object(1.0)); - BOOST_CHECK(!arithmetic_object("1")); - BOOST_CHECK(!arithmetic_object(static_cast(0))); + BOOST_TEST(!arithmetic_object("1")); + BOOST_TEST(!arithmetic_object(static_cast(0))); - return 0; + return boost::report_errors(); } diff --git a/test/eif_partial_specializations.cpp b/test/eif_partial_specializations.cpp index 1d4db99..a023f53 100644 --- a/test/eif_partial_specializations.cpp +++ b/test/eif_partial_specializations.cpp @@ -10,10 +10,9 @@ // Jeremiah Willcock (jewillco at osl.iu.edu) // Andrew Lumsdaine (lums at osl.iu.edu) -#include - #include #include +#include using boost::enable_if_c; using boost::disable_if_c; @@ -47,21 +46,21 @@ struct tester2 >::type> { BOOST_STATIC_CONSTANT(bool, value = false); }; -int test_main(int, char*[]) +int main() { - BOOST_CHECK(tester::value); - BOOST_CHECK(tester::value); + BOOST_TEST(tester::value); + BOOST_TEST(tester::value); - BOOST_CHECK(!tester::value); - BOOST_CHECK(!tester::value); + BOOST_TEST(!tester::value); + BOOST_TEST(!tester::value); - BOOST_CHECK(tester2::value); - BOOST_CHECK(tester2::value); + BOOST_TEST(tester2::value); + BOOST_TEST(tester2::value); - BOOST_CHECK(!tester2::value); - BOOST_CHECK(!tester2::value); + BOOST_TEST(!tester2::value); + BOOST_TEST(!tester2::value); - return 0; + return boost::report_errors(); }
    - boost.png (6897 bytes) + boost.png (6897 bytes) +

    checked_delete.hpp