38 lines
756 B
C++
38 lines
756 B
C++
#ifndef QUERY_FOREIGN_HPP
|
|
#define QUERY_FOREIGN_HPP
|
|
|
|
#include <memory>
|
|
|
|
namespace matador::sql {
|
|
|
|
template < class Type >
|
|
class foreign
|
|
{
|
|
public:
|
|
using value_type = Type;
|
|
using pointer = value_type*;
|
|
using reference = value_type&;
|
|
|
|
foreign() = default;
|
|
explicit foreign(Type *obj)
|
|
: obj_(obj) {}
|
|
|
|
pointer operator->() { return obj_.get(); }
|
|
const value_type* operator->() const { return obj_.get(); }
|
|
|
|
reference operator*() { return *obj_; }
|
|
const value_type& operator*() const { return *obj_; }
|
|
|
|
private:
|
|
std::unique_ptr<value_type> obj_;
|
|
};
|
|
|
|
template<class Type, typename... Args>
|
|
[[maybe_unused]] foreign<Type> make_foreign(Args&&... args)
|
|
{
|
|
return foreign(new Type(std::forward<Args>(args)...));
|
|
}
|
|
|
|
}
|
|
#endif //QUERY_FOREIGN_HPP
|