make THPPointer have explicit constructors (#1636)

This commit is contained in:
Trevor Killeen
2017-05-25 15:35:54 -04:00
committed by Soumith Chintala
parent 6a7c56499c
commit 05bc877a05
22 changed files with 117 additions and 117 deletions

View File

@ -37,7 +37,7 @@ bool THPUtils_tryUnpackLongs(PyObject *arg, THLongStoragePtr& result) {
bool list = PyList_Check(arg);
if (tuple || list) {
int nDim = tuple ? PyTuple_GET_SIZE(arg) : PyList_GET_SIZE(arg);
THLongStoragePtr storage = THLongStorage_newWithSize(nDim);
THLongStoragePtr storage(THLongStorage_newWithSize(nDim));
for (int i = 0; i != nDim; ++i) {
PyObject* item = tuple ? PyTuple_GET_ITEM(arg, i) : PyList_GET_ITEM(arg, i);
if (!THPUtils_checkLong(item)) {
@ -45,7 +45,7 @@ bool THPUtils_tryUnpackLongs(PyObject *arg, THLongStoragePtr& result) {
}
storage->data[i] = THPUtils_unpackLong(item);
}
result = storage.release();
result = std::move(storage);
return true;
}
return false;
@ -136,14 +136,14 @@ static const char* classOrTypename(PyObject* obj) {
PyObject * THPUtils_dispatchStateless(
PyObject *tensor, const char *name, PyObject *args, PyObject *kwargs)
{
THPObjectPtr methods = PyObject_GetAttrString(tensor, THP_STATELESS_ATTRIBUTE_NAME);
THPObjectPtr methods(PyObject_GetAttrString(tensor, THP_STATELESS_ATTRIBUTE_NAME));
if (!methods) {
return PyErr_Format(
PyExc_TypeError,
"Type %s doesn't implement stateless methods",
classOrTypename(tensor));
}
THPObjectPtr method = PyObject_GetAttrString(methods, name);
THPObjectPtr method(PyObject_GetAttrString(methods, name));
if (!method) {
return PyErr_Format(
PyExc_TypeError,