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,52 +11,80 @@
namespace boost namespace boost
{ {
template <class Model> namespace concept_checking
struct concept_check
{ {
virtual void failed(Model* x) template <class Model>
{ struct concept_check_
x->~Model(); {
} virtual void failed(Model* x)
{
int test; x->~Model();
}; }
};
}
# ifdef BOOST_OLD_CONCEPT_SUPPORT # ifdef BOOST_OLD_CONCEPT_SUPPORT
template <class Model> namespace concept_checking
struct constraint_check
{ {
virtual void failed(Model* x) template <class Model>
{ struct constraint_check
x->constraints(); {
} virtual void failed(Model* x)
{
x->constraints();
}
};
}
template <class Model>
struct concept_check
: mpl::if_c<
concept_checking::has_constraints<Model>::value
, concept_checking::constraint_check<Model>
, concept_checking::concept_check_<Model>
>::type
{};
int test; # else
};
template <class Model> template <class Model>
typename mpl::if_c< struct concept_check
concept_checking::has_constraints<Model>::value : concept_checking::concept_check_<Model>
, constraint_check<Model> {};
, concept_check<Model>
>::type concept_check_(void(*)(Model)); # endif
# if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
//
// 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 ) \
enum { BOOST_PP_CAT(boost_concept_check,__LINE__) = \
sizeof(::boost::concept_check<void(*) ModelInParens>) \
}
# else # else
template <class Model> template <class Model>
concept_check<Model> concept_check_(void(*)(Model)); concept_check<Model>
concept_check_(void(*)(Model));
# endif # define BOOST_CONCEPT_ASSERT( ModelInParens ) \
// Usage, in class or function context:
//
// BOOST_CONCEPT_ASSERT((UnaryFunctionConcept<F,bool,int>));
# 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)0)) \
} }
# endif
} }
#endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP #endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP

View File

@@ -11,52 +11,80 @@
namespace boost namespace boost
{ {
template <class Model> namespace concept_checking
struct concept_check
{ {
virtual void failed(Model* x) template <class Model>
{ struct concept_check_
x->~Model(); {
} virtual void failed(Model* x)
{
int test; x->~Model();
}; }
};
}
# ifdef BOOST_OLD_CONCEPT_SUPPORT # ifdef BOOST_OLD_CONCEPT_SUPPORT
template <class Model> namespace concept_checking
struct constraint_check
{ {
virtual void failed(Model* x) template <class Model>
{ struct constraint_check
x->constraints(); {
} virtual void failed(Model* x)
{
x->constraints();
}
};
}
template <class Model>
struct concept_check
: mpl::if_c<
concept_checking::has_constraints<Model>::value
, concept_checking::constraint_check<Model>
, concept_checking::concept_check_<Model>
>::type
{};
int test; # else
};
template <class Model> template <class Model>
typename mpl::if_c< struct concept_check
concept_checking::has_constraints<Model>::value : concept_checking::concept_check_<Model>
, constraint_check<Model> {};
, concept_check<Model>
>::type concept_check_(void(*)(Model)); # endif
# if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
//
// 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 ) \
enum { BOOST_PP_CAT(boost_concept_check,__LINE__) = \
sizeof(::boost::concept_check<void(*) ModelInParens>) \
}
# else # else
template <class Model> template <class Model>
concept_check<Model> concept_check_(void(*)(Model)); concept_check<Model>
concept_check_(void(*)(Model));
# endif # define BOOST_CONCEPT_ASSERT( ModelInParens ) \
// Usage, in class or function context:
//
// BOOST_CONCEPT_ASSERT((UnaryFunctionConcept<F,bool,int>));
# 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)0)) \
} }
# endif
} }
#endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP #endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP