Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. abstract class ICacheable
  2. {
  3.    virtual void cache() = 0;
  4. }
  5.  
  6. template <bool Caching = false>
  7. class Cacheable : public ICacheable
  8. {
  9.    inline void cache() {}
  10. }
  11.  
  12. template <>
  13. class Cacheable<true> : public ICacheable
  14. {
  15.    inline void cache() { /* ... */ }
  16. }
  17.  
  18. class Scheduler
  19. {
  20.    inline static ICacheable new(bool isCacheable)
  21.    {
  22.       return (isCacheable)? new Cacheable<true> : Cacheable<false>;
  23.    }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement