突然进入我的命名空间,因缺乏功能而声称错误

时间:2012-01-27 19:47:24

标签: c++ oop boost

在这个传奇故事“Me vs Boost,libconfig,protocol buffers and glog”的新一集中,我们发现我们的主人公(我)在与命名空间的所有权的绝望斗争中与Boost作战!。

好吧,我一直在使用这个漂亮的代码:

server.h

#ifndef SERVER_H
#define SERVER_H 1

#include "configuration.h"
#include "client.h"
#include "client_manager.h"
#include <string>
#include <boost/noncopyable.hpp>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>

namespace BBCP {
    namespace Server {

class Server : private boost::noncopyable {
public:
    Server(BBCP::App::Config const &wrapper) :
        acceptor(io_service),
        wrapper(wrapper)
        //signals(io_service),
        { }
    void run();
protected:
    void acceptHandler(boost::system::error_code const &error);
    void startAccept();
    void stopServer();
private:
    boost::asio::io_service io_service;
    boost::asio::ip::tcp::acceptor acceptor;
    boost::asio::ip::tcp::endpoint endpoint;
    //boost::asio::signal_set signals;

    BBCP::Server::client_ptr newClient;
    BBCP::Server::ClientManager manager;

    boost::thread_group client_pool;
    BBCP::App::Config wrapper;
};

    }
}

#endif

现在进行了一些构建,并且它一切正常,直到...之后,一切都没有,它开始出错:

In file included from /usr/include/boost/type_traits/has_nothrow_constructor.hpp:12:0,
                 from /usr/include/boost/optional/optional.hpp:25,
                 from /usr/include/boost/optional.hpp:15,
                 from /usr/include/boost/thread/pthread/thread_data.hpp:13,
                 from /usr/include/boost/thread/thread.hpp:17,
                 from /usr/include/boost/thread.hpp:13,
                 from ../include/server.h:10,
                 from main.cpp:17:
/usr/include/boost/type_traits/has_trivial_constructor.hpp:36:1: error: ‘has_trivial_ctor_impl’ is not a member of ‘boost::detail’
/usr/include/boost/type_traits/has_trivial_constructor.hpp:36:1: note: suggested alternative:
/usr/include/boost/type_traits/has_trivial_constructor.hpp:25:8: note:   ‘BBCP::Server::boost::detail::has_trivial_ctor_impl’

(...) This goes on and on with a lot of dependencies.

现在,从我所看到的情况来看,BBCP::Server::boost::detail::has_trivial_ctor_impl指的是boost::detail中定义的某种方法。点是,boost::detail不应该进入我的命名空间,BBCP::Server!。

说实话,我看不出这个错误来自哪里,所以......

任何帮助将不胜感激!,

儒略。

1 个答案:

答案 0 :(得分:2)

可能是之前包含之一的标题中的一个错误,该标题未正确关闭命名空间。