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
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved C++ Gurus
4 Posts 3 Posters 535 Views
  • 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 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
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 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.

      kshegunovK 1 Reply Last reply
      3
      • Chris KawaC Chris Kawa

        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.

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on 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

        Chris KawaC 1 Reply Last reply
        1
        • kshegunovK kshegunov

          @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 ... ;)

          Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on 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

          • Login

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