Skip to content

Commit

Permalink
made pedantic build run in gcc again
Browse files Browse the repository at this point in the history
  • Loading branch information
Cooolrik committed Dec 16, 2023
1 parent 6dea0fe commit 01ec65e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions ctle_code_gen/property_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,15 @@ def generate_property( path:str ):
out.ln('#pragma once')
out.ln()
out.ln('#include <functional>')
out.ln('#include <type_traits>')
out.ln('#include "status.h"')
out.ln()

out.ln('namespace ctle')
with out.blk():
out.comment_ln('trivially_default_constructible_identity_assign is a conditional template function which initializes trivially constructable values using the = {} assignment. For all other types, the template is a noop and does nothing.')
out.ln('template<typename _Ty, std::enable_if_t<std::is_trivially_default_constructible<_Ty>{},bool> = true> void trivially_default_constructible_identity_assign( _Ty &val ) { val = {}; }')
out.ln('template<typename _Ty, std::enable_if_t<!std::is_trivially_default_constructible<_Ty>{},bool> = true> void trivially_default_constructible_identity_assign( _Ty & ) { /*noop*/ }')
out.ln('template<typename _Ty, typename std::enable_if<std::is_trivially_default_constructible<_Ty>{},bool>::type = true> void trivially_default_constructible_identity_assign( _Ty &val ) { val = {}; }')
out.ln('template<typename _Ty, typename std::enable_if<!std::is_trivially_default_constructible<_Ty>{},bool>::type = true> void trivially_default_constructible_identity_assign( _Ty & ) { /*noop*/ }')
out.ln()

out.comment_ln('The property_[...] template classes are a convenient way to implement properties in classes, where each property can be accessed as a normal variable, but can also be made read-only, write-only, read/write, and let the owner class override if a value is returned from a variable, or evaluated on-the-fly, etc.')
Expand Down
6 changes: 3 additions & 3 deletions unit_tests/test_property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ class folks
persons.v.resize(nums);
for (size_t i = 0; i < (size_t)nums; ++i)
{
persons.v[i] = std::make_unique<person>();
persons.v[i] = std::unique_ptr<person>( new person() );
}
simple_int.v = nums;
}

};

folks::folks()
: persons( [this]( const auto *prop, status &result ) -> const auto &
: persons( [this]( const property_getcref_value<std::vector<std::unique_ptr<person>>, folks> *prop, status &result ) -> const std::vector<std::unique_ptr<person>> &
{
if( prop->v.size() < 30 )
{
Expand All @@ -123,7 +123,7 @@ folks::folks()
return prop->v;
}
)
, simple_int( 23 , [this]( const auto *prop, status & ) -> const auto & { return prop->v; } )
, simple_int( 23 , [this]( const property_getcref_value<int, folks> *prop, status & ) -> const int & { return prop->v; } )
{
}

Expand Down

0 comments on commit 01ec65e

Please sign in to comment.