mardi 24 février 2015

boost asio custom allocator handler io service post compile errors

I have working io_service post call that looks as follows:



_io_service.post(std::tr1::bind(&BlitzLogger::push,this,
std::tr1::bind(&BlitzLogger::stringer<typename boost::decay<T const &>::type,
typename boost::decay<Args const &>::type ...>, this,
t, args ...)));


I suspect the bind calls are having some overhead that can be done away with, so I proceeded to lay out the custom allocators for handlers as described at



http://ift.tt/1A3pta0


Following this, I would like to do something as follows:



_io_service.post(
makeCustomAllocHandler(_allocator1,std::tr1::bind(&BlitzLogger::push,this,
makeCustomAllocHandler(_allocator2,std::tr1::bind(&BlitzLogger::stringer<typename boost::decay<T const &>::type,
typename boost::decay<Args const &>::type ...>,this,t,args ...)))));


This piece of code above throws compile time errors (host of template argument deduction / substitution failures), however, if I remove the _io_service.post call, and limit it to



makeCustomAllocHandler(_allocator1,std::tr1::bind(&BlitzLogger::push,this,
makeCustomAllocHandler(_allocator2,std::tr1::bind(&BlitzLogger::stringer<typename boost::decay<T const &>::type,
typename boost::decay<Args const &>::type ...>,this,t,args ...))));


then the code compiles fine.


So obviously the problem is that the return type of makeCustomAllocHandler is not compliant with the template handler argument of the post function.


Why is this happening, and how do I get around this problem.


Aucun commentaire:

Enregistrer un commentaire