Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. passing-variable-number-of-arguments-with-different-type
Forum Updated to NodeBB v4.3 + New Features

passing-variable-number-of-arguments-with-different-type

Scheduled Pinned Locked Moved Unsolved C++ Gurus
4 Posts 3 Posters 620 Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on 3 May 2021, 16:11 last edited by
    #1

    I like to enhance or make life complicated - depending on your point of view.

    Up front - so there is no (usual) derailing the post - I am not interested in discussing why such and such way is not recommend.

    Here is my starting point - RTFM.

    https://stackoverflow.com/questions/3555583/passing-variable-number-of-arguments-with-different-type-c

    For those who work better with exxamples - this is what I am trying to replace

    int ScanAllLocal(QTextEdit*, QListWidget*, QListWidget* );

    I like to start with multiple parameter of SAME type something like

    int ScanAllLocal( QListWidget*... QListWidget* );

    I understand that the key is using ellipsis (....) , but obviously that is not enough.

    1 Reply Last reply
    0
    • C Online
      C Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on 3 May 2021, 16:35 last edited by
      #2

      The answer is already in that SO thread, but the short version is

      template <class... Args> int ScanAllLocal(Args... args)
      

      It doesn't matter if parameters are same or different type.

      K 1 Reply Last reply 3 May 2021, 16:49
      3
      • C Chris Kawa
        3 May 2021, 16:35

        The answer is already in that SO thread, but the short version is

        template <class... Args> int ScanAllLocal(Args... args)
        

        It doesn't matter if parameters are same or different type.

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 3 May 2021, 16:49 last edited by
        #3

        @Chris-Kawa said in passing-variable-number-of-arguments-with-different-type:

        It doesn't matter if parameters are same or different type.

        And then you'd SFINAE-out incompatible types and you're going to hate your life for even starting on that path ... sigh, it's just how life goes ... ;)

        Read and abide by the Qt Code of Conduct

        C 1 Reply Last reply 3 May 2021, 16:50
        1
        • K kshegunov
          3 May 2021, 16:49

          @Chris-Kawa said in passing-variable-number-of-arguments-with-different-type:

          It doesn't matter if parameters are same or different type.

          And then you'd SFINAE-out incompatible types and you're going to hate your life for even starting on that path ... sigh, it's just how life goes ... ;)

          C Online
          C Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on 3 May 2021, 16:50 last edited by
          #4

          @kshegunov said in passing-variable-number-of-arguments-with-different-type:

          And then you'd SFINAE-out incompatible types and you're going to hate your life for even starting on that path

          Well yeah, the entire idea is terrible, but OP explicitly said not to discuss that, so I didn't ;)

          1 Reply Last reply
          3

          1/4

          3 May 2021, 16:11

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved