From ad93b8282468b3224ba5ba8cc946e38d0be8acce Mon Sep 17 00:00:00 2001 From: myun2 Date: Mon, 28 Nov 2011 15:44:19 +0900 Subject: [PATCH] =?utf8?q?any.hpp:=20get()=E3=81=AE=E4=BD=BF=E3=81=84?= =?utf8?q?=E5=8B=9D=E6=89=8B=E3=82=92=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- roast/include/roast/std/any.hpp | 7 ++++--- roast/test/lexical_test/lex_var_test.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/roast/include/roast/std/any.hpp b/roast/include/roast/std/any.hpp index 21d3a927..9436910a 100644 --- a/roast/include/roast/std/any.hpp +++ b/roast/include/roast/std/any.hpp @@ -50,9 +50,10 @@ namespace roast m_pvalue = new _value_type(v); return *this; } - - void* get(){ - return m_pvalue->get(); + + template + _RetType& get(){ + return *((_RetType*)m_pvalue->get()); } }; diff --git a/roast/test/lexical_test/lex_var_test.cpp b/roast/test/lexical_test/lex_var_test.cpp index 14c8529e..040b45a8 100644 --- a/roast/test/lexical_test/lex_var_test.cpp +++ b/roast/test/lexical_test/lex_var_test.cpp @@ -12,9 +12,11 @@ int main() long_ aa4(33); ::roast::any hoge(2.5); - printf("%f\n", *((double*)hoge.get()) ); + //printf("%f\n", *((double*)hoge.get()) ); + printf("%f\n", hoge.get() ); hoge = 100; - printf("%d\n", *((int*)hoge.get()) ); + //printf("%d\n", *((int*)hoge.get()) ); + printf("%d\n", hoge.get() ); return 0; } -- 2.11.0