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:
@ -31,15 +31,18 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Dropbox_m
|
||||
const bool debugPop= false or C::debug;
|
||||
}
|
||||
|
||||
|
||||
enum Dropbox_tag {};
|
||||
|
||||
inline namespace exports
|
||||
{
|
||||
template< typename > class Dropbox;
|
||||
|
||||
using DropboxFinishedException= synthetic_exception< struct finished_exception, FinishedException >;
|
||||
using DropboxFinishedException= synthetic_exception< Dropbox_tag, FinishedException >;
|
||||
using AnyTaggedDropboxFinishedException= AnyTagged< DropboxFinishedException >;
|
||||
template< typename tag > using TaggedDropboxFinishedException= Tagged< DropboxFinishedException, tag >;
|
||||
|
||||
using DropboxFinishedCondition= synthetic_exception< struct finished_exception, FinishedCondition, DropboxFinishedException >;
|
||||
using DropboxFinishedCondition= synthetic_exception< Dropbox_tag, FinishedCondition, DropboxFinishedException >;
|
||||
using AnyTaggedDropboxFinishedCondition= AnyTagged< DropboxFinishedCondition >;
|
||||
template< typename tag > using TaggedDropboxFinishedCondition= Tagged< DropboxFinishedCondition, tag >;
|
||||
}
|
||||
@ -71,12 +74,15 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Dropbox_m
|
||||
template< typename Item >
|
||||
class exports::Dropbox
|
||||
{
|
||||
private:
|
||||
enum Finished_tag {};
|
||||
|
||||
public:
|
||||
using FinishedException= synthetic_exception< struct finished_exception, DropboxFinishedException >;
|
||||
using FinishedException= synthetic_exception< Dropbox_tag, DropboxFinishedException >;
|
||||
//using AnyTaggedFinishedException= AnyTagged< FinishedException >;
|
||||
//template< typename tag > using TaggedFinishedException= Tagged< FinishedException, tag >;
|
||||
|
||||
using FinishedCondition= synthetic_exception< struct finished_exception, DropboxFinishedCondition, FinishedException >;
|
||||
using FinishedCondition= synthetic_exception< Dropbox_tag, DropboxFinishedCondition, FinishedException >;
|
||||
//using AnyTaggedFinishedCondition= AnyTagged< FinishedCondition >;
|
||||
//template< typename tag > using TaggedFinishedCondition= Tagged< FinishedCondition, tag >;
|
||||
|
||||
|
||||
@ -29,15 +29,18 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m
|
||||
const bool debugPop= false or C::debug;
|
||||
}
|
||||
|
||||
|
||||
enum Mailbox_tag {};
|
||||
|
||||
inline namespace exports
|
||||
{
|
||||
template< typename > class Mailbox;
|
||||
|
||||
using MailboxFinishedException= synthetic_exception< struct finished_exception, FinishedException >;
|
||||
using MailboxFinishedException= synthetic_exception< Mailbox_tag, FinishedException >;
|
||||
using AnyTaggedMailboxFinishedException= AnyTagged< MailboxFinishedException >;
|
||||
template< typename tag > using TaggedMailboxFinishedException= Tagged< MailboxFinishedException, tag >;
|
||||
|
||||
using MailboxFinishedCondition= synthetic_exception< struct finished_exception, FinishedCondition, MailboxFinishedException >;
|
||||
using MailboxFinishedCondition= synthetic_exception< Mailbox_tag, FinishedCondition, MailboxFinishedException >;
|
||||
using AnyTaggedMailboxFinishedCondition= AnyTagged< MailboxFinishedCondition >;
|
||||
template< typename tag > using TaggedMailboxFinishedCondition= Tagged< MailboxFinishedCondition, tag >;
|
||||
}
|
||||
@ -74,12 +77,15 @@ namespace Alepha::Hydrogen::Atomic ::detail:: Mailbox_m
|
||||
template< typename Item >
|
||||
class exports::Mailbox
|
||||
{
|
||||
private:
|
||||
enum Finished_tag {};
|
||||
|
||||
public:
|
||||
using FinishedException= synthetic_exception< struct finished_exception, MailboxFinishedException >;
|
||||
using FinishedException= synthetic_exception< Finished_tag, MailboxFinishedException >;
|
||||
//using AnyTaggedFinishedException= AnyTagged< FinishedException >;
|
||||
//template< typename tag > using TaggedFinishedException= Tagged< FinishedException, tag >;
|
||||
|
||||
using FinishedCondition= synthetic_exception< struct finished_exception, MailboxFinishedCondition, FinishedException >;
|
||||
using FinishedCondition= synthetic_exception< Finished_tag, MailboxFinishedCondition, FinishedException >;
|
||||
//using AnyTaggedFinishedCondition= AnyTagged< FinishedCondition >;
|
||||
//template< typename tag > using TaggedFinishedCondition= Tagged< FinishedCondition, tag >;
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
static_assert( __cplusplus > 2020'99 );
|
||||
|
||||
#include "../Mailbox.h"
|
||||
#include "../Dropbox.h"
|
||||
|
||||
#include <Alepha/Testing/test.h>
|
||||
#include <Alepha/Testing/TableTest.h>
|
||||
@ -14,7 +15,7 @@ static auto init= Alepha::Utility::enroll <=[]
|
||||
|
||||
"Smoke Test"_test <=[]
|
||||
{
|
||||
Alepha::Atomic::Mailbox< int > m( 1024 );
|
||||
Alepha::Atomic::Dropbox< int > m( 1024 );
|
||||
|
||||
m.push( 42 );
|
||||
m.push( 42 );
|
||||
@ -34,17 +35,22 @@ static auto init= Alepha::Utility::enroll <=[]
|
||||
std::cerr << "We caught an exception." << std::endl;
|
||||
const Alepha::Exception *const cond_p= &cond;
|
||||
|
||||
assert( dynamic_cast< const Alepha::Atomic::MailboxFinishedException * >( cond_p ) );
|
||||
assert( not dynamic_cast< const Alepha::Atomic::MailboxFinishedException * >( cond_p ) );
|
||||
assert( dynamic_cast< const Alepha::Atomic::DropboxFinishedException * >( cond_p ) );
|
||||
|
||||
assert( dynamic_cast< const Alepha::FinishedException * >( cond_p ) );
|
||||
assert( dynamic_cast< const Alepha::Exception * >( cond_p ) );
|
||||
|
||||
assert( dynamic_cast< const Alepha::Atomic::MailboxFinishedCondition * >( cond_p ) );
|
||||
assert( not dynamic_cast< const Alepha::Atomic::MailboxFinishedCondition * >( cond_p ) );
|
||||
assert( dynamic_cast< const Alepha::Atomic::DropboxFinishedCondition * >( cond_p ) );
|
||||
|
||||
assert( dynamic_cast< const Alepha::FinishedCondition * >( cond_p ) );
|
||||
assert( dynamic_cast< const Alepha::Condition * >( cond_p ) );
|
||||
|
||||
|
||||
|
||||
assert( not dynamic_cast< const Alepha::Atomic::AnyTaggedMailboxFinishedException * >( cond_p ) );
|
||||
assert( not dynamic_cast< const Alepha::Atomic::AnyTaggedDropboxFinishedException * >( cond_p ) );
|
||||
assert( not dynamic_cast< const Alepha::AnyTaggedFinishedException * >( cond_p ) );
|
||||
assert( not dynamic_cast< const Alepha::AnyTaggedException * >( cond_p ) );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user