I have a class for holding a list of rgb colors in a particular way, and I'm interested in making a class that inherits the original, but instead of storing all the colors, trying to access the list runs a function to generate one on the fly.
struct rgb {unsigned char r,g,b};
subclass {
std::function<rgb(int)> create_color;
public:
subclass(std::function<rgb(int)> job){
create_color = job;
}
get_color () {
}
};
superclass {
subclass* colorlist;
public:
superclass () {
colorlist = new subclass([this] (int x) { //would like some way for "this" to be the subclass object
return hsv_to_rgb(x % 360, 1.0, 1.0);
}
}
}
I recognize that I could define the function like std::function<rgb(int,&subclass)> and then pass this as a variable, but it can be entirely transparent when using [this] in the lambda definition