I am looking for an elegant solution to the following problem. I have a task structure that I use for deferred function calls.
template <typename T> struct Task1 { T Arg1; Delegate<T> TaskDelegate; };
The problem I encountered is this:
Task1<const Foo&> MyTask;
This will cause the parameter to be held as a reference to a constant. Does anyone know a good solution to get around this? I could apply rules like delegate signature always accepting const & params, but that seems restrictive. I can always have two task structures (one for ref and one for value), but that seems unpleasant.
Another solution would be to create the following:
template <typename T1, typename T2> struct Task1 { T2 Arg1; Delegate<T1> TaskDelegate; };
In any case, will T2 default to the same type as T1? Thus, whenever I have a signature for a method value, I do not need to have additional template parameters.
EDIT: The template is used for multi-threaded task scheduler. Here is an example:
void MyClass::Populate(const std::string& instrText); CTaskScheduler::Schedule(Task1<const std::string&>(this, &MyClass::Popluate, "MyString"));
source share