mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-08 18:33:54 +00:00
36 lines
890 B
C++
36 lines
890 B
C++
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include <boost/bind.hpp>
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
namespace osquery {
|
|
|
|
template <typename T>
|
|
void do_release_boost(typename boost::shared_ptr<T> const&, T*) {}
|
|
|
|
/**
|
|
* @brief Convert a boost::shared_ptr to a std::shared_ptr
|
|
*/
|
|
template <typename T>
|
|
typename std::shared_ptr<T> boost_to_std_shared_ptr(
|
|
typename boost::shared_ptr<T> const& p) {
|
|
return std::shared_ptr<T>(p.get(), boost::bind(&do_release_boost<T>, p, _1));
|
|
}
|
|
|
|
template <typename T>
|
|
void do_release_std(typename std::shared_ptr<T> const&, T*) {}
|
|
|
|
/**
|
|
* @brief Convert a std::shared_ptr to a boost::shared_ptr
|
|
*/
|
|
template <typename T>
|
|
typename boost::shared_ptr<T> std_to_boost_shared_ptr(
|
|
typename std::shared_ptr<T> const& p) {
|
|
return boost::shared_ptr<T>(p.get(), boost::bind(&do_release_std<T>, p, _1));
|
|
}
|
|
}
|