diff --git a/include/boost/detail/container_fwd.hpp b/include/boost/detail/container_fwd.hpp index 1a58935..6716afd 100644 --- a/include/boost/detail/container_fwd.hpp +++ b/include/boost/detail/container_fwd.hpp @@ -1,25 +1,75 @@ -// 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 #include -#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__) + // The default VACPP std lib, forward declaration seems to be fine. +# 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 #include @@ -34,17 +84,6 @@ #include -#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 #endif @@ -74,11 +113,7 @@ namespace std #else template class complex; #endif -} -// gcc 3.4 and greater -namespace std -{ #if !defined(BOOST_CONTAINER_FWD_BAD_DEQUE) template class deque; #endif @@ -101,6 +136,9 @@ namespace std #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 diff --git a/test/Jamfile b/test/Jamfile index 9413621..59c0a8d 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -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 clang:-Wno-unused diff --git a/test/container_fwd/Jamfile b/test/container_fwd/Jamfile new file mode 100644 index 0000000..b39d447 --- /dev/null +++ b/test/container_fwd/Jamfile @@ -0,0 +1,28 @@ + +# 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 + all + intel:on + gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion" + darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion" + on + ; + +run container_no_fwd_test.cpp ; +run container_fwd_test.cpp : : : : container_fwd ; +run container_fwd_test.cpp : : + : _STLP_DEBUG _GLIBCXX_DEBUG + : container_fwd_debug ; + +compile-fail correctly_disable_fail.cpp + : off + : correctly_disable ; +compile-fail correctly_disable_fail.cpp + : off _STLP_DEBUG _GLIBCXX_DEBUG + : correctly_disable_debug ; diff --git a/test/container_fwd_test.cpp b/test/container_fwd/container_fwd_test.cpp similarity index 100% rename from test/container_fwd_test.cpp rename to test/container_fwd/container_fwd_test.cpp diff --git a/test/container_no_fwd_test.cpp b/test/container_fwd/container_no_fwd_test.cpp similarity index 100% rename from test/container_no_fwd_test.cpp rename to test/container_fwd/container_no_fwd_test.cpp diff --git a/test/container_fwd/correctly_disable_fail.cpp b/test/container_fwd/correctly_disable_fail.cpp new file mode 100644 index 0000000..2301686 --- /dev/null +++ b/test/container_fwd/correctly_disable_fail.cpp @@ -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 + +#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 + +template +void test(std::vector const&) +{ +} + +#include + +int main () +{ + std::vector x; + test(x); +} + +#endif +