Boost-Graph
view release on metacpan or search on metacpan
include/boost/concept_check.hpp view on Meta::CPAN
template <class Func, class Return, class Arg>
struct AdaptableUnaryFunctionConcept
{
void constraints() {
typedef typename Func::argument_type argument_type;
typedef typename Func::result_type result_type;
BOOST_STATIC_ASSERT((is_convertible<result_type, Return>::value));
BOOST_STATIC_ASSERT((is_convertible<Arg, argument_type>::value));
function_requires< UnaryFunctionConcept<Func, result_type, argument_type> >();
}
};
template <class Func, class Return, class First, class Second>
struct AdaptableBinaryFunctionConcept
{
void constraints() {
typedef typename Func::first_argument_type first_argument_type;
typedef typename Func::second_argument_type second_argument_type;
typedef typename Func::result_type result_type;
BOOST_STATIC_ASSERT((is_convertible<result_type, Return>::value));
BOOST_STATIC_ASSERT((is_convertible<First, first_argument_type>::value));
BOOST_STATIC_ASSERT((is_convertible<Second, second_argument_type>::value));
function_requires< BinaryFunctionConcept<Func, result_type,
first_argument_type, second_argument_type> >();
}
};
template <class Func, class Arg>
struct AdaptablePredicateConcept
{
void constraints() {
function_requires< UnaryPredicateConcept<Func, Arg> >();
function_requires< AdaptableUnaryFunctionConcept<Func, bool, Arg> >();
}
};
template <class Func, class First, class Second>
struct AdaptableBinaryPredicateConcept
{
void constraints() {
function_requires< BinaryPredicateConcept<Func, First, Second> >();
function_requires< AdaptableBinaryFunctionConcept<Func, bool, First, Second> >();
}
};
//===========================================================================
// Iterator Concepts
template <class TT>
struct InputIteratorConcept
{
void constraints() {
function_requires< AssignableConcept<TT> >();
function_requires< EqualityComparableConcept<TT> >();
TT j(i);
(void)*i; // require dereference operator
#ifndef BOOST_NO_STD_ITERATOR_TRAITS
// require iterator_traits typedef's
typedef typename std::iterator_traits<TT>::difference_type D;
// Hmm, the following is a bit fragile
//function_requires< SignedIntegerConcept<D> >();
typedef typename std::iterator_traits<TT>::reference R;
typedef typename std::iterator_traits<TT>::pointer P;
typedef typename std::iterator_traits<TT>::iterator_category C;
function_requires< ConvertibleConcept<C, std::input_iterator_tag> >();
#endif
++j; // require preincrement operator
i++; // require postincrement operator
}
TT i;
};
template <class TT, class ValueT>
struct OutputIteratorConcept
{
void constraints() {
function_requires< AssignableConcept<TT> >();
++i; // require preincrement operator
i++; // require postincrement operator
*i++ = t; // require postincrement and assignment
}
TT i, j;
ValueT t;
};
template <class TT>
struct ForwardIteratorConcept
{
void constraints() {
function_requires< InputIteratorConcept<TT> >();
#ifndef BOOST_NO_STD_ITERATOR_TRAITS
typedef typename std::iterator_traits<TT>::iterator_category C;
function_requires< ConvertibleConcept<C, std::forward_iterator_tag> >();
typedef typename std::iterator_traits<TT>::reference reference;
reference r = *i;
ignore_unused_variable_warning(r);
#endif
}
TT i;
};
template <class TT>
struct Mutable_ForwardIteratorConcept
{
void constraints() {
function_requires< ForwardIteratorConcept<TT> >();
*i++ = *i; // require postincrement and assignment
}
TT i;
};
template <class TT>
struct BidirectionalIteratorConcept
{
void constraints() {
function_requires< ForwardIteratorConcept<TT> >();
#ifndef BOOST_NO_STD_ITERATOR_TRAITS
typedef typename std::iterator_traits<TT>::iterator_category C;
function_requires< ConvertibleConcept<C,
std::bidirectional_iterator_tag> >();
( run in 1.316 second using v1.01-cache-2.11-cpan-364913b4093 )