Function template specialization to force enum value with type
<p>A function is required to send messages, given a message type and a data structure of a type specific to the message type:</p>

<pre><code>enum class MsgType
{
    msgInt,
    msgDouble,
    msgString
};

template &lt; some template here &gt;
void sendMessage(MsgType type, T value);
</code></pre>

<p>I expect to call this function in the following way:</p>

<pre><code>sendMessage( MsgType::msgInt, 42 );
sendMessage( MsgType::msgString, "Answer to the life, etc,etc.");
//sendMessage( MsgType::msgDouble, "Should not compile");
//sendMessage&lt;MsgType::msgString&gt;( "That is easy!" );
</code></pre>

<p>How could I implement the previously described template function specialization?</p>

<p>Note: If possible, with C++11, but C++14 is also acceptable.</p>

<p>EDITED: </p>

<p>The current implementation, which only accept the MsgType as template parameter (not as function parameter).</p>

<pre><code>template&lt;MsgType Id, typename T&gt;
void sendMessage(T data);

template&lt;&gt;void sendMesssage&lt;MsgType::msgNumCar, int&gt;( int data ){ //...   }
template&lt;&gt;void sendMesssage&lt;MsgType::msgInt, int&gt;( int data ){ //...   }
template&lt;&gt;void sendMesssage&lt;MsgType::msgString, string&gt;( string data ){ //...   }
// A call
sendMessage&lt;MsgType::msgNumCar&gt;( 42 );
</code></pre>