Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3442098
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:37:47+00:00 2026-05-18T08:37:47+00:00

// UsingDirective.cpp : Defines the entry point for the console application. // #include stdafx.h

  • 0
    // UsingDirective.cpp : Defines the entry point for the console application.
    //

    #include "stdafx.h"
    #include <iostream>
    using namespace std;

    #pragma once

    #include <type_traits>

    #pragma region CheckForFailureSignalPolicy
     template<class Exception>
     struct ThrowOnFailure;

     template<class Exception>
     struct NullOnFailure;

     template<template<class>class FailureSignalPolicy>
     struct IsThrowOnFailure;





     template<>
     struct IsThrowOnFailure<ThrowOnFailure>
     {
      enum {value = 1};
     };

     template<>
     struct IsThrowOnFailure<NullOnFailure>
     {
      enum {value = 0};
     };



    #pragma endregion

      template<int v>
     struct Int2Type
     {};

     template<template<class> class FailurePolicy,class ExceptionType >
     struct IReportFailure
     {
      enum {isThrowing = IsThrowOnFailure<FailurePolicy>::value};
    #pragma region empty
      static auto reportFailure()-> typename std::conditional<isThrowing,void,std::nullptr_t>::type
      {
       return rprt_help(Int2Type<isThrowing>());
      }

      static void rprt_help(Int2Type<true>)
      {
       throw ExceptionType();
      }

      static std::nullptr_t rprt_help(Int2Type<false>)
      {
       return nullptr;
      }
    #pragma endregion
//******************************************
      template<class Argument>
      static auto reportFailure(const Argument& arg)-> typename std::conditional<isThrowing,void,std::nullptr_t>::type
      {
       return rprt_help(const Argument& arg,Int2Type<isThrowing>());
      }

      template<class Argument>
      static void rprt_help(const Argument& arg,Int2Type<true>)
      {
       throw ExceptionType(arg);
      }
      template<class Argument>
      static std::nullptr_t rprt_help(const Argument& arg,Int2Type<false>)
      {
       return nullptr;
      }
    #pragma region ExceptionType
      static auto reportFailure(const ExceptionType& ex)-> typename std::conditional<isThrowing,void,std::nullptr_t>::type
      {
       return rprt_help(const ExceptionType& ex,Int2Type<isThrowing>());
      }

      static void rprt_help(const ExceptionType& ex,Int2Type<true>)
      {
       throw ExceptionType(ex);
      }

      static std::nullptr_t rprt_help(const ExceptionType& ex,Int2Type<false>)
      {
       return nullptr;
      }
    #pragma endregion




     };

     template<template<class> class FailurePolicy, class ExceptionType>
     struct FailureSignalPolicy
     {
      enum {isThrowing = IsThrowOnFailure<FailurePolicy>::value};


      static auto
       signalFailure() -> typename std::conditional<IsThrowOnFailure<FailurePolicy>::value,void,std::nullptr_t>::type

      {
       return IReportFailure<FailurePolicy,ExceptionType>::reportFailure();
      }

      static auto
       signalFailure(const ExceptionType& ex) -> typename std::conditional<IsThrowOnFailure<FailurePolicy>::value,void,std::nullptr_t>::type

      {
       return IReportFailure<FailurePolicy,ExceptionType>::reportFailure(ex);
      }
///*******************************************
      template<class Argument>
      static auto
       signalFailure(const Argument& arg) -> typename std::conditional<IsThrowOnFailure<FailurePolicy>::value,void,std::nullptr_t>::type

      {
       return IReportFailure<FailurePolicy,ExceptionType>::reportFailure(arg);
      }
     };

     template<class ExceptionType>
     struct ThrowOnFailure : private FailureSignalPolicy<ThrowOnFailure,ExceptionType>
     {
      using FailureSignalPolicy< ::ThrowOnFailure,ExceptionType>::signalFailure; 
     };

     template<class ExceptionType>
     struct NullOnFailure : private FailureSignalPolicy<NullOnFailure,ExceptionType>
     {
      using FailureSignalPolicy< ::NullOnFailure,ExceptionType>::signalFailure;
     };


    int _tmain(int argc, _TCHAR* argv[])
    {
     try
     {
     /*ThrowOnFailure<int>::signalFailure();
     NullOnFailure<int>::signalFailure();*/
     ThrowOnFailure<std::out_of_range>::signalFailure(1);
     }
     catch(...)
     {
     }
     return 0;
    }

Trying to compile this I’m getting bizzare errors:
Error 1 error C2143: syntax error : missing ‘)’ before ‘const’
Error 2 error C2661: ‘IReportFailure::rprt_help’ : no overloaded function takes 0 arguments
Error 3 error C2059: syntax error : ‘)’

The problematic fnc is marked in code with ****

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:37:48+00:00Added an answer on May 18, 2026 at 8:37 am

    The body of IReportFailure::reportFailure should be changed to :

    return rprt_help(arg, Int2Type<isThrowing>());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Xcode using LLVM 2.0, when I put the line using namespace std; in
I have a mut.cs as follows. using System; namespace ns { public class Arith
I'm developing a application for Windows Mobile using C#(.Net Compact Framework 3.5), but I
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Diagnostics { class Program {
Shouldn't functions within a namespace only be accessible via using the namespace scoping or
im writing an application using Visual Studio 2010 Express Edition. I have a problem
I am creating a VS2010 console app using C# language on .NetFramework 4. I
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; namespace yplaylist.Models { [MatadataType(typeof(Song_Validation))]
I'm trying to create new application using BLToolkit but i can't compile the code,
I am developing MVC 3 application and its first time i am using subsonic.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.