mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Add a inplace_function constructor from a nullptr (#1336)
* Add a inplace_function constructor with a nullptr argument * Add unit test for nullptr construction --------- Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
This commit is contained in:
parent
f718c54396
commit
2c2ce9a39f
@ -572,6 +572,16 @@ namespace etl
|
||||
set(f);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from a nullptr.
|
||||
/// Clears the inplace_function.
|
||||
/// \param nullptr_t Null pointer
|
||||
//*************************************************************************
|
||||
inplace_function(etl::nullptr_t) noexcept
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from object + non-const member function (runtime).
|
||||
/// \tparam TObject The object type.
|
||||
|
||||
@ -509,6 +509,16 @@ namespace
|
||||
CHECK(function_called == FunctionCalled::Free_Void_Called);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_construct_from_nullptr)
|
||||
{
|
||||
etl::inplace_function<void(void)> ipf(nullptr);
|
||||
|
||||
CHECK_FALSE(ipf.is_valid());
|
||||
CHECK_FALSE(ipf);
|
||||
CHECK_THROW(ipf(), etl::inplace_function_uninitialized);
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP17
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_make_free_void_compile_time)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user