T
titanandrews
Hi All,
I'm trying to create a helper function that converts a collection of T
into a vector of std::string.
The toStdStringFunc is so the caller can provide the T to std::string
conversion.
I want to use Collection::value_type as the first param of the
toStdStringFunc, but this does not compile.
Is there any way to make this work using templates?
template<class Collection>
static void fromCollectionT(const Collection& collection,
std::vector<Location_t>& locations, boost::function<void (const
Collection::value_type&, std::string& )> toStdStringFunc)
{
}
The following does work, but it's a little verbose to the caller and I
would like to avoid the extra class ValueType if possible. Any way to
do it?
template<class Collection, class ValueType>
static void fromCollectionT(const Collection& collection,
std::vector<Location_t>& locations, boost::function<void (const
ValueType&, std::string& )> toStdStringFunc)
{
}
many thanks,
B
I'm trying to create a helper function that converts a collection of T
into a vector of std::string.
The toStdStringFunc is so the caller can provide the T to std::string
conversion.
I want to use Collection::value_type as the first param of the
toStdStringFunc, but this does not compile.
Is there any way to make this work using templates?
template<class Collection>
static void fromCollectionT(const Collection& collection,
std::vector<Location_t>& locations, boost::function<void (const
Collection::value_type&, std::string& )> toStdStringFunc)
{
}
The following does work, but it's a little verbose to the caller and I
would like to avoid the extra class ValueType if possible. Any way to
do it?
template<class Collection, class ValueType>
static void fromCollectionT(const Collection& collection,
std::vector<Location_t>& locations, boost::function<void (const
ValueType&, std::string& )> toStdStringFunc)
{
}
many thanks,
B