I have a use case for the std::placeholder in a test application but am wondering if, in an effort to make things look a little cleaner on an API side, there is a way to bend using, typedef or even #define to alias the namespace at the header level.
// .../datarequestprocessor.h
class DataRequestProcessor {
public:
using ProcessFunction = std::function<void(const ResultData &)>;
using RequestResultHandle = std::placeholders; // No go. Same with ::_1
...
};
// ../datarequestprocessor.cpp
ProcessFunction DataRequestProcessor::prepOne()
{
auto func = std::bind( &DataModel::setData,
m_model,
RequestResultHandle::_1 );
return func;
}
... // For other variations.
This is purely semantic and also just an effort to learn about the nature of the using keyword. More of a learning experience then a real world application proposition.
Cheers
std::placeholderis a namespace, not a type), but it has to be at namespace or function scope:namespace RequestResultHandle = std::placeholder)std::placeholders(orstd::placeholder, which doesn't exist), which you'd have found out if you'd played around and discovered that this problem is about how you're using namespace aliases (which cannot be at class scope).std::placeholdersis what I meant to type :) Thank you guys.