libc++: create portable smart ptr / hash_map/set

Creates ceph:: namespaced versions of smart pointers and unordered map
and sets.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
This commit is contained in:
Noah Watkins 2013-10-29 07:37:59 -07:00
parent 47bc71a7b4
commit 8e8672047c
5 changed files with 103 additions and 1 deletions

View File

@ -81,4 +81,8 @@ noinst_HEADERS += \
include/rbd/librbd.hpp\
include/util.h\
include/stat.h \
include/on_exit.h
include/on_exit.h \
include/memory.h \
include/hash_namespace.h \
include/unordered_set.h \
include/unordered_map.h

View File

@ -0,0 +1,24 @@
#ifndef CEPH_HASH_NAMESPACE_H
#define CEPH_HASH_NAMESPACE_H
#include <ciso646>
#ifdef _LIBCPP_VERSION
#include <functional>
#define CEPH_HASH_NAMESPACE_START namespace std {
#define CEPH_HASH_NAMESPACE_END }
#define CEPH_HASH_NAMESPACE std
#else
#include <tr1/functional>
#define CEPH_HASH_NAMESPACE_START namespace std { namespace tr1 {
#define CEPH_HASH_NAMESPACE_END }}
#define CEPH_HASH_NAMESPACE std::tr1
#endif
#endif

26
src/include/memory.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef CEPH_MEMORY_H
#define CEPH_MEMORY_H
#include <ciso646>
#ifdef _LIBCPP_VERSION
#include <memory>
namespace ceph {
using std::shared_ptr;
using std::weak_ptr;
}
#else
#include <tr1/memory>
namespace ceph {
using std::tr1::shared_ptr;
using std::tr1::weak_ptr;
}
#endif
#endif

View File

@ -0,0 +1,24 @@
#ifndef CEPH_UNORDERED_MAP_H
#define CEPH_UNORDERED_MAP_H
#include <ciso646>
#ifdef _LIBCPP_VERSION
#include <unordered_map>
namespace ceph {
using std::unordered_map;
}
#else
#include <tr1/unordered_map>
namespace ceph {
using std::tr1::unordered_map;
}
#endif
#endif

View File

@ -0,0 +1,24 @@
#ifndef CEPH_UNORDERED_SET_H
#define CEPH_UNORDERED_SET_H
#include <ciso646>
#ifdef _LIBCPP_VERSION
#include <unordered_set>
namespace ceph {
using std::unordered_set;
}
#else
#include <tr1/unordered_set>
namespace ceph {
using std::tr1::unordered_set;
}
#endif
#endif