Skip to content

Instantly share code, notes, and snippets.

@define-private-public
Last active April 16, 2024 23:30
Show Gist options
  • Save define-private-public/e93c4bbb89482d5d07e36eed104f92a2 to your computer and use it in GitHub Desktop.
Save define-private-public/e93c4bbb89482d5d07e36eed104f92a2 to your computer and use it in GitHub Desktop.
C++ `final` keyword experiment (TODO blog link)
option(WITH_FINAL "Use the `final` specifier on derived classes (faster?)" OFF)
# ...
if (WITH_FINAL)
message(STATUS "Using `final` spicifer (faster?)")
target_compile_definitions(PSRayTracing_StaticLibrary PUBLIC USE_FINAL)
else()
message(STATUS "Turned off use of `final` (slower?)")
endif()
#ifdef USE_FINAL
#define FINAL final
#else
#define FINAL
#endif
$ rg FINAL
RandomGenerator.hpp
185:class RandomGenerator FINAL : public _GeneralizedRandomGenerator<std::uniform_real_distribution, rreal, RNG_ENGINE> {
Materials/Lambertian.hpp
8:class Lambertian FINAL : public IMaterial {
...
Materials/SurfaceNormal.hpp
7:class SurfaceNormal FINAL : public IMaterial {
...
PDFs/HittablePDF.hpp
7:class HittablePDF FINAL : public IPDF {
...
Objects/Sphere.hpp
19:class Sphere FINAL : public IHittable {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment