Hi,
I'm working on a thin libcurl layer. Therefore I have the following classes:
template<typena me T, long CURLOPT_ID>
class CurlOption: boost::noncopya ble {
public:
typedef typename boost::call_tra its<T>::param_t ype param_type;
....
public:
// constructors:
CurlOption() {}
CurlOption(para m_type v) : m_value(v) {}
public:
long option() const { return CURLOPT_ID; }
result_type parameter() { return m_value; }
void setopt(CURL* handle);
private:
value_type m_value;
};
and the specialized for the templated arguments T (ether bool, long,
std::string etc.):
template<long CURLOPT_ID>
class CurlOption<bool , CURLOPT_ID{
public:
void setopt(CURL* handle) {
curl_easy_setop t(handle,
this->option(), this->value() ? 1 : 0);
}
};
e.g. used like
struct CurlOpt {
typedef CurlOption<bool , CURLOPT_VERBOSE > Verbose;
};
and than the cURL handle class self using a double dispatch approach:
class EasyCurl : boost::noncopya ble
{
public:
...
template<typena me T, long ID>
void setopt(const CurlOption<T, ID>& opt) {
opt.setopt(m_cu rl);
}
private:
CURL* m_curl;
};
By use of this, e.g.
CurlOpt::Verbos e v(on);
I get a compiler error:
EasyCurl.cpp: In member function »void EasyCurl::setVe rbose(bool)«:
EasyCurl.cpp:12 4: Fehler: keine passende Funktion für Aufruf von
CurlOption<bool , 41l>::CurlOptio n(bool&)«
EasyCurl.hpp:19 : Anmerkung: Kandidaten sind: CurlOption<bool ,
41l>::CurlOptio n()
EasyCurl.hpp:19 : Anmerkung: CurlOption<bool , 41l>::CurlOptio n(const
CurlOption<bool , 41l>&)
Obviously the right ctor is missing. Anyway, do I have all the stuff
from the Template (typedefs including) to rewrite for the specialized
template class? Or is there another way? I thought I need only to
overwrite the specialized members - where is my mistake? Is there a
better and correct way?
Thanks
Olaf