boost::variant: need help with 'get'
I'm trying to use the "get" template with boost::variant but
can't figure out how to get my compiler to recognize it.
Here's a simple test program:
---
#include <iostream>
#include <cmath>
#include <string>
#include
On Friday 28 May 2004 20:43, Caleb Epstein wrote:
typedef variant
elem_t; int main () { elem_t pi = M_PI; double d = get (pi);
If my understanding is correct, "get" expects the desired result type to be specified explicitly. In fact, how should the compiler deduce the return type of "get" otherwise? So you need to write: double d = get<double>(pi); Regards, Wolfgang Meyer
On Fri, May 28, 2004 at 11:38:15PM +0000, Wolfgang Meyer wrote:
If my understanding is correct, "get" expects the desired result type to be specified explicitly. In fact, how should the compiler deduce the return type of "get" otherwise? So you need to write: double d = get<double>(pi);
Thanks. This works. I missed the example usage of get<T> in the documentation. -- Caleb Epstein | bklyn . org | Without love intelligence is dangerous; cae at | Brooklyn Dust | without intelligence love is not enough. bklyn dot org | Bunny Mfg. | -- Ashley Montagu
participants (2)
-
Caleb Epstein
-
Wolfgang Meyer