根據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. 爲什麼這個C++ STL分配器沒有分配?
- 7. 爲什麼close_on_exec不是默認配置?
- 8. 哪個是G ++ 4.4.1默認分配器?
- 9. 管理參數默認分配的規則是什麼?
- 10. 什麼是軌質量分配的默認行爲
- 11. OWIN託管web api時分配的默認端口是什麼?
- 12. 什麼是Z3的默認解算器?
- 13. 竹神器分享 - 什麼是默認分支
- 14. 什麼是默認的MaxPoolSize?
- 15. 什麼是默認的TransformerFactory?
- 16. STL容器的默認初始化
- 17. STL的TCMalloc分配器
- 18. 什麼是用於分配在DLL
- 19. 爲什麼不是默認
- 20. UnityContainer:什麼是默認lifetimemanager
- 21. 什麼是Page.ResponseEncoding默認值?
- 22. 什麼是GOMAXPROCS默認值
- 23. 什麼是AdMob默認ID?
- 24. 什麼是ContinueWith默認值
- 25. 什麼是PHImageRequestOptionsResizeMode默認值?
- 26. WebRequest.Proxy - 什麼是默認值
- 27. 什麼是默認goroutine?
- 28. 爲什麼UIBarButtonItem默認是禁用的?
- 29. ASP.net中用於用戶登錄的默認機制是什麼?
- 30. 爲什麼默認的控制適配器映射不適用於Chrome或Safari?
我想象編譯器不會做關於內存分配器的_anything_;我期望它將所有的內存分配給鏈接器/加載器和運行庫'libc'和'libstdC++'庫。 – sarnold 2011-06-10 02:09:18