'link/language'에 해당되는 글 21건
- 2018.03.12 Return Value Optimization
- 2018.03.06 c++ move semantics
- 2016.12.23 Binary-compatible C++ Interfaces
- 2015.11.24 Standard Library Locales
- 2015.11.02 iostream & UTF8
- 2015.08.05 C++11 - the new ISO C++ standard
- 2015.06.17 explanation of bind, placeholder
- 2013.01.22 c++ Optimization
- 2011.08.02 Advanced STL
- 2009.02.09 assembly
Binary-compatible C++ Interfaces
// Window.h class Window { public: virtual void CALL destroy() = 0; virtual void CALL setTitle(const char* title) = 0; virtual const char* CALL getTitle() = 0; void operator delete(void* p) { if (p) { Window* w = static_cast<Window*>(p); w->destroy(); } } }; extern "C" Window* CALL CreateWindow(const char* title);
// Window.cpp #include <string> #include <windows.h> #include "DefaultDelete.h" class WindowImpl : public DefaultDelete<Window> { public: WindowImpl(HWND window) { m_window = window; } ~WindowImpl() { DestroyWindow(m_window); } void CALL destroy() { delete this; } void CALL setTitle(const char* title) { SetWindowText(m_window, title); } const char* CALL getTitle() { char title[512]; GetWindowText(m_window, title, 512); m_title = title; // save the title past the call return m_title.c_str(); } private: HWND window; std::string m_title; }; Window* CALL CreateWindow(const char* title) { // create the Win32 window object HWND window = ::CreateWindow(..., title, ...); return (window ? new WindowImpl(window) : 0); }// DefaultDelete.h
template<typename T> class DefaultDelete : public T { public: void operator delete(void* p) { ::operator delete(p); } };
How Do Those Funky Placeholders Work?
bind, placeholder ...
http://www.tantalon.com/pete/cppopt/main.htm
c++ Optimization 에 대한 정리 글