Skip to content

Commit

Permalink
- Added back the second ctor with a specific default value parameter
Browse files Browse the repository at this point in the history
- Modified the test to make sure the default value parameter is used
  • Loading branch information
Cooolrik committed Jan 1, 2024
1 parent d19fdc7 commit 0d6b18c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion ctle_code_gen/property_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,19 @@ def generate_class( self, out ):
out.ln( name + '(' )
match self.storageType:
case storage_type.value:
out.ln( ' _Ty &_value ) : value(_value) {}', append = True )
out.ln( ' _Ty &_value ) : value(_value)', append = True )
with out.blk():
out.comment_ln('set a default value IF the value type does not automatically set a default value')
out.ln('identity_assign_if_trivially_default_constructible<_Ty>( _value );')
out.ln()

# add a second ctor with default value assignment
out.comment_ln('property standard ctor with specific assignment of default value')
out.ln( name + '( _Ty &_value, const _Ty &_initial_value ) : value(_value)' )
with out.blk():
out.comment_ln('set an initial value to the object')
out.ln('this->value = _initial_value;')

case storage_type.ptr:
out.ln( ' std::unique_ptr<_Ty> &_value ) : value(_value) {}', append = True )
case storage_type.atomic:
Expand Down
4 changes: 2 additions & 2 deletions unit_tests/test_prop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class folks
{
private:
std::vector<std::unique_ptr<person>> _persons;
int _simple_int = 23;
int _simple_int;

public:
folks();
Expand Down Expand Up @@ -95,7 +95,7 @@ folks::folks()
return this->_persons;
}
)
, simple_int( _simple_int )
, simple_int( _simple_int, 23 )
{
}

Expand Down

0 comments on commit 0d6b18c

Please sign in to comment.