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
If you want it at the header level, then it's a simple matter of introducing a namespace alias:
namespace RequestResultHandle = std::placeholders;
The above won't be accepted inside a class however.