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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:03:36+00:00 2026-06-01T23:03:36+00:00

I am working with the SystemC library which requires all user defined types to

  • 0

I am working with the SystemC library which requires all user defined types to have a operator<< and sc_trace() function. However the user defined type is actually a nested type inside a template class, because the “nested type” is computed from the template argument specified in the outer class.

template<typename T>
class Block {
    typedef typename transform<T>::value NewType;
public:
    struct SomeType {
        SomeType() {}
        SomeType(T val) : member(val) {}
        NewType member;
    };
};

When I define the operator<< for SomeType like so

template<typename T>
std::ostream& operator<<(std::ostream& os, const typename Block<T>::SomeType& type) {
    return os << type.member;
}

The compiler cannot deduce the call inside the systemC library that does attempt to dump the nested defined type using the streaming operator. Since I rather not touch the library code (outside my control). Would any one of you experts out there know a way to work around this?

And if there is no clean workaround, would you know if the C++11 has a solution for this?

  • 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-06-01T23:03:37+00:00Added an answer on June 1, 2026 at 11:03 pm

    I actually found a solution myself. It is referred to as the Barton-Nackman Trick in Vandevoorde/Josuttis.

    The key is to avoid using function template. The standard excludes nested type of a dependent template class from template argument deduction. The operator<< and sc_trace function needs to be defined as a friend function in the template class. This way the function is a non-templated function when the template class is instantiated, but with the friend keyword the function takes on the scope of the enclosing namespace.

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

Sidebar

Related Questions

Greetings all, I’m working on a C# program that requires being able to get
I'm working on a library which implements the actor model on top of Grand
I have a database and a C# class library which acts as a repository
I'm working on a C# library class which is being consumed by an ASP.NET
I'm working on C++ project on Windows which involve FFmpeg library. The problem is
I am working on a c++ library which is split up into multiple namespaces.
I am working with System.Func but have reached a stumbling block with it. System.Func<TReturn>
So i am trying to get a simple system working where i have an
I'm working with a system that consists of several applications and services, almost all
I am working on a system on which currently linux kernel and microwindows windowing

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.