title: Simple way to pass temporary struct by value in C++?
body: <p>Suppose I want to pass a temporary object into a function.  Is there a way to do that in 1 line of code vs. 2, with a struct?</p>
  
  <hr>
  
  <p>With a class, I can do:</p>
  
  <pre><code>class_func(TestClass(5, 7));
  </code></pre>
  
  <p>given:</p>
  
  <pre><code>class TestClass
  {
  private:
      int a;
      short b;
  
  public:
      TestClass(int a_a, short a_b) : a(a_a), b(a_b)
      {
      }
  
      int A() const
      {
          return a;
      }
  
      short B() const
      {
          return b;
      }
  };
  
  void class_func(const TestClass &amp; a_class)
  {
      printf("%d %d\n", a_class.A(), a_class.B());
  }
  </code></pre>
  
  <hr>
  
  <p>Now, how do I do that with a struct?  The closest I've got is:</p>
  
  <pre><code>test_struct new_struct = { 5, 7 };
  struct_func(new_struct);
  </code></pre>
  
  <p>given:</p>
  
  <pre><code>struct test_struct
  {
      int a;
      short b;
  };
  
  void struct_func(const test_struct &amp; a_struct)
  {
      printf("%d %d\n", a_struct.a, a_struct.b);
  }
  </code></pre>
  
  <p>The object is more simple, but I wonder if there's a way to do the struct member initialization right in line with the function call, without giving the struct a constructor.  (I don't want a constructor.  The whole reason I'm using a struct is to avoid the boilerplate get/set class conventions in this isolated case.)</p>