1
0
forked from Alepha/Alepha

Avoid type confusion in exceptions.

When creating these typedefs, if we use in-place
declared types, we wind up with surprising aliasing
of various types, via namespace exposure.
This commit is contained in:
2024-05-30 19:50:58 -04:00
parent f1f1a8017d
commit 9e0c714798
6 changed files with 61 additions and 35 deletions

View File

@ -74,12 +74,12 @@ namespace Alepha::Hydrogen ::detail:: Exception_m
template< typename ... Bases >
struct bases : virtual public Bases... {};
template< typename unique, typename GradeType, typename Bases >
template< Enumeration unique, typename GradeType, typename Bases >
class synthetic_any_tagged_type
{
};
template< typename unique_handle, typename GradeType, typename ... Bases >
template< Enumeration unique_handle, typename GradeType, typename ... Bases >
class synthetic_exception
: virtual public bases< GradeType, Bases... >
{
@ -122,7 +122,7 @@ namespace Alepha::Hydrogen ::detail:: Exception_m
template< typename T >
concept ExceptionGrade= list_contains_v< Grades, T >;
template< typename unique_handle, ExceptionGrade GradeType, typename ... Bases >
template< Enumeration unique_handle, ExceptionGrade GradeType, typename ... Bases >
using create_exception= synthetic_exception< unique_handle, GradeType, Bases ... >;
template< typename Exc >
@ -314,6 +314,7 @@ namespace Alepha::Hydrogen ::detail:: Exception_m
template< typename T >
concept DerivedFromError= std::is_base_of_v< Error, T >;
enum NamedResource_tag {};
class NamedResourceStorage;
class NamedResourceInterface
{
@ -332,52 +333,55 @@ namespace Alepha::Hydrogen ::detail:: Exception_m
public:
std::string_view resourceName() const noexcept final { return storage; }
};
class NamedResourceException : public virtual create_exception< struct named_resource_throwable, Exception >, virtual public NamedResourceInterface {};
class NamedResourceException : public virtual create_exception< NamedResource_tag, Exception >, virtual public NamedResourceInterface {};
using AnyTaggedNamedResourceException= NamedResourceException::any_tagged_type;
template< typename tag >
using TaggedNamedResourceException= NamedResourceException::tagged_type< tag >;
using NamedResourceNotification= create_exception< struct named_resource_notification, Notification, NamedResourceException >;
using NamedResourceNotification= create_exception< NamedResource_tag, Notification, NamedResourceException >;
using AnyTaggedNamedResourceNotification= NamedResourceNotification::any_tagged_type;
template< typename tag >
using TaggedNamedResourceNotification= NamedResourceNotification::tagged_type< tag >;
using NamedResourceError= create_exception< struct named_resource_exception, Error, NamedResourceException >;
using NamedResourceError= create_exception< NamedResource_tag, Error, NamedResourceException >;
using AnyTaggedNamedResourceError= NamedResourceError::any_tagged_type;
template< typename tag >
using TaggedNamedResourceError= NamedResourceError::tagged_type< tag >;
using NamedResourceCriticalError= create_exception< struct named_resource_error, CriticalError, NamedResourceException >;
using NamedResourceCriticalError= create_exception< NamedResource_tag, CriticalError, NamedResourceException >;
using AnyTaggedNamedResourceCriticalError= NamedResourceCriticalError::any_tagged_type;
template< typename tag >
using TaggedNamedResourceCriticalError= NamedResourceCriticalError::tagged_type< tag >;
using NamedResourceViolation= create_exception< struct named_resource_violation, Violation, NamedResourceException >;
using NamedResourceViolation= create_exception< NamedResource_tag, Violation, NamedResourceException >;
using AnyTaggedNamedResourceViolation= NamedResourceViolation::any_tagged_type;
template< typename tag >
using TaggedNamedResourceViolation= NamedResourceViolation::tagged_type< tag >;
enum OutOfRange_tag {};
class OutOfRangeException
: virtual public create_exception< struct out_of_range_throwable, Exception > {};
: virtual public create_exception< OutOfRange_tag, Exception > {};
using AnyTaggedOutOfRangeException= OutOfRangeException::any_tagged_type;
template< typename tag >
using TaggedOutOfRangeException= OutOfRangeException::tagged_type< tag >;
using OutOfRangeError= create_exception< struct out_of_range_throwable, Error, OutOfRangeException >;
using OutOfRangeError= create_exception< OutOfRange_tag, Error, OutOfRangeException >;
using AnyTaggedOutOfRangeError= OutOfRangeError::any_tagged_type;
template< typename tag >
using TaggedOutOfRangeError= OutOfRangeError::tagged_type< tag >;
using OutOfRangeCriticalError= create_exception< struct out_of_range_throwable, CriticalError, OutOfRangeException >;
using OutOfRangeCriticalError= create_exception< OutOfRange_tag, CriticalError, OutOfRangeException >;
using AnyTaggedOutOfRangeCriticalError= OutOfRangeCriticalError::any_tagged_type;
template< typename tag >
using TaggedOutOfRangeCriticalError= OutOfRangeCriticalError::tagged_type< tag >;
using OutOfRangeViolation= create_exception< struct out_of_range_throwable, Violation, OutOfRangeException >;
using OutOfRangeViolation= create_exception< OutOfRange_tag, Violation, OutOfRangeException >;
using AnyTaggedOutOfRangeViolation= OutOfRangeViolation::any_tagged_type;
template< typename tag >
using TaggedOutOfRangeViolation= OutOfRangeViolation::tagged_type< tag >;
enum IndexOutOfRange_tag {};
class IndexedRangeInformationStorage;
class IndexedRangeInformationInterface
{
@ -402,26 +406,26 @@ namespace Alepha::Hydrogen ::detail:: Exception_m
std::size_t requested() const noexcept override { return request; }
};
class IndexOutOfRangeException
: virtual public create_exception< struct index_out_of_range_throwable, Exception, OutOfRangeException > {};
: virtual public create_exception< IndexOutOfRange_tag, Exception, OutOfRangeException > {};
using AnyTaggedIndexOutOfRangeException= IndexOutOfRangeException::any_tagged_type;
template< typename tag >
using TaggedIndexOutOfRangeException= IndexOutOfRangeException::tagged_type< tag >;
class IndexOutOfRangeError
: virtual public create_exception< struct index_out_of_range_throwable, Error, OutOfRangeError, IndexOutOfRangeException > {};
: virtual public create_exception< IndexOutOfRange_tag, Error, OutOfRangeError, IndexOutOfRangeException > {};
using AnyTaggedIndexOutOfRangeException= IndexOutOfRangeException::any_tagged_type;
template< typename tag >
using TaggedIndexOutOfRangeException= IndexOutOfRangeException::tagged_type< tag >;
class IndexOutOfRangeCriticalError
: virtual public create_exception< struct index_out_of_range_throwable, CriticalError, OutOfRangeCriticalError, IndexOutOfRangeException > {};
: virtual public create_exception< IndexOutOfRange_tag, CriticalError, OutOfRangeCriticalError, IndexOutOfRangeException > {};
using AnyTaggedIndexOutOfRangeCriticalError= IndexOutOfRangeCriticalError::any_tagged_type;
template< typename tag >
using TaggedIndexOutOfRangeCriticalError= IndexOutOfRangeCriticalError::tagged_type< tag >;
class IndexOutOfRangeViolation
: virtual public create_exception< struct index_out_of_range_throwable, Violation, OutOfRangeViolation, IndexOutOfRangeException > {};
: virtual public create_exception< IndexOutOfRange_tag, Violation, OutOfRangeViolation, IndexOutOfRangeException > {};
using AnyTaggedIndexOutOfRangeViolation= IndexOutOfRangeViolation::any_tagged_type;
template< typename tag >
using TaggedIndexOutOfRangeViolation= IndexOutOfRangeViolation::tagged_type< tag >;
@ -444,23 +448,24 @@ namespace Alepha::Hydrogen ::detail:: Exception_m
public:
std::size_t allocationAmount() const noexcept final { return amount; }
};
enum Allocation_tag {};
class AllocationException
: virtual public create_exception< struct allocation_throwable, Exception >, virtual public AllocationAmountInterface {};
: virtual public create_exception< Allocation_tag, Exception >, virtual public AllocationAmountInterface {};
using AnyTaggedAllocationException= AllocationException::any_tagged_type;
template< typename tag >
using TaggedAllocationException= AllocationException::tagged_type< tag >;
using AllocationError= create_exception< struct allocation_exception, Error, AllocationException >;
using AllocationError= create_exception< Allocation_tag, Error, AllocationException >;
using AnyTaggedAllocationError= AllocationError::any_tagged_type;
template< typename tag >
using TaggedAllocationError= AllocationError::tagged_type< tag >;
using AllocationCriticalError= create_exception< struct allocation_error, CriticalError, AllocationException >;
using AllocationCriticalError= create_exception< Allocation_tag, CriticalError, AllocationException >;
using AnyTaggedAllocationCriticalError= AllocationCriticalError::any_tagged_type;
template< typename tag >
using TaggedAllocationCriticalError= AllocationCriticalError::tagged_type< tag >;
using AllocationViolation= create_exception< struct allocation_violation, Violation, AllocationException >;
using AllocationViolation= create_exception< Allocation_tag, Violation, AllocationException >;
using AnyTaggedAllocationViolation= AllocationViolation::any_tagged_type;
template< typename tag >
using TaggedAllocationViolation= AllocationViolation::tagged_type< tag >;
@ -564,11 +569,12 @@ namespace Alepha::Hydrogen ::detail:: Exception_m
}
}
using FinishedException= create_exception< struct finished_exception, Exception >;
enum Finished_tag {};
using FinishedException= create_exception< Finished_tag, Exception >;
using AnyTaggedFinishedException= AnyTagged< FinishedException >;
template< typename tag > using TaggedFinishedException= Tagged< FinishedException, tag >;
using FinishedCondition= create_exception< struct finished_condition, Condition, FinishedException >;
using FinishedCondition= create_exception< Finished_tag, Condition, FinishedException >;
using AnyTaggedFinishedCondition= AnyTagged< FinishedCondition >;
template< typename tag > using TaggedFinishedCondition= Tagged< FinishedCondition, tag >;
}