خرید بک لینک

Vote count: 0

I'm trying to create a reference variable cParamIDsByAge to one side of a boost::bimap for convenience (MVCE):

code.h

#include <boost/bimap.hpp>

typedef boost::bimap <int, int> ParamIDs;
exte const ParamIDs cParamIDs;
exte auto &cParamIDsByAge = cParamIDs.left;

code.cpp

#include "code.h"

// In my code this inits the variable with some data via a function.
const ParamIDs cParamIDs {};
auto &cParamIDsByAge = cParamIDs.left;

The compiler complains:

code.h:5:14: waing: ‘cParamIDsByAge’ initialized and declared ‘exte’
exte auto &cParamIDsByAge = cParamIDs.left;
            ^~~~~~~~~~~~~~
code.cpp:4:7: error: conflicting declaration ‘auto& cParamIDsByAge’
auto &cParamIDsByAge = cParamIDs.left;
    ^~~~~~~~~~~~~~
In file included from code.cpp:1:0:
code.h:5:14: note: previous declaration as ‘const boost::bimaps::views::map_view<boost::bimaps::relation::member_at::left, boost::bimaps::detail::bimap_core<int, int, mpl_::na, mpl_::na, mpl_::na> >& cParamIDsByAge’
exte auto &cParamIDsByAge = cParamIDs.left;
            ^~~~~~~~~~~~~~


Then I tried defining the reference cParamIDsByAge in the header directly:

code.h

#include <boost/bimap.hpp>

typedef boost::bimap <int, int> ParamIDs;
exte const ParamIDs cParamIDs;
auto &cParamIDsByAge = cParamIDs.left;

code.cpp

#include "code.h"

const ParamIDs cParamIDs {};

But that complained about:

error: multiple definitions of cParamIDsByAge

asked 36 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 24 خرداد 1395 ساعت: 15:37

صفحه بندی