From af629ffa59094048c335609f285afe342fd1f1e4 Mon Sep 17 00:00:00 2001 From: K-ballo Date: Mon, 9 Jun 2014 19:41:23 -0300 Subject: [PATCH 01/31] Added ref folding creation overloads --- include/boost/core/ref.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/boost/core/ref.hpp b/include/boost/core/ref.hpp index 2fd4dc8..8a1acc5 100644 --- a/include/boost/core/ref.hpp +++ b/include/boost/core/ref.hpp @@ -20,6 +20,7 @@ // // Copyright (C) 2014 Glen Joseph Fernandes // glenfe at live dot com +// Copyright (C) 2014 Agustin Berge // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -112,6 +113,15 @@ template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST ref( T return reference_wrapper(t); } +/** + @return `ref(t.get())` + @remark Does not throw. +*/ +template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST ref( reference_wrapper t ) +{ + return reference_wrapper(t.get()); +} + // cref /** @@ -123,6 +133,15 @@ template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST c return reference_wrapper(t); } +/** + @return `cref(t.get())` + @remark Does not throw. +*/ +template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST cref( reference_wrapper t ) +{ + return reference_wrapper(t.get()); +} + # undef BOOST_REF_CONST // is_reference_wrapper From 45f7564db29a3bafa5dfd8c41396843493d1378a Mon Sep 17 00:00:00 2001 From: K-ballo Date: Mon, 9 Jun 2014 19:50:22 -0300 Subject: [PATCH 02/31] Disable binding ref to temporaries when rvalue references are supported --- include/boost/core/ref.hpp | 36 ++++++++++++++++++++++++++++++++++++ test/Jamfile.v2 | 3 +++ test/ref_rv_fail1.cpp | 21 +++++++++++++++++++++ test/ref_rv_fail2.cpp | 15 +++++++++++++++ test/ref_rv_fail3.cpp | 25 +++++++++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100644 test/ref_rv_fail1.cpp create mode 100644 test/ref_rv_fail2.cpp create mode 100644 test/ref_rv_fail3.cpp diff --git a/include/boost/core/ref.hpp b/include/boost/core/ref.hpp index 8a1acc5..c8e7c6a 100644 --- a/include/boost/core/ref.hpp +++ b/include/boost/core/ref.hpp @@ -66,6 +66,14 @@ public: */ BOOST_FORCEINLINE explicit reference_wrapper(T& t): t_(boost::addressof(t)) {} +# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + /** + @remark Construction from a temporary object is disabled. + */ + BOOST_DELETED_FUNCTION(reference_wrapper(T&& t)) +public: +# endif + /** @return The stored reference. @remark Does not throw. @@ -144,6 +152,34 @@ template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST c # undef BOOST_REF_CONST +# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + +/** + @cond +*/ +# if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) +# define BOOST_REF_DELETE +# else +# define BOOST_REF_DELETE = delete +# endif +/** + @endcond +*/ + +/** + @remark Construction from a temporary object is disabled. +*/ +template void ref(T const&& t) BOOST_REF_DELETE; + +/** + @remark Construction from a temporary object is disabled. +*/ +template void cref(T const&& t) BOOST_REF_DELETE; + +# undef BOOST_REF_DELETE + +# endif + // is_reference_wrapper /** diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index e44688e..f98ca08 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -19,6 +19,9 @@ compile-fail checked_delete_fail2.cpp ; compile ref_ct_test.cpp ; run ref_test.cpp ; +compile-fail ref_rv_fail1.cpp ; +compile-fail ref_rv_fail2.cpp ; +compile-fail ref_rv_fail3.cpp ; run eif_constructors.cpp ; run eif_dummy_arg_disambiguation.cpp ; diff --git a/test/ref_rv_fail1.cpp b/test/ref_rv_fail1.cpp new file mode 100644 index 0000000..6e6f706 --- /dev/null +++ b/test/ref_rv_fail1.cpp @@ -0,0 +1,21 @@ +// Copyright 2002-2004 David Abrahams and Aleksey Gurtovoy +// Copyright 2014 Agustin Berge +// +// 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 + +# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + +int main() +{ + boost::reference_wrapper r(1); // this should produce an ERROR + + return 0; +} + +# else +# error To fail, this test requires rvalue references +# endif diff --git a/test/ref_rv_fail2.cpp b/test/ref_rv_fail2.cpp new file mode 100644 index 0000000..1ca8222 --- /dev/null +++ b/test/ref_rv_fail2.cpp @@ -0,0 +1,15 @@ +// Copyright 2002-2004 David Abrahams and Aleksey Gurtovoy +// Copyright 2014 Agustin Berge +// +// 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 + +int main() +{ + boost::reference_wrapper r = boost::ref(2); // this should produce an ERROR + + return 0; +} diff --git a/test/ref_rv_fail3.cpp b/test/ref_rv_fail3.cpp new file mode 100644 index 0000000..d93cb4e --- /dev/null +++ b/test/ref_rv_fail3.cpp @@ -0,0 +1,25 @@ +// Copyright 2002-2004 David Abrahams and Aleksey Gurtovoy +// Copyright 2014 Agustin Berge +// +// 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 + +# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + +struct X {}; + +X const crv() { return X(); } + +int main() +{ + boost::reference_wrapper r = boost::ref(crv()); // this should produce an ERROR + + return 0; +} + +# else +# error To fail, this test requires rvalue references +# endif From a0f547512613f27507bfa531447358b15d2ce735 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 03:14:33 +0300 Subject: [PATCH 03/31] Copyright and cosmetic fixes. --- test/ref_rv_fail1.cpp | 13 +++++-------- test/ref_rv_fail2.cpp | 5 +---- test/ref_rv_fail3.cpp | 13 +++++-------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/test/ref_rv_fail1.cpp b/test/ref_rv_fail1.cpp index 6e6f706..9924626 100644 --- a/test/ref_rv_fail1.cpp +++ b/test/ref_rv_fail1.cpp @@ -1,4 +1,3 @@ -// Copyright 2002-2004 David Abrahams and Aleksey Gurtovoy // Copyright 2014 Agustin Berge // // Distributed under the Boost Software License, Version 1.0. (See @@ -7,15 +6,13 @@ #include -# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) int main() { - boost::reference_wrapper r(1); // this should produce an ERROR - - return 0; + boost::reference_wrapper r(1); // this should produce an ERROR } -# else -# error To fail, this test requires rvalue references -# endif +#else +# error To fail, this test requires rvalue references +#endif diff --git a/test/ref_rv_fail2.cpp b/test/ref_rv_fail2.cpp index 1ca8222..2893c21 100644 --- a/test/ref_rv_fail2.cpp +++ b/test/ref_rv_fail2.cpp @@ -1,4 +1,3 @@ -// Copyright 2002-2004 David Abrahams and Aleksey Gurtovoy // Copyright 2014 Agustin Berge // // Distributed under the Boost Software License, Version 1.0. (See @@ -9,7 +8,5 @@ int main() { - boost::reference_wrapper r = boost::ref(2); // this should produce an ERROR - - return 0; + boost::reference_wrapper r = boost::ref(2); // this should produce an ERROR } diff --git a/test/ref_rv_fail3.cpp b/test/ref_rv_fail3.cpp index d93cb4e..f6f64e8 100644 --- a/test/ref_rv_fail3.cpp +++ b/test/ref_rv_fail3.cpp @@ -1,4 +1,3 @@ -// Copyright 2002-2004 David Abrahams and Aleksey Gurtovoy // Copyright 2014 Agustin Berge // // Distributed under the Boost Software License, Version 1.0. (See @@ -7,7 +6,7 @@ #include -# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) struct X {}; @@ -15,11 +14,9 @@ X const crv() { return X(); } int main() { - boost::reference_wrapper r = boost::ref(crv()); // this should produce an ERROR - - return 0; + boost::reference_wrapper r = boost::ref(crv()); // this should produce an ERROR } -# else -# error To fail, this test requires rvalue references -# endif +#else +# error To fail, this test requires rvalue references +#endif From c48adcc3ea993bd7326f4c0d441da5c84143677b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 03:21:22 +0300 Subject: [PATCH 04/31] Added negative tests for rvalue to reference_wrapper implicit conversion. --- test/Jamfile.v2 | 2 ++ test/ref_implicit_fail.cpp | 20 ++++++++++++++++++++ test/ref_implicit_fail2.cpp | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 test/ref_implicit_fail.cpp create mode 100644 test/ref_implicit_fail2.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f98ca08..f34efe4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -22,6 +22,8 @@ run ref_test.cpp ; compile-fail ref_rv_fail1.cpp ; compile-fail ref_rv_fail2.cpp ; compile-fail ref_rv_fail3.cpp ; +compile-fail ref_implicit_fail.cpp ; +compile-fail ref_implicit_fail2.cpp ; run eif_constructors.cpp ; run eif_dummy_arg_disambiguation.cpp ; diff --git a/test/ref_implicit_fail.cpp b/test/ref_implicit_fail.cpp new file mode 100644 index 0000000..a012f52 --- /dev/null +++ b/test/ref_implicit_fail.cpp @@ -0,0 +1,20 @@ +// +// Rvalues should not implicitly convert to a reference_wrapper +// +// Copyright 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 +// + +#include + +void f( boost::reference_wrapper< int > ) +{ +} + +int main() +{ + f( 1 ); // should fail +} diff --git a/test/ref_implicit_fail2.cpp b/test/ref_implicit_fail2.cpp new file mode 100644 index 0000000..ff67630 --- /dev/null +++ b/test/ref_implicit_fail2.cpp @@ -0,0 +1,20 @@ +// +// Rvalues should not implicitly convert to a reference_wrapper +// +// Copyright 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 +// + +#include + +void f( boost::reference_wrapper< int const > ) +{ +} + +int main() +{ + f( 1 ); // should fail +} From 78892a472a6d7917e0cdd8d496fe6cc1a200aced Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 03:26:09 +0300 Subject: [PATCH 05/31] More cosmetic fixes in ref tests. --- test/ref_rv_fail1.cpp | 12 ++++++++---- test/ref_rv_fail2.cpp | 12 ++++++++---- test/ref_rv_fail3.cpp | 12 ++++++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/test/ref_rv_fail1.cpp b/test/ref_rv_fail1.cpp index 9924626..a2e708d 100644 --- a/test/ref_rv_fail1.cpp +++ b/test/ref_rv_fail1.cpp @@ -1,8 +1,12 @@ +// +// Test that a reference_wrapper can't be constructed from an rvalue +// // Copyright 2014 Agustin Berge // -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +// #include @@ -10,7 +14,7 @@ int main() { - boost::reference_wrapper r(1); // this should produce an ERROR + boost::reference_wrapper r( 1 ); // this should produce an ERROR } #else diff --git a/test/ref_rv_fail2.cpp b/test/ref_rv_fail2.cpp index 2893c21..7258411 100644 --- a/test/ref_rv_fail2.cpp +++ b/test/ref_rv_fail2.cpp @@ -1,12 +1,16 @@ +// +// Test that an rvalue can't be passed to ref() +// // Copyright 2014 Agustin Berge // -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +// #include int main() { - boost::reference_wrapper r = boost::ref(2); // this should produce an ERROR + boost::reference_wrapper r = boost::ref( 2 ); // this should produce an ERROR } diff --git a/test/ref_rv_fail3.cpp b/test/ref_rv_fail3.cpp index f6f64e8..fff6508 100644 --- a/test/ref_rv_fail3.cpp +++ b/test/ref_rv_fail3.cpp @@ -1,8 +1,12 @@ +// +// Test that a const rvalue can't be passed to ref() +// // Copyright 2014 Agustin Berge // -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +// #include @@ -14,7 +18,7 @@ X const crv() { return X(); } int main() { - boost::reference_wrapper r = boost::ref(crv()); // this should produce an ERROR + boost::reference_wrapper r = boost::ref( crv() ); // this should produce an ERROR } #else From 2fbec91fe86ce6733d4ff7ca2039fb7b236ae5ab Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 03:31:28 +0300 Subject: [PATCH 06/31] Add negative tests for cref() and rvalues. --- test/Jamfile.v2 | 2 ++ test/ref_rv_fail4.cpp | 23 +++++++++++++++++++++++ test/ref_rv_fail5.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 test/ref_rv_fail4.cpp create mode 100644 test/ref_rv_fail5.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f34efe4..d88d6cb 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -22,6 +22,8 @@ run ref_test.cpp ; compile-fail ref_rv_fail1.cpp ; compile-fail ref_rv_fail2.cpp ; compile-fail ref_rv_fail3.cpp ; +compile-fail ref_rv_fail4.cpp ; +compile-fail ref_rv_fail5.cpp ; compile-fail ref_implicit_fail.cpp ; compile-fail ref_implicit_fail2.cpp ; diff --git a/test/ref_rv_fail4.cpp b/test/ref_rv_fail4.cpp new file mode 100644 index 0000000..7f49123 --- /dev/null +++ b/test/ref_rv_fail4.cpp @@ -0,0 +1,23 @@ +// +// Test that an rvalue can't be passed to cref() +// +// Copyright 2014 Agustin Berge +// Copyright 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 +// + +#include + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + +int main() +{ + boost::reference_wrapper r = boost::cref( 2 ); // should fail +} + +#else +# error To fail, this test requires rvalue references. +#endif diff --git a/test/ref_rv_fail5.cpp b/test/ref_rv_fail5.cpp new file mode 100644 index 0000000..84bc467 --- /dev/null +++ b/test/ref_rv_fail5.cpp @@ -0,0 +1,27 @@ +// +// Test that a const rvalue can't be passed to cref() +// +// Copyright 2014 Agustin Berge +// Copyright 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 +// + +#include + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + +struct X {}; + +X const crv() { return X(); } + +int main() +{ + boost::reference_wrapper r = boost::cref( crv() ); // must fail +} + +#else +# error To fail, this test requires rvalue references. +#endif From 4b0bca5ec2b9330bbb1d604cae29b7d54a7abe8b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 03:37:21 +0300 Subject: [PATCH 07/31] Add a test for ref(ref(x)). --- test/Jamfile.v2 | 1 + test/ref_ref_test.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/ref_ref_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d88d6cb..ebd3bd9 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -19,6 +19,7 @@ compile-fail checked_delete_fail2.cpp ; compile ref_ct_test.cpp ; run ref_test.cpp ; +run ref_ref_test.cpp ; compile-fail ref_rv_fail1.cpp ; compile-fail ref_rv_fail2.cpp ; compile-fail ref_rv_fail3.cpp ; diff --git a/test/ref_ref_test.cpp b/test/ref_ref_test.cpp new file mode 100644 index 0000000..202c01c --- /dev/null +++ b/test/ref_ref_test.cpp @@ -0,0 +1,37 @@ +// +// Test for ref(ref(x)) +// +// Copyright 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 +// + +#include +#include + +int main() +{ + int x = 0; + + { + boost::reference_wrapper< int > r = boost::ref( boost::ref( x ) ); + BOOST_TEST_EQ( &r.get(), &x ); + } + + { + boost::reference_wrapper< int const > r = boost::ref( boost::cref( x ) ); + BOOST_TEST_EQ( &r.get(), &x ); + } + + { + boost::reference_wrapper< int const > r = boost::cref( boost::ref( x ) ); + BOOST_TEST_EQ( &r.get(), &x ); + } + + { + boost::reference_wrapper< int const > r = boost::cref( boost::cref( x ) ); + BOOST_TEST_EQ( &r.get(), &x ); + } +} From b6b214731147cc3b1c3db2dd3016c3d5d05408e8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 03:41:03 +0300 Subject: [PATCH 08/31] Switch ref_ct_test to core::is_same. --- test/ref_ct_test.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/ref_ct_test.cpp b/test/ref_ct_test.cpp index 34a79d2..731d62d 100644 --- a/test/ref_ct_test.cpp +++ b/test/ref_ct_test.cpp @@ -7,7 +7,7 @@ // see 'ref_test.cpp' for run-time part #include -#include +#include #include #include @@ -17,8 +17,8 @@ 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)); + BOOST_STATIC_ASSERT((boost::core::is_same::value)); + BOOST_STATIC_ASSERT((boost::core::is_same::value)); } template< typename T > @@ -36,14 +36,14 @@ void is_reference_wrapper_test(T) template< typename R, typename Ref > void cxx_reference_test(Ref) { - BOOST_STATIC_ASSERT((boost::is_same::value)); + BOOST_STATIC_ASSERT((boost::core::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)); + BOOST_STATIC_ASSERT((boost::core::is_same::value)); } } // namespace From c5dd995eadd9638b2a7657ff1b1dc984b771a24d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 04:40:21 +0300 Subject: [PATCH 09/31] Add boost::report_errors to ref_ref_test. --- test/ref_ref_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/ref_ref_test.cpp b/test/ref_ref_test.cpp index 202c01c..b667a7f 100644 --- a/test/ref_ref_test.cpp +++ b/test/ref_ref_test.cpp @@ -34,4 +34,6 @@ int main() boost::reference_wrapper< int const > r = boost::cref( boost::cref( x ) ); BOOST_TEST_EQ( &r.get(), &x ); } + + return boost::report_errors(); } From f659e1164a07b42393da9c404b8047947a5a154a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 04:40:57 +0300 Subject: [PATCH 10/31] Add report_errors_remind to some passing tests. --- include/boost/core/lightweight_test.hpp | 2 ++ include/boost/core/lightweight_test_trait.hpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 2cd02e7..f5943b3 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -90,6 +90,7 @@ template inline void test_eq_impl( char const * expr1, char co { if( t == u ) { + report_errors_remind(); } else { @@ -106,6 +107,7 @@ template inline void test_ne_impl( char const * expr1, char co { if( t != u ) { + report_errors_remind(); } else { diff --git a/include/boost/core/lightweight_test_trait.hpp b/include/boost/core/lightweight_test_trait.hpp index ff03e37..0e2aab4 100644 --- a/include/boost/core/lightweight_test_trait.hpp +++ b/include/boost/core/lightweight_test_trait.hpp @@ -31,6 +31,7 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T { if( T::value == expected ) { + report_errors_remind(); } else { @@ -41,7 +42,7 @@ template< class T > inline void test_trait_impl( char const * trait, void (*)( T << "' (should have been " << ( expected? "true": "false" ) << ")" << std::endl; - ++boost::detail::test_errors(); + ++test_errors(); } } From d0f895f0bb36bed1949a83828883e52ad689ca7d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 04:51:38 +0300 Subject: [PATCH 11/31] Copy ref_fn_test from libs/bind. --- test/Jamfile.v2 | 1 + test/ref_fn_test.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 test/ref_fn_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ebd3bd9..b698f29 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -20,6 +20,7 @@ compile-fail checked_delete_fail2.cpp ; compile ref_ct_test.cpp ; run ref_test.cpp ; run ref_ref_test.cpp ; +run ref_fn_test.cpp ; compile-fail ref_rv_fail1.cpp ; compile-fail ref_rv_fail2.cpp ; compile-fail ref_rv_fail3.cpp ; diff --git a/test/ref_fn_test.cpp b/test/ref_fn_test.cpp new file mode 100644 index 0000000..aec54e8 --- /dev/null +++ b/test/ref_fn_test.cpp @@ -0,0 +1,81 @@ +#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 + +// ref_fn_test.cpp: ref( f ) +// +// Copyright (c) 2008 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + +#include +#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) +{ +} + +#define BOOST_TEST_REF( f ) BOOST_TEST( &boost::ref( f ).get() == &f ) + +int main() +{ + int v = 0; + BOOST_TEST_REF( v ); + + BOOST_TEST_REF( f0 ); + BOOST_TEST_REF( f1 ); + BOOST_TEST_REF( f2 ); + BOOST_TEST_REF( f3 ); + BOOST_TEST_REF( f4 ); + BOOST_TEST_REF( f5 ); + BOOST_TEST_REF( f6 ); + BOOST_TEST_REF( f7 ); + BOOST_TEST_REF( f8 ); + BOOST_TEST_REF( f9 ); + + return boost::report_errors(); +} From 97e13914d05a52f30f84591d3f5931993fd9487b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 13:25:46 +0300 Subject: [PATCH 12/31] Minor documentation updates. --- doc/addressof.qbk | 20 ++++++ doc/checked_delete.qbk | 18 ++--- doc/ignore_unused.qbk | 17 ++++- doc/lightweight_test.qbk | 119 +++++++++++++++++++++++++++++++--- doc/no_exceptions_support.qbk | 29 ++++++++- doc/noncopyable.qbk | 33 ++++++++++ 6 files changed, 215 insertions(+), 21 deletions(-) diff --git a/doc/addressof.qbk b/doc/addressof.qbk index 99e0d45..4de845d 100644 --- a/doc/addressof.qbk +++ b/doc/addressof.qbk @@ -1,3 +1,12 @@ +[/ + Copyright 2014 Peter Dimov + + Distributed under the Boost Software License, Version 1.0. + + See accompanying file LICENSE_1_0.txt + or copy at http://boost.org/LICENSE_1_0.txt +] + [section:addressof addressof] [section Authors] @@ -18,6 +27,15 @@ address of `x`. Ordinarily, this address can be obtained by `boost::addressof` was originally contributed by Brad King based on ideas from discussion with Doug Gregor. +[section Synopsis] + +`` +namespace boost +{ + template T* addressof( T& x ); +} +`` + [endsect] [section Example] @@ -41,3 +59,5 @@ void f() { [endsect] [endsect] + +[endsect] diff --git a/doc/checked_delete.qbk b/doc/checked_delete.qbk index ffc2c95..cb00ad3 100644 --- a/doc/checked_delete.qbk +++ b/doc/checked_delete.qbk @@ -12,9 +12,9 @@ [section Overview] -The header ** defines two function -templates, *checked_delete* and *checked_array_delete*, and two -class templates, *checked_deleter* and *checked_array_deleter*. +The header `` 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 @@ -25,7 +25,7 @@ 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::~scoped_ptr*, is +destructor, such as `boost::scoped_ptr::~scoped_ptr`, is instantiated with an incomplete type. This can often lead to silent, hard to track failures. @@ -53,7 +53,7 @@ namespace boost [section template void checked_delete(T * p);] -* *Requires:* *T* must be a complete type. The expression +* *Requires:* `T` must be a complete type. The expression `delete p` must be well-formed. * *Effects:* `delete p;` @@ -65,7 +65,7 @@ namespace boost [section template void checked_array_delete(T * p);] -* *Requires:* *T* must be a complete type. The expression +* *Requires:* `T` must be a complete type. The expression `delete [] p` must be well-formed. * *Effects:* `delete [] p;` @@ -117,9 +117,9 @@ template struct checked_array_deleter [section Acknowledgements] -The function templates *checked_delete* and -*checked_array_delete* were originally part of -**, and the documentation +The function templates `checked_delete` and +`checked_array_delete` were originally part of +``, and the documentation acknowledged Beman Dawes, Dave Abrahams, Vladimir Prus, Rainer Deyke, John Maddock, and others as contributors. diff --git a/doc/ignore_unused.qbk b/doc/ignore_unused.qbk index 64adfd7..991c9a5 100644 --- a/doc/ignore_unused.qbk +++ b/doc/ignore_unused.qbk @@ -1,3 +1,12 @@ +[/ + Copyright 2014 Adam Wulkiewicz + + Distributed under the Boost Software License, Version 1.0. + + See accompanying file LICENSE_1_0.txt + or copy at http://boost.org/LICENSE_1_0.txt +] + [section:ignore_unused ignore_unused] [section Authors] @@ -15,14 +24,16 @@ can't be removed or commented out, e.g. when some blocks of the code are conditionally activated. C++11 variadic templates are used if they're supported, otherwise they're emulated with overloads. -Usage +[section Usage] `` boost::ignore_unused(v1, v2, v3); boost::ignore_unused(); `` -Example +[endsect] + +[section Example] `` int fun( int foo, int bar ) @@ -38,6 +49,8 @@ int fun( int foo, int bar ) [endsect] +[endsect] + [section Acknowledgments] `boost::ignore_unused()` was contributed by Adam Wulkiewicz. diff --git a/doc/lightweight_test.qbk b/doc/lightweight_test.qbk index 58ad45c..a840906 100644 --- a/doc/lightweight_test.qbk +++ b/doc/lightweight_test.qbk @@ -1,3 +1,14 @@ +[/ + Copyright 2010, 2011 Beman Dawes + Copyright 2013 Ion Gaztanaga + Copyright 2014 Peter Dimov + + Distributed under the Boost Software License, Version 1.0. + + See accompanying file LICENSE_1_0.txt + or copy at http://boost.org/LICENSE_1_0.txt +] + [section:lightweight_test lightweight_test] [section Authors] @@ -9,6 +20,31 @@ [section Header ] +The header `` is a +lightweight test framework. It's useful for writing +Boost regression tests for components that are dependencies +of Boost.Test. + +When using `lightweight_test.hpp`, *do not forget* to +`return boost::report_errors()` from `main`. + +[section Synopsis] + +`` +#define BOOST_TEST(expression) /*unspecified*/ +#define BOOST_ERROR(message) /*unspecified*/ +#define BOOST_TEST_EQ(expr1, expr2) /*unspecified*/ +#define BOOST_TEST_NE(expr1, expr2) /*unspecified*/ +#define BOOST_TEST_THROWS(expr, excep) /*unspecified*/ + +namespace boost +{ + int report_errors(); +} +`` + +[endsect] + [section BOOST_TEST] `` @@ -37,7 +73,7 @@ Increases error count and outputs a message containing BOOST_TEST_EQ(expr1, expr2) `` -If `expr1` != `expr2` increases the error count and outputs a +If `expr1 != expr2` increases the error count and outputs a message containing both expressions. [endsect] @@ -48,7 +84,7 @@ message containing both expressions. BOOST_TEST_NE(expr1, expr2) `` -If `expr1` == `expr2` increases the error count and outputs a +If `expr1 == expr2` increases the error count and outputs a message containing both expressions. [endsect] @@ -59,11 +95,11 @@ message containing both expressions. BOOST_TEST_THROWS(expr, excep) `` -If BOOST_NO_EXCEPTIONS is NOT defined and if `expr` does not +If `BOOST_NO_EXCEPTIONS` is *not* defined and if `expr` does not throw an exception of type `excep`, increases the error count and outputs a message containing the expression. -If BOOST_NO_EXCEPTIONS is defined, this macro expands to +If `BOOST_NO_EXCEPTIONS` is defined, this macro expands to nothing and `expr` is not evaluated. [endsect] @@ -76,19 +112,84 @@ int boost::report_errors() Return the error count from `main`. -Example: +[endsect] + +[section Example] `` #include -void sqr( int x ); // should return x * x +int sqr( int x ); // should return x * x int main() { - BOOST_TEST( sqr( 2 ) == 4 ); - BOOST_TEST_EQ( sqr(-3), 9 ); + BOOST_TEST( sqr(2) == 4 ); + BOOST_TEST_EQ( sqr(-3), 9 ); - return boost::report_errors(); + return boost::report_errors(); +} +`` + +[endsect] + +[endsect] + +[section Header ] + +The header `` defines +a couple of extra macros for testing compile-time traits that +return a boolean value. + +[section Synopsis] + +`` +#define BOOST_TEST_TRAIT_TRUE((Trait)) /*unspecified*/ +#define BOOST_TEST_TRAIT_FALSE((Trait)) /*unspecified*/ +`` + +[endsect] + +[section BOOST_TEST_TRAIT_TRUE] + +`` +BOOST_TEST_TRAIT_TRUE((Trait)) +`` + +If `Trait::value != true` increases the error count and outputs a +message containing `Trait`. Note the double set of parentheses; these +enable `Trait` to contain a comma, which is common for templates. + +[endsect] + +[section BOOST_TEST_TRAIT_FALSE] + +`` +BOOST_TEST_TRAIT_FALSE((Trait)) +`` + +If `Trait::value != false` increases the error count and outputs a +message containing `Trait`. Note the double set of parentheses. + +[endsect] + +[section Example] + +`` +#include +#include + +template struct X +{ + typedef T type; +} + +using boost::core::is_same; + +int main() +{ + BOOST_TEST_TRAIT_TRUE(( is_same::type, int> )); + + return boost::report_errors(); } `` diff --git a/doc/no_exceptions_support.qbk b/doc/no_exceptions_support.qbk index e9da12f..ecc3073 100644 --- a/doc/no_exceptions_support.qbk +++ b/doc/no_exceptions_support.qbk @@ -1,3 +1,13 @@ +[/ + Copyright 2004 Pavel Vozenilek + Copyright 2014 Peter Dimov + + Distributed under the Boost Software License, Version 1.0. + + See accompanying file LICENSE_1_0.txt + or copy at http://boost.org/LICENSE_1_0.txt +] + [section:no_exceptions_support no_exceptions_support] [section Authors] @@ -8,7 +18,22 @@ [section Header ] -Example of use: +The header `` defines +macros for use in code that needs to be portable to environments +that do not have support for C++ exceptions. + +[section Synopsis] + +`` +#define BOOST_TRY /*unspecified*/ +#define BOOST_CATCH(x) /*unspecified*/ +#define BOOST_CATCH_END /*unspecified*/ +#define BOOST_RETHROW /*unspecified*/ +`` + +[endsect] + +[section Example Use] `` void foo() { @@ -58,3 +83,5 @@ void foo() { [endsect] [endsect] + +[endsect] diff --git a/doc/noncopyable.qbk b/doc/noncopyable.qbk index d7a5d28..3ad9bf8 100644 --- a/doc/noncopyable.qbk +++ b/doc/noncopyable.qbk @@ -1,3 +1,13 @@ +[/ + Copyright 1999-2003 Beman Dawes + Copyright 2014 Peter Dimov + + Distributed under the Boost Software License, Version 1.0. + + See accompanying file LICENSE_1_0.txt + or copy at http://boost.org/LICENSE_1_0.txt +] + [section:noncopyable noncopyable] [section Authors] @@ -18,6 +28,29 @@ from it inherits these properties. `boost::noncopyable` was originally contributed by Dave Abrahams. +[section Synopsis] + +`` +namespace boost +{ + class noncopyable; +} +`` + +[endsect] + +[section Example] + +`` +#include + +class X: private boost::noncopyable +{ +}; +`` + +[endsect] + [endsect] [endsect] From 004ef17e42316d2060927900d0bc8cc779d98207 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 17:44:08 +0300 Subject: [PATCH 13/31] Update documentation. --- doc/core.qbk | 3 ++ doc/demangle.qbk | 74 +++++++++++++++++++++++++++++++++++++ doc/is_same.qbk | 69 +++++++++++++++++++++++++++++++++++ doc/lightweight_test.qbk | 7 +++- doc/typeinfo.qbk | 79 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 230 insertions(+), 2 deletions(-) create mode 100644 doc/demangle.qbk create mode 100644 doc/is_same.qbk create mode 100644 doc/typeinfo.qbk diff --git a/doc/core.qbk b/doc/core.qbk index 0c90773..a225d16 100644 --- a/doc/core.qbk +++ b/doc/core.qbk @@ -34,9 +34,11 @@ criteria for inclusion is that the utility component be: [include:core addressof.qbk] [include:core checked_delete.qbk] +[include:core demangle.qbk] [include:core enable_if.qbk] [include:core explicit_operator_bool.qbk] [include:core ignore_unused.qbk] +[include:core is_same.qbk] [include:core lightweight_test.qbk] [include:core no_exceptions_support.qbk] [include:core noncopyable.qbk] @@ -44,3 +46,4 @@ criteria for inclusion is that the utility component be: [include:core ref.qbk] [include:core scoped_enum.qbk] [include:core swap.qbk] +[include:core typeinfo.qbk] diff --git a/doc/demangle.qbk b/doc/demangle.qbk new file mode 100644 index 0000000..3971fae --- /dev/null +++ b/doc/demangle.qbk @@ -0,0 +1,74 @@ +[/ + Copyright 2014 Peter Dimov + + Distributed under the Boost Software License, Version 1.0. + + See accompanying file LICENSE_1_0.txt + or copy at http://boost.org/LICENSE_1_0.txt +] + +[section:demangle demangle] + +[section Authors] + +* Peter Dimov +* Andrey Semashev + +[endsect] + +[section Header ] + +The header `` defines the function +`boost::core::demangle`. It takes a mangled string such as +those returned by `typeid(T).name()` on certain implementations +such as `g++`, and returns its demangled, human-readable, form. + +[section Synopsis] + +`` +namespace boost +{ + +namespace core +{ + std::string demangle( char const * name ); +} + +} +`` + +[endsect] + +[section Example] + +`` +#include +#include +#include + +template struct X +{ +}; + +int main() +{ + char const * name = typeid( X ).name(); + + std::cout << name << std::endl; // prints 1XIiE + std::cout << boost::core::demangle( name ) << std::endl; // prints X +} +`` + +[endsect] + +[endsect] + +[section Acknowledgments] + +The implementation of `core::demangle` was taken from +`boost/exception/detail/type_info.hpp`, which in turn was adapted +from `boost/units/detail/utility.hpp`. + +[endsect] + +[endsect] diff --git a/doc/is_same.qbk b/doc/is_same.qbk new file mode 100644 index 0000000..a73b3e0 --- /dev/null +++ b/doc/is_same.qbk @@ -0,0 +1,69 @@ +[/ + Copyright 2014 Peter Dimov + + Distributed under the Boost Software License, Version 1.0. + + See accompanying file LICENSE_1_0.txt + or copy at http://boost.org/LICENSE_1_0.txt +] + +[section:is_same is_same] + +[section Authors] + +* Peter Dimov + +[endsect] + +[section Header ] + +The header `` defines the class template +`boost::core::is_same`. It defines a nested integral constant +`value` which is `true` when `T1` and `T2` are the same type, and +`false` when they are not. + +In tandem with `BOOST_TEST_TRAIT_TRUE` and `BOOST_TEST_TRAIT_FALSE`, +`is_same` is useful for writing tests for traits classes that have +to define specific nested types. + +[section Synopsis] + +`` +namespace boost +{ + +namespace core +{ + template struct is_same; +} + +} +`` + +[endsect] + +[section Example] + +`` +#include +#include + +template struct X +{ + typedef T& type; +}; + +using boost::core::is_same; + +int main() +{ + BOOST_TEST_TRAIT_TRUE(( is_same::type, int&> )); + return boost::report_errors(); +} +`` + +[endsect] + +[endsect] + +[endsect] diff --git a/doc/lightweight_test.qbk b/doc/lightweight_test.qbk index a840906..d41e820 100644 --- a/doc/lightweight_test.qbk +++ b/doc/lightweight_test.qbk @@ -119,7 +119,10 @@ Return the error count from `main`. `` #include -int sqr( int x ); // should return x * x +int sqr( int x ) +{ + return x * x; +} int main() { @@ -181,7 +184,7 @@ message containing `Trait`. Note the double set of parentheses. template struct X { typedef T type; -} +}; using boost::core::is_same; diff --git a/doc/typeinfo.qbk b/doc/typeinfo.qbk new file mode 100644 index 0000000..4ce3840 --- /dev/null +++ b/doc/typeinfo.qbk @@ -0,0 +1,79 @@ +[/ + Copyright 2014 Peter Dimov + + Distributed under the Boost Software License, Version 1.0. + + See accompanying file LICENSE_1_0.txt + or copy at http://boost.org/LICENSE_1_0.txt +] + +[section:typeinfo typeinfo] + +[section Authors] + +* Peter Dimov + +[endsect] + +[section Header ] + +The header `` defines a class +`boost::core::typeinfo`, which is an alias for `std::type_info` +when RTTI is enabled, and is a reasonable substitute when RTTI +is not supported. + +The macro `BOOST_CORE_TYPEID`, when applied to a type `T`, is the +equivalent of `typeid(T)` and produces a reference to a const +`typeinfo` object. + +The function `boost::core::demangled_name` takes a +`boost::core::typeinfo const & ti` and either returns `ti.name()`, +when that string doesn't need to be demangled, or +`boost::core::demangle(ti.name())`, when it does. The return type +of `boost::core::demangled_name` is `char const*` in the first case +and `std::string` in the second. + +[section Synopsis] + +`` +namespace boost +{ + +namespace core +{ + class typeinfo; + /* char const* or std::string */ demangled_name( typeinfo const & ti ); +} + +} + +#define BOOST_CORE_TYPEID(T) /*unspecified*/ +`` + +[endsect] + +[section Example] + +`` +#include +#include + +template struct X +{ +}; + +int main() +{ + typedef X T; + + boost::core::typeinfo const & ti = BOOST_CORE_TYPEID(T); + + std::cout << boost::core::demangled_name( ti ) << std::endl; +} +`` + +[endsect] + +[endsect] + +[endsect] From 0b2dea1f36800df733c3154fa5e41fa4d277ce87 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 10 Jun 2014 19:12:54 +0300 Subject: [PATCH 14/31] Documentation updates. --- doc/addressof.qbk | 4 ++-- doc/checked_delete.qbk | 4 ++-- doc/core.qbk | 38 ++++++++++++++++++++-------------- doc/demangle.qbk | 4 ++-- doc/enable_if.qbk | 4 ++-- doc/explicit_operator_bool.qbk | 8 +++---- doc/ignore_unused.qbk | 4 ++-- doc/is_same.qbk | 4 ++-- doc/lightweight_test.qbk | 4 ++-- doc/no_exceptions_support.qbk | 4 ++-- doc/noncopyable.qbk | 4 ++-- doc/null_deleter.qbk | 18 +++++++++------- doc/ref.qbk | 4 ++-- doc/scoped_enum.qbk | 2 ++ doc/swap.qbk | 4 ++-- doc/typeinfo.qbk | 4 ++-- 16 files changed, 62 insertions(+), 52 deletions(-) diff --git a/doc/addressof.qbk b/doc/addressof.qbk index 4de845d..fcd5c0c 100644 --- a/doc/addressof.qbk +++ b/doc/addressof.qbk @@ -9,13 +9,13 @@ [section:addressof addressof] -[section Authors] +[simplesect Authors] * Brad King * Douglas Gregor * Peter Dimov -[endsect] +[endsimplesect] [section Header ] diff --git a/doc/checked_delete.qbk b/doc/checked_delete.qbk index cb00ad3..ff83678 100644 --- a/doc/checked_delete.qbk +++ b/doc/checked_delete.qbk @@ -1,6 +1,6 @@ [section:checked_delete checked_delete] -[section Authors] +[simplesect Authors] * Beman Dawes * Dave Abrahams @@ -8,7 +8,7 @@ * Rainer Deyke * John Maddock -[endsect] +[endsimplesect] [section Overview] diff --git a/doc/core.qbk b/doc/core.qbk index a225d16..1f2bcf8 100644 --- a/doc/core.qbk +++ b/doc/core.qbk @@ -8,7 +8,7 @@ ] [library Boost.Core - [quickbook 1.5] + [quickbook 1.6] [id core] [copyright 2014 Peter Dimov] [copyright 2014 Glen Fernandes] @@ -20,6 +20,12 @@ ] ] +[template simplesect[title] +[block ''''''[title]'''''']] + +[template endsimplesect[] +[block '''''']] + [section Introduction] The Boost.Core library is a collection of core utilities. The @@ -32,18 +38,18 @@ criteria for inclusion is that the utility component be: [endsect] -[include:core addressof.qbk] -[include:core checked_delete.qbk] -[include:core demangle.qbk] -[include:core enable_if.qbk] -[include:core explicit_operator_bool.qbk] -[include:core ignore_unused.qbk] -[include:core is_same.qbk] -[include:core lightweight_test.qbk] -[include:core no_exceptions_support.qbk] -[include:core noncopyable.qbk] -[include:core null_deleter.qbk] -[include:core ref.qbk] -[include:core scoped_enum.qbk] -[include:core swap.qbk] -[include:core typeinfo.qbk] +[include addressof.qbk] +[include checked_delete.qbk] +[include demangle.qbk] +[include enable_if.qbk] +[include explicit_operator_bool.qbk] +[include ignore_unused.qbk] +[include is_same.qbk] +[include lightweight_test.qbk] +[include no_exceptions_support.qbk] +[include noncopyable.qbk] +[include null_deleter.qbk] +[include ref.qbk] +[include scoped_enum.qbk] +[include swap.qbk] +[include typeinfo.qbk] diff --git a/doc/demangle.qbk b/doc/demangle.qbk index 3971fae..0255bfb 100644 --- a/doc/demangle.qbk +++ b/doc/demangle.qbk @@ -9,12 +9,12 @@ [section:demangle demangle] -[section Authors] +[simplesect Authors] * Peter Dimov * Andrey Semashev -[endsect] +[endsimplesect] [section Header ] diff --git a/doc/enable_if.qbk b/doc/enable_if.qbk index 65a453f..fedafcd 100644 --- a/doc/enable_if.qbk +++ b/doc/enable_if.qbk @@ -1,12 +1,12 @@ [section:enable_if enable_if] -[section Authors] +[simplesect Authors] * Jaakko J\u00E4rvi * Jeremiah Willcock * Andrew Lumsdaine -[endsect] +[endsimplesect] [section Introduction] diff --git a/doc/explicit_operator_bool.qbk b/doc/explicit_operator_bool.qbk index 419b1ec..8abb9f1 100644 --- a/doc/explicit_operator_bool.qbk +++ b/doc/explicit_operator_bool.qbk @@ -7,13 +7,13 @@ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) /] -[/==============] -[section Authors] -[/==============] +[/=================] +[simplesect Authors] +[/=================] * Andrey Semashev -[endsect] +[endsimplesect] [/===============] [section Overview] diff --git a/doc/ignore_unused.qbk b/doc/ignore_unused.qbk index 991c9a5..e3bdc4c 100644 --- a/doc/ignore_unused.qbk +++ b/doc/ignore_unused.qbk @@ -9,11 +9,11 @@ [section:ignore_unused ignore_unused] -[section Authors] +[simplesect Authors] * Adam Wulkiewicz -[endsect] +[endsimplesect] [section Header ] diff --git a/doc/is_same.qbk b/doc/is_same.qbk index a73b3e0..657c591 100644 --- a/doc/is_same.qbk +++ b/doc/is_same.qbk @@ -9,11 +9,11 @@ [section:is_same is_same] -[section Authors] +[simplesect Authors] * Peter Dimov -[endsect] +[endsimplesect] [section Header ] diff --git a/doc/lightweight_test.qbk b/doc/lightweight_test.qbk index d41e820..7b706c3 100644 --- a/doc/lightweight_test.qbk +++ b/doc/lightweight_test.qbk @@ -11,12 +11,12 @@ [section:lightweight_test lightweight_test] -[section Authors] +[simplesect Authors] * Peter Dimov * Beman Dawes -[endsect] +[endsimplesect] [section Header ] diff --git a/doc/no_exceptions_support.qbk b/doc/no_exceptions_support.qbk index ecc3073..c5eb0fe 100644 --- a/doc/no_exceptions_support.qbk +++ b/doc/no_exceptions_support.qbk @@ -10,11 +10,11 @@ [section:no_exceptions_support no_exceptions_support] -[section Authors] +[simplesect Authors] * Pavel Vozenilek -[endsect] +[endsimplesect] [section Header ] diff --git a/doc/noncopyable.qbk b/doc/noncopyable.qbk index 3ad9bf8..511f0ef 100644 --- a/doc/noncopyable.qbk +++ b/doc/noncopyable.qbk @@ -10,11 +10,11 @@ [section:noncopyable noncopyable] -[section Authors] +[simplesect Authors] * Dave Abrahams -[endsect] +[endsimplesect] [section Header ] diff --git a/doc/null_deleter.qbk b/doc/null_deleter.qbk index 068ff7e..8de7f6b 100644 --- a/doc/null_deleter.qbk +++ b/doc/null_deleter.qbk @@ -7,11 +7,11 @@ [section:null_deleter null_deleter] -[section Authors] +[simplesect Authors] * Andrey Semashev -[endsect] +[endsimplesect] [section Header ] @@ -20,12 +20,14 @@ which can be used as a deleter with smart pointers such as `unique_ptr` or `shar deleter doesn't do anything with the pointer provided upon deallocation, which makes it useful when the pointed object is deallocated elsewhere. -Example - - std::shared_ptr< std::ostream > make_stream() - { - return std::shared_ptr< std::ostream >(&std::cout, boost::null_deleter()); - } +[section Example] +`` +std::shared_ptr< std::ostream > make_stream() +{ + return std::shared_ptr< std::ostream >(&std::cout, boost::null_deleter()); +} +`` +[endsect] [endsect] diff --git a/doc/ref.qbk b/doc/ref.qbk index daf9574..54ddf00 100644 --- a/doc/ref.qbk +++ b/doc/ref.qbk @@ -1,6 +1,6 @@ [section:ref ref] -[section Authors] +[simplesect Authors] * Jaakko J\u00E4rvi * Peter Dimov @@ -9,7 +9,7 @@ * Frank Mori Hess * Ronald Garcia -[endsect] +[endsimplesect] [section Introduction] diff --git a/doc/scoped_enum.qbk b/doc/scoped_enum.qbk index ff62aad..905b916 100644 --- a/doc/scoped_enum.qbk +++ b/doc/scoped_enum.qbk @@ -1,3 +1,5 @@ +[quickbook 1.5] + [section:scoped_enum scoped_enum] [section Authors] diff --git a/doc/swap.qbk b/doc/swap.qbk index 7d07e88..bcb41b2 100644 --- a/doc/swap.qbk +++ b/doc/swap.qbk @@ -1,13 +1,13 @@ [section:swap swap] -[section Authors] +[simplesect Authors] * Niels Dekker * Joseph Gauterin * Steven Watanabe * Eric Niebler -[endsect] +[endsimplesect] [section Header ] diff --git a/doc/typeinfo.qbk b/doc/typeinfo.qbk index 4ce3840..304110e 100644 --- a/doc/typeinfo.qbk +++ b/doc/typeinfo.qbk @@ -9,11 +9,11 @@ [section:typeinfo typeinfo] -[section Authors] +[simplesect Authors] * Peter Dimov -[endsect] +[endsimplesect] [section Header ] From 3a10e3f5c67fe45726acbb37f7743d444e675206 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 11 Jun 2014 19:47:25 +0300 Subject: [PATCH 15/31] Work around msvc-10.0 ref_fn_test failure. --- include/boost/core/ref.hpp | 52 ++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/include/boost/core/ref.hpp b/include/boost/core/ref.hpp index c8e7c6a..b8b920c 100644 --- a/include/boost/core/ref.hpp +++ b/include/boost/core/ref.hpp @@ -39,6 +39,12 @@ namespace boost { +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 ) + + struct ref_workaround_tag {}; + +#endif + // reference_wrapper /** @@ -66,13 +72,19 @@ public: */ BOOST_FORCEINLINE explicit reference_wrapper(T& t): t_(boost::addressof(t)) {} -# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 ) + + BOOST_FORCEINLINE explicit reference_wrapper( T & t, ref_workaround_tag ): t_( boost::addressof( t ) ) {} + +#endif + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) /** @remark Construction from a temporary object is disabled. */ BOOST_DELETED_FUNCTION(reference_wrapper(T&& t)) public: -# endif +#endif /** @return The stored reference. @@ -103,11 +115,11 @@ private: /** @cond */ -# if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) ) +#if defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) ) # define BOOST_REF_CONST -# else +#else # define BOOST_REF_CONST const -# endif +#endif /** @endcond */ @@ -118,7 +130,15 @@ private: */ template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST ref( T & t ) { - return reference_wrapper(t); +#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 ) + + return reference_wrapper( t, ref_workaround_tag() ); + +#else + + return reference_wrapper( t ); + +#endif } /** @@ -127,7 +147,7 @@ template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST ref( T */ template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST ref( reference_wrapper t ) { - return reference_wrapper(t.get()); + return t; } // cref @@ -150,18 +170,18 @@ template BOOST_FORCEINLINE reference_wrapper BOOST_REF_CONST c return reference_wrapper(t.get()); } -# undef BOOST_REF_CONST +#undef BOOST_REF_CONST -# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) /** @cond */ -# if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) -# define BOOST_REF_DELETE -# else -# define BOOST_REF_DELETE = delete -# endif +#if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) +# define BOOST_REF_DELETE +#else +# define BOOST_REF_DELETE = delete +#endif /** @endcond */ @@ -176,9 +196,9 @@ template void ref(T const&& t) BOOST_REF_DELETE; */ template void cref(T const&& t) BOOST_REF_DELETE; -# undef BOOST_REF_DELETE +#undef BOOST_REF_DELETE -# endif +#endif // is_reference_wrapper From 755572b9956057f0cbf0c7d85a2e982965616819 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 00:15:52 +0400 Subject: [PATCH 16/31] Documentation tweaks. 1. Changed scoped_enum.qbk so that it's compatible with QuickBook 1.6. 2. Added Doxygen predefined macros to improve quality of the generated reference sections. --- doc/Jamfile.v2 | 18 ++++++++++++++++++ doc/scoped_enum.qbk | 27 ++++++++++++++------------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index e39b821..ee477d9 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -18,6 +18,24 @@ doxygen ref_reference EXTRACT_PRIVATE=NO HIDE_UNDOC_MEMBERS=YES MACRO_EXPANSION=YES + "PREDEFINED=BOOST_CORE_DOXYGEN \\ + BOOST_SYMBOL_VISIBLE= \\ + BOOST_FORCEINLINE=inline \\ + BOOST_STATIC_ASSERT(x)= \\ + BOOST_STATIC_ASSERT_MSG(x,y)= \\ + BOOST_STATIC_CONSTANT(x,y)=\"static constexpr x y\" \\ + BOOST_RV_REF(x)=\"x&&\" \\ + BOOST_NESTED_TEMPLATE=template \\ + BOOST_CONSTEXPR=constexpr \\ + BOOST_CONSTEXPR_OR_CONST=constexpr \\ + BOOST_NOEXCEPT=noexcept \\ + BOOST_NOEXCEPT_IF(x)=noexcept(x) \\ + BOOST_NOEXCEPT_OR_NOTHROW=noexcept \\ + BOOST_COPY_ASSIGN_REF(x)=\"x const&\" \\ + BOOST_DEFAULTED_FUNCTION(x,y)=\"x = default;\" \\ + BOOST_DELETED_FUNCTION(x)=\"x = delete;\" \\ + BOOST_EXPLICIT_OPERATOR_BOOL()=\"explicit operator bool() const;\" \\ + BOOST_REF_CONST=const" ; xml core : core.qbk ; diff --git a/doc/scoped_enum.qbk b/doc/scoped_enum.qbk index 905b916..d0931f8 100644 --- a/doc/scoped_enum.qbk +++ b/doc/scoped_enum.qbk @@ -1,14 +1,12 @@ -[quickbook 1.5] - [section:scoped_enum scoped_enum] -[section Authors] +[simplesect Authors] * Beman Dawes * Vicente J. Botet Escriba * Anthony Williams -[endsect] +[endsimplesect] [section Overview] @@ -59,12 +57,9 @@ The enumeration can be forward declared: BOOST_SCOPED_ENUM_FORWARD_DECLARE(future_errc); -There are however some limitations: +There are however some limitations. First, the emulated scoped enum is not a C++ enum, so `is_enum< future_errc >` will be `false_type`. -* The emulated scoped enum is not a C++ enum, so `is_enum< future_errc >` will be `false_type`. -* The emulated scoped enum can not be used in switch nor in template arguments. For these cases the user needs to use some helpers. - -Instead of +Second, the emulated scoped enum can not be used in switch nor in template arguments. For these cases the user needs to use some helpers. Instead of switch (ev) { @@ -78,7 +73,7 @@ use case future_errc::broken_promise: // ... -And instead of +and instead of template <> struct is_error_code_enum< future_errc > : @@ -94,13 +89,19 @@ use { }; -* Explicit conversion to the underlying type should be performed with `boost::underlying_cast` instead of `static_cast`: +Lastly, explicit conversion to the underlying type should be performed with `boost::underlying_cast` instead of `static_cast`: unsigned int val = boost::underlying_cast< unsigned int >(ev); -Sample usage: +Here is usage example: - BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(algae, char) { green, red, cyan }; BOOST_SCOPED_ENUM_DECLARE_END(algae) + BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(algae, char) + { + green, + red, + cyan + } + BOOST_SCOPED_ENUM_DECLARE_END(algae) ... algae sample( algae::red ); void foo( algae color ); From a8974bcbda6b2571694ba67c688c51ab60e85147 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 00:27:16 +0400 Subject: [PATCH 17/31] Added BOOST_GPU_ENABLED to Doxygen predefined macros. --- doc/Jamfile.v2 | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index ee477d9..1344132 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -21,6 +21,7 @@ doxygen ref_reference "PREDEFINED=BOOST_CORE_DOXYGEN \\ BOOST_SYMBOL_VISIBLE= \\ BOOST_FORCEINLINE=inline \\ + BOOST_GPU_ENABLED= \\ BOOST_STATIC_ASSERT(x)= \\ BOOST_STATIC_ASSERT_MSG(x,y)= \\ BOOST_STATIC_CONSTANT(x,y)=\"static constexpr x y\" \\ From f910872d54283a9d35590e698d72072ab0bf0528 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 02:10:10 +0400 Subject: [PATCH 18/31] Added missing copyright comments. Corrected links to the documentation on the comments. --- doc/checked_delete.qbk | 11 +++++++++++ doc/enable_if.qbk | 13 +++++++++++++ doc/explicit_operator_bool.qbk | 4 ++-- doc/ref.qbk | 12 ++++++++++++ doc/scoped_enum.qbk | 10 ++++++++++ doc/swap.qbk | 10 ++++++++++ include/boost/checked_delete.hpp | 8 ++++++++ include/boost/core/checked_delete.hpp | 2 +- include/boost/core/ref.hpp | 2 +- include/boost/detail/lightweight_test.hpp | 8 ++++++++ include/boost/detail/no_exceptions_support.hpp | 8 ++++++++ include/boost/detail/scoped_enum_emulation.hpp | 8 ++++++++ include/boost/noncopyable.hpp | 8 ++++++++ include/boost/ref.hpp | 8 ++++++++ include/boost/swap.hpp | 8 ++++++++ include/boost/utility/addressof.hpp | 8 ++++++++ include/boost/utility/enable_if.hpp | 8 ++++++++ include/boost/utility/explicit_operator_bool.hpp | 8 ++++++++ include/boost/utility/null_deleter.hpp | 9 --------- include/boost/utility/swap.hpp | 8 ++++++++ 20 files changed, 148 insertions(+), 13 deletions(-) delete mode 100644 include/boost/utility/null_deleter.hpp diff --git a/doc/checked_delete.qbk b/doc/checked_delete.qbk index ff83678..8205272 100644 --- a/doc/checked_delete.qbk +++ b/doc/checked_delete.qbk @@ -1,3 +1,14 @@ +[/ + / Copyright (c) 2002, 2003 Peter Dimov + / Copyright (c) 2003 Daniel Frey + / Copyright (c) 2003 Howard Hinnant + / Copyright (c) 2014 Glen Fernandes + / + / 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) + /] + [section:checked_delete checked_delete] [simplesect Authors] diff --git a/doc/enable_if.qbk b/doc/enable_if.qbk index fedafcd..4af43c8 100644 --- a/doc/enable_if.qbk +++ b/doc/enable_if.qbk @@ -1,3 +1,16 @@ +[/ + / Copyright 2003 (c) The Trustees of Indiana University. + / Copyright 2014 (c) Glen Fernandes + / + / 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 Jarvi (jajarvi at osl.iu.edu) + / Jeremiah Willcock (jewillco at osl.iu.edu) + / Andrew Lumsdaine (lums at osl.iu.edu) + /] + [section:enable_if enable_if] [simplesect Authors] diff --git a/doc/explicit_operator_bool.qbk b/doc/explicit_operator_bool.qbk index 8abb9f1..1c50332 100644 --- a/doc/explicit_operator_bool.qbk +++ b/doc/explicit_operator_bool.qbk @@ -1,5 +1,3 @@ -[section:explicit_operator_bool explicit_operator_bool] - [/ / Copyright (c) 2013 Andrey Semashev / @@ -7,6 +5,8 @@ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) /] +[section:explicit_operator_bool explicit_operator_bool] + [/=================] [simplesect Authors] [/=================] diff --git a/doc/ref.qbk b/doc/ref.qbk index 54ddf00..3e524ca 100644 --- a/doc/ref.qbk +++ b/doc/ref.qbk @@ -1,3 +1,15 @@ +[/ + / Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) + / Copyright (C) 2001, 2002 Peter Dimov + / Copyright (C) 2002 David Abrahams + / Copyright (C) 2014 Glen Joseph Fernandes + / Copyright (C) 2014 Agustin Berge + / + / 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) + /] + [section:ref ref] [simplesect Authors] diff --git a/doc/scoped_enum.qbk b/doc/scoped_enum.qbk index d0931f8..7c7f687 100644 --- a/doc/scoped_enum.qbk +++ b/doc/scoped_enum.qbk @@ -1,3 +1,13 @@ +[/ + / Copyright (c) 2009 Beman Dawes + / Copyright (C) 2011-2012 Vicente J. Botet Escriba + / Copyright (C) 2012 Anthony Williams + / Copyright (c) 2014 Andrey Semashev + / + / 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) + /] + [section:scoped_enum scoped_enum] [simplesect Authors] diff --git a/doc/swap.qbk b/doc/swap.qbk index bcb41b2..5c64f55 100644 --- a/doc/swap.qbk +++ b/doc/swap.qbk @@ -1,3 +1,13 @@ +[/ + / Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker + / Copyright (C) 2014 Glen Fernandes + / + / 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 + /] + [section:swap swap] [simplesect Authors] diff --git a/include/boost/checked_delete.hpp b/include/boost/checked_delete.hpp index 10716cf..fb71c78 100644 --- a/include/boost/checked_delete.hpp +++ b/include/boost/checked_delete.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Glen Fernandes + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_CHECKED_DELETE_HPP #define BOOST_CHECKED_DELETE_HPP diff --git a/include/boost/core/checked_delete.hpp b/include/boost/core/checked_delete.hpp index 48ff044..b086e03 100644 --- a/include/boost/core/checked_delete.hpp +++ b/include/boost/core/checked_delete.hpp @@ -18,7 +18,7 @@ // 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. +// See http://www.boost.org/libs/core/doc/html/core/checked_delete.html for documentation. // namespace boost diff --git a/include/boost/core/ref.hpp b/include/boost/core/ref.hpp index b8b920c..8ae1140 100644 --- a/include/boost/core/ref.hpp +++ b/include/boost/core/ref.hpp @@ -26,7 +26,7 @@ // 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. +// See http://www.boost.org/libs/core/doc/html/core/ref.html for documentation. // /** diff --git a/include/boost/detail/lightweight_test.hpp b/include/boost/detail/lightweight_test.hpp index d91d49e..9fece8a 100644 --- a/include/boost/detail/lightweight_test.hpp +++ b/include/boost/detail/lightweight_test.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Glen Fernandes + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP #define BOOST_DETAIL_LIGHTWEIGHT_TEST_HPP diff --git a/include/boost/detail/no_exceptions_support.hpp b/include/boost/detail/no_exceptions_support.hpp index 943222d..7d17454 100644 --- a/include/boost/detail/no_exceptions_support.hpp +++ b/include/boost/detail/no_exceptions_support.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Glen Fernandes + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP #define BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP diff --git a/include/boost/detail/scoped_enum_emulation.hpp b/include/boost/detail/scoped_enum_emulation.hpp index 8a81c1b..1c7bc23 100644 --- a/include/boost/detail/scoped_enum_emulation.hpp +++ b/include/boost/detail/scoped_enum_emulation.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Andrey Semashev + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_DETAIL_SCOPED_ENUM_EMULATION_HPP #define BOOST_DETAIL_SCOPED_ENUM_EMULATION_HPP diff --git a/include/boost/noncopyable.hpp b/include/boost/noncopyable.hpp index 7e96266..e998ee8 100644 --- a/include/boost/noncopyable.hpp +++ b/include/boost/noncopyable.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Glen Fernandes + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_NONCOPYABLE_HPP #define BOOST_NONCOPYABLE_HPP diff --git a/include/boost/ref.hpp b/include/boost/ref.hpp index b9b4b12..17b56ec 100644 --- a/include/boost/ref.hpp +++ b/include/boost/ref.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Glen Fernandes + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_REF_HPP #define BOOST_REF_HPP diff --git a/include/boost/swap.hpp b/include/boost/swap.hpp index e233a00..55cafa4 100644 --- a/include/boost/swap.hpp +++ b/include/boost/swap.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Glen Fernandes + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_SWAP_HPP #define BOOST_SWAP_HPP diff --git a/include/boost/utility/addressof.hpp b/include/boost/utility/addressof.hpp index 8b59faf..db4da80 100644 --- a/include/boost/utility/addressof.hpp +++ b/include/boost/utility/addressof.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Glen Fernandes + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_UTILITY_ADDRESSOF_HPP #define BOOST_UTILITY_ADDRESSOF_HPP diff --git a/include/boost/utility/enable_if.hpp b/include/boost/utility/enable_if.hpp index 0943d7d..803bfca 100644 --- a/include/boost/utility/enable_if.hpp +++ b/include/boost/utility/enable_if.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Glen Fernandes + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_UTILITY_ENABLE_IF_HPP #define BOOST_UTILITY_ENABLE_IF_HPP diff --git a/include/boost/utility/explicit_operator_bool.hpp b/include/boost/utility/explicit_operator_bool.hpp index 70937b3..9b625cd 100644 --- a/include/boost/utility/explicit_operator_bool.hpp +++ b/include/boost/utility/explicit_operator_bool.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Glen Fernandes + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_UTILITY_EXPLICIT_OPERATOR_BOOL_HPP #define BOOST_UTILITY_EXPLICIT_OPERATOR_BOOL_HPP diff --git a/include/boost/utility/null_deleter.hpp b/include/boost/utility/null_deleter.hpp deleted file mode 100644 index 496f21d..0000000 --- a/include/boost/utility/null_deleter.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef BOOST_UTILITY_NULL_DELETER_HPP -#define BOOST_UTILITY_NULL_DELETER_HPP - -// The header file at this path is deprecated; -// use boost/core/null_deleter.hpp instead. - -#include - -#endif diff --git a/include/boost/utility/swap.hpp b/include/boost/utility/swap.hpp index ca891e3..dd9ecd9 100644 --- a/include/boost/utility/swap.hpp +++ b/include/boost/utility/swap.hpp @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2014 Glen Fernandes + * + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef BOOST_UTILITY_SWAP_HPP #define BOOST_UTILITY_SWAP_HPP From 216e57693ed218e1f2b9ebb25ff8b7d024707990 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 03:22:05 +0400 Subject: [PATCH 19/31] Corrected documentation copyrights based on git history. --- doc/checked_delete.qbk | 4 +--- doc/enable_if.qbk | 10 ++++------ doc/ref.qbk | 11 ++++++----- doc/scoped_enum.qbk | 4 ++-- doc/swap.qbk | 7 ++++--- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/doc/checked_delete.qbk b/doc/checked_delete.qbk index 8205272..156eb1b 100644 --- a/doc/checked_delete.qbk +++ b/doc/checked_delete.qbk @@ -1,7 +1,5 @@ [/ - / Copyright (c) 2002, 2003 Peter Dimov - / Copyright (c) 2003 Daniel Frey - / Copyright (c) 2003 Howard Hinnant + / Copyright (c) 2002, 2003, 2005 Peter Dimov / Copyright (c) 2014 Glen Fernandes / / Distributed under the Boost Software License, Version 1.0. (See diff --git a/doc/enable_if.qbk b/doc/enable_if.qbk index 4af43c8..7a2af6c 100644 --- a/doc/enable_if.qbk +++ b/doc/enable_if.qbk @@ -1,14 +1,12 @@ [/ - / Copyright 2003 (c) The Trustees of Indiana University. - / Copyright 2014 (c) Glen Fernandes + / Copyright (c) 2003, 2004 Jaakko Jarvi + / Copyright (c) 2008 John Maddock + / Copyright (c) 2011, 2013 Jeremiah Willcock + / Copyright (c) 2014 Glen Fernandes / / 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 Jarvi (jajarvi at osl.iu.edu) - / Jeremiah Willcock (jewillco at osl.iu.edu) - / Andrew Lumsdaine (lums at osl.iu.edu) /] [section:enable_if enable_if] diff --git a/doc/ref.qbk b/doc/ref.qbk index 3e524ca..454851b 100644 --- a/doc/ref.qbk +++ b/doc/ref.qbk @@ -1,9 +1,10 @@ [/ - / Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) - / Copyright (C) 2001, 2002 Peter Dimov - / Copyright (C) 2002 David Abrahams - / Copyright (C) 2014 Glen Joseph Fernandes - / Copyright (C) 2014 Agustin Berge + / Copyright (c) 2001, 2002, 2006 Peter Dimov + / Copyright (c) 2002 David Abrahams + / Copyright (c) 2002 Aleksey Gurtovoy + / Copyright (c) 2003, 2004 Douglas Gregor + / Copyright (c) 2009 Ronald Garcia + / Copyright (c) 2014 Glen Joseph Fernandes / / Distributed under the Boost Software License, Version 1.0. (See / accompanying file LICENSE_1_0.txt or copy at diff --git a/doc/scoped_enum.qbk b/doc/scoped_enum.qbk index 7c7f687..abe2c69 100644 --- a/doc/scoped_enum.qbk +++ b/doc/scoped_enum.qbk @@ -1,7 +1,7 @@ [/ / Copyright (c) 2009 Beman Dawes - / Copyright (C) 2011-2012 Vicente J. Botet Escriba - / Copyright (C) 2012 Anthony Williams + / Copyright (c) 2011-2012 Vicente J. Botet Escriba + / Copyright (c) 2012 Anthony Williams / Copyright (c) 2014 Andrey Semashev / / Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/doc/swap.qbk b/doc/swap.qbk index 5c64f55..dc866fd 100644 --- a/doc/swap.qbk +++ b/doc/swap.qbk @@ -1,6 +1,7 @@ [/ - / Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker - / Copyright (C) 2014 Glen Fernandes + / Copyright (c) 2008 Joseph Gauterin + / Copyright (c) 2008, 2009 Niels Dekker + / Copyright (c) 2014 Glen Fernandes / / Distributed under the Boost Software License, Version 1.0. (See / accompanying file LICENSE_1_0.txt or copy at @@ -33,7 +34,7 @@ select a specialized swap function if available. If no specialized swap function is available, `std::swap` is used. [endsect] - + [section Rationale] The generic `std::swap` function requires that the elements From 6cdeec8841db20dfa6d078c6ed28b984ebcd62b1 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 19:23:36 +0400 Subject: [PATCH 20/31] Added low level tools for demangling. Requested by Boost.TypeIndex author. --- doc/demangle.qbk | 120 ++++++++++++++++++++++++-------- include/boost/core/demangle.hpp | 86 +++++++++++++++-------- test/demangle_test.cpp | 42 ++++++++++- 3 files changed, 189 insertions(+), 59 deletions(-) diff --git a/doc/demangle.qbk b/doc/demangle.qbk index 0255bfb..16bd65e 100644 --- a/doc/demangle.qbk +++ b/doc/demangle.qbk @@ -1,5 +1,6 @@ [/ Copyright 2014 Peter Dimov + Copyright 2014 Andrey Semashev Distributed under the Boost Software License, Version 1.0. @@ -18,46 +19,107 @@ [section Header ] -The header `` defines the function -`boost::core::demangle`. It takes a mangled string such as -those returned by `typeid(T).name()` on certain implementations -such as `g++`, and returns its demangled, human-readable, form. +The header `` defines several tools for undecorating +symbol names. [section Synopsis] -`` -namespace boost -{ + namespace boost + { -namespace core -{ - std::string demangle( char const * name ); -} + namespace core + { + std::string demangle( char const * name ); -} -`` + char const * demangle_alloc( char const * name ) noexcept; + void demangle_free( char const * demangled_name ) noexcept; + + class scoped_demangled_name + { + public: + explicit scoped_demangled_name( char const * name ) noexcept; + ~scoped_demangled_name() noexcept; + char const * get() const noexcept; + + scoped_demangled_name( scoped_demangled_name const& ) = delete; + scoped_demangled_name& operator= ( scoped_demangled_name const& ) = delete; + }; + } + + } [endsect] +[section Conventional interface] + +The function `boost::core::demangle` is the conventional +way to obtain demangled symbol name. It takes a mangled string such as +those returned by `typeid(T).name()` on certain implementations +such as `g++`, and returns its demangled, human-readable, form. In case if +demangling fails (e.g. if `name` cannot be interpreted as a mangled name) +the function returns `name`. + [section Example] -`` -#include -#include -#include + #include + #include + #include -template struct X -{ -}; + template struct X + { + }; -int main() -{ - char const * name = typeid( X ).name(); - - std::cout << name << std::endl; // prints 1XIiE - std::cout << boost::core::demangle( name ) << std::endl; // prints X -} -`` + int main() + { + char const * name = typeid( X ).name(); + + std::cout << name << std::endl; // prints 1XIiE + std::cout << boost::core::demangle( name ) << std::endl; // prints X + } + +[endsect] + +[endsect] + +[section Low level interface] + +In some cases more low level interface may be desirable. For example: + +* Assuming that symbol demangling may fail, the user wants to be able to handle such errors. +* The user needs to post-process the demangled name (e.g. remove common namespaces), and +allocating a temporary string with the complete demangled name is significant overhead. + +The function `boost::core::demangle_alloc` performs name demangling and returns a pointer +to a string with the demangled name, if succeeded, or `nullptr` otherwise. The returned pointer +must be passed to `boost::core::demangle_free` to reclaim resources. Note that on some platforms +the pointer returned by `boost::core::demangle_alloc` may refer to the string denoted by `name`, +so this string must be kept immutable for the whole life time of the returned pointer. + +The `boost::core::scoped_demangled_name` class is a scope guard that automates the calls to +`boost::core::demangle_alloc` (on its construction) and `boost::core::demangle_free` (on destruction). +The string with the demangled name can be obtained with its `get` method. Note that this method may +return `nullptr` if demangling failed. + +[section Example] + + #include + #include + #include + + template struct X + { + }; + + int main() + { + char const * name = typeid( X ).name(); + boost::core::scoped_demangled_name demangled( name ); + + std::cout << name << std::endl; // prints 1XIiE + std::cout << (demangled.get() ? demangled.get() : "[unknown]") << std::endl; // prints X + } + +[endsect] [endsect] @@ -67,7 +129,7 @@ int main() The implementation of `core::demangle` was taken from `boost/exception/detail/type_info.hpp`, which in turn was adapted -from `boost/units/detail/utility.hpp`. +from `boost/units/detail/utility.hpp` and `boost/log/utility/type_info_wrapper.hpp`. [endsect] diff --git a/include/boost/core/demangle.hpp b/include/boost/core/demangle.hpp index 556ebb3..67cad8a 100644 --- a/include/boost/core/demangle.hpp +++ b/include/boost/core/demangle.hpp @@ -1,15 +1,10 @@ #ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED #define BOOST_CORE_DEMANGLE_HPP_INCLUDED -// MS compatible compilers support #pragma once - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - // core::demangle // // Copyright 2014 Peter Dimov +// Copyright 2014 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -18,6 +13,10 @@ #include #include +#if defined(BOOST_HAS_PRAGMA_ONCE) +# pragma once +#endif + #if defined( __clang__ ) && defined( __has_include ) # if __has_include() # define BOOST_CORE_HAS_CXXABI_H @@ -38,34 +37,56 @@ namespace boost namespace core { +char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT; +void demangle_free( char const * name ) BOOST_NOEXCEPT; + +class scoped_demangled_name +{ +private: + char const * m_p; + +public: + explicit scoped_demangled_name( char const * name ) BOOST_NOEXCEPT : + m_p( demangle_alloc( name ) ) + { + } + + ~scoped_demangled_name() BOOST_NOEXCEPT + { + demangle_free( m_p ); + } + + char const * get() const BOOST_NOEXCEPT + { + return m_p; + } + + BOOST_DELETED_FUNCTION(scoped_demangled_name( scoped_demangled_name const& )) + BOOST_DELETED_FUNCTION(scoped_demangled_name& operator= ( scoped_demangled_name const& )) +}; + + #if defined( BOOST_CORE_HAS_CXXABI_H ) -// lifted from boost/exception/detail/type_info.hpp +inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT +{ + int status = 0; + std::size_t size = 0; + return abi::__cxa_demangle( name, NULL, &size, &status ); +} + +inline void demangle_free( char const * name ) BOOST_NOEXCEPT +{ + std::free( const_cast< char* >( name ) ); +} inline std::string demangle( char const * name ) { - struct auto_free + scoped_demangled_name demangled_name( name ); + char const * const p = demangled_name.get(); + if( p ) { - explicit auto_free( char * ptr ): p( ptr ) - { - } - - ~auto_free() - { - std::free( p ); - } - - char * p; - }; - - int status = 0; - std::size_t size = 0; - - auto_free demangled( abi::__cxa_demangle( name, NULL, &size, &status ) ); - - if( demangled.p ) - { - return demangled.p; + return p; } else { @@ -75,6 +96,15 @@ inline std::string demangle( char const * name ) #else +inline char const * demangle_alloc( char const * name ) BOOST_NOEXCEPT +{ + return name; +} + +inline void demangle_free( char const * ) BOOST_NOEXCEPT +{ +} + inline std::string demangle( char const * name ) { return name; diff --git a/test/demangle_test.cpp b/test/demangle_test.cpp index a54e743..ca12608 100644 --- a/test/demangle_test.cpp +++ b/test/demangle_test.cpp @@ -2,6 +2,7 @@ // Trivial test for core::demangle // // Copyright (c) 2014 Peter Dimov +// Copyright (c) 2014 Andrey Semashev // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at @@ -15,9 +16,46 @@ template struct Y1 { }; -int main() +void test_demangle() { typedef Y1 T; - std::cout << boost::core::demangle( typeid( T ).name() ); + std::cout << boost::core::demangle( typeid( T ).name() ) << std::endl; +} + +void test_demangle_alloc() +{ + typedef Y1 T; + const char* p = boost::core::demangle_alloc( typeid( T ).name() ); + if (p) + { + std::cout << p << std::endl; + boost::core::demangle_free(p); + } + else + { + std::cout << "[demangling failed]" << std::endl; + } +} + +void test_scoped_demangled_name() +{ + typedef Y1 T; + boost::core::scoped_demangled_name demangled_name( typeid( T ).name() ); + const char* p = demangled_name.get(); + if (p) + { + std::cout << p << std::endl; + } + else + { + std::cout << "[demangling failed]" << std::endl; + } +} + +int main() +{ + test_demangle(); + test_demangle_alloc(); + test_scoped_demangled_name(); return 0; } From 30a3834181cecb32cf58cbe2aede42fa728abe8f Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 7 Jul 2000 16:04:40 +0000 Subject: [PATCH 21/31] This commit was generated by cvs2svn to compensate for changes in r4, which included commits to RCS files with non-trunk default branches. [SVN r7621] --- noncopyable_test.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 noncopyable_test.cpp diff --git a/noncopyable_test.cpp b/noncopyable_test.cpp new file mode 100644 index 0000000..e5103fb --- /dev/null +++ b/noncopyable_test.cpp @@ -0,0 +1,38 @@ +// boost class noncopyable test program ------------------------------------// + +// (C) Copyright boost.org 1999. 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 +// 9 Jun 99 Add unnamed namespace +// 2 Jun 99 Initial Version + +#include +#include + +// This program demonstrates compiler errors resulting from trying to copy +// construct or copy assign a class object derived from class noncopyable. + +namespace +{ + class DontTreadOnMe : boost::noncopyable + { + public: + DontTreadOnMe() { std::cout << "defanged!" << std::endl; } + }; // DontTreadOnMe + +} // unnamed namespace + +int main() +{ + DontTreadOnMe object1; + DontTreadOnMe object2(object1); + object1 = object2; + return 0; +} // main + \ No newline at end of file From f82204548798fb0c8bd5c5f9f508394548462ca8 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sat, 19 Jan 2002 16:07:28 +0000 Subject: [PATCH 22/31] tabs [SVN r12360] --- noncopyable_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noncopyable_test.cpp b/noncopyable_test.cpp index e5103fb..6ff951d 100644 --- a/noncopyable_test.cpp +++ b/noncopyable_test.cpp @@ -35,4 +35,4 @@ int main() object1 = object2; return 0; } // main - \ No newline at end of file + From 963781e154cc9005cc5b73790977f3276a5d2300 Mon Sep 17 00:00:00 2001 From: Darin Adler Date: Fri, 8 Feb 2002 20:08:15 +0000 Subject: [PATCH 23/31] Always say "private noncopyable" to avoid warnings. [SVN r12762] --- noncopyable_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noncopyable_test.cpp b/noncopyable_test.cpp index 6ff951d..9986401 100644 --- a/noncopyable_test.cpp +++ b/noncopyable_test.cpp @@ -20,7 +20,7 @@ namespace { - class DontTreadOnMe : boost::noncopyable + class DontTreadOnMe : private boost::noncopyable { public: DontTreadOnMe() { std::cout << "defanged!" << std::endl; } From 600f6e43f900814dcaef9cbb8b4bda8d8f5e9128 Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Mon, 17 Feb 2003 06:20:57 +0000 Subject: [PATCH 24/31] split utility.hpp header [SVN r17472] --- noncopyable_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noncopyable_test.cpp b/noncopyable_test.cpp index 9986401..373ed5c 100644 --- a/noncopyable_test.cpp +++ b/noncopyable_test.cpp @@ -12,7 +12,7 @@ // 9 Jun 99 Add unnamed namespace // 2 Jun 99 Initial Version -#include +#include #include // This program demonstrates compiler errors resulting from trying to copy From 3e6a53891161b523fd67712f0065e5c12348b3d7 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Wed, 11 Aug 2004 10:59:33 +0000 Subject: [PATCH 25/31] Removed boost.org copyright assignments, and reverted to orginal author (as based on cvs history). [SVN r24402] --- noncopyable_test.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/noncopyable_test.cpp b/noncopyable_test.cpp index 373ed5c..d5d2994 100644 --- a/noncopyable_test.cpp +++ b/noncopyable_test.cpp @@ -1,10 +1,8 @@ // boost class noncopyable test program ------------------------------------// -// (C) Copyright boost.org 1999. 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. 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 for most recent version including documentation. From 79a9e9414b93b447f5815f199dcbf81525b8a5c5 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 19:50:47 +0400 Subject: [PATCH 26/31] The test was moved from Boost.Utility. --- test/noncopyable_test.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/noncopyable_test.cpp diff --git a/test/noncopyable_test.cpp b/test/noncopyable_test.cpp new file mode 100644 index 0000000..d5d2994 --- /dev/null +++ b/test/noncopyable_test.cpp @@ -0,0 +1,36 @@ +// boost class noncopyable test program ------------------------------------// + +// (C) Copyright Beman Dawes 1999. 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 for most recent version including documentation. + +// Revision History +// 9 Jun 99 Add unnamed namespace +// 2 Jun 99 Initial Version + +#include +#include + +// This program demonstrates compiler errors resulting from trying to copy +// construct or copy assign a class object derived from class noncopyable. + +namespace +{ + class DontTreadOnMe : private boost::noncopyable + { + public: + DontTreadOnMe() { std::cout << "defanged!" << std::endl; } + }; // DontTreadOnMe + +} // unnamed namespace + +int main() +{ + DontTreadOnMe object1; + DontTreadOnMe object2(object1); + object1 = object2; + return 0; +} // main + From 2ace824e444d3a96010c6a87334d7d575ac0aa90 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 19:53:08 +0400 Subject: [PATCH 27/31] Renamed test and added to Jamfile. --- test/Jamfile.v2 | 2 ++ test/{noncopyable_test.cpp => noncopyable_compile_fail.cpp} | 0 2 files changed, 2 insertions(+) rename test/{noncopyable_test.cpp => noncopyable_compile_fail.cpp} (100%) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index b698f29..12ea67a 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -38,6 +38,8 @@ run eif_namespace_disambiguation.cpp ; run eif_no_disambiguation.cpp ; run eif_partial_specializations.cpp ; +compile-fail ../noncopyable_compile_fail.cpp ; + run explicit_operator_bool.cpp ; run explicit_operator_bool_noexcept.cpp ; compile-fail explicit_operator_bool_compile_fail_conv_int.cpp ; diff --git a/test/noncopyable_test.cpp b/test/noncopyable_compile_fail.cpp similarity index 100% rename from test/noncopyable_test.cpp rename to test/noncopyable_compile_fail.cpp From 10a2b35c4ac96bdc4b182ddb623e7a17885c2ae6 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 20:05:59 +0400 Subject: [PATCH 28/31] Removed trailing spaces. --- test/noncopyable_compile_fail.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/noncopyable_compile_fail.cpp b/test/noncopyable_compile_fail.cpp index d5d2994..f1f0293 100644 --- a/test/noncopyable_compile_fail.cpp +++ b/test/noncopyable_compile_fail.cpp @@ -33,4 +33,4 @@ int main() object1 = object2; return 0; } // main - + From e3e304fc219dba87c772e2700a6de61c2fa33374 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 21:06:45 +0400 Subject: [PATCH 29/31] Added Rationale section from the original docs in Boost.Utility. --- doc/addressof.qbk | 3 ++- doc/noncopyable.qbk | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/addressof.qbk b/doc/addressof.qbk index fcd5c0c..8c9cb5e 100644 --- a/doc/addressof.qbk +++ b/doc/addressof.qbk @@ -22,7 +22,8 @@ The header `` defines the function template `boost::addressof`. `boost::addressof(x)` returns the address of `x`. Ordinarily, this address can be obtained by -`&x`, but the unary `&` operator can be overloaded. +`&x`, but the unary `&` operator can be overloaded. `boost::addressof` +avoids calling used-defined `operator&()`. `boost::addressof` was originally contributed by Brad King based on ideas from discussion with Doug Gregor. diff --git a/doc/noncopyable.qbk b/doc/noncopyable.qbk index 511f0ef..9e74ba0 100644 --- a/doc/noncopyable.qbk +++ b/doc/noncopyable.qbk @@ -51,6 +51,22 @@ class X: private boost::noncopyable [endsect] +[section Rationale] + +Class noncopyable has protected constructor and destructor members to emphasize +that it is to be used only as a base class. Dave Abrahams notes concern about +the effect on compiler optimization of adding (even trivial inline) destructor +declarations. He says: + +["Probably this concern is misplaced, because `noncopyable` will be used mostly +for classes which own resources and thus have non-trivial destruction semantics.] + +With C++2011, using an optimized and trivial constructor and similar destructor +can be enforced by declaring both and marking them `default`. This is done in +the current implementation. + +[endsect] + [endsect] [endsect] From 5cedbf8548d98e3b6cf8a9d6590d0e0e58d12d64 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 21:13:50 +0400 Subject: [PATCH 30/31] Removed the old test. --- noncopyable_test.cpp | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 noncopyable_test.cpp diff --git a/noncopyable_test.cpp b/noncopyable_test.cpp deleted file mode 100644 index d5d2994..0000000 --- a/noncopyable_test.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// boost class noncopyable test program ------------------------------------// - -// (C) Copyright Beman Dawes 1999. 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 for most recent version including documentation. - -// Revision History -// 9 Jun 99 Add unnamed namespace -// 2 Jun 99 Initial Version - -#include -#include - -// This program demonstrates compiler errors resulting from trying to copy -// construct or copy assign a class object derived from class noncopyable. - -namespace -{ - class DontTreadOnMe : private boost::noncopyable - { - public: - DontTreadOnMe() { std::cout << "defanged!" << std::endl; } - }; // DontTreadOnMe - -} // unnamed namespace - -int main() -{ - DontTreadOnMe object1; - DontTreadOnMe object2(object1); - object1 = object2; - return 0; -} // main - From 95ad3ede45165512959b98f8593ad26275865280 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 12 Jun 2014 21:24:49 +0400 Subject: [PATCH 31/31] Corrected the path to noncopyable_compile_fail.cpp test. --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 12ea67a..ba8a83a 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -38,7 +38,7 @@ run eif_namespace_disambiguation.cpp ; run eif_no_disambiguation.cpp ; run eif_partial_specializations.cpp ; -compile-fail ../noncopyable_compile_fail.cpp ; +compile-fail noncopyable_compile_fail.cpp ; run explicit_operator_bool.cpp ; run explicit_operator_bool_noexcept.cpp ;