@@ -283,27 +283,31 @@ namespace etl
283283 // /\param value The value to push to the stack.
284284 // *************************************************************************
285285 template <typename ... Args>
286- void emplace (Args && ... args)
286+ reference emplace (Args && ... args)
287287 {
288288#if defined(ETL_CHECK_PUSH_POP)
289289 ETL_ASSERT (!full (), ETL_ERROR (stack_full));
290290#endif
291291 base_t::add_in ();
292292 ::new (&p_buffer[top_index]) T (etl::forward<Args>(args)...);
293+
294+ return p_buffer[top_index];
293295 }
294296#else
295297 // *************************************************************************
296298 // / Constructs a value in the stack place'.
297299 // / If asserts or exceptions are enabled, throws an etl::stack_full if the stack is already full.
298300 // /\param value The value to push to the stack.
299301 // *************************************************************************
300- void emplace ()
302+ reference emplace ()
301303 {
302304#if defined(ETL_CHECK_PUSH_POP)
303305 ETL_ASSERT (!full (), ETL_ERROR (stack_full));
304306#endif
305307 base_t::add_in ();
306308 ::new (&p_buffer[top_index]) T ();
309+
310+ return p_buffer[top_index];
307311 }
308312
309313 // *************************************************************************
@@ -312,13 +316,15 @@ namespace etl
312316 // /\param value The value to push to the stack.
313317 // *************************************************************************
314318 template <typename T1>
315- void emplace (const T1& value1)
319+ reference emplace (const T1& value1)
316320 {
317321#if defined(ETL_CHECK_PUSH_POP)
318322 ETL_ASSERT (!full (), ETL_ERROR (stack_full));
319323#endif
320324 base_t::add_in ();
321325 ::new (&p_buffer[top_index]) T (value1);
326+
327+ return p_buffer[top_index];
322328 }
323329
324330 // *************************************************************************
@@ -327,13 +333,15 @@ namespace etl
327333 // /\param value The value to push to the stack.
328334 // *************************************************************************
329335 template <typename T1, typename T2>
330- void emplace (const T1& value1, const T2& value2)
336+ reference emplace (const T1& value1, const T2& value2)
331337 {
332338#if defined(ETL_CHECK_PUSH_POP)
333339 ETL_ASSERT (!full (), ETL_ERROR (stack_full));
334340#endif
335341 base_t::add_in ();
336342 ::new (&p_buffer[top_index]) T (value1, value2);
343+
344+ return p_buffer[top_index];
337345 }
338346
339347 // *************************************************************************
@@ -342,13 +350,15 @@ namespace etl
342350 // /\param value The value to push to the stack.
343351 // *************************************************************************
344352 template <typename T1, typename T2, typename T3>
345- void emplace (const T1& value1, const T2& value2, const T3& value3)
353+ reference emplace (const T1& value1, const T2& value2, const T3& value3)
346354 {
347355#if defined(ETL_CHECK_PUSH_POP)
348356 ETL_ASSERT (!full (), ETL_ERROR (stack_full));
349357#endif
350358 base_t::add_in ();
351359 ::new (&p_buffer[top_index]) T (value1, value2, value3);
360+
361+ return p_buffer[top_index];
352362 }
353363
354364 // *************************************************************************
@@ -357,13 +367,15 @@ namespace etl
357367 // /\param value The value to push to the stack.
358368 // *************************************************************************
359369 template <typename T1, typename T2, typename T3, typename T4>
360- void emplace (const T1& value1, const T2& value2, const T3& value3, const T4& value4)
370+ reference emplace (const T1& value1, const T2& value2, const T3& value3, const T4& value4)
361371 {
362372#if defined(ETL_CHECK_PUSH_POP)
363373 ETL_ASSERT (!full (), ETL_ERROR (stack_full));
364374#endif
365375 base_t::add_in ();
366376 ::new (&p_buffer[top_index]) T (value1, value2, value3, value4);
377+
378+ return p_buffer[top_index];
367379 }
368380#endif
369381
0 commit comments