diff --git a/ndnboost/smart_ptr/detail/shared_array_nmt.hpp b/ndnboost/smart_ptr/detail/shared_array_nmt.hpp
new file mode 100644
index 0000000..4d53afa
--- /dev/null
+++ b/ndnboost/smart_ptr/detail/shared_array_nmt.hpp
@@ -0,0 +1,151 @@
+#ifndef BOOST_SMART_PTR_DETAIL_SHARED_ARRAY_NMT_HPP_INCLUDED
+#define BOOST_SMART_PTR_DETAIL_SHARED_ARRAY_NMT_HPP_INCLUDED
+
+//
+//  detail/shared_array_nmt.hpp - shared_array.hpp without member templates
+//
+//  (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+//  Copyright (c) 2001, 2002 Peter Dimov
+//
+//  Distributed under the Boost Software License, Version 1.0. (See
+//  accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//  See http://www.boost.org/libs/smart_ptr/shared_array.htm for documentation.
+//
+
+#include <ndnboost/assert.hpp>
+#include <ndnboost/checked_delete.hpp>
+#include <ndnboost/throw_exception.hpp>
+#include <ndnboost/smart_ptr/detail/atomic_count.hpp>
+
+#include <cstddef>          // for std::ptrdiff_t
+#include <algorithm>        // for std::swap
+#include <functional>       // for std::less
+#include <new>              // for std::bad_alloc
+
+namespace ndnboost
+{
+
+template<class T> class shared_array
+{
+private:
+
+    typedef detail::atomic_count count_type;
+
+public:
+
+    typedef T element_type;
+      
+    explicit shared_array(T * p = 0): px(p)
+    {
+#ifndef BOOST_NO_EXCEPTIONS
+
+        try  // prevent leak if new throws
+        {
+            pn = new count_type(1);
+        }
+        catch(...)
+        {
+            ndnboost::checked_array_delete(p);
+            throw;
+        }
+
+#else
+
+        pn = new count_type(1);
+
+        if(pn == 0)
+        {
+            ndnboost::checked_array_delete(p);
+            ndnboost::throw_exception(std::bad_alloc());
+        }
+
+#endif
+    }
+
+    ~shared_array()
+    {
+        if(--*pn == 0)
+        {
+            ndnboost::checked_array_delete(px);
+            delete pn;
+        }
+    }
+
+    shared_array(shared_array const & r) : px(r.px)  // never throws
+    {
+        pn = r.pn;
+        ++*pn;
+    }
+
+    shared_array & operator=(shared_array const & r)
+    {
+        shared_array(r).swap(*this);
+        return *this;
+    }
+
+    void reset(T * p = 0)
+    {
+        BOOST_ASSERT(p == 0 || p != px);
+        shared_array(p).swap(*this);
+    }
+
+    T * get() const  // never throws
+    {
+        return px;
+    }
+
+    T & operator[](std::ptrdiff_t i) const  // never throws
+    {
+        BOOST_ASSERT(px != 0);
+        BOOST_ASSERT(i >= 0);
+        return px[i];
+    }
+
+    long use_count() const  // never throws
+    {
+        return *pn;
+    }
+
+    bool unique() const  // never throws
+    {
+        return *pn == 1;
+    }
+
+    void swap(shared_array<T> & other)  // never throws
+    {
+        std::swap(px, other.px);
+        std::swap(pn, other.pn);
+    }
+
+private:
+
+    T * px;            // contained pointer
+    count_type * pn;   // ptr to reference counter
+      
+};  // shared_array
+
+template<class T, class U> inline bool operator==(shared_array<T> const & a, shared_array<U> const & b)
+{
+    return a.get() == b.get();
+}
+
+template<class T, class U> inline bool operator!=(shared_array<T> const & a, shared_array<U> const & b)
+{
+    return a.get() != b.get();
+}
+
+template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b)
+{
+    return std::less<T*>()(a.get(), b.get());
+}
+
+template<class T> void swap(shared_array<T> & a, shared_array<T> & b)
+{
+    a.swap(b);
+}
+
+} // namespace ndnboost
+
+#endif  // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_ARRAY_NMT_HPP_INCLUDED
diff --git a/ndnboost/smart_ptr/scoped_array.hpp b/ndnboost/smart_ptr/scoped_array.hpp
new file mode 100644
index 0000000..7584d27
--- /dev/null
+++ b/ndnboost/smart_ptr/scoped_array.hpp
@@ -0,0 +1,132 @@
+#ifndef BOOST_SMART_PTR_SCOPED_ARRAY_HPP_INCLUDED
+#define BOOST_SMART_PTR_SCOPED_ARRAY_HPP_INCLUDED
+
+//  (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+//  Copyright (c) 2001, 2002 Peter Dimov
+//
+//  Distributed under the Boost Software License, Version 1.0. (See
+//  accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//  http://www.boost.org/libs/smart_ptr/scoped_array.htm
+//
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/assert.hpp>
+#include <ndnboost/checked_delete.hpp>
+#include <ndnboost/smart_ptr/detail/sp_nullptr_t.hpp>
+
+#include <ndnboost/detail/workaround.hpp>
+
+#include <cstddef>            // for std::ptrdiff_t
+
+namespace ndnboost
+{
+
+// Debug hooks
+
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+
+void sp_array_constructor_hook(void * p);
+void sp_array_destructor_hook(void * p);
+
+#endif
+
+//  scoped_array extends scoped_ptr to arrays. Deletion of the array pointed to
+//  is guaranteed, either on destruction of the scoped_array or via an explicit
+//  reset(). Use shared_array or std::vector if your needs are more complex.
+
+template<class T> class scoped_array // noncopyable
+{
+private:
+
+    T * px;
+
+    scoped_array(scoped_array const &);
+    scoped_array & operator=(scoped_array const &);
+
+    typedef scoped_array<T> this_type;
+
+    void operator==( scoped_array const& ) const;
+    void operator!=( scoped_array const& ) const;
+
+public:
+
+    typedef T element_type;
+
+    explicit scoped_array( T * p = 0 ) BOOST_NOEXCEPT : px( p )
+    {
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+        ndnboost::sp_array_constructor_hook( px );
+#endif
+    }
+
+    ~scoped_array() // never throws
+    {
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+        ndnboost::sp_array_destructor_hook( px );
+#endif
+        ndnboost::checked_array_delete( px );
+    }
+
+    void reset(T * p = 0) // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
+    {
+        BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
+        this_type(p).swap(*this);
+    }
+
+    T & operator[](std::ptrdiff_t i) const // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
+    {
+        BOOST_ASSERT( px != 0 );
+        BOOST_ASSERT( i >= 0 );
+        return px[i];
+    }
+
+    T * get() const BOOST_NOEXCEPT
+    {
+        return px;
+    }
+
+// implicit conversion to "bool"
+#include <ndnboost/smart_ptr/detail/operator_bool.hpp>
+
+    void swap(scoped_array & b) BOOST_NOEXCEPT
+    {
+        T * tmp = b.px;
+        b.px = px;
+        px = tmp;
+    }
+};
+
+#if !defined( BOOST_NO_CXX11_NULLPTR )
+
+template<class T> inline bool operator==( scoped_array<T> const & p, ndnboost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
+{
+    return p.get() == 0;
+}
+
+template<class T> inline bool operator==( ndnboost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_NOEXCEPT
+{
+    return p.get() == 0;
+}
+
+template<class T> inline bool operator!=( scoped_array<T> const & p, ndnboost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
+{
+    return p.get() != 0;
+}
+
+template<class T> inline bool operator!=( ndnboost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_NOEXCEPT
+{
+    return p.get() != 0;
+}
+
+#endif
+
+template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) BOOST_NOEXCEPT
+{
+    a.swap(b);
+}
+
+} // namespace ndnboost
+
+#endif  // #ifndef BOOST_SMART_PTR_SCOPED_ARRAY_HPP_INCLUDED
diff --git a/ndnboost/smart_ptr/scoped_ptr.hpp b/ndnboost/smart_ptr/scoped_ptr.hpp
new file mode 100644
index 0000000..7ee252b
--- /dev/null
+++ b/ndnboost/smart_ptr/scoped_ptr.hpp
@@ -0,0 +1,157 @@
+#ifndef BOOST_SMART_PTR_SCOPED_PTR_HPP_INCLUDED
+#define BOOST_SMART_PTR_SCOPED_PTR_HPP_INCLUDED
+
+//  (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+//  Copyright (c) 2001, 2002 Peter Dimov
+//
+//  Distributed under the Boost Software License, Version 1.0. (See
+//  accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//  http://www.boost.org/libs/smart_ptr/scoped_ptr.htm
+//
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/assert.hpp>
+#include <ndnboost/checked_delete.hpp>
+#include <ndnboost/smart_ptr/detail/sp_nullptr_t.hpp>
+#include <ndnboost/detail/workaround.hpp>
+
+#ifndef BOOST_NO_AUTO_PTR
+# include <memory>          // for std::auto_ptr
+#endif
+
+namespace ndnboost
+{
+
+// Debug hooks
+
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+
+void sp_scalar_constructor_hook(void * p);
+void sp_scalar_destructor_hook(void * p);
+
+#endif
+
+//  scoped_ptr mimics a built-in pointer except that it guarantees deletion
+//  of the object pointed to, either on destruction of the scoped_ptr or via
+//  an explicit reset(). scoped_ptr is a simple solution for simple needs;
+//  use shared_ptr or std::auto_ptr if your needs are more complex.
+
+template<class T> class scoped_ptr // noncopyable
+{
+private:
+
+    T * px;
+
+    scoped_ptr(scoped_ptr const &);
+    scoped_ptr & operator=(scoped_ptr const &);
+
+    typedef scoped_ptr<T> this_type;
+
+    void operator==( scoped_ptr const& ) const;
+    void operator!=( scoped_ptr const& ) const;
+
+public:
+
+    typedef T element_type;
+
+    explicit scoped_ptr( T * p = 0 ): px( p ) // never throws
+    {
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+        ndnboost::sp_scalar_constructor_hook( px );
+#endif
+    }
+
+#ifndef BOOST_NO_AUTO_PTR
+
+    explicit scoped_ptr( std::auto_ptr<T> p ) BOOST_NOEXCEPT : px( p.release() )
+    {
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+        ndnboost::sp_scalar_constructor_hook( px );
+#endif
+    }
+
+#endif
+
+    ~scoped_ptr() // never throws
+    {
+#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
+        ndnboost::sp_scalar_destructor_hook( px );
+#endif
+        ndnboost::checked_delete( px );
+    }
+
+    void reset(T * p = 0) // never throws
+    {
+        BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
+        this_type(p).swap(*this);
+    }
+
+    T & operator*() const // never throws
+    {
+        BOOST_ASSERT( px != 0 );
+        return *px;
+    }
+
+    T * operator->() const // never throws
+    {
+        BOOST_ASSERT( px != 0 );
+        return px;
+    }
+
+    T * get() const BOOST_NOEXCEPT
+    {
+        return px;
+    }
+
+// implicit conversion to "bool"
+#include <ndnboost/smart_ptr/detail/operator_bool.hpp>
+
+    void swap(scoped_ptr & b) BOOST_NOEXCEPT
+    {
+        T * tmp = b.px;
+        b.px = px;
+        px = tmp;
+    }
+};
+
+#if !defined( BOOST_NO_CXX11_NULLPTR )
+
+template<class T> inline bool operator==( scoped_ptr<T> const & p, ndnboost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
+{
+    return p.get() == 0;
+}
+
+template<class T> inline bool operator==( ndnboost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_NOEXCEPT
+{
+    return p.get() == 0;
+}
+
+template<class T> inline bool operator!=( scoped_ptr<T> const & p, ndnboost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
+{
+    return p.get() != 0;
+}
+
+template<class T> inline bool operator!=( ndnboost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_NOEXCEPT
+{
+    return p.get() != 0;
+}
+
+#endif
+
+template<class T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) BOOST_NOEXCEPT
+{
+    a.swap(b);
+}
+
+// get_pointer(p) is a generic way to say p.get()
+
+template<class T> inline T * get_pointer(scoped_ptr<T> const & p) BOOST_NOEXCEPT
+{
+    return p.get();
+}
+
+} // namespace ndnboost
+
+#endif // #ifndef BOOST_SMART_PTR_SCOPED_PTR_HPP_INCLUDED
diff --git a/ndnboost/smart_ptr/shared_array.hpp b/ndnboost/smart_ptr/shared_array.hpp
new file mode 100644
index 0000000..e5626f7
--- /dev/null
+++ b/ndnboost/smart_ptr/shared_array.hpp
@@ -0,0 +1,290 @@
+#ifndef BOOST_SMART_PTR_SHARED_ARRAY_HPP_INCLUDED
+#define BOOST_SMART_PTR_SHARED_ARRAY_HPP_INCLUDED
+
+//
+//  shared_array.hpp
+//
+//  (C) Copyright Greg Colvin and Beman Dawes 1998, 1999.
+//  Copyright (c) 2001, 2002, 2012 Peter Dimov
+//
+//  Distributed under the Boost Software License, Version 1.0. (See
+//  accompanying file LICENSE_1_0.txt or copy at
+//  http://www.boost.org/LICENSE_1_0.txt)
+//
+//  See http://www.boost.org/libs/smart_ptr/shared_array.htm for documentation.
+//
+
+#include <ndnboost/config.hpp>   // for broken compiler workarounds
+
+#if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
+#include <ndnboost/smart_ptr/detail/shared_array_nmt.hpp>
+#else
+
+#include <memory>             // TR1 cyclic inclusion fix
+
+#include <ndnboost/assert.hpp>
+#include <ndnboost/checked_delete.hpp>
+
+#include <ndnboost/smart_ptr/shared_ptr.hpp>
+#include <ndnboost/smart_ptr/detail/shared_count.hpp>
+#include <ndnboost/smart_ptr/detail/sp_nullptr_t.hpp>
+#include <ndnboost/detail/workaround.hpp>
+
+#include <cstddef>            // for std::ptrdiff_t
+#include <algorithm>          // for std::swap
+#include <functional>         // for std::less
+
+namespace ndnboost
+{
+
+//
+//  shared_array
+//
+//  shared_array extends shared_ptr to arrays.
+//  The array pointed to is deleted when the last shared_array pointing to it
+//  is destroyed or reset.
+//
+
+template<class T> class shared_array
+{
+private:
+
+    // Borland 5.5.1 specific workarounds
+    typedef checked_array_deleter<T> deleter;
+    typedef shared_array<T> this_type;
+
+public:
+
+    typedef T element_type;
+
+    shared_array() BOOST_NOEXCEPT : px( 0 ), pn()
+    {
+    }
+
+    template<class Y>
+    explicit shared_array( Y * p ): px( p ), pn( p, checked_array_deleter<Y>() )
+    {
+        ndnboost::detail::sp_assert_convertible< Y[], T[] >();
+    }
+
+    //
+    // Requirements: D's copy constructor must not throw
+    //
+    // shared_array will release p by calling d(p)
+    //
+
+    template<class Y, class D> shared_array( Y * p, D d ): px( p ), pn( p, d )
+    {
+        ndnboost::detail::sp_assert_convertible< Y[], T[] >();
+    }
+
+    // As above, but with allocator. A's copy constructor shall not throw.
+
+    template<class Y, class D, class A> shared_array( Y * p, D d, A a ): px( p ), pn( p, d, a )
+    {
+        ndnboost::detail::sp_assert_convertible< Y[], T[] >();
+    }
+
+//  generated copy constructor, destructor are fine...
+
+#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
+
+// ... except in C++0x, move disables the implicit copy
+
+    shared_array( shared_array const & r ) BOOST_NOEXCEPT : px( r.px ), pn( r.pn )
+    {
+    }
+
+    shared_array( shared_array && r ) BOOST_NOEXCEPT : px( r.px ), pn()
+    {
+        pn.swap( r.pn );
+        r.px = 0;
+    }
+
+#endif
+
+    // conversion
+
+    template<class Y>
+#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
+
+    shared_array( shared_array<Y> const & r, typename ndnboost::detail::sp_enable_if_convertible< Y[], T[] >::type = ndnboost::detail::sp_empty() )
+
+#else
+
+    shared_array( shared_array<Y> const & r )
+
+#endif
+    BOOST_NOEXCEPT : px( r.px ), pn( r.pn ) // never throws
+    {
+        ndnboost::detail::sp_assert_convertible< Y[], T[] >();
+    }
+
+    // aliasing
+
+    template< class Y >
+    shared_array( shared_array<Y> const & r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn( r.pn )
+    {
+    }
+
+    // assignment
+
+    shared_array & operator=( shared_array const & r ) BOOST_NOEXCEPT
+    {
+        this_type( r ).swap( *this );
+        return *this;
+    }
+
+#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400)
+
+    template<class Y>
+    shared_array & operator=( shared_array<Y> const & r ) BOOST_NOEXCEPT
+    {
+        this_type( r ).swap( *this );
+        return *this;
+    }
+
+#endif
+
+#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
+
+    shared_array & operator=( shared_array && r ) BOOST_NOEXCEPT
+    {
+        this_type( static_cast< shared_array && >( r ) ).swap( *this );
+        return *this;
+    }
+
+    template<class Y>
+    shared_array & operator=( shared_array<Y> && r ) BOOST_NOEXCEPT
+    {
+        this_type( static_cast< shared_array<Y> && >( r ) ).swap( *this );
+        return *this;
+    }
+
+#endif
+
+    void reset() BOOST_NOEXCEPT
+    {
+        this_type().swap( *this );
+    }
+
+    template<class Y> void reset( Y * p ) // Y must be complete
+    {
+        BOOST_ASSERT( p == 0 || p != px ); // catch self-reset errors
+        this_type( p ).swap( *this );
+    }
+
+    template<class Y, class D> void reset( Y * p, D d )
+    {
+        this_type( p, d ).swap( *this );
+    }
+
+    template<class Y, class D, class A> void reset( Y * p, D d, A a )
+    {
+        this_type( p, d, a ).swap( *this );
+    }
+
+    template<class Y> void reset( shared_array<Y> const & r, element_type * p )
+    {
+        this_type( r, p ).swap( *this );
+    }
+
+    T & operator[] (std::ptrdiff_t i) const // never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
+    {
+        BOOST_ASSERT(px != 0);
+        BOOST_ASSERT(i >= 0);
+        return px[i];
+    }
+    
+    T * get() const BOOST_NOEXCEPT
+    {
+        return px;
+    }
+
+// implicit conversion to "bool"
+#include <ndnboost/smart_ptr/detail/operator_bool.hpp>
+
+    bool unique() const BOOST_NOEXCEPT
+    {
+        return pn.unique();
+    }
+
+    long use_count() const BOOST_NOEXCEPT
+    {
+        return pn.use_count();
+    }
+
+    void swap(shared_array<T> & other) BOOST_NOEXCEPT
+    {
+        std::swap(px, other.px);
+        pn.swap(other.pn);
+    }
+
+    void * _internal_get_deleter( ndnboost::detail::sp_typeinfo const & ti ) const
+    {
+        return pn.get_deleter( ti );
+    }
+
+private:
+
+    template<class Y> friend class shared_array;
+
+    T * px;                     // contained pointer
+    detail::shared_count pn;    // reference counter
+
+};  // shared_array
+
+template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT
+{
+    return a.get() == b.get();
+}
+
+template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT
+{
+    return a.get() != b.get();
+}
+
+#if !defined( BOOST_NO_CXX11_NULLPTR )
+
+template<class T> inline bool operator==( shared_array<T> const & p, ndnboost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
+{
+    return p.get() == 0;
+}
+
+template<class T> inline bool operator==( ndnboost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_NOEXCEPT
+{
+    return p.get() == 0;
+}
+
+template<class T> inline bool operator!=( shared_array<T> const & p, ndnboost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
+{
+    return p.get() != 0;
+}
+
+template<class T> inline bool operator!=( ndnboost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_NOEXCEPT
+{
+    return p.get() != 0;
+}
+
+#endif
+
+template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) BOOST_NOEXCEPT
+{
+    return std::less<T*>()(a.get(), b.get());
+}
+
+template<class T> void swap(shared_array<T> & a, shared_array<T> & b) BOOST_NOEXCEPT
+{
+    a.swap(b);
+}
+
+template< class D, class T > D * get_deleter( shared_array<T> const & p )
+{
+    return static_cast< D * >( p._internal_get_deleter( BOOST_SP_TYPEID(D) ) );
+}
+
+} // namespace ndnboost
+
+#endif  // #if defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
+
+#endif  // #ifndef BOOST_SMART_PTR_SHARED_ARRAY_HPP_INCLUDED
