Skip to content

Commit 83d2251

Browse files
committed
local_shared_ptr, storage policies
1 parent 147eb88 commit 83d2251

File tree

10 files changed

+523
-276
lines changed

10 files changed

+523
-276
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/local_shared_ptr"]
2+
path = lib/local_shared_ptr
3+
url = https://github.com/flipcoder/local_shared_ptr

kit/kit.h

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <future>
1414
#include <chrono>
1515
#include <boost/algorithm/string.hpp>
16+
#include <boost/smart_ptr/local_shared_ptr.hpp>
1617
#include <boost/optional.hpp>
1718
#include <boost/bimap.hpp>
1819
#include <boost/any.hpp>
@@ -70,6 +71,14 @@ namespace kit
7071
struct is_shared_ptr<std::shared_ptr<T>> {
7172
static bool const value = true;
7273
};
74+
template<class T, class _ = void>
75+
struct is_local_shared_ptr {
76+
static const bool value = false;
77+
};
78+
template<class T>
79+
struct is_local_shared_ptr<boost::local_shared_ptr<T>> {
80+
static bool const value = true;
81+
};
7382

7483
template<class T>
7584
T mod(T a, T b)
@@ -804,6 +813,12 @@ namespace kit
804813
{
805814
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
806815
}
816+
template<class T, class... Args>
817+
T make(Args&&... args)
818+
{
819+
return T(new typename T::element_type(std::forward<Args>(args)...));
820+
}
821+
807822
template<class T, class... Args>
808823
std::unique_ptr<T> init_unique(Args&&... args)
809824
{
@@ -818,18 +833,18 @@ namespace kit
818833
p->init();
819834
return p;
820835
}
821-
template<class T, class... Args>
822-
std::unique_ptr<T>& make(std::unique_ptr<T>& p, Args&&... args)
823-
{
824-
p = std::unique_ptr<T>(new T(std::forward<Args>(args)...));
825-
return p;
826-
}
827-
template<class T, class... Args>
828-
std::shared_ptr<T>& make(std::shared_ptr<T>& p, Args&&... args)
829-
{
830-
p = std::shared_ptr<T>(new T(std::forward<Args>(args)...));
831-
return p;
832-
}
836+
//template<class T, class... Args>
837+
//std::unique_ptr<T>& make(std::unique_ptr<T>& p, Args&&... args)
838+
//{
839+
// p = std::unique_ptr<T>(new T(std::forward<Args>(args)...));
840+
// return p;
841+
//}
842+
//template<class T, class... Args>
843+
//std::shared_ptr<T>& make(std::shared_ptr<T>& p, Args&&... args)
844+
//{
845+
// p = std::shared_ptr<T>(new T(std::forward<Args>(args)...));
846+
// return p;
847+
//}
833848
template<class T, class... Args>
834849
std::unique_ptr<T>& init(std::unique_ptr<T>& p, Args&&... args)
835850
{

0 commit comments

Comments
 (0)