Question about explicit instantiation in ofColor

At the bottom of ofColor.cpp there are some explicit instantiations

But why do we using it, could it increase the effient of the program?

usually templated classes need to have their implementation in the .h file and will only create actual machine code when instantiated with a certain type.

in order to be able to move the implementation in the cpp file, to make the header cleaner and the compile times shorter, we instantiate ofColor for all the possible types so the library contains the symbols for all of them

3 Likes

Thanks a lot!That really help me to solve the problem.