Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72990 - in trunk: boost/detail libs/detail/test libs/detail/test/container_fwd
From: dnljms_at_[hidden]
Date: 2011-07-09 13:13:41


Author: danieljames
Date: 2011-07-09 13:13:39 EDT (Sat, 09 Jul 2011)
New Revision: 72990
URL: http://svn.boost.org/trac/boost/changeset/72990

Log:
Detail: More pessimistic `container_fwd.hpp`

Have a separate config stage, which by default disables forward
declaration of containers. Also add a test to check that if it is
disabled correctly.

Removed forward declaration of std::pair - since it's almost always
included by `<utility>`.
Added:
   trunk/libs/detail/test/container_fwd/
   trunk/libs/detail/test/container_fwd/Jamfile (contents, props changed)
   trunk/libs/detail/test/container_fwd/container_fwd_test.cpp (contents, props changed)
      - copied, changed from r72989, /trunk/libs/detail/test/container_fwd_test.cpp
   trunk/libs/detail/test/container_fwd/container_no_fwd_test.cpp (contents, props changed)
      - copied, changed from r72989, /trunk/libs/detail/test/container_no_fwd_test.cpp
   trunk/libs/detail/test/container_fwd/correctly_disable_fail.cpp (contents, props changed)
Removed:
   trunk/libs/detail/test/container_fwd_test.cpp
   trunk/libs/detail/test/container_no_fwd_test.cpp
Text files modified:
   trunk/boost/detail/container_fwd.hpp | 89 ++++++++++++++++++++++++++++-----------
   trunk/libs/detail/test/Jamfile | 2
   2 files changed, 66 insertions(+), 25 deletions(-)

Modified: trunk/boost/detail/container_fwd.hpp
==============================================================================
--- trunk/boost/detail/container_fwd.hpp (original)
+++ trunk/boost/detail/container_fwd.hpp 2011-07-09 13:13:39 EDT (Sat, 09 Jul 2011)
@@ -1,25 +1,76 @@
 
-// Copyright 2005-2008 Daniel James.
+// Copyright 2005-2011 Daniel James.
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
+// Note: if you change this include guard, you also need to change
+// container_fwd_compile_fail.cpp
 #if !defined(BOOST_DETAIL_CONTAINER_FWD_HPP)
 #define BOOST_DETAIL_CONTAINER_FWD_HPP
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+#if defined(_MSC_VER) && (_MSC_VER >= 1020) && \
+ !defined(BOOST_DETAIL_TEST_CONFIG_ONLY)
 # pragma once
 #endif
 
 #include <boost/config.hpp>
 #include <boost/detail/workaround.hpp>
 
-#if defined(BOOST_DETAIL_NO_CONTAINER_FWD) \
- || ((defined(__GLIBCPP__) || defined(__GLIBCXX__)) \
- && (defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL))) \
- || BOOST_WORKAROUND(__BORLANDC__, > 0x551) \
- || BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x842)) \
- || (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) \
- || (defined(_LIBCPP_VERSION))
+#if !defined(BOOST_DETAIL_NO_CONTAINER_FWD)
+# if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
+ // STLport
+# define BOOST_DETAIL_NO_CONTAINER_FWD
+# elif defined(__LIBCOMO__)
+ // Comeau STL:
+# define BOOST_DETAIL_NO_CONTAINER_FWD
+# elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)
+ // Rogue Wave library:
+# define BOOST_DETAIL_NO_CONTAINER_FWD
+# elif defined(_LIBCPP_VERSION)
+ // libc++
+# define BOOST_DETAIL_NO_CONTAINER_FWD
+# elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
+ // GNU libstdc++ 3
+# if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL)
+# define BOOST_DETAIL_NO_CONTAINER_FWD
+# endif
+# elif defined(__STL_CONFIG_H)
+ // generic SGI STL
+ //
+ // Forward declaration seems to be okay, but it has a copule of odd
+ // implementations.
+# define BOOST_CONTAINER_FWD_BAD_BITSET
+# if !defined(__STL_NON_TYPE_TMPL_PARAM_BUG)
+# define BOOST_CONTAINER_FWD_BAD_DEQUE
+# endif
+# elif defined(__MSL_CPP__)
+ // MSL standard lib:
+# define BOOST_DETAIL_NO_CONTAINER_FWD
+# elif defined(__IBMCPP__)
+ // take the default VACPP std lib
+# define BOOST_DETAIL_NO_CONTAINER_FWD
+# elif defined(MSIPL_COMPILE_H)
+ // Modena C++ standard library
+# define BOOST_DETAIL_NO_CONTAINER_FWD
+# elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
+ // Dinkumware Library (this has to appear after any possible replacement
+ // libraries)
+ //
+ // Works fine.
+# else
+# define BOOST_DETAIL_NO_CONTAINER_FWD
+# endif
+#endif
+
+// BOOST_DETAIL_TEST_* macros are for testing only
+// and shouldn't be relied upon. But you can use
+// BOOST_DETAIL_NO_CONTAINER_FWD to prevent forward
+// declaration of containers.
+
+#if !defined(BOOST_DETAIL_TEST_CONFIG_ONLY)
+
+#if defined(BOOST_DETAIL_NO_CONTAINER_FWD) && \
+ !defined(BOOST_DETAIL_TEST_FORCE_CONTAINER_FWD)
 
 #include <deque>
 #include <list>
@@ -34,17 +85,6 @@
 
 #include <cstddef>
 
-#if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && \
- defined(__STL_CONFIG_H)
-
-#define BOOST_CONTAINER_FWD_BAD_BITSET
-
-#if !defined(__STL_NON_TYPE_TMPL_PARAM_BUG)
-#define BOOST_CONTAINER_FWD_BAD_DEQUE
-#endif
-
-#endif
-
 #if defined(BOOST_CONTAINER_FWD_BAD_DEQUE)
 #include <deque>
 #endif
@@ -74,11 +114,7 @@
     #else
         template <class T> class complex;
     #endif
-}
 
-// gcc 3.4 and greater
-namespace std
-{
 #if !defined(BOOST_CONTAINER_FWD_BAD_DEQUE)
     template <class T, class Allocator> class deque;
 #endif
@@ -101,6 +137,9 @@
 #pragma warning(pop)
 #endif
 
-#endif
+#endif // BOOST_DETAIL_NO_CONTAINER_FWD &&
+ // !defined(BOOST_DETAIL_TEST_FORCE_CONTAINER_FWD)
+
+#endif // BOOST_DETAIL_TEST_CONFIG_ONLY
 
 #endif

Modified: trunk/libs/detail/test/Jamfile
==============================================================================
--- trunk/libs/detail/test/Jamfile (original)
+++ trunk/libs/detail/test/Jamfile 2011-07-09 13:13:39 EDT (Sat, 09 Jul 2011)
@@ -5,6 +5,8 @@
 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 ################################################################################
 
+build-project container_fwd ;
+
 project detail/test
   : requirements
     <toolset>clang:<cxxflags>-Wno-unused

Added: trunk/libs/detail/test/container_fwd/Jamfile
==============================================================================
--- (empty file)
+++ trunk/libs/detail/test/container_fwd/Jamfile 2011-07-09 13:13:39 EDT (Sat, 09 Jul 2011)
@@ -0,0 +1,22 @@
+
+# Copyright 2011 Daniel James.
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+import testing ;
+
+project detail/test/container_fwd
+ : requirements
+ <warnings>all
+ <toolset>intel:<warnings>on
+ <toolset>gcc:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion"
+ <toolset>darwin:<cxxflags>"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion"
+ <warnings-as-errors>on
+ ;
+
+run container_fwd_test.cpp : : : release : container_fwd_release ;
+run container_fwd_test.cpp : : : debug : container_fwd_debug ;
+run container_no_fwd_test.cpp ;
+
+compile-fail correctly_disable_fail.cpp : release : correctly_disable_release ;
+compile-fail correctly_disable_fail.cpp : debug : correctly_disable_debug ;

Copied: trunk/libs/detail/test/container_fwd/container_fwd_test.cpp (from r72989, /trunk/libs/detail/test/container_fwd_test.cpp)
==============================================================================

Copied: trunk/libs/detail/test/container_fwd/container_no_fwd_test.cpp (from r72989, /trunk/libs/detail/test/container_no_fwd_test.cpp)
==============================================================================

Added: trunk/libs/detail/test/container_fwd/correctly_disable_fail.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/detail/test/container_fwd/correctly_disable_fail.cpp 2011-07-09 13:13:39 EDT (Sat, 09 Jul 2011)
@@ -0,0 +1,43 @@
+
+// Copyright 2011 Daniel James.
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// This tests if container forwarding is correctly disabled. If it isn't
+// disabled it causes a compile error (which causes the test to pass).
+// If it is disabled it tries container forwarding. If it doesn't work
+// then there will be a compile error, indicating that it is correctly
+// disabled. But if there isn't a compile error that indicates that
+// container forwarding might work.
+//
+// Since this test only tries std::vector, it might get it wrong but I didn't
+// want it to fail because of some incompatibility with a trickier class.
+
+#define BOOST_DETAIL_TEST_CONFIG_ONLY
+#include <boost/detail/container_fwd.hpp>
+
+#if !defined(BOOST_DETAIL_NO_CONTAINER_FWD)
+#error "Failing in order to pass test"
+#else
+#define BOOST_DETAIL_TEST_FORCE_CONTAINER_FWD
+
+#undef BOOST_DETAIL_CONTAINER_FWD_HPP
+#undef BOOST_DETAIL_TEST_CONFIG_ONLY
+
+#include <boost/detail/container_fwd.hpp>
+
+template <class T, class Allocator>
+void test(std::vector<T, Allocator> const&)
+{
+}
+
+#include <vector>
+
+int main ()
+{
+ std::vector<int> x;
+ test(x);
+}
+
+#endif
+

Deleted: trunk/libs/detail/test/container_fwd_test.cpp
==============================================================================
--- trunk/libs/detail/test/container_fwd_test.cpp 2011-07-09 13:13:39 EDT (Sat, 09 Jul 2011)
+++ (empty file)
@@ -1,112 +0,0 @@
-
-// Copyright 2005-2009 Daniel James.
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#include <boost/functional/detail/container_fwd.hpp>
-
-#if BOOST_WORKAROUND(__GNUC__, < 3) && \
- !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
-template <class charT, class Allocator>
-static void test(
- std::basic_string<charT, std::string_char_traits<charT>, Allocator> const&)
-{
-}
-#else
-template <class charT, class Allocator>
-static void test(
- std::basic_string<charT, std::char_traits<charT>, Allocator> const&)
-{
-}
-#endif
-
-template <class T, class Allocator>
-static void test(std::deque<T, Allocator> const&)
-{
-}
-
-template <class T, class Allocator>
-static void test(std::list<T, Allocator> const&)
-{
-}
-
-template <class T, class Allocator>
-static void test(std::vector<T, Allocator> const&)
-{
-}
-
-template <class Key, class T, class Compare, class Allocator>
-static void test(std::map<Key, T, Compare, Allocator> const&)
-{
-}
-
-template <class Key, class T, class Compare, class Allocator>
-static void test(std::multimap<Key, T, Compare, Allocator> const&)
-{
-}
-
-template <class Key, class Compare, class Allocator>
-static void test(std::set<Key, Compare, Allocator> const&)
-{
-}
-
-template <class Key, class Compare, class Allocator>
-static void test(std::multiset<Key, Compare, Allocator> const&)
-{
-}
-
-template <std::size_t N>
-static void test(std::bitset<N> const&)
-{
-}
-
-template <class T>
-static void test(std::complex<T> const&)
-{
-}
-
-template <class X, class Y>
-static void test(std::pair<X, Y> const&)
-{
-}
-
-#include <deque>
-#include <list>
-#include <vector>
-#include <map>
-#include <set>
-#include <bitset>
-#include <string>
-#include <complex>
-#include <utility>
-
-int main()
-{
- std::deque<int> x1;
- std::list<std::string> x2;
- std::vector<float> x3;
- std::vector<bool> x4;
- std::map<int, int> x5;
- std::multimap<float, int*> x6;
- std::set<std::string> x7;
- std::multiset<std::vector<int> > x8;
- std::bitset<10> x9;
- std::string x10;
- std::complex<double> x11;
- std::pair<std::list<int>, char***> x12;
-
- test(x1);
- test(x2);
- test(x3);
- test(x4);
- test(x5);
- test(x6);
- test(x7);
- test(x8);
- test(x9);
- test(x10);
- test(x11);
- test(x12);
-
- return 0;
-}

Deleted: trunk/libs/detail/test/container_no_fwd_test.cpp
==============================================================================
--- trunk/libs/detail/test/container_no_fwd_test.cpp 2011-07-09 13:13:39 EDT (Sat, 09 Jul 2011)
+++ (empty file)
@@ -1,14 +0,0 @@
-
-// Copyright 2010 Daniel James.
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#define BOOST_DETAIL_NO_CONTAINER_FWD
-
-#include <boost/detail/container_fwd.hpp>
-
-int main()
-{
- std::set<int> x;
- std::vector<std::string> y;
-}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk