Workarounds for a nasty vc-7.1 bug that only shows up in the iterator

library tests.


[SVN r33866]
This commit is contained in:
Dave Abrahams
2006-04-30 03:01:58 +00:00
parent 24326c9df5
commit 3c2a976d2a
2 changed files with 120 additions and 64 deletions

View File

@@ -11,20 +11,23 @@
namespace boost namespace boost
{
namespace concept_checking
{ {
template <class Model> template <class Model>
struct concept_check struct concept_check_
{ {
virtual void failed(Model* x) virtual void failed(Model* x)
{ {
x->~Model(); x->~Model();
} }
int test;
}; };
}
# ifdef BOOST_OLD_CONCEPT_SUPPORT # ifdef BOOST_OLD_CONCEPT_SUPPORT
namespace concept_checking
{
template <class Model> template <class Model>
struct constraint_check struct constraint_check
{ {
@@ -32,31 +35,56 @@ namespace boost
{ {
x->constraints(); x->constraints();
} }
int test;
}; };
}
template <class Model> template <class Model>
typename mpl::if_c< struct concept_check
: mpl::if_c<
concept_checking::has_constraints<Model>::value concept_checking::has_constraints<Model>::value
, constraint_check<Model> , concept_checking::constraint_check<Model>
, concept_check<Model> , concept_checking::concept_check_<Model>
>::type concept_check_(void(*)(Model)); >::type
{};
# else # else
template <class Model> template <class Model>
concept_check<Model> concept_check_(void(*)(Model)); struct concept_check
: concept_checking::concept_check_<Model>
{};
# endif # endif
// Usage, in class or function context: # if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
// //
// BOOST_CONCEPT_ASSERT((UnaryFunctionConcept<F,bool,int>)); // The iterator library sees some really strange errors unless we
// use partial specialization to extract the model type with
// msvc-7.1
//
template <class Model>
struct concept_check<void(*)(Model)>
: concept_check<Model>
{ };
# define BOOST_CONCEPT_ASSERT( ModelInParens ) \ # define BOOST_CONCEPT_ASSERT( ModelInParens ) \
enum { BOOST_PP_CAT(boost_concept_check,__LINE__) = \ enum { BOOST_PP_CAT(boost_concept_check,__LINE__) = \
sizeof(boost::concept_check_((void(*) ModelInParens)0).test) \ sizeof(::boost::concept_check<void(*) ModelInParens>) \
} }
# else
template <class Model>
concept_check<Model>
concept_check_(void(*)(Model));
# define BOOST_CONCEPT_ASSERT( ModelInParens ) \
enum { BOOST_PP_CAT(boost_concept_check,__LINE__) = \
sizeof(::boost::concept_check_((void(*) ModelInParens)0)) \
}
# endif
} }
#endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP #endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP

View File

@@ -11,20 +11,23 @@
namespace boost namespace boost
{
namespace concept_checking
{ {
template <class Model> template <class Model>
struct concept_check struct concept_check_
{ {
virtual void failed(Model* x) virtual void failed(Model* x)
{ {
x->~Model(); x->~Model();
} }
int test;
}; };
}
# ifdef BOOST_OLD_CONCEPT_SUPPORT # ifdef BOOST_OLD_CONCEPT_SUPPORT
namespace concept_checking
{
template <class Model> template <class Model>
struct constraint_check struct constraint_check
{ {
@@ -32,31 +35,56 @@ namespace boost
{ {
x->constraints(); x->constraints();
} }
int test;
}; };
}
template <class Model> template <class Model>
typename mpl::if_c< struct concept_check
: mpl::if_c<
concept_checking::has_constraints<Model>::value concept_checking::has_constraints<Model>::value
, constraint_check<Model> , concept_checking::constraint_check<Model>
, concept_check<Model> , concept_checking::concept_check_<Model>
>::type concept_check_(void(*)(Model)); >::type
{};
# else # else
template <class Model> template <class Model>
concept_check<Model> concept_check_(void(*)(Model)); struct concept_check
: concept_checking::concept_check_<Model>
{};
# endif # endif
// Usage, in class or function context: # if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
// //
// BOOST_CONCEPT_ASSERT((UnaryFunctionConcept<F,bool,int>)); // The iterator library sees some really strange errors unless we
// use partial specialization to extract the model type with
// msvc-7.1
//
template <class Model>
struct concept_check<void(*)(Model)>
: concept_check<Model>
{ };
# define BOOST_CONCEPT_ASSERT( ModelInParens ) \ # define BOOST_CONCEPT_ASSERT( ModelInParens ) \
enum { BOOST_PP_CAT(boost_concept_check,__LINE__) = \ enum { BOOST_PP_CAT(boost_concept_check,__LINE__) = \
sizeof(boost::concept_check_((void(*) ModelInParens)0).test) \ sizeof(::boost::concept_check<void(*) ModelInParens>) \
} }
# else
template <class Model>
concept_check<Model>
concept_check_(void(*)(Model));
# define BOOST_CONCEPT_ASSERT( ModelInParens ) \
enum { BOOST_PP_CAT(boost_concept_check,__LINE__) = \
sizeof(::boost::concept_check_((void(*) ModelInParens)0)) \
}
# endif
} }
#endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP #endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP