根據this的鏈接,gcc提供了很多有趣的內存分配器來與STL容器一起使用,但是如果我在創建std :: list時沒有指定一個,默認情況下會使用它?GCC用於STL的默認分配器是什麼?
4
A
回答
6
3
作爲每維基:「的默認分配器使用操作者新分配內存[13]這通常實現爲圍繞C堆中分配函數的薄層,[14],其通常用於大不頻繁分配優化。存儲器塊」
從 「ISO/IEC(2003)ISO/IEC 14882:2003(E):編程語言 - C++」(維基參考)
默認分配器:
namespace std {
template <class T> class allocator;
// specialize for void: template <> class allocator<void>
{
public:
typedef void* pointer;
typedef const void* const_pointer;
// reference-to-void members are impossible. typedef void value_type;
template <class U> struct rebind { typedef allocator<U> other; };
};
template <class T> class allocator
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef T template value_type;
template <class U> struct rebind { typedef allocator<U> other;
};
allocator() throw();
allocator(const allocator&) throw();
template <class U> allocator(const allocator<U>&) throw();
̃allocator() throw();
pointer address(reference x) const;
const_pointer address(const_reference x) const;`
pointer allocate(
size_type, allocator<void>::const_pointer hint = 0);
void deallocate(pointer p, size_type n);
size_type max_size() const throw();
void construct(pointer p, const T& val);
void destroy(pointer p);
};
}
相關問題
- 1. 替換默認的STL分配器
- 2. 什麼分配器在STL
- 3. 什麼是默認的PHP配置?
- 4. SGI STL默認分配器有內存泄漏嗎?
- 5. 爲什麼這個C++ STL分配器沒有分配?
- 6. 哪個是G ++ 4.4.1默認分配器?
- 7. 爲什麼close_on_exec不是默認配置?
- 8. OWIN託管web api時分配的默認端口是什麼?
- 9. 管理參數默認分配的規則是什麼?
- 10. 什麼是Z3的默認解算器?
- 11. 竹神器分享 - 什麼是默認分支
- 12. 什麼是默認的TransformerFactory?
- 13. 什麼是默認的MaxPoolSize?
- 14. STL容器的默認初始化
- 15. STL的TCMalloc分配器
- 16. 什麼是PHImageRequestOptionsResizeMode默認值?
- 17. UnityContainer:什麼是默認lifetimemanager
- 18. 什麼是默認goroutine?
- 19. 爲什麼UIBarButtonItem默認是禁用的?
- 20. ASP.net中用於用戶登錄的默認機制是什麼?
- 21. 爲什麼默認的控制適配器映射不適用於Chrome或Safari?
- 22. 默認GCC架構
- 23. Python的io.open()用作默認分隔符是什麼?
- 24. 在分配器感知的STL類中,爲什麼分配器不是模板模板參數?
- 25. 什麼是GCC
- 26. C++ STL問題:分配器
- 27. 什麼是MSVC相當於gcc的-Wundef?
- 28. STL中是否有默認的計數器對象
- 29. 使用基於動態/狀態的分配器的STL實現?
- 30. 什麼是「self.default =默認,如果默認其他類型()」是什麼意思?
我想象編譯器不會做關於內存分配器的_anything_;我期望它將所有的內存分配給鏈接器/加載器和運行庫'libc'和'libstdC++'庫。 – sarnold 2011-06-10 02:09:18