小编use*_*617的帖子

如何制作std :: weak_ptr的c ++ 11 std :: unordered_set

我有这样的一套: set<weak_ptr<Node>, owner_less<weak_ptr<Node> > > setName;

它工作正常.但我想将它改为无序集.但是,当我这样做时,我得到大约六页的错误.任何想法如何做到这一点?

查看了所有错误消息页面后,我发现了可能有用的行.

/usr/include/c++/4.7/bits/functional_hash.h:60:7: error: static assertion failed: std::hash is not specialized for this type
/usr/include/c++/4.7/bits/stl_function.h: In instantiation of ‘bool std::equal_to<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = std::weak_ptr<Node>]’:
Run Code Online (Sandbox Code Playgroud)

c++ std weak-ptr unordered-set c++11

10
推荐指数
3
解决办法
6813
查看次数

在 Windows 上构建 boost 时出错“#error“Not ARM””和“错误:没有最佳替代方案”

我正在使用 mingw 在 Windows 上构建 boost,并收到诸如“#error“Not ARM””或“错误:没有...的最佳替代方案”之类的错误。这些错误是我应该担心的还是只是测试它所构建的系统?默认输出中有很多噪音,但下面是输出的压缩版本。谢谢

...found 13 targets...
...updating 5 targets...
common.mkdir bbuild\boost\bin.v2\libs\context
common.mkdir bbuild\boost\bin.v2\libs\context\config
common.mkdir bbuild\boost\bin.v2\libs\context\config\gcc-mingw-4.8.1
common.mkdir bbuild\boost\bin.v2\libs\context\config\gcc-mingw-4.8.1\debug
gcc.compile.c++ bbuild\boost\bin.v2\libs\context\config\gcc-mingw-4.8.1\debug\32.o
...updated 5 targets...
Performing configuration checks

    - 32-bit                   : yes
...found 2 targets...
...updating 1 target...
gcc.compile.c++ bbuild\boost\bin.v2\libs\context\config\gcc-mingw-4.8.1\debug\arm.o
E:\boost_1_54_0_win\libs\context\config\arm.cpp:12:2: error: #error "Not ARM"
 #error "Not ARM"
  ^

    "g++"  -ftemplate-depth-128 -O0 -fno-inline -Wall -g  -DBOOST_ALL_NO_LIB=1  -I"." -c -o "bbuild\boost\bin.v2\libs\context\config\gcc-mingw-4.8.1\debug\arm.o" "E:\boost_1_54_0_win\libs\context\config\arm.cpp"

...failed gcc.compile.c++ bbuild\boost\bin.v2\libs\context\config\gcc-mingw-4.8.1\debug\arm.o...
...failed updating 1 target...
    - arm                      : no
...found 2 targets...
...updating 1 target...
gcc.compile.c++ …
Run Code Online (Sandbox Code Playgroud)

windows boost mingw boost-build

5
推荐指数
1
解决办法
1493
查看次数

无法访问C++ std :: set中对象的非const成员函数

消息是我制作的课程.我在main函数中有一组它们传递给messageTimeOut(以及其他一些函数).在使用itorator的messageTimeOut中,我循环遍历它们并访问不同的成员函数.但是,我只能访问迭代器指向的Message的const成员函数.如果我尝试访问非const成员函数,我会收到错误:

"在函数中'void messageTimeOut(threadParameters*)':main.cpp:74:33:错误:将'const Message'作为'void Message :: setTimedOut(bool)'的'this'参数传递'丢弃限定符[-fpermissive]. "

有意义的是我无法访问const Message对象的非const成员函数,但是我如何使它成为一个非const的Message对象,以便我可以访问非const成员函数并更改Message?谢谢

我的部分代码:

     [ . . . ]

void messageTimeOut( threadParameters* params )
{
     set<Message>::iterator it = params->messages->begin();
     [ . . . ]
    for ( ; it != params->messages->end(); ++it )
    {
        if ( (it->createdTime() + RESPONSE_WAIT) < GetTickCount() ) 
        {
            it->setTimedOut(true); // error 
        }
    }
    ReleaseMutex(sentQueueMutex);
}

     [ . . . ]

int main()
{
    threadParameters rmparameters;
    set<Message> sentMessages;
     [ . . . ]


    rmparameters.logFile = &logFile;
    rmparameters.socket = socketDesciptor;
    rmparameters.messages …
Run Code Online (Sandbox Code Playgroud)

c++ iterator stl const set

2
推荐指数
1
解决办法
1742
查看次数

标签 统计

c++ ×2

boost ×1

boost-build ×1

c++11 ×1

const ×1

iterator ×1

mingw ×1

set ×1

std ×1

stl ×1

unordered-set ×1

weak-ptr ×1

windows ×1