Fix internal linkage of unique_c_ptr
The anonymous namespace was causing an internal linkage error when
trying to use unique_c_ptr. Make it in an "internal" namespace instead.
Change-Id: If6662537dfc928706a8c1e5d4348caec3a9f6215
diff --git a/aos/unique_malloc_ptr.h b/aos/unique_malloc_ptr.h
index bd2c37c..eb92f11 100644
--- a/aos/unique_malloc_ptr.h
+++ b/aos/unique_malloc_ptr.h
@@ -1,8 +1,11 @@
+#ifndef AOS_UNIQUE_MALLOC_PTR_H_
+#define AOS_UNIQUE_MALLOC_PTR_H_
+
#include <memory>
namespace aos {
-namespace {
+namespace internal {
// Written as a functor so that it doesn't have to get passed to
// std::unique_ptr's constructor as an argument.
@@ -19,26 +22,30 @@
template<typename T>
void free_type(T *ptr) { ::free(reinterpret_cast<void *>(ptr)); }
-} // namespace
+} // namespace internal
// A std::unique_ptr that should get freed with a C-style free function
// (free(2) by default).
-template<typename T, void(*function)(T *) = free_type<T>>
-class unique_c_ptr : public std::unique_ptr<T, const_wrap<T, function>> {
+template <typename T, void (*function)(T *) = internal::free_type<T>>
+class unique_c_ptr
+ : public std::unique_ptr<T, internal::const_wrap<T, function>> {
public:
- unique_c_ptr(T *value) : std::unique_ptr<T, const_wrap<T, function>>(value) {}
+ unique_c_ptr(T *value)
+ : std::unique_ptr<T, internal::const_wrap<T, function>>(value) {}
// perfect forwarding of these 2 to make unique_ptr work
- template<typename... Args>
- unique_c_ptr(Args&&... args)
- : std::unique_ptr<T, const_wrap<T, function>>(std::forward<Args>(args)...) {
- }
+ template <typename... Args>
+ unique_c_ptr(Args &&... args)
+ : std::unique_ptr<T, internal::const_wrap<T, function>>(
+ std::forward<Args>(args)...) {}
template<typename... Args>
unique_c_ptr<T, function> &operator=(Args&&... args) {
- std::unique_ptr<T, const_wrap<T, function>>::operator=(
+ std::unique_ptr<T, internal::const_wrap<T, function>>::operator=(
std::forward<Args>(args)...);
return *this;
}
};
} // namespace aos
+
+#endif // AOS_UNIQUE_MALLOC_PTR_H_