constant sized circular (ring) buffer
Type aliases


The container alias is never used, it can be removed.
The const_reference alias is wrong, it is still an alias to T&amp;.
Use a consistent aliasing scheme, only use T when aliasing value_type.
Provide a const_pointer alias.


With these points in mind, your type aliases become:

using value_type = T;
using reference = value_type&amp;;
using const_reference = value_type const&amp;; // is now actually reference-to-const alias
using pointer = value_type*; // use value_type alias
using const_pointer = value_type const*; // for iterators, casting, etc.
using size_type = std::size_t;


Consider the rule of 5 when your class manages a resource.

Whenever your class manages a resource, it probably needs to implement the destructor, copy and move operations. You definitely do not want pointers to be copied when a copy of circular_buffer&lt;&gt; is made. Possible issues:


Memory being freed twice.
Dangling references.
Invalid object states.


Use static memory when the size is known at compile-time.

This will be more efficient and exception-free during allocation. Possible replacement:

#include &lt;type_traits&gt;
std::aligned_storage_t&lt;mcapacity * sizeof( T ), alignof( T )&gt; data;


Now that you are using static memory, you can provide two private functions to avoid having to use ugly casts everywhere:

T* data() { return reinterpret_cast&lt;T*&gt;( &amp;data ); }
T const* data() const { return reinterpret_cast&lt;T const*&gt;( &amp;data ); }


Your constructor becomes:

circular_buffer() noexcept /* no exceptions with static memory allocation */ :
    /* members reordered to match class */
    begin( data() ),
    end( begin ),
    msize( 0 ),
    is_empty( false )
{}



We now explicitly initialize is_empty in the constructor initializer list. I think this is clearer.
To avoid weird bugs, members are initialized in the same order that they
are declared in the class.
If your class needs really big chunks of memory that aren't available statically, then don't make the capacity a template parameter: make it a constructor parameter.


Use universal references in the definition of emplace().

This avoids unnecessary copying of arguments. Replacement:

template &lt;typename... ArgTypes&gt;
void emplace( ArgTypes&amp;&amp;... args ); // variadic template of universal references


This change requires that we also perfect-forward these universal references wherever they may be used:

T{ std::forward&lt;ArgTypes&gt;( args )... }; // perfect-forward example


Use std::move() when you're finished with rvalue arguments.

In push( T&amp;&amp; ), argument value is actually used as an T const&amp; (which calls the copy constructor) because you forget to call std::move(). The fix is simple:

end-&gt;T( value );


Becomes:

end-&gt;T( std::move( value ) );


Factor out repeated code.

Your push() overloads and emplace() have the exact same block of code being repeated; this block is a prime candidate for being extracted into a private function:

void tidy() noexcept // feel free to use a descriptive function name
{ // the repeating block of code
    ++end;

    if ( end == data + mcapacity )
        end = data;

    if ( msize != mcapacity )
        ++msize;
}


After modifications, emplace() and push() now look like this:

template &lt;typename... ArgTypes&gt;
void emplace( ArgTypes&amp;&amp;... args )
{
    ::new ( end ) T( std::forward&lt;ArgTypes&gt;( args )... );
    tidy();
}

void push( T const&amp; value )
{
    ::new ( end ) T( value );
    tidy();
}

void push( T&amp;&amp; value )
{
    ::new ( end ) T( std::move( value ) );
    tidy();
}


Note the consistent use of the same construction approach (placement-new) which looks nice and prevents syntax issues with primitive types.

Mark functions as noexcept when appropriate.

Non-throwing functions of yours include size(), capacity() and a few more. This will help programmers know that certain functions do not throw, which can help with optimizations.

For compile-time conditional noexcept marking, use type traits. Here's a sample:

template &lt;typename... ArgTypes&gt;
void emplace( ArgTypes&amp;&amp;... args )
noexcept( std::is_nothrow_constructible&lt;T, ArgTypes&amp;&amp;...&gt;::value )
{ /* ... */ }


Mark non-modifying functions as const.

const functions of yours include front(), size() and a few more. Member functions that don't modify any of the class data members should be marked as const so that they can be used in the appropriate scenario (accessed through a circular_buffer&lt;&gt; const&amp;).