Generic Producer-Consumer in C++11
Buffer&lt;T&gt;

This class seems fine for the most part. Some small issues:


The while(true) loops in insert(T) and remove() only ever run one iteration. Those loops can be replaced by their body.
add calls m_buffer.push_back(x), which might not compile for types without a copy constructor. Try m_buffer.push_back(std::move(x)) instead: That will move if possible, and fall back to copy if not.
m_buffer is treated like a stack (push_back and pop_back are used only), so newest insertions get removed first. Maybe a queue was intended (using e.g. push_front and pop_back)?
The constructors initialize Buffer&lt;T&gt;::m_size (an unsigned int) with a signed value (1 or int s, respectively).
notify_all() is called on the condition variable. This would wake up every thread waiting on it - but very likely only one would actually be able to do anything. notify_one() would likely be a better fit.
The notify_all calls on the condition variable aren't needed every time: remove only needs to notify if other threads might be waiting to add elements, which is only when m_buffer.size() == m_size - 1 after the call to pop_back. Similarly, add only needs to notify if m_buffer.size() == 1 after push_front.
Buffer&lt;T&gt;::m_size doesn't represent the current size of the buffer (= number of elements contained), but the maximum capacity. Maybe m_capacity would be a better name.
Buffer itself isn't very descriptive of what it actually does. ConcurrentQueue, MessageQueue or similar would better represent its behavior.
While add and remove by themselves are fine names, common expectation for queue-like types are push and pop.
This actually is a working queue for n producers and m consumers. It seems a bit overkill for a 1 producer + 1 consumer scenario.


Furthermore, some improvements could be made:


bool try_push(T&amp;&amp;)/bool try_push(const T&amp;)/bool try_pop(T&amp;) member functions could be added that return early if the operation would otherwise have to wait.
push could be overloaded for const T&amp; and T&amp;&amp; to enable better performance for moveable types.


Producer&lt;T&gt;/Consumer&lt;T&gt;

Both of these don't really seem necessary. Generally, its unlikely that someone will ever need generic producers/consumers (other than maybe for testing purposes), so I won't go into too much detail


Default constructors initialize m_buf to nullptr, but this is never checked afterwards. Either add checks for nullptr in the other member functions, or simply remove the default constructor.
Similarly, the buf parameter of the other constructor can be nullptr. If m_buf should never be nullptr (as the member functions seem to assume), simply make buf a Buffer&lt;T&gt;&amp; instead. m_buf could then be initialized to &amp;buf - but it might be more reasonable to change m_buf to Buffer&lt;T&gt;&amp;, too.
Access to std::cout isn't synchronized. In some cases, this means the consumer might print before the producer does.
There is no way to stop a producer/consumer (other than forcefully terminating the program).
The member m_id is never used.
The second constructor takes a std::string&amp;&amp; id parameter - but initializes m_id without moving - which creates a copy. Generally, it would be expected that the object id refers to would be moved from after construction.


General stuff


main never checks if argv[1] is actually valid.
Using struct data when referencing the type isn't necessary in C++, just data suffices. So typedef struct data elem_t; could be simplified to typedef data elem_t;, or with a more modern approach, using elem_t = data;. (The struct data would be necessary in C, but this code will never interact with C as C doesn't support templates anyways.)
Many places use parentheses to initialize objects, like std::unique_lock&lt;std::mutex&gt; locker(m_mtx);. Prefer braces {} instead: In the example, if m_mtx could be interpreted as a type, then the compiler would be forced to make locker a function declaration. Using braces would prevent that from happening.
Prefer the utilities in the &lt;random&gt; header for generating random numbers, as std::rand is kinda terrible.
There's no need to create buffer, p and c on the heap (inside main). Using local variables would be just fine. (Also, they never get deleted properly. If allocation on the heap is absolutely needed, prefer using smart pointers like std::unique_ptr or std::shared_ptr.)
I cannot think of a 1 producer/1 consumer scenario in which threads are necessary: Most could be simplified to this pseudocode:

int main() {
    while(keep_running()) {
        consume_one(produce_one());
    }
}