mirror of
https://github.com/boostorg/concept_check.git
synced 2025-07-29 20:17:36 +02:00
Moved library specifics out of boost/concept_check and into boost/concept.
Moved implementation details into boost/concept/detail. Improved error messages by renaming has_constraints not_satisfied. [SVN r33893]
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
// Copyright David Abrahams 2006. 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_CONCEPT_CHECK_ASSERT_DWA2006430_HPP
|
||||
# define BOOST_CONCEPT_CHECK_ASSERT_DWA2006430_HPP
|
||||
#ifndef BOOST_CONCEPT_ASSERT_DWA2006430_HPP
|
||||
# define BOOST_CONCEPT_ASSERT_DWA2006430_HPP
|
||||
|
||||
# include <boost/config.hpp>
|
||||
# include <boost/detail/workaround.hpp>
|
||||
@ -25,11 +25,11 @@
|
||||
# endif
|
||||
|
||||
# ifdef BOOST_MSVC
|
||||
# include <boost/concept_check/msvc.hpp>
|
||||
# include <boost/concept/detail/msvc.hpp>
|
||||
# elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
# include <boost/concept_check/borland.hpp>
|
||||
# include <boost/concept/detail/borland.hpp>
|
||||
# else
|
||||
# include <boost/concept_check/general.hpp>
|
||||
# include <boost/concept/detail/general.hpp>
|
||||
# endif
|
||||
|
||||
// Usage, in class or function context:
|
||||
@ -39,4 +39,4 @@
|
||||
# define BOOST_CONCEPT_ASSERT(ModelInParens) \
|
||||
BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens)
|
||||
|
||||
#endif // BOOST_CONCEPT_CHECK_ASSERT_DWA2006430_HPP
|
||||
#endif // BOOST_CONCEPT_ASSERT_DWA2006430_HPP
|
@ -1,18 +1,18 @@
|
||||
// Copyright David Abrahams 2006. 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_CONCEPT_CHECK_BORLAND_DWA2006429_HPP
|
||||
# define BOOST_CONCEPT_CHECK_BORLAND_DWA2006429_HPP
|
||||
#ifndef BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP
|
||||
# define BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP
|
||||
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace boost { namespace concept {
|
||||
|
||||
template <class ModelFnPtr>
|
||||
struct concept_check;
|
||||
struct require;
|
||||
|
||||
template <class Model>
|
||||
struct concept_check<void(*)(Model)>
|
||||
struct require<void(*)(Model)>
|
||||
{
|
||||
enum { instantiate = sizeof((((Model*)0)->~Model()), 3) };
|
||||
};
|
||||
@ -21,9 +21,9 @@ struct concept_check<void(*)(Model)>
|
||||
enum \
|
||||
{ \
|
||||
BOOST_PP_CAT(boost_concept_check,__LINE__) = \
|
||||
boost::concept_check<ModelFnPtr>::instantiate \
|
||||
boost::concept::require<ModelFnPtr>::instantiate \
|
||||
}
|
||||
|
||||
} // namespace boost::concept_checking
|
||||
}} // namespace boost::concept
|
||||
|
||||
#endif // BOOST_CONCEPT_CHECK_BORLAND_DWA2006429_HPP
|
||||
#endif // BOOST_CONCEPT_DETAIL_BORLAND_DWA2006429_HPP
|
66
include/boost/concept/detail/general.hpp
Executable file
66
include/boost/concept/detail/general.hpp
Executable file
@ -0,0 +1,66 @@
|
||||
// Copyright David Abrahams 2006. 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_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP
|
||||
# define BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP
|
||||
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
|
||||
# ifdef BOOST_OLD_CONCEPT_SUPPORT
|
||||
# include <boost/concept/detail/has_constraints.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
# endif
|
||||
|
||||
// This implementation works on Comeau and GCC, all the way back to
|
||||
// 2.95
|
||||
namespace boost { namespace concept {
|
||||
|
||||
template <class ModelFn>
|
||||
struct requirement_;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <void(*)()> struct instantiate {};
|
||||
}
|
||||
|
||||
template <class Model>
|
||||
struct requirement
|
||||
{
|
||||
static void failed() { ((Model*)0)->~Model(); }
|
||||
};
|
||||
|
||||
# ifdef BOOST_OLD_CONCEPT_SUPPORT
|
||||
|
||||
template <class Model>
|
||||
struct constraint
|
||||
{
|
||||
static void failed() { ((Model*)0)->constraints(); }
|
||||
};
|
||||
|
||||
template <class Model>
|
||||
struct requirement_<void(*)(Model)>
|
||||
: mpl::if_<
|
||||
concept::not_satisfied<Model>
|
||||
, constraint<Model>
|
||||
, requirement<Model>
|
||||
>::type
|
||||
{};
|
||||
|
||||
# else
|
||||
|
||||
// For GCC-2.x, these can't have exactly the same name
|
||||
template <class Model>
|
||||
struct requirement_<void(*)(Model)>
|
||||
: requirement<Model>
|
||||
{};
|
||||
|
||||
# endif
|
||||
|
||||
# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
|
||||
typedef ::boost::concept::detail::instantiate< \
|
||||
&::boost::concept::requirement_<ModelFnPtr>::failed> \
|
||||
BOOST_PP_CAT(boost_concept_check,__LINE__)
|
||||
|
||||
}}
|
||||
|
||||
#endif // BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP
|
40
include/boost/concept/detail/has_constraints.hpp
Executable file
40
include/boost/concept/detail/has_constraints.hpp
Executable file
@ -0,0 +1,40 @@
|
||||
// Copyright David Abrahams 2006. 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_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP
|
||||
# define BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP
|
||||
|
||||
# include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace concept {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Here we implement the metafunction that detects whether a
|
||||
// constraints metafunction exists
|
||||
typedef char yes;
|
||||
typedef char (&no)[2];
|
||||
|
||||
template <class Model, void (Model::*)()>
|
||||
struct wrap_constraints {};
|
||||
|
||||
template <class Model>
|
||||
inline yes has_constraints_(Model*, wrap_constraints<Model,&Model::constraints>* = 0);
|
||||
inline no has_constraints_(...);
|
||||
}
|
||||
|
||||
// This would be called "detail::has_constraints," but it has a strong
|
||||
// tendency to show up in error messages.
|
||||
template <class Model>
|
||||
struct not_satisfied
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool
|
||||
, value = sizeof( detail::has_constraints_((Model*)0) ) == sizeof(detail::yes) );
|
||||
typedef mpl::bool_<value> type;
|
||||
};
|
||||
|
||||
}} // namespace boost::concept::detail
|
||||
|
||||
#endif // BOOST_CONCEPT_DETAIL_HAS_CONSTRAINTS_DWA2006429_HPP
|
88
include/boost/concept/detail/msvc.hpp
Executable file
88
include/boost/concept/detail/msvc.hpp
Executable file
@ -0,0 +1,88 @@
|
||||
// Copyright David Abrahams 2006. 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_CONCEPT_CHECK_MSVC_DWA2006429_HPP
|
||||
# define BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP
|
||||
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
|
||||
# ifdef BOOST_OLD_CONCEPT_SUPPORT
|
||||
# include <boost/concept/detail/has_constraints.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
# endif
|
||||
|
||||
|
||||
namespace boost { namespace concept {
|
||||
|
||||
template <class Model>
|
||||
struct check
|
||||
{
|
||||
virtual void failed(Model* x)
|
||||
{
|
||||
x->~Model();
|
||||
}
|
||||
};
|
||||
|
||||
# ifdef BOOST_OLD_CONCEPT_SUPPORT
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// No need for a virtual function here, since evaluatiing
|
||||
// not_satisfied below will have already instantiated the
|
||||
// constraints() member.
|
||||
struct constraint {};
|
||||
}
|
||||
template <class Model>
|
||||
struct require
|
||||
: mpl::if_c<
|
||||
not_satisfied<Model>::value
|
||||
, detail::constraint
|
||||
, check<Model>
|
||||
>::type
|
||||
{};
|
||||
|
||||
# else
|
||||
|
||||
template <class Model>
|
||||
struct require
|
||||
: check<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 require<void(*)(Model)>
|
||||
: require<Model>
|
||||
{};
|
||||
|
||||
# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
|
||||
enum \
|
||||
{ \
|
||||
BOOST_PP_CAT(boost_concept_check,__LINE__) = \
|
||||
sizeof(::boost::concept::require<ModelFnPtr>) \
|
||||
}
|
||||
|
||||
# else // Not vc-7.1
|
||||
|
||||
template <class Model>
|
||||
require<Model>
|
||||
require_(void(*)(Model));
|
||||
|
||||
# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
|
||||
enum \
|
||||
{ \
|
||||
BOOST_PP_CAT(boost_concept_check,__LINE__) = \
|
||||
sizeof(::boost::concept::require_((ModelFnPtr)0)) \
|
||||
}
|
||||
|
||||
# endif
|
||||
}}
|
||||
|
||||
#endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP
|
@ -1,11 +1,11 @@
|
||||
// Copyright David Abrahams 2006. 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_CONCEPT_CHECK_WHERE_DWA2006430_HPP
|
||||
# define BOOST_CONCEPT_CHECK_WHERE_DWA2006430_HPP
|
||||
#ifndef BOOST_CONCEPT_WHERE_DWA2006430_HPP
|
||||
# define BOOST_CONCEPT_WHERE_DWA2006430_HPP
|
||||
|
||||
# include <boost/parameter/aux_/parenthesized_type.hpp>
|
||||
# include <boost/concept_check/assert.hpp>
|
||||
# include <boost/concept/assert.hpp>
|
||||
# include <boost/preprocessor/seq/for_each.hpp>
|
||||
|
||||
namespace boost {
|
||||
@ -47,4 +47,4 @@ struct where : More
|
||||
|
||||
} // namespace boost::concept_check
|
||||
|
||||
#endif // BOOST_CONCEPT_CHECK_WHERE_DWA2006430_HPP
|
||||
#endif // BOOST_CONCEPT_WHERE_DWA2006430_HPP
|
@ -15,7 +15,7 @@
|
||||
#ifndef BOOST_CONCEPT_CHECKS_HPP
|
||||
# define BOOST_CONCEPT_CHECKS_HPP
|
||||
|
||||
# include <boost/concept_check/assert.hpp>
|
||||
# include <boost/concept/assert.hpp>
|
||||
|
||||
# include <boost/iterator.hpp>
|
||||
# include <boost/type_traits/conversion_traits.hpp>
|
||||
@ -35,7 +35,7 @@ namespace boost
|
||||
//
|
||||
|
||||
template <class Model>
|
||||
inline void function_requires(BOOST_EXPLICIT_TEMPLATE_TYPE(Model))
|
||||
inline void function_requires(Model* = 0)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT((Model));
|
||||
}
|
||||
|
@ -1,66 +0,0 @@
|
||||
// Copyright David Abrahams 2006. 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_CONCEPT_CHECK_MSVC_DWA2006429_HPP
|
||||
# define BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP
|
||||
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/parameter/aux_/parenthesized_type.hpp>
|
||||
|
||||
# ifdef BOOST_OLD_CONCEPT_SUPPORT
|
||||
# include <boost/concept_check/has_constraints.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
# endif
|
||||
|
||||
// This implementation works on Comeau and GCC, all the way back to
|
||||
// 2.95
|
||||
namespace boost
|
||||
{
|
||||
template <class ModelFnPtr>
|
||||
struct concept_check_;
|
||||
|
||||
namespace concept_checking
|
||||
{
|
||||
template <void(*)()> struct instantiate {};
|
||||
}
|
||||
|
||||
template <class Model>
|
||||
struct concept_check
|
||||
{
|
||||
static void failed() { ((Model*)0)->~Model(); }
|
||||
};
|
||||
|
||||
# ifdef BOOST_OLD_CONCEPT_SUPPORT
|
||||
|
||||
template <class Model>
|
||||
struct constraint_check
|
||||
{
|
||||
static void failed() { ((Model*)0)->constraints(); }
|
||||
};
|
||||
|
||||
template <class Model>
|
||||
struct concept_check_<void(*)(Model)>
|
||||
: mpl::if_c<
|
||||
concept_checking::has_constraints<Model>::value
|
||||
, constraint_check<Model>
|
||||
, concept_check<Model>
|
||||
>::type
|
||||
{};
|
||||
|
||||
# else
|
||||
|
||||
template <class Model>
|
||||
struct concept_check_<void(*)(Model)>
|
||||
: concept_check<Model>
|
||||
{};
|
||||
|
||||
# endif
|
||||
|
||||
# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
|
||||
typedef boost::concept_checking::instantiate< \
|
||||
&boost::concept_check_<ModelFnPtr>::failed> \
|
||||
BOOST_PP_CAT(boost_concept_check,__LINE__)
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP
|
@ -1,31 +0,0 @@
|
||||
// Copyright David Abrahams 2006. 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_CONCEPT_CHECK_HAS_CONSTRAINTS_DWA2006429_HPP
|
||||
# define BOOST_CONCEPT_CHECK_HAS_CONSTRAINTS_DWA2006429_HPP
|
||||
|
||||
namespace boost { namespace concept_checking {
|
||||
|
||||
// Here we implement the "metafunction" that detects whether a
|
||||
// constraints metafunction exists
|
||||
typedef char yes;
|
||||
typedef char (&no)[2];
|
||||
|
||||
template <class Model, void (Model::*)()>
|
||||
struct wrap_constraints {};
|
||||
|
||||
template <class Model>
|
||||
inline yes has_constraints_(Model*, wrap_constraints<Model,&Model::constraints>* = 0);
|
||||
inline no has_constraints_(...);
|
||||
|
||||
template <class Model>
|
||||
struct has_constraints
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(
|
||||
bool
|
||||
, value = sizeof( concept_checking::has_constraints_((Model*)0) ) == 1 );
|
||||
};
|
||||
|
||||
}} // namespace boost::concept_checking
|
||||
|
||||
#endif // BOOST_CONCEPT_CHECK_HAS_CONSTRAINTS_DWA2006429_HPP
|
@ -1,99 +0,0 @@
|
||||
// Copyright David Abrahams 2006. 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_CONCEPT_CHECK_MSVC_DWA2006429_HPP
|
||||
# define BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP
|
||||
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
|
||||
# ifdef BOOST_OLD_CONCEPT_SUPPORT
|
||||
# include <boost/concept_check/has_constraints.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
# endif
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace concept_checking
|
||||
{
|
||||
template <class Model>
|
||||
struct concept_check_
|
||||
{
|
||||
~concept_check_();
|
||||
virtual void failed(Model* x)
|
||||
{
|
||||
x->~Model();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
# ifdef BOOST_OLD_CONCEPT_SUPPORT
|
||||
|
||||
namespace concept_checking
|
||||
{
|
||||
template <class Model>
|
||||
struct constraint_check
|
||||
{
|
||||
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
|
||||
{};
|
||||
|
||||
# else
|
||||
|
||||
template <class Model>
|
||||
struct concept_check
|
||||
: concept_checking::concept_check_<Model>
|
||||
{
|
||||
~concept_check();
|
||||
};
|
||||
|
||||
# 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_FN( ModelFnPtr ) \
|
||||
enum \
|
||||
{ \
|
||||
BOOST_PP_CAT(boost_concept_check,__LINE__) = \
|
||||
sizeof(::boost::concept_check<ModelFnPtr>) \
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
template <class Model>
|
||||
concept_check<Model>
|
||||
concept_check_(void(*)(Model));
|
||||
|
||||
# define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
|
||||
enum \
|
||||
{ \
|
||||
BOOST_PP_CAT(boost_concept_check,__LINE__) = \
|
||||
sizeof(::boost::concept_check_((ModelFnPtr)0)) \
|
||||
}
|
||||
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP
|
Reference in New Issue
Block a user