|
Boost : |
From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2006-04-30 02:41:09
Hi Felipe,
--- Felipe Magno de Almeida <felipe.m.almeida_at_[hidden]> wrote:
> Why is the default implementations in the global namespace?
> Shouldnt it be in asio namespace?
While this stuff was in development, putting it in the global
namespace was the only way I could get it to work with some
compilers -- Borland C++ 5.6 was the culprit if I remember
correctly. However since I had to give up supporting custom
memory allocation for that compiler anyway, then yes I should
put them into the asio namespace. I just need to put a "using
namespace asio" or similar at the point in the implementation
where the call to the allocate function is made.
I also suppose if I put it into the asio namespace then I can
drop the asio_ prefix from the functions. I.e. you would now
write:
class my_handler
{
...
void operator()(const asio::error& e)
{
...
}
friend void* handler_allocate(size_t s, my_handler* h)
{
...
}
friend void handler_deallocate(void* p, size_t s, my_handler* h)
{
...
}
};
On a related note, you should be able to customise allocation
for all handlers by writing:
template <typename Handler>
void* handler_allocate(size_t s, Handler* h)
{
...
}
template <typename Handler>
void handler_deallocate(void* p, size_t s, Handler* h)
{
...
}
at global scope.
Cheers,
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk