diff --git a/boost_typeindex/examples.html b/boost_typeindex/examples.html new file mode 100644 index 0000000..cc1246e --- /dev/null +++ b/boost_typeindex/examples.html @@ -0,0 +1,112 @@ + + + +Examples + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+Examples +

+

+ All the code in examples will work with and without RTTI support. +

+

+ Class that allows to register type only once. +

+
class types_registry {
+    unordered_set<type_index> types_;
+
+public:
+    template <class T>
+    void add_type() {
+        type_index ti = type_id<T>();
+        std::cout << "Adding type " << ti << " to registry \n";
+        if (!types_.insert(ti).second)
+            throw std::logic_error("Type " + ti.name_demangled() + " already in registry");
+    }
+
+    template <class T>
+    bool has_type() const {
+        return types_.cend() != types_.find(type_id<T>());
+    }
+};
+
+int main () {
+    types_registry tr;
+    tr.add_type<int>();
+    tr.add_type<float>();
+
+    std::cout << "Has type int: " << tr.has_type<int>()
+        << "\nHas type std::string: " << tr.has_type<std::string>()
+        << '\n';
+}
+
+

+

+

+ This will output: +

+
Adding type int to registry
+Adding type float to registry
+Has type int: 1
+Has type std::string: 0
+
+

+

+

+ Another example (this time checking for exact parameter match). my_unary_function is a class, that stroes + function with result type ResultT + and any input parameter type. In opertaor(), it checks for input parameter match and + then executes the stored function: +

+

+

+
template <class ResultT>
+class my_unary_function {
+    void*           function_ptr_;
+    template_index  exact_param_t_;
+    ...
+
+    template <class ParamT>
+    ResultT operator()(ParamT& v) {
+        BOOST_ASSERT(exact_param_t_ == template_id_with_cvr<ParamT&>());
+        return (static_cast<ResultT(ParamT&)>(function_ptr_))(v);
+    }
+};
+
+

+

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost_typeindex/getting_started.html b/boost_typeindex/getting_started.html new file mode 100644 index 0000000..a295bde --- /dev/null +++ b/boost_typeindex/getting_started.html @@ -0,0 +1,71 @@ + + + +Getting started + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+Getting started +

+

+ In short: Just replace &typeid(T), + typeid(T) with + boost::type_id<T>() and + const std::type_info&, std::type_index + with boost::type_index. That's all, you are now using + Boost.TypeIndex. +

+

+ To get nice human readable name, use name_demangled() member function: +

+
type_index ti = type_id<T>();
+std::string nice_name = ti.name_demangled();
+...
+std::string nice_name_with_const_volatile_ref = template_id_with_cvr<ParamT&>().name_demangled();
+
+

+

+

+ template_index and type_index have full set of comparison operators, + hashing functions and ostream operators. Thay can be used with any container + class. +

+

+ If you need to save const, volatile and references, use boost::template_index + instead of boost::type_index; boost::template_id_with_cvr<T>() + instead of boost::type_id<T>(). +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/boost_typeindex/performance.html b/boost_typeindex/performance.html new file mode 100644 index 0000000..c76a507 --- /dev/null +++ b/boost_typeindex/performance.html @@ -0,0 +1,64 @@ + + + +Performance + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHome +
+
+

+Performance +

+

+ type_index and template_index classes hold a single pointer, + so they are easy and fast to copy. Calls to const + char* name() do + not require dynamic memory allocation and usually just return a pointer to + an array of chars in read-only section of binary file. Comparison operators + are optimized as much as possible, and in worst case only execute std::strcmp. + Calls to std::string name_demangled() for type_index + do usually require dynamic memory allocation and some computations, so they + are not recomended for usage in performance critical sections. Calls to std::string + name_demangled() + for template_index require + only std::strlen call and are much faster than std::string + name_demangled() + for type_index. +

+

+ template_index uses BOOST_CURRENT_FUNCTION macro, which could + lead to code bloat. So if you do not need to save const, + volatile and references, use + type_index. +

+
+ + + +
+
+
+PrevUpHome +
+ + diff --git a/boost_typeindex/reference.html b/boost_typeindex/reference.html new file mode 100644 index 0000000..862f6b1 --- /dev/null +++ b/boost_typeindex/reference.html @@ -0,0 +1,46 @@ + + + +Reference + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+

+Reference +

+

+ TODO: +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/index.html b/index.html index e039e54..1c71948 100644 --- a/index.html +++ b/index.html @@ -1,63 +1,72 @@ - - - - - Type index by apolukhin - - - - - - - -
-
-

Type index

-

-

View the Project on GitHub apolukhin/type_index

- -
-
-

Welcome to GitHub Pages.

- -

This automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:

- -
$ cd your_repo_root/repo_name
-$ git fetch origin
-$ git checkout gh-pages
-
- -

If you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.

- -

Designer Templates

- -

We've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.

- -

Rather Drive Stick?

- -

If you prefer to not use the automatic generator, push a branch named gh-pages to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.

- -

Authors and Contributors

- -

You can @mention a GitHub username to generate a link to their profile. The resulting <a> element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.

- -

Support or Contact

- -

Having trouble with Pages? Check out the documentation at http://help.github.com/pages or contact support@github.com and we’ll help you sort it out.

-
- -
- - - - \ No newline at end of file + + +Chapter 1. Boost.TypeIndex 1.0 + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
Next
+
+
+

+Chapter 1. Boost.TypeIndex 1.0

+
+
+

+ Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +

+
+
+
+

Table of Contents

+
+
Motivation
+
Getting started
+
Examples
+
Reference
+
Performance
+
+
+
+ +

+ Sometimes getting and storing at runtime information about template type is + required. For such cases usually used a construction like &typeid(T) or C++11 class std::type_index. + And that is the point, where problems strat: * typeid(T) + and std::type_index require Run Time Type Info (RTTI) + * typeid(T) strips + const, volatile and references from type * some compilers have bugs and do + not correctly compare std::type_info across shared libraries * some + implementations of typeid(T) do not + strip const, volatile and references * only a few STLs have std::type_index + implementation * no easy way to store type info without stripping const, volatile + and references * no nice and portable way to get human readable type name +

+

+ Boost.TypeIndex was designed to work around those issues. +

+
+
+ + + +

Last revised: June 03, 2012 at 09:04:50 GMT

+
+
Next
+ + diff --git a/javascripts/scale.fix.js b/javascripts/scale.fix.js deleted file mode 100644 index 87a40ca..0000000 --- a/javascripts/scale.fix.js +++ /dev/null @@ -1,17 +0,0 @@ -var metas = document.getElementsByTagName('meta'); -var i; -if (navigator.userAgent.match(/iPhone/i)) { - for (i=0; i` element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.\r\n\r\n### Support or Contact\r\nHaving trouble with Pages? Check out the documentation at http://help.github.com/pages or contact support@github.com and we’ll help you sort it out.","tagline":"","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file diff --git a/standalone_HTML.manifest b/standalone_HTML.manifest new file mode 100644 index 0000000..aec9fcf --- /dev/null +++ b/standalone_HTML.manifest @@ -0,0 +1,5 @@ +index.html +boost_typeindex/getting_started.html +boost_typeindex/examples.html +boost_typeindex/reference.html +boost_typeindex/performance.html diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css deleted file mode 100644 index c6a6452..0000000 --- a/stylesheets/pygment_trac.css +++ /dev/null @@ -1,69 +0,0 @@ -.highlight { background: #ffffff; } -.highlight .c { color: #999988; font-style: italic } /* Comment */ -.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ -.highlight .k { font-weight: bold } /* Keyword */ -.highlight .o { font-weight: bold } /* Operator */ -.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ -.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ -.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */ -.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ -.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ -.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gr { color: #aa0000 } /* Generic.Error */ -.highlight .gh { color: #999999 } /* Generic.Heading */ -.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ -.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */ -.highlight .go { color: #888888 } /* Generic.Output */ -.highlight .gp { color: #555555 } /* Generic.Prompt */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */ -.highlight .gt { color: #aa0000 } /* Generic.Traceback */ -.highlight .kc { font-weight: bold } /* Keyword.Constant */ -.highlight .kd { font-weight: bold } /* Keyword.Declaration */ -.highlight .kn { font-weight: bold } /* Keyword.Namespace */ -.highlight .kp { font-weight: bold } /* Keyword.Pseudo */ -.highlight .kr { font-weight: bold } /* Keyword.Reserved */ -.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */ -.highlight .m { color: #009999 } /* Literal.Number */ -.highlight .s { color: #d14 } /* Literal.String */ -.highlight .na { color: #008080 } /* Name.Attribute */ -.highlight .nb { color: #0086B3 } /* Name.Builtin */ -.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */ -.highlight .no { color: #008080 } /* Name.Constant */ -.highlight .ni { color: #800080 } /* Name.Entity */ -.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */ -.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */ -.highlight .nn { color: #555555 } /* Name.Namespace */ -.highlight .nt { color: #000080 } /* Name.Tag */ -.highlight .nv { color: #008080 } /* Name.Variable */ -.highlight .ow { font-weight: bold } /* Operator.Word */ -.highlight .w { color: #bbbbbb } /* Text.Whitespace */ -.highlight .mf { color: #009999 } /* Literal.Number.Float */ -.highlight .mh { color: #009999 } /* Literal.Number.Hex */ -.highlight .mi { color: #009999 } /* Literal.Number.Integer */ -.highlight .mo { color: #009999 } /* Literal.Number.Oct */ -.highlight .sb { color: #d14 } /* Literal.String.Backtick */ -.highlight .sc { color: #d14 } /* Literal.String.Char */ -.highlight .sd { color: #d14 } /* Literal.String.Doc */ -.highlight .s2 { color: #d14 } /* Literal.String.Double */ -.highlight .se { color: #d14 } /* Literal.String.Escape */ -.highlight .sh { color: #d14 } /* Literal.String.Heredoc */ -.highlight .si { color: #d14 } /* Literal.String.Interpol */ -.highlight .sx { color: #d14 } /* Literal.String.Other */ -.highlight .sr { color: #009926 } /* Literal.String.Regex */ -.highlight .s1 { color: #d14 } /* Literal.String.Single */ -.highlight .ss { color: #990073 } /* Literal.String.Symbol */ -.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #008080 } /* Name.Variable.Class */ -.highlight .vg { color: #008080 } /* Name.Variable.Global */ -.highlight .vi { color: #008080 } /* Name.Variable.Instance */ -.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */ - -.type-csharp .highlight .k { color: #0000FF } -.type-csharp .highlight .kt { color: #0000FF } -.type-csharp .highlight .nf { color: #000000; font-weight: normal } -.type-csharp .highlight .nc { color: #2B91AF } -.type-csharp .highlight .nn { color: #000000 } -.type-csharp .highlight .s { color: #A31515 } -.type-csharp .highlight .sc { color: #A31515 } diff --git a/stylesheets/styles.css b/stylesheets/styles.css deleted file mode 100644 index dacf2e1..0000000 --- a/stylesheets/styles.css +++ /dev/null @@ -1,255 +0,0 @@ -@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700); - -body { - padding:50px; - font:14px/1.5 Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; - color:#777; - font-weight:300; -} - -h1, h2, h3, h4, h5, h6 { - color:#222; - margin:0 0 20px; -} - -p, ul, ol, table, pre, dl { - margin:0 0 20px; -} - -h1, h2, h3 { - line-height:1.1; -} - -h1 { - font-size:28px; -} - -h2 { - color:#393939; -} - -h3, h4, h5, h6 { - color:#494949; -} - -a { - color:#39c; - font-weight:400; - text-decoration:none; -} - -a small { - font-size:11px; - color:#777; - margin-top:-0.6em; - display:block; -} - -.wrapper { - width:860px; - margin:0 auto; -} - -blockquote { - border-left:1px solid #e5e5e5; - margin:0; - padding:0 0 0 20px; - font-style:italic; -} - -code, pre { - font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; - color:#333; - font-size:12px; -} - -pre { - padding:8px 15px; - background: #f8f8f8; - border-radius:5px; - border:1px solid #e5e5e5; - overflow-x: auto; -} - -table { - width:100%; - border-collapse:collapse; -} - -th, td { - text-align:left; - padding:5px 10px; - border-bottom:1px solid #e5e5e5; -} - -dt { - color:#444; - font-weight:700; -} - -th { - color:#444; -} - -img { - max-width:100%; -} - -header { - width:270px; - float:left; - position:fixed; -} - -header ul { - list-style:none; - height:40px; - - padding:0; - - background: #eee; - background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%); - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd)); - background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); - background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); - background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%); - background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%); - - border-radius:5px; - border:1px solid #d2d2d2; - box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0; - width:270px; -} - -header li { - width:89px; - float:left; - border-right:1px solid #d2d2d2; - height:40px; -} - -header ul a { - line-height:1; - font-size:11px; - color:#999; - display:block; - text-align:center; - padding-top:6px; - height:40px; -} - -strong { - color:#222; - font-weight:700; -} - -header ul li + li { - width:88px; - border-left:1px solid #fff; -} - -header ul li + li + li { - border-right:none; - width:89px; -} - -header ul a strong { - font-size:14px; - display:block; - color:#222; -} - -section { - width:500px; - float:right; - padding-bottom:50px; -} - -small { - font-size:11px; -} - -hr { - border:0; - background:#e5e5e5; - height:1px; - margin:0 0 20px; -} - -footer { - width:270px; - float:left; - position:fixed; - bottom:50px; -} - -@media print, screen and (max-width: 960px) { - - div.wrapper { - width:auto; - margin:0; - } - - header, section, footer { - float:none; - position:static; - width:auto; - } - - header { - padding-right:320px; - } - - section { - border:1px solid #e5e5e5; - border-width:1px 0; - padding:20px 0; - margin:0 0 20px; - } - - header a small { - display:inline; - } - - header ul { - position:absolute; - right:50px; - top:52px; - } -} - -@media print, screen and (max-width: 720px) { - body { - word-wrap:break-word; - } - - header { - padding:0; - } - - header ul, header p.view { - position:static; - } - - pre, code { - word-wrap:normal; - } -} - -@media print, screen and (max-width: 480px) { - body { - padding:15px; - } - - header ul { - display:none; - } -} - -@media print { - body { - padding:0.4in; - font-size:12pt; - color:#444; - } -}