1 #ifndef STAN_MATH_REV_FUN_VALUE_OF_HPP
2 #define STAN_MATH_REV_FUN_VALUE_OF_HPP
3 
4 #include <stan/math/rev/meta.hpp>
5 #include <stan/math/rev/core.hpp>
6 
7 namespace stan {
8 namespace math {
9 
10 /**
11  * Return the value of the specified variable.
12  *
13  * <p>This function is used internally by autodiff functions along
14  * with <code>value_of(T x)</code> to extract the
15  * <code>double</code> value of either a scalar or an autodiff
16  * variable.  This function will be called when the argument is a
17  * <code>var</code> even if the function is not
18  * referred to by namespace because of argument-dependent lookup.
19  *
20  * @param v Variable.
21  * @return Value of variable.
22  */
23 template <typename T>
value_of(const var_value<T> & v)24 inline auto& value_of(const var_value<T>& v) {
25   return v.vi_->val_;
26 }
27 
28 }  // namespace math
29 }  // namespace stan
30 #endif
31