#include <exception>
#include <testsuite_hooks.h>
#ifndef _TESTSUITE_API
#define _TESTSUITE_API 1
namespace __gnu_test
{
struct bad_non_virtual : virtual public std::exception { };
template<typename Exception, bool DefaultCons>
struct diamond_derivation_base;
template<typename Exception>
struct diamond_derivation_base<Exception, true>
{
struct diamond_derivation_error: bad_non_virtual, Exception
{
diamond_derivation_error() : bad_non_virtual(), Exception() { }
};
};
template<typename Exception>
struct diamond_derivation_base<Exception, false>
{
struct diamond_derivation_error: bad_non_virtual, Exception
{
diamond_derivation_error()
: bad_non_virtual(), Exception("construct diamond") { }
};
};
template<typename Exception, bool DefaultCons>
struct diamond_derivation: diamond_derivation_base<Exception, DefaultCons>
{
typedef diamond_derivation_base<Exception, DefaultCons> base_type;
typedef typename base_type::diamond_derivation_error error_type;
static void test()
{
bool test __attribute__((unused)) = true;
try { throw error_type(); }
catch (std::exception const& e) { }
catch (...)
{ VERIFY( false ); }
}
};
struct NonDefaultConstructible
{
NonDefaultConstructible(int) { }
NonDefaultConstructible(const NonDefaultConstructible&) { }
};
inline bool
operator==(const NonDefaultConstructible&, const NonDefaultConstructible&)
{ return false; }
inline bool
operator<(const NonDefaultConstructible&, const NonDefaultConstructible&)
{ return false; }
inline NonDefaultConstructible
operator+(const NonDefaultConstructible& lhs,
const NonDefaultConstructible& rhs)
{ return NonDefaultConstructible(1); }
inline NonDefaultConstructible
operator-(const NonDefaultConstructible& lhs,
const NonDefaultConstructible& rhs)
{ return NonDefaultConstructible(1); }
inline NonDefaultConstructible
operator*(const NonDefaultConstructible& lhs,
const NonDefaultConstructible& rhs)
{ return NonDefaultConstructible(1); }
template<typename _Result>
struct void_function
{
typedef _Result result_type;
result_type
operator()() const
{ return result_type(); }
};
template<>
struct void_function<NonDefaultConstructible>
{
typedef NonDefaultConstructible result_type;
result_type
operator()() const
{ return result_type(2); }
};
}
#endif