|
Boost : |
From: François Wanadoo (francois.amelie_at_[hidden])
Date: 2002-11-12 11:37:53
Hello Boosters
I am currently developing some template algorithm and had some trouble
using BCCL. I have an algorithm using a unary function as one of its
template parameter but I don't care about the result type of this unary
function (like the for_each standard algo). I can't use the
UnaryFunctionConcept because you have to stipulate the result type. What do
you think about creating a boost::AnyType to indicate that we don't care
about a type in a template specialization. A very simple partial
specialization of UnaryFunctionConcept would lead to:
template <class Func, class Arg>
struct UnaryFunctionConcept<Func, AnyType, Arg> {
void constraints() {
f(arg);
}
Func f;
Arg arg;
};
I know it is the same specialization that for the void result type and I
could have use it but I don't want to use it because I don't want a void
unary function I want a AnyType unary function!
I tried to have the same tought about the argument type but it no as simple
to implement because clearly the UnaryFunctionConcept is a rather a
UnaryFunctorConcept. I mean that you can easily find the agument type when
you have a function but not when you have a functor; there is no
functor_traits like the function_traits and so you can't write something
like:
template <class Func>
struct UnaryFunctionConcept<Func, AnyType, AnyType> {
void constraints() {
f(arg);
}
Func f;
functor_traits<Func>::arg1_type arg;
}
I also want to signal that the type_traits/conversion_traits.hpp file is
included twice in the concept_check.hpp.
I am waiting for your remarks, thank you for reading.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk