File: cpp_function_lib.h

package info (click to toggle)
cython 3.1.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,932 kB
  • sloc: python: 92,172; ansic: 19,275; cpp: 1,407; xml: 1,031; javascript: 511; makefile: 373; sh: 223; sed: 11
file content (35 lines) | stat: -rw-r--r-- 758 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef CPP_FUNCTION_LIB_H
#define CPP_FUNCTION_LIB_H

#include <functional>

// Functions, functor and a holder of std::function used by cpp_stl_function.pyx tests.

double add_one(double a, int b);
double add_two(double a, int b);

class AddAnotherFunctor
{
    double to_add;

public:
    AddAnotherFunctor(double to_add);
    double operator()(double a, int b) const;
};


class FunctionKeeper
{
    std::function<double(double, int)> my_function;

public:
    FunctionKeeper(std::function<double(double, int)> user_function);
    virtual ~FunctionKeeper();

    void set_function(std::function<double(double, int)> user_function);
    std::function<double(double, int)> get_function() const;

    double call_function(double a, int b) const;
};

#endif