joboccara / NamedType

Implementation of strong types in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use "final" if available

DBJDBJ opened this issue · comments

commented

I might be so bold, as to suggest this...

   #ifdef __cpp_lib_is_final
        #define FLUENT_FINAL final
 #else
       #define FLUENT_FINAL
 #endif

Little optimization and big, clear message from interface author:

         template <
                       typename T, 
                       typename Parameter, 
                       template<typename> class... Skills
                   >
      class FLUENT_EBCO NamedType FLUENT_FINAL
            : public Skills<NamedType<T, Parameter, Skills...>>...
       {
       } ;

Regards ...

I disagree. Declaring your named type like this seems like a valid strategy to me:

using namespace fluent;
struct MyType : public NamedType<int, Addable, Comparable> {
  using NamedType<int, Addable, Comparable>::NamedType;
  // Potentially add other, special capabilities
};

It also has the bonus of shortening your compiler's error messages if you used a lot of "skills".

commented

Huh? What is the connection with having or not having final?

I'm not quite sure what you're asking, but marking the NamedType class as final would mean that the above example code fails to compile.