2018. 3. 12. 21:09

Return Value Optimization

Const, Move and RVO

2018. 3. 6. 18:40

c++ move semantics

Intro to smart pointers and move semantics


Value categories

2016. 12. 23. 16:46

Binary-compatible C++ Interfaces

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);
  }
};


2015. 11. 24. 15:43

Standard Library Locales

2015. 11. 2. 17:28

iostream & UTF8

2015. 8. 5. 14:41

C++11 - the new ISO C++ standard

2015. 6. 17. 13:24

explanation of bind, placeholder

2013. 1. 22. 17:53

c++ Optimization

http://www.tantalon.com/pete/cppopt/main.htm

c++ Optimization 에 대한 정리 글

2011. 8. 2. 16:49

Advanced STL

2009. 2. 9. 09:24

assembly