[edit] Can’t instantiate this template:

```
template int bernoulli_logit_rng(const double&);
```

for function signature

```
int bernoulli_logit_rng(real)
```

I was on the wrong track below. But still wondering how VectorBuilder works - why can’t this function return an int?

I think it’s interesting (and neat if annoying for my current task) that our `bernoulli_logit_rng(const double&)`

returns a `short`

(and can’t be made to return an `int`

despite the signature in the manual stating its signature is `int bernoulli_logit_rng(real)`

). I can’t find how that happens in the code - it seems to return `typename VectorBuilder<true, int, T_t>::type`

. In fact, the word `short`

only appears 4 times in our code, and two of those are in comments.

Anyone know how this works?

[edit] I just realized that I should have said how I figured this out, because maybe that is where I’m going wrong. After compiling a model using this, you can inspect it with `nm`

to see which symbols it exports:

```
00000001000519b0 unsigned short stan::VectorBuilder<true, int, double, double, double, double, double, double>::type stan::math::bernoulli_logit_rng<double, boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> > >(double const&, boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014u, 0u, 2147483563u>, boost::random::linear_congruential_engine<unsigned int, 40692u, 0u, 2147483399u> >&)
```

So I suppose the compiler could be making this optimization somehow. But I also can’t get an explicit template instantiation to compile for this signature:

```
math.cpp:1059:14: error: explicit instantiation of 'bernoulli_logit_rng' does not refer to a function
template, variable template, member function, member class, or static data member
template int bernoulli_logit_rng(const double&);
^
lib/stan_math/stan/math/prim/scal/prob/bernoulli_logit_rng.hpp:30:53: note: candidate template
ignored: failed template argument deduction
inline typename VectorBuilder<true, int, T_t>::type bernoulli_logit_rng(
const T_t& t, RNG& rng) {
```

[edit 2] - that “unsigned short” actually seems spurious!