调试vs2013报错!

安倍大人 2018-01-04 04:38:06
错误 7 error C2882: “db”: 在表达式中非法使用命名空间标识符
错误 8 error C2143: 语法错误 : 缺少“,”(在“:”的前面)
错误 9 error C2974: 'boost::scoped_ptr' : 模板 对于 'T'是无效参数,应为类型
错误 10 error C2514: “boost::scoped_ptr”: 类没有构造函数

错误行如下
scoped_ptr<db:DB> db(db::GetDB(FLAGS_backend));

scoped_ptr文件代码如下:

#ifndef BOOST_SCOPED_PTR_HPP_INCLUDED
#define BOOST_SCOPED_PTR_HPP_INCLUDED

// (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
// Copyright (c) 2001, 2002 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// http://www.boost.org/libs/smart_ptr/scoped_ptr.htm
//

#include <boost/smart_ptr/scoped_ptr.hpp>

#endif // #ifndef BOOST_SCOPED_PTR_HPP_INCLUDED
#define BOOST_INTERPROCESS_SCOPED_PTR_HPP_INCLUDED

#ifndef BOOST_CONFIG_HPP
# include <boost/config.hpp>
#endif
#
#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif

#include <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
#include <boost/interprocess/detail/pointer_type.hpp>
#include <boost/interprocess/detail/utilities.hpp>
#include <boost/assert.hpp>
#include <boost/move/adl_move_swap.hpp>

//!\file
//!Describes the smart pointer scoped_ptr

namespace boost {
namespace interprocess {

//!scoped_ptr stores a pointer to a dynamically allocated object.
//!The object pointed to is guaranteed to be deleted, either on destruction
//!of the scoped_ptr, or via an explicit reset. The user can avoid this
//!deletion using release().
//!scoped_ptr is parameterized on T (the type of the object pointed to) and
//!Deleter (the functor to be executed to delete the internal pointer).
//!The internal pointer will be of the same pointer type as typename
//!Deleter::pointer type (that is, if typename Deleter::pointer is
//!offset_ptr<void>, the internal pointer will be offset_ptr<T>).
template<class T, class Deleter>
class scoped_ptr
: private Deleter
{
#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
scoped_ptr(scoped_ptr const &);
scoped_ptr & operator=(scoped_ptr const &);

typedef scoped_ptr<T, Deleter> this_type;
typedef typename ipcdetail::add_reference<T>::type reference;
#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED

public:

typedef T element_type;
typedef Deleter deleter_type;
typedef typename ipcdetail::pointer_type<T, Deleter>::type pointer;

//!Constructs a scoped_ptr, storing a copy of p(which can be 0) and d.
//!Does not throw.
explicit scoped_ptr(const pointer &p = 0, const Deleter &d = Deleter())
: Deleter(d), m_ptr(p) // throws if pointer/Deleter copy ctor throws
{}

//!If the stored pointer is not 0, destroys the object pointed to by the stored pointer.
//!calling the operator() of the stored deleter. Never throws
~scoped_ptr()
{
if (m_ptr){
Deleter &del = static_cast<Deleter&>(*this);
del(m_ptr);
}
}

//!Deletes the object pointed to by the stored pointer and then
//!stores a copy of p. Never throws
void reset(const pointer &p = 0) // never throws
{
BOOST_ASSERT(p == 0 || p != m_ptr); this_type(p).swap(*this);
}

//!Deletes the object pointed to by the stored pointer and then
//!stores a copy of p and a copy of d.
void reset(const pointer &p, const Deleter &d) // never throws
{
BOOST_ASSERT(p == 0 || p != m_ptr); this_type(p, d).swap(*this);
}

//!Assigns internal pointer as 0 and returns previous pointer. This will
//!avoid deletion on destructor
pointer release()
{
pointer tmp(m_ptr); m_ptr = 0; return tmp;
}

//!Returns a reference to the object pointed to by the stored pointer.
//!Never throws.
reference operator*() const
{
BOOST_ASSERT(m_ptr != 0); return *m_ptr;
}

//!Returns the internal stored pointer.
//!Never throws.
pointer &operator->()
{
BOOST_ASSERT(m_ptr != 0); return m_ptr;
}

//!Returns the internal stored pointer.
//!Never throws.
const pointer &operator->() const
{
BOOST_ASSERT(m_ptr != 0); return m_ptr;
}

//!Returns the stored pointer.
//!Never throws.
pointer & get()
{
return m_ptr;
}

//!Returns the stored pointer.
//!Never throws.
const pointer & get() const
{
return m_ptr;
}

typedef pointer this_type::*unspecified_bool_type;

//!Conversion to bool
//!Never throws
operator unspecified_bool_type() const
{
return m_ptr == 0 ? 0 : &this_type::m_ptr;
}

//!Returns true if the stored pointer is 0.
//!Never throws.
bool operator! () const // never throws
{
return m_ptr == 0;
}

//!Exchanges the internal pointer and deleter with other scoped_ptr
//!Never throws.
void swap(scoped_ptr & b) // never throws
{
::boost::adl_move_swap(static_cast<Deleter&>(*this), static_cast<Deleter&>(b));
::boost::adl_move_swap(m_ptr, b.m_ptr);
}

#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
private:
pointer m_ptr;
#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
};

//!Exchanges the internal pointer and deleter with other scoped_ptr
//!Never throws.
template<class T, class D> inline
void swap(scoped_ptr<T, D> & a, scoped_ptr<T, D> & b)
{
a.swap(b);
}

//!Returns a copy of the stored pointer
//!Never throws
template<class T, class D> inline
typename scoped_ptr<T, D>::pointer to_raw_pointer(scoped_ptr<T, D> const & p)
{
return p.get();
}

} // namespace interprocess

#if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)

#if defined(_MSC_VER) && (_MSC_VER < 1400)
template<class T, class D> inline
T *to_raw_pointer(boost::interprocess::scoped_ptr<T, D> const & p)
{
return p.get();
}
#endif

#endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED

} // namespace boost

#include <boost/interprocess/detail/config_end.hpp>


...全文
306 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
安倍大人 2018-01-05
  • 打赏
  • 举报
回复
db::DB

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧