? boost/program_options/A.diff
? libs/program_options/test/tmp.cpp
Index: boost/program_options/value_semantic.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/program_options/value_semantic.hpp,v
retrieving revision 1.12
diff -u -r1.12 value_semantic.hpp
--- boost/program_options/value_semantic.hpp	15 May 2005 06:32:18 -0000	1.12
+++ boost/program_options/value_semantic.hpp	23 Nov 2005 09:10:12 -0000
@@ -14,9 +14,9 @@
 #include <boost/lexical_cast.hpp>
 
 
-
 #include <string>
 #include <vector>
+#include <typeinfo>
 
 namespace boost { namespace program_options {
 
@@ -74,6 +74,13 @@
         // Nothing here. Specializations to follow.
     };
 
+    /** Helper conversion class for values that accept ascii
+        strings as input.
+        Overrides the 'parse' method and defines new 'xparse'
+        method taking std::string. Depending on whether input
+        to parse is ascii or UTF8, will pass it to xparse unmodified,
+        or with UTF8->ascii conversion.
+    */
     template<>
     class BOOST_PROGRAM_OPTIONS_DECL 
     value_semantic_codecvt_helper<char> : public value_semantic {
@@ -87,6 +94,13 @@
             const = 0;
     };
 
+    /** Helper conversion class for values that accept ascii
+        strings as input.
+        Overrides the 'parse' method and defines new 'xparse'
+        method taking std::wstring. Depending on whether input
+        to parse is ascii or UTF8, will recode input to Unicode, or
+        pass it unmodified.
+    */
     template<>
     class BOOST_PROGRAM_OPTIONS_DECL
     value_semantic_codecvt_helper<wchar_t> : public value_semantic {
@@ -101,6 +115,7 @@
             const = 0;
 #endif
     };
+
     /** Class which specifies a simple handling of a value: the value will
         have string type and only one token is allowed. */    
     class BOOST_PROGRAM_OPTIONS_DECL 
@@ -134,9 +149,29 @@
         bool m_zero_tokens;
     };
 
+    /** Base class for all option that have a fixed type, and are
+        willing to announce this type to the outside world.
+        Any 'value_semantics' for which you want to find out the
+        type can be dynamic_cast-ed to typed_value_base. If conversion
+        succeeds, the 'type' method can be called.
+    */
+    class typed_value_base 
+    {
+    public:
+        // Returns the type of the value described by this
+        // object.
+        virtual const std::type_info& value_type() const = 0;
+        // Not really needed, since deletion from this
+        // class is silly, but just in case.
+        virtual ~typed_value_base() {}
+    };
+
+
     /** Class which handles value of a specific type. */
     template<class T, class charT = char>
-    class typed_value : public value_semantic_codecvt_helper<charT>  {
+    class typed_value : public value_semantic_codecvt_helper<charT>,
+                        public typed_value_base
+    {
     public:
         /** Ctor. The 'store_to' parameter tells where to store
             the value when it's known. The parameter can be NULL. */
@@ -227,7 +262,7 @@
 
 
         /** Creates an instance of the 'validator' class and calls
-            its operator() to perform athe ctual conversion. */
+            its operator() to perform the actual conversion. */
         void xparse(boost::any& value_store, 
                     const std::vector< std::basic_string<charT> >& new_tokens) 
             const;
@@ -250,6 +285,13 @@
             when creating *this, stores the value there. Otherwise,
             does nothing. */
         void notify(const boost::any& value_store) const;
+
+    public: // typed_value_base overrides
+        
+        const std::type_info& value_type() const
+        {
+            return typeid(T);
+        }
         
 
     private:
Index: libs/program_options/test/options_description_test.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/program_options/test/options_description_test.cpp,v
retrieving revision 1.3
diff -u -r1.3 options_description_test.cpp
--- libs/program_options/test/options_description_test.cpp	22 Apr 2005 13:35:44 -0000	1.3
+++ libs/program_options/test/options_description_test.cpp	23 Nov 2005 09:10:12 -0000
@@ -14,8 +14,28 @@
 #include <boost/test/test_tools.hpp>
 
 #include <utility>
+#include <string>
 using namespace std;
 
+void test_type()
+{
+    options_description desc;
+    desc.add_options()
+        ("foo", value<int>(), "")
+        ("bar", value<std::string>(), "")
+        ;
+    
+    const typed_value_base* b = dynamic_cast<const typed_value_base*>
+        (desc.find("foo", false).semantic().get());
+    BOOST_CHECK(b);
+    BOOST_CHECK(b->value_type() == typeid(int));
+
+    const typed_value_base* b2 = dynamic_cast<const typed_value_base*>
+        (desc.find("bar", false).semantic().get());
+    BOOST_CHECK(b2);
+    BOOST_CHECK(b2->value_type() == typeid(std::string));
+}
+
 void test_approximation()
 {
     options_description desc;
@@ -34,6 +54,7 @@
 
 int test_main(int, char* [])
 {
+    test_type();
     test_approximation();
     return 0;
 }

