Click here to Skip to main content
12,396,461 members (41,638 online)
Click here to Skip to main content

Stats

24.3K views
205 downloads
43 bookmarked
Posted

Session of low-level optimization of memory usage in C++ programs with total exposure

, , 22 Jun 2009 CPOL
In this article, we will try to make our algorithms work faster using the methods of low-level optimization of memory allocation in C++.
#ifndef CRT_STL_ALLOCATORS_H
#define CRT_STL_ALLOCATORS_H

#include "crt_allocators.h"
#include "map"
#include "list"
#include "vector"
#include "set"

namespace utils
{

template<class KeyType, class ValueType>
struct crt_map
{
    typedef  std::map<KeyType,
                      ValueType,
                      std::less<KeyType>,
                      utils::factory<
                                    utils::crt_allocator,    // allocator type
                                    utils::without_params      // this type cannot use params
                                >
                                ::result
                                <
                                    std::pair<
                                                const KeyType,
                                                ValueType
                                            >
                                >
    > result;
};

template<class KeyType>
struct crt_set
{
    typedef  std::set<KeyType,
                      std::less<KeyType>,
                      utils::factory<
                                    utils::crt_allocator,    // allocator type
                                    utils::without_params      // this type cannot use params
                                >
                                ::result
                                <
                                    const KeyType
                                >
    > result;
};

template<class ValueType>
struct crt_list
{
    typedef  std::list<ValueType,
                      utils::factory<
                                    utils::crt_allocator,    // allocator type
                                    utils::without_params      // this type cannot use params
                                >
                                ::result
                                <
                                    ValueType
                                >
    > result;
};

template<class ValueType>
struct crt_vector
{
    typedef  std::vector<ValueType,
                      utils::factory<
                                    utils::crt_allocator,    // allocator type
                                    utils::without_params      // this type cannot use params
                                >
                                ::result
                                <
                                    ValueType
                                >
    > result;
};



} // utils

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Authors

No Biography provided

Apriorit Inc
Apriorit Inc.
Hungary Hungary
ApriorIT is a Software Research and Development company that works in advanced knowledge-intensive scopes.

Company offers integrated research&development services for the software projects in such directions as Corporate Security, Remote Control, Mobile Development, Embedded Systems, Virtualization, Drivers and others.

Official site http://www.apriorit.com
Group type: Organisation

32 members


You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160721.1 | Last Updated 23 Jun 2009
Article Copyright 2009 by Victor A. Milokum, Apriorit Inc
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid