feat: add lab-rv32i-freertos-vector-raii card
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
|
||||
#include "freertos/vector_v1.hpp"
|
||||
|
||||
static_assert( !std::is_copy_constructible< freertos::VectorV1 >::value );
|
||||
static_assert( !std::is_copy_assignable< freertos::VectorV1 >::value );
|
||||
static_assert( std::is_nothrow_move_constructible< freertos::VectorV1 >::value );
|
||||
static_assert( std::is_nothrow_move_assignable< freertos::VectorV1 >::value );
|
||||
|
||||
int main()
|
||||
{
|
||||
freertos::VectorV1 source { 4U };
|
||||
for( size_t index = 0U; index < source.size(); ++index )
|
||||
{
|
||||
source[ index ] = static_cast< double >( index + 1U );
|
||||
}
|
||||
double * const original = source.data();
|
||||
|
||||
freertos::VectorV1 destination { 2U };
|
||||
double * const replaced = destination.data();
|
||||
destination = static_cast< freertos::VectorV1 && >( source );
|
||||
|
||||
assert( source.empty() );
|
||||
assert( source.data() == nullptr );
|
||||
assert( destination.data() == original );
|
||||
assert( destination.data() != replaced );
|
||||
assert( destination.size() == 4U );
|
||||
assert( destination[ 0 ] + destination[ 1 ] +
|
||||
destination[ 2 ] + destination[ 3 ] == 10.0 );
|
||||
|
||||
freertos::VectorV1 final_owner {
|
||||
static_cast< freertos::VectorV1 && >( destination ) };
|
||||
assert( destination.empty() );
|
||||
assert( destination.data() == nullptr );
|
||||
assert( final_owner.data() == original );
|
||||
|
||||
final_owner = static_cast< freertos::VectorV1 && >( final_owner );
|
||||
assert( final_owner.data() == original );
|
||||
assert( final_owner.size() == 4U );
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user