在我的代码中有这样的东西:
shared_ptr<vector<unsigned int>> f =
make_shared<vector<unsigned int>>();
Run Code Online (Sandbox Code Playgroud)
我怎样才能打印出我只能访问shared_ptr对象的向量
frame variable f
Run Code Online (Sandbox Code Playgroud)
和
frame variable f.__ptr_->size()
call to a function 'std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >::size() const' that is not present in the target
Run Code Online (Sandbox Code Playgroud)
得到这个错误?
这是我实现Knuth算法M的C++代码,它生成混合基数:
#include "visit.h"
void algorithmM(vector<int>& m)
{
m.insert(m.begin(),2);
const int n=m.size();
vector<int> a(n,0);
M2:
visit(false,a);
int j=n-1;
M4:
if (a[j]==m[j]-1) {a[j]=0;--j;goto M4;}
if (j==0) return;
else {a[j]++;goto M2;}
}
int main()
{
vector<int> m;
int i;
while(std::cin>>i)
{if(i<0) continue;
m.push_back(i);
}
algorithmM(m);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是"visit.h"的代码:
#include <iostream>
#include <vector>
using std::vector;
using std::cout;
template<class T> void visit(bool first,vector<T>& l)
{
size_t dt=first?0:1;
for(typename vector<T>::iterator i=l.begin()+dt;i!=l.end();++i)
cout<<*i;
cout<<'\n';
}
Run Code Online (Sandbox Code Playgroud)
C++代码非常接近Knuth的伪代码.现在,这是使用可变数组的命令式Haskell实现:
import Data.Array.IO
import Control.Monad.State
import Data.IORef
data CountList = CountList …Run Code Online (Sandbox Code Playgroud) 我正在寻找numpy.where与scipy offers(scipy.sparse)的稀疏表示一起使用的等价物.是否有任何东西可以让你处理这些矩阵,就好像你在哪里使用if-then-else语句一样?
UPDATE
更具体:我需要where一个IF-THEN-ELSE vectorialized功能,即在这样的任务,因为这等于K的矩阵A的每个值,放在矩阵B对应的值,否则C.你可以使用类似find来检索满足逻辑条件的那些条目的索引,然后否定它们以找到所有剩余的条目,但对于稀疏矩阵,是不是有更紧凑的方法?
如何在objective-c中构思2个字符串,就像在VB.net中一样,你可以做"foo"和"bar"