您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

用于提升python的指针参数

5b51 2022/1/14 8:21:28 python 字数 1892 阅读 521 来源 www.jb51.cc/python

使用指针作为参数的函数使用boost python的最佳方法是什么?我看到文档中有很多返回值的可能性,但我不知道如何用参数来做.void Tesuto::testp(std::string* s) { if (!s) cout << ' NULL s' << endl; else cou

概述

使用指针作为参数的函数使用boost python的最佳方法是什么?
我看到文档中有很多返回值的可能性,但我不知道如何用参数来做.

void Tesuto::testp(std::string* s)
{
    if (!s)
        cout << " NULL s" << endl;
    else
        cout << s << endl;
}

>>> t.testp(None)
 NULL s
>>>       
>>> s='test'
>>> t.testp(s)
Traceback (most recent call last):
  File "
  

编辑:你可以像这样添加一个包装函数

 
std::string * pointer (std::string& p)
{
    return &p;
}

然后调用您的代码


>>> s = 'hello'
>>> t.testp (pointer (s))
hello
>>>

总结

以上是编程之家为你收集整理的用于提升python的指针参数全部内容,希望文章能够帮你解决用于提升python的指针参数所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶