
Felipe Magno de Almeida wrote:
On 11/7/07, Thorsten Ottosen <thorsten.ottosen@dezide.com> wrote:
Felipe Magno de Almeida skrev:
This gives multiple definition errors when #include'd by more than one translation unit.
namespace boost { namespace ptr_container_detail { const char* count = "count"; const char* item = "item"; const char* first = "first"; const char* second = "second"; } } Thanks. Is there an easy way to fix it?
I couldn't think of anything that wouldn't cause ODR violation.
It's a bit ugly, but you can use templates. There's an example in boost/date_time/time_facet.hpp, but it goes something like this: template <class CharT> struct ptr_container_stuff { public: typedef CharT char_type; static const char_type count[6]; static const char_type item[5]; ... }; template <class CharT> const typename ptr_container_stuff<CharT>::char_type ptr_container_stuff<CharT>::count[6] = {'f','i','r','s','t'}; template <class CharT> const typename ptr_container_stuff<CharT>::char_type ptr_container_stuff<CharT>::item[5] = {'i','t','e','m'}; Jeff