Ignore:
Timestamp:
2018-07-05T21:41:17Z (7 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b6d68a3
Parents:
de89870
git-author:
Jaroslav Jindrak <dzejrou@…> (2017-10-22 17:02:19)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:17)
Message:

cpp: added mostly functioning version of std::vector, but inserts currently reallocate everytime

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/impl/memory.hpp

    rde89870 r35584b19  
    3939     */
    4040
    41     template<class T>
     41    template<class Ptr>
    4242    struct pointer_traits
    4343    {
    44         // TODO:
     44        using pointer = Ptr;
     45        // TODO: element type, difference type
     46
     47        // TODO: this is conditional, see standard
     48        template<class U>
     49        using rebind = typename Ptr::template rebind<U>;
    4550    };
    4651
     
    180185        using pointer = typename aux::get_pointer<Alloc>::type;
    181186        using const_pointer = typename aux::get_const_pointer<Alloc, pointer>::type;
    182         using void_pointer = typename aux::get_void_pointer<Alloc, pointer>::type;
    183         using const_void_pointer = typename aux::get_const_void_pointer<Alloc, pointer>::type;
     187        // TODO: fix void pointer typedefs
     188        /* using void_pointer = typename aux::get_void_pointer<Alloc, pointer>::type; */
     189        /* using const_void_pointer = typename aux::get_const_void_pointer<Alloc, pointer>::type; */
     190        using void_pointer = void*;
     191        using const_void_pointer = const void*;
    184192        using difference_type = typename aux::get_difference_type<Alloc, pointer>::type;
    185193        using size_type = typename aux::get_size_type<Alloc, difference_type>::type;
     
    279287            using is_always_equal                        = true_type;
    280288
    281             allocator() noexcept;
    282 
    283             allocator(const allocator&) noexcept;
     289            allocator() noexcept = default;
     290
     291            allocator(const allocator&) noexcept = default;
    284292
    285293            template<class U>
    286             allocator(const allocator<U>&) noexcept;
     294            allocator(const allocator<U>&) noexcept
     295            {
     296                // TODO: implement
     297            }
    287298
    288299            ~allocator() = default;
     
    303314                 * Note: The usage of hint is unspecified.
    304315                 *       TODO: Check HelenOS hint allocation capabilities.
     316                 * TODO: assert that n < max_size()
    305317                 */
    306                 return ::operator new(n);
     318                return static_cast<pointer>(::operator new(n * sizeof(value_type)));
    307319            }
    308320
Note: See TracChangeset for help on using the changeset viewer.