Designing a generic C++1z class I'm designing a generic interface for a MessageEntry class for a .h file. 

I'm looking for guidance on form and terminology (would I call this an interface/template/generic class?):

#ifndef cppmq_message_types_h
#define cppmq_message_types_h

template &lt;class T&gt;
struct MessageEntry {
 public:
  MessageEntry&lt;T&gt;() {}
  MessageEntry&lt;T&gt;(T data) : data(data) {
    creation_time =
        std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
  }
  time_t CreationTime() { return creation_time; }

 private:
  T data;
  time_t creation_time;
};

#endif`
There are several problems with this code, starting from the fact that it is syntactically invalid. Getting past that, you have no access to your data, which makes it somewhat pointless, and the only way to construct a MessageEntry is to preconstruct a T, then copy it into the MessageEntry constructor, then copy it again into data. That can be unnecessarily expensive, and then you're not actually timestamping when you constructed the original object - you're timestamping two copies later.

You definitely want to be able to support in-place construction and you definitely want easy access to the data. Fortunately, you can solve both problems in one go with just simple inheritance:

template &lt;typename T, typename Clock=std::chrono::system_clock&gt;
struct MessageEntry : T
{
    using T::T;
    decltype(Clock::now()) creation_time = Clock::now();
};


That's... it. I added a second template argument in case your users want a different clock (e.g. std::chrono::steady_clock). I intentionally left creation_time non-const so as to make the class copyable. If you don't need this to be copyable, then I would write it as:

template &lt;typename T, typename Clock=std::chrono::system_clock&gt;
struct MessageEntry : T
{
    using T::T;
    const decltype(Clock::now()) creation_time = Clock::now();

    MessageEntry(MessageEntry const&amp; ) = delete;
    MessageEntry&amp; operator=(MessageEntry const&amp; ) = delete;
};


It might be worth renaming the class to something that adds clarity to its intent. Perhaps WithCreationTime.

Lastly, I would prefer #pragma once just to be able to write less code for include guards, and you are missing your #include for &lt;chrono&gt;. 

Full solution:

#pragma once

#include &lt;chrono&gt;

template &lt;typename T,
          typename Clock = std::chrono::system_clock&gt;
struct WithCreationTime : T
{
    using T::T;
    decltype(Clock::now()) creation_time = Clock::now();
};


Example usage:

WithCreationTime&lt;std::vector&lt;int&gt;&gt; v{1, 2, 3, 4};
std::cout &lt;&lt; v.size() &lt;&lt; '\n'; // 4
std::cout &lt;&lt; v.creation_time &lt;&lt; '\n'; // whatever now() is