Ask Your Question

jdoolitt's profile - activity

2021-04-09 15:15:08 +0200 received badge  Famous Question (source)
2021-04-09 15:15:08 +0200 received badge  Notable Question (source)
2021-04-09 15:15:08 +0200 received badge  Popular Question (source)
2020-02-15 11:01:45 +0200 asked a question How can you import C++ code into a Jupyter notebook?

I have a c++ function that I would like to use with Jupyter. I'd like to be able to call it from the main python thread. A minimal example would be something like the following:

#begin c code definition

#include <vector>
#include <iostream>
void printout(std::vector<int> input){
    std::vector<int>::iterator start;
    std::vector<int>::iterator end;
    end=input.end();
    for (start=input.begin();start!=end;++start){
        std::cout<< *start;
    }
    std::cout<< std::endl;
}

int main(){
    std::vector<int> sample{1,2,3};
    printout(sample);
    return 0;
}

#switch back to python
printout((1,2,3))

I don't particularly need to call the function or run the main thread in C++, the main() is included to show how this function would be used in the C++ context. Broadly, I want something like the reverse of Cythonize