title: expose class in Rcpp - factory instead of constructor
body: <p>There is a class I have to port to R. I have exposed it as a Rcpp module. However, I need to use that class outside of R also. I mean I want to test the class with google tests. In order to compile the tests the class must not use anything from Rcpp.</p>
  
  <p>Unfortunately, the function creating an instance of the class has to have quite flexible argument list. I would like to use named arguments since there will be many arguments you may choose to specify. For that reasons I cannot declare constructor that would be of any use within R. It would be ok, if I could define a function that would perform as a factory method. I did.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>RcppExport SEXP CEC__new(SEXP args);
  
  RCPP_MODULE(cec) {
    using namespace Rcpp;
    class_&lt;CEC&gt;("cec")
      .method("test", &amp;CEC::test)
      .method("loop", &amp;CEC::loop)
      .method("singleLoop", &amp;CEC::singleLoop)
      .method("entropy", &amp;CEC::entropy)
      ;
  }
  </code></pre>
  
  <pre><code>setClass("cec", representation(pointer = "externalptr"))
  
  setMethod("initialize", "cec", function(.Object, ...) {
      .Object@pointer &lt;- .Call("CEC__new", ...)
      .Object
  })
  </code></pre>
  
  <p>The problem is that I cannot call any methods of the instance I create. It looks like I have to define '$' for the class within R. I don't want do that. I would like to take advantage of the pretty, compact form Rcpp module offers. Can you suggest me how to solve this issue?</p>