Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code: conform to c++23 #184

Merged
merged 1 commit into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions middleware/common/include/common/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ namespace casual
namespace detail
{
template< typename P>
auto pivot( P&& pivot, traits::priority::tag< 1>) -> decltype( std::begin( pivot))
auto pivot( P pivot, traits::priority::tag< 1>) -> decltype( std::begin( pivot))
{ return std::begin( pivot);}

template< typename P>
auto pivot( P pivot, traits::priority::tag< 0>) -> std::enable_if_t< traits::is::iterator_v< P>, P>
//auto pivot( P pivot, traits::priority::tag< 0>) -> std::enable_if_t< traits::is::iterator_v< P>, P>
auto pivot( P pivot, traits::priority::tag< 0>) -> decltype( void( *pivot++), P{})
{ return pivot;}


template< typename P>
auto pivot( P&& pivot) -> decltype( detail::pivot( pivot, traits::priority::tag< 1>{}))
auto pivot( P pivot) -> decltype( detail::pivot( pivot, traits::priority::tag< 1>{}))
{ return detail::pivot( pivot, traits::priority::tag< 1>{});}

} // detail
Expand Down
24 changes: 12 additions & 12 deletions middleware/common/include/common/argument.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,18 @@ namespace casual
Cardinality cardinality() const { return m_callable->cardinality();}

private:
struct concept
struct Concept
{
virtual ~concept() = default;
virtual ~Concept() = default;
virtual void assign( const std::string& key, range_type values) = 0;
virtual void invoke() = 0;
virtual std::vector< std::string> complete( range_type values, bool help) const = 0;
virtual Cardinality cardinality() const = 0;
virtual std::unique_ptr< concept> copy() const = 0;
virtual std::unique_ptr< Concept> copy() const = 0;
};

template< typename C>
struct model : concept
struct model : Concept
{
model( C callable) : m_callable( std::move( callable)) {}

Expand All @@ -150,11 +150,11 @@ namespace casual

Cardinality cardinality() const override { return m_callable.cardinality();}

std::unique_ptr< concept> copy() const override { return std::make_unique< model>( *this); }
std::unique_ptr< Concept> copy() const override { return std::make_unique< model>( *this); }
private:
C m_callable;
};
std::unique_ptr< concept> m_callable;
std::unique_ptr< Concept> m_callable;
};

//! A representation of an "option" and possible it's nested structure
Expand Down Expand Up @@ -233,9 +233,9 @@ namespace casual


private:
struct concept
struct Concept
{
virtual ~concept() = default;
virtual ~Concept() = default;
virtual bool has( const std::string& key) const = 0;
virtual bool next( const std::string& key) const = 0;
virtual void assign( const std::string& key, range_type values) = 0;
Expand All @@ -249,11 +249,11 @@ namespace casual

virtual void validate() const = 0;

virtual std::unique_ptr< concept> copy() const = 0;
virtual std::unique_ptr< Concept> copy() const = 0;
};

template< typename H>
struct model : concept
struct model : Concept
{
model( H handler) : m_handler( std::move( handler)) {}

Expand All @@ -271,7 +271,7 @@ namespace casual

inline void validate() const override { return selective_validate( m_handler);}

std::unique_ptr< concept> copy() const override { return std::make_unique< model>( *this); }
std::unique_ptr< Concept> copy() const override { return std::make_unique< model>( *this); }
private:
template< typename T>
using has_validate = decltype( std::declval< T&>().validate());
Expand All @@ -289,7 +289,7 @@ namespace casual

H m_handler;
};
std::unique_ptr< concept> m_handler;
std::unique_ptr< Concept> m_handler;
};

namespace invoke
Expand Down
18 changes: 9 additions & 9 deletions middleware/common/include/common/buffer/pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ namespace casual

Holder() = default;

struct concept
struct Concept
{
virtual ~concept() = default;
virtual ~Concept() = default;

virtual buffer::handle::mutate::type allocate( std::string_view type, platform::binary::size::type size) = 0;
virtual buffer::handle::mutate::type reallocate( buffer::handle::type handle, platform::binary::size::type size) = 0;
Expand All @@ -104,7 +104,7 @@ namespace casual
};

template< typename P>
struct model : concept
struct model : Concept
{
using pool_type = P;

Expand Down Expand Up @@ -170,12 +170,12 @@ namespace casual

constexpr static auto manage_key( std::string_view key)
{
return [ key]( const auto& concept){ return concept->manage( key);};
return [ key]( const auto& Concept){ return Concept->manage( key);};
};

constexpr static auto manage_buffer( buffer::handle::type handle)
{
return [ handle]( const auto& concept){ return concept->manage( handle);};
return [ handle]( const auto& Concept){ return Concept->manage( handle);};
};

template< typename P>
Expand All @@ -194,14 +194,14 @@ namespace casual
return address;
}

concept& get_pool( std::string_view type);
concept& get_pool( buffer::handle::type handle);
concept* find_pool( std::string_view type);
Concept& get_pool( std::string_view type);
Concept& get_pool( buffer::handle::type handle);
Concept* find_pool( std::string_view type);

const Payload& null_payload() const;

buffer::handle::type m_inbound;
std::vector< std::unique_ptr< concept>> m_pools;
std::vector< std::unique_ptr< Concept>> m_pools;

};

Expand Down
16 changes: 8 additions & 8 deletions middleware/common/include/common/serialize/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ namespace casual
}

private:
struct concept
struct Concept
{
virtual ~concept() = default;
virtual ~Concept() = default;

virtual std::tuple< platform::size::type, bool> container_start( platform::size::type size, const char* name) = 0;
virtual void container_end( const char* name) = 0;
Expand All @@ -99,7 +99,7 @@ namespace casual
};

template< typename P>
struct model : concept
struct model : Concept
{
using protocol_type = P;

Expand Down Expand Up @@ -146,7 +146,7 @@ namespace casual
Reader( std::unique_ptr< model< Protocol>>&& model)
: m_protocol( std::move( model)), m_type{ traits::archive::dynamic::convert_v< Protocol>} {}

std::unique_ptr< concept> m_protocol;
std::unique_ptr< Concept> m_protocol;
archive::dynamic::Type m_type;
};

Expand Down Expand Up @@ -223,9 +223,9 @@ namespace casual
//! @todo: Change to std::span with C++20
inline void save( view::immutable::Binary value, const char* name) { m_protocol->write( value, name);}

struct concept
struct Concept
{
virtual ~concept() = default;
virtual ~Concept() = default;

virtual void container_start( platform::size::type size, const char* name) = 0;
virtual void container_end( const char* name) = 0;
Expand All @@ -251,7 +251,7 @@ namespace casual
};

template< typename protocol_type>
struct model : concept
struct model : Concept
{
template< typename... Ts>
model( Ts&&... ts) : m_protocol( std::forward< Ts>( ts)...) {}
Expand Down Expand Up @@ -286,7 +286,7 @@ namespace casual
Writer( std::unique_ptr< model< Protocol>>&& model)
: m_protocol( std::move( model)), m_type{ traits::archive::dynamic::convert_v< Protocol>} {}

std::unique_ptr< concept> m_protocol;
std::unique_ptr< Concept> m_protocol;
archive::dynamic::Type m_type;
};

Expand Down
8 changes: 4 additions & 4 deletions middleware/common/include/common/serialize/create/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ namespace casual
: m_implementation{ std::make_shared< model< C>>( std::forward< C>( creator))} {}


struct concept
struct Concept
{
virtual ~concept() = default;
virtual ~Concept() = default;
virtual serialize::Reader create( std::istream& stream) const = 0;
virtual serialize::Reader create( const platform::binary::type& data) const = 0;
};

template< typename create_type>
struct model : concept
struct model : Concept
{
model( create_type&& creator) : m_creator( std::move( creator)) {}

Expand All @@ -67,7 +67,7 @@ namespace casual
create_type m_creator;
};

std::shared_ptr< const concept> m_implementation;
std::shared_ptr< const Concept> m_implementation;
};

static_assert( std::is_copy_constructible< Creator>::value, "");
Expand Down
6 changes: 3 additions & 3 deletions middleware/common/include/common/serialize/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -731,19 +731,19 @@ namespace casual
//! @todo: Remove usage of string::utf8 when using C++20
static auto write( A& archive, const std::filesystem::path& path, const char* name)
{
const auto data = path.u8string();
const auto data = path.string();
const string::immutable::utf8 wrapper{ data};
value::write( archive, wrapper, name);
}

//! @todo: Remove usage of string::utf8 when using C++20
static auto read( A& archive, std::filesystem::path& path, const char* name)
{
auto data = path.u8string();
auto data = path.string();
string::utf8 wrapper{ data};
if( value::read( archive, wrapper, name))
{
path = std::filesystem::u8path( std::move( data));
path = std::filesystem::path( std::move( data));
return true;
}
return false;
Expand Down
10 changes: 5 additions & 5 deletions middleware/common/include/common/terminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ namespace casual
}


struct concept
struct Concept
{
virtual ~concept() = default;
virtual ~Concept() = default;
virtual std::string name() const = 0;
virtual std::size_t width( const value_type& value, const std::ostream& out) const = 0;
virtual void print( std::ostream& out, const value_type& value, std::size_t size) const = 0;
Expand All @@ -284,7 +284,7 @@ namespace casual

struct column_holder
{
column_holder( std::unique_ptr< concept> column)
column_holder( std::unique_ptr< Concept> column)
: m_column( std::move( column)), m_width( m_column->name().size()) {}

template< typename Range>
Expand Down Expand Up @@ -312,13 +312,13 @@ namespace casual
return m_width;
}

std::unique_ptr< concept> m_column;
std::unique_ptr< Concept> m_column;
std::size_t m_width;
};


template< typename I>
struct basic_column : concept
struct basic_column : Concept
{
using implementation_type = I;
basic_column( implementation_type implementation) : m_implementation( std::move( implementation)) {}
Expand Down
2 changes: 1 addition & 1 deletion middleware/common/include/common/traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ namespace casual
using iterable = std::tuple< decltype( std::begin( std::declval< T&>())), decltype( std::end( std::declval< T&>()))>;

template< typename T>
using iterator = typename std::iterator_traits< std::remove_reference_t< T>>::iterator_category;
using iterator = typename std::iterator_traits< traits::remove_cvref_t< T>>::iterator_category;

template< typename T>
using begin_dereferenced = decltype( *std::begin( std::declval< T&>()));
Expand Down
1 change: 1 addition & 0 deletions middleware/common/include/common/transaction/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ namespace casual

friend bool operator == ( const Transaction& lhs, const ID& rhs) noexcept;
friend bool operator == ( const Transaction& lhs, const XID& rhs) noexcept;
inline friend bool operator == ( const Transaction& lhs, const Transaction& rhs) noexcept { return lhs.trid == rhs.trid;}

CASUAL_LOG_SERIALIZE({
CASUAL_SERIALIZE( trid);
Expand Down
8 changes: 4 additions & 4 deletions middleware/common/source/buffer/pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ namespace casual
namespace common::buffer::pool
{

Holder::concept* Holder::find_pool( std::string_view type)
Holder::Concept* Holder::find_pool( std::string_view type)
{
if( auto found = algorithm::find_if( m_pools, manage_key( type)))
return found->get();

return nullptr;
}

Holder::concept& Holder::get_pool( std::string_view type)
Holder::Concept& Holder::get_pool( std::string_view type)
{
if( auto found = Holder::find_pool( type))
return *found;

code::raise::error( code::xatmi::buffer_input, "invalid buffer type: ", type);
}

Holder::concept& Holder::get_pool( buffer::handle::type handle)
Holder::Concept& Holder::get_pool( buffer::handle::type handle)
{
if( auto found = algorithm::find_if( m_pools, manage_buffer( handle)))
return **found;
Expand Down Expand Up @@ -178,7 +178,7 @@ namespace casual
m_inbound = {};
});
}
algorithm::for_each( m_pools, std::mem_fn( &Holder::concept::clear));
algorithm::for_each( m_pools, std::mem_fn( &Holder::Concept::clear));
}

} // casual.laz.se:80880/documentation/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,15 @@ namespace casual
}

// TODO: gives warning from clang and gives failure on OSX with locale "UTF-8"
/*
TYPED_TEST( common_serialize_write_read, DISABLED_type_extended_string)
{
unittest::Trace trace;

std::string value = u8"Bängen Trålar";
EXPECT_TRUE( TestFixture::write_read( value) == u8"Bängen Trålar");
}
*/

TYPED_TEST( common_serialize_write_read, type_double)
{
Expand Down
Loading