Skip to content

Commit 98df597

Browse files
committed
Fixed curl_pair<CURLformoption,string> handling of string constants
refs #57
1 parent 11c4979 commit 98df597

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

include/curl_pair.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ namespace curl {
7474
* The two parameters constructor gives users a fast way to
7575
* build an object of this type.
7676
*/
77-
curl_pair(const CURLformoption option, const std::string &value) : option(option), value(value) {}
77+
curl_pair(const CURLformoption option, const std::string &value) : option(option), value(value.c_str()) {}
78+
/**
79+
* Alternate constructor that handles string constants without
80+
* referencing temporary objects.
81+
*/
82+
curl_pair(const CURLformoption option, const char *value) : option(option), value(value) {}
7883
/**
7984
* Simple method that returns the first field of the pair.
8085
*/
@@ -86,11 +91,11 @@ namespace curl {
8691
* a C string, so a const char *.
8792
*/
8893
inline const char *second() const NOEXCEPT {
89-
return this->value.c_str();
94+
return this->value;
9095
}
9196
private:
9297
const CURLformoption option;
93-
const std::string &value;
98+
const char* value;
9499
};
95100

96101
/**

0 commit comments

Comments
 (0)