Boost logo

Boost Users :

Subject: [Boost-users] thread/call_once compile error on trunk on my code
From: Olaf Peter (ope-devel_at_[hidden])
Date: 2013-04-20 11:03:38


Hello,

my svn and compiler versions are:

Path: .
URL: http://svn.boost.org/svn/boost/trunk
Repository Root: http://svn.boost.org/svn/boost
Repository UUID: b8fc166d-592f-0410-95f2-cb63ce0dd405
Revision: 83985
Node Kind: directory
Schedule: normal
Last Changed Author: viboes
Last Changed Rev: 83985
Last Changed Date: 2013-04-20 16:12:43 +0200 (Sat, 20 Apr 2013)

$ LANG=en g++ --version
g++ (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

and maybe the last changes

$ svn log boost/thread/pthread/once_atomic.hpp
------------------------------------------------------------------------
r83466 | viboes | 2013-03-16 16:36:21 +0100 (Sa, 16. Mär 2013) | 1 Zeile

Thread: add invoke when no variadic templates are available; adapt
call_once.

breaks my code now which is basically:

---8<---
namespace {

        struct id_string
        {
                static boost::once_flag flag;
                typedef std::map<int, std::string> map_type;
                ...

                static void do_init(token_id_string& self)
                {
                        insert(self.m_map)(x, "y")(...)
                                ;
                }

                std::string const& operator()(id::type id) const
                {
                        boost::call_once(flag, &id_string::do_init, *this);

                        map_iterator s = m_map.find(id);
                        ...
                }
        };

id_string::map_type id_string::m_map;

#ifdef BOOST_THREAD_PROVIDES_ONCE_CXX11
boost::once_flag id_string::flag;
#else
boost::once_flag id_string::flag = BOOST_ONCE_INIT;
#endif
}
--->8---

The error is about

/usr/local/include/boost/thread/detail/invoke.hpp: In function 'typename
boost::enable_if_c<(! boost::is_member_function_pointer<Fp>::value),
Ret>::type boost::detail::invoke(Fp&&, Args&& ...) [with Ret = void, Fp
= void (*)({anonymous}::id_string&), Args = {{anonymous}::id_string},
typename boost::enable_if_c<(!
boost::is_member_function_pointer<Fp>::value), Ret>::type = void]':
/usr/local/include/boost/thread/pthread/once_atomic.hpp:127:9:
instantiated from 'void boost::call_once(boost::once_flag&, Function&&,
ArgTypes&& ...) [with Function = void (*)({anonymous}::id_string&),
ArgTypes = {{anonymous}::id_string&}]'
/home/olaf/work/token_ids.cpp:93:59: instantiated from here
/usr/local/include/boost/thread/detail/invoke.hpp:406:65: error: invalid
initialization of non-const reference of type '{anonymous}::id_string&'
from an rvalue of type '{anonymous}::id_string'

Is this intentionally or do I miss something?

Thanks,
Olaf


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net