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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:11:41+00:00 2026-06-17T18:11:41+00:00

I had some class like this: class Test { public: bool bar(int &i, char

  • 0

I had some class like this:

class Test {
public:
    bool bar(int &i, char c) // some arguments are passed by ref, some are by value
    {/*...*/}
    bool foo(/*...*/)
    {}
};

And I don’t want repeatly call bar1/bar2, etc. and then check the return value again and again, so I wrote a macro and variadic template to handle those things

#define help_macro(object, memfn, ...) help_func(#object "." #memfn, \
        object, &decltype(object)::memfn, ##__VA_ARGS__)

template<class T, typename Func, typename... Args>
void help_func(char const * name, T &&object, Func memfn, Args&&... args)
{
    auto ret = (object.*memfn)(forward<Args>(args)...);
    cout<<name<<":\t"
        <<(ret ? "OK" : "Oops")  // maybe I'll throw an exception here  
        <<endl;
}

And use it like this

int i = 0;
Test t;
help_macro(t, bar, i, 'a');

It works on g++-4.7/Debian, but ICC13.0/Win refuses to compile it(a very strange error message)

main.cpp(37): error : type name is not allowed
help_macro(t, bar, i, ‘a’);
^
main.cpp(37): error : expected a “)”
help_macro(t, bar, i, ‘a’);
^

I turn on the C++11 for ICC, and confirmed that ICC13 support variadic template and decltype
Do I use it incorrectly or it’s ICC’s problem?

  • 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-17T18:11:42+00:00Added an answer on June 17, 2026 at 6:11 pm

    Edit: Having actually bothered to test my theory it turns out I was wrong, in that context decltype(t) is Test as can be shown by a static_assert(std::is_same<decltype(t), Test>::value, "not a reference")

    So ICC (or the EDG front end it uses) probably just doesn’t properly support using decltype in nested-name-specifiers, which was changed by DR 743

    Using std::decay does make ICC accept it though, and so is a useful workaround.

    Original, wrong, answer:

    I think ICC is right here, decltype(object) is actually Test& and a reference type cannot have members, so &decltype(t)::memfn is ill-formed.

    The code can be simplified to:

    struct Test {
        void foo() {}
    };
    
    int main()
    {
      Test t;
      auto p = &decltype(t)::foo;
    }
    

    Which G++ and Clang accept, but ICC rejects, correctly IMHO.

    You can fix it by using std::remove_reference or std::decay

    #include <type_traits>
    
    // ...
    
    Test t;
    auto p = &std::decay<decltype(t)>::type::foo;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, So I have the following situation. I originally had some code like this:
I have a base class looking like this: public class BaseController : Controller {
I had some decryption code (using wincrypt.h ) that lived within my FileReader.cpp class.
This is probably an easy one for some of you. I'm trying to test
class constType { public static const Type messageType = typeof(int); // HOW TO DO
Following on from this question , I'm using a simple ViewModel class to test
I had some code that constructed an object: function gridObjConst(id, itemName, itemPrice, itemListPrice, width,
we had some demands here in my job that include working with asp. We
I had some issues with XPTemplate vim plugin. Sometimes it yields with errors, and
I had some experience of android but know almost nothing of GCC Makefile. Here

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.