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 6913975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:17:15+00:00 2026-05-27T09:17:15+00:00

I have run into some strange behavior. I am not sure if this should

  • 0

I have run into some strange behavior. I am not sure if this should work or not. Note that I am not trying to make it work, I am rather concerned with theoretical side. I am using Visual C++ 2010. Observe the following code

template <class T_>
ostream &operator <<(std::ostream &out, 
        typename SequenceCheckResult<T_>::directiontype const &direction) {

    switch(direction) {
    case SequenceCheckResult<T_>::None:
        out<<"none o";
        break;
    case SequenceCheckResult<T_>::Horizontal:
        out<<"horizontal _";
        break;
    case SequenceCheckResult<T_>::Vertical:
        out<<"vertical |";
        break;
    case SequenceCheckResult<T_>::ForwardDiagonal:
        out<<"forward diagonal \\";
        break;
    case SequenceCheckResult<T_>::BackwardDiagonal:
        out<<"backward diagonal /";
        break;
    }

    return out;
}

Obviously the template class SequenceCheckResult contains an enum named directiontype. Now the code above does not get instantiated and integer value of the variable is printed. Even if I provide specialization, it still does not work. If I create the following function, it is used and the textual value is printed. Notice that the following code and int specialization of the above function only differs by template<> line and <int> following operator <<.

ostream &operator << (std::ostream &out, 
         SequenceCheckResult<int>::directiontype const &direction) {

    switch(direction) {
    case SequenceCheckResult<int>::None:
        out<<"none o";
        break;
    case SequenceCheckResult<int>::Horizontal:
        out<<"horizontal _";
        break;
    case SequenceCheckResult<int>::Vertical:
        out<<"vertical |";
        break;
    case SequenceCheckResult<int>::ForwardDiagonal:
        out<<"forward diagonal \\";
        break;
    case SequenceCheckResult<int>::BackwardDiagonal:
        out<<"backward diagonal /";
        break;
    }

    return out;
}

I wish to know why this happens, possible causes are:

  • Compiler bug
  • Implementation defines this behavior
  • Standards define this behavior
  • I am missing something

Thanks in advance

  • 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-27T09:17:16+00:00Added an answer on May 27, 2026 at 9:17 am

    Your approach does not and cannot work. You cannot deduce a “container based on an element”!

    For a simple argument, consider this thought experiment:

    struct Foo { typedef int type; }
    struct Bar { typedef int type; }
    
    template <typename T> void deduce_me(typename T::type n) { }
    

    Now if I call deduce_me(5), how are we supposed to deduce either Foo or Bar?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build my first generic list and have run into some problems.
I'm trying to create a Textmate snippet, but have run into some difficulties. Basically,
I am using a WPF ribbon and I have just run into some strange
I seem to have run into a strange bug or more likely some setting
I have run into a strange to me problem. For some reason multiple ||
I've run into some strange behavior with git and I was wondering if anyone
I have run into a pretty strange error that I can't get my head
I have run into some trouble with the gd library's imagefilledpolygon() . For some
I am creating a small Yahtzee game and i have run into some regex
I have run into a bit of a tricky problem in some C++ code,

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.