Help us understand the problem. What is going on with this article?

CREATE_FUNCマクロを引数付きinitに対応させた

More than 5 years have passed since last update.

CREATE_FUNCマクロを少しだけ改造。
initの引数を好きに宣言できます。

それ以外はCREATE_FUNCとまったく同じ使い方です。
(できるだけ元のCREATE_FUNCのコードを使っています)

マクロ名はお好きに変えてください。

#define CREATE_FUNC_ARGS(__TYPE__) \
template<class... Args> \
static __TYPE__* create(Args&&... args) \
{ \
    __TYPE__ *pRet = new(std::nothrow) __TYPE__(); \
    if (pRet && pRet->init(std::forward<Args>(args)...)) \
    { \
        pRet->autorelease(); \
        return pRet; \
    } \
    else \
    { \
        delete pRet; \
        pRet = NULL; \
        return NULL; \
    } \
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away