diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/tools/auto_index | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/tools/auto_index')
-rw-r--r-- | src/boost/tools/auto_index/build/Jamfile.v2 | 35 | ||||
-rw-r--r-- | src/boost/tools/auto_index/include/auto_index_helpers.qbk | 19 | ||||
-rw-r--r-- | src/boost/tools/auto_index/index.html | 15 | ||||
-rw-r--r-- | src/boost/tools/auto_index/src/auto_index.cpp | 783 | ||||
-rw-r--r-- | src/boost/tools/auto_index/src/auto_index.hpp | 137 | ||||
-rw-r--r-- | src/boost/tools/auto_index/src/file_scanning.cpp | 495 | ||||
-rw-r--r-- | src/boost/tools/auto_index/src/index_generator.cpp | 327 | ||||
-rw-r--r-- | src/boost/tools/auto_index/src/tiny_xml.cpp | 257 | ||||
-rw-r--r-- | src/boost/tools/auto_index/src/tiny_xml.hpp | 83 | ||||
-rw-r--r-- | src/boost/tools/auto_index/test/Jamfile.v2 | 62 | ||||
-rw-r--r-- | src/boost/tools/auto_index/test/index.idx | 26 | ||||
-rw-r--r-- | src/boost/tools/auto_index/test/test1.gold | 6671 | ||||
-rw-r--r-- | src/boost/tools/auto_index/test/test2.gold | 6671 | ||||
-rw-r--r-- | src/boost/tools/auto_index/test/test3.gold | 6671 | ||||
-rw-r--r-- | src/boost/tools/auto_index/test/type_traits.docbook | 6673 |
15 files changed, 28925 insertions, 0 deletions
diff --git a/src/boost/tools/auto_index/build/Jamfile.v2 b/src/boost/tools/auto_index/build/Jamfile.v2 new file mode 100644 index 000000000..2e6227732 --- /dev/null +++ b/src/boost/tools/auto_index/build/Jamfile.v2 @@ -0,0 +1,35 @@ +#============================================================================== +# Copyright (c) 2015 Rene Rivera +# +# Use, modification and distribution is subject to 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) +#============================================================================== + +import quickbook ; +import modules ; +import boostcpp ; +import path ; +import option ; + +local DIST_DIR = [ option.get distdir ] ; +DIST_DIR ?= [ option.get build-dir ] ; +DIST_DIR ?= [ path.join $(BOOST_ROOT) dist ] ; +DIST_DIR = [ path.root [ path.make $(DIST_DIR) ] [ path.pwd ] ] ; +local DIST_BIN = [ path.join $(DIST_DIR) bin ] ; + +exe auto_index : + ../src/auto_index.cpp + ../src/file_scanning.cpp + ../src/index_generator.cpp + ../src/tiny_xml.cpp + /boost//regex + /boost//filesystem + /boost//system + /boost//program_options +: <define>BOOST_ALL_NO_LIB=1 <link>static release ; + +install aii : auto_index : <location>. ; +explicit aii ; + +install i : auto_index : <location>$(DIST_BIN) ; diff --git a/src/boost/tools/auto_index/include/auto_index_helpers.qbk b/src/boost/tools/auto_index/include/auto_index_helpers.qbk new file mode 100644 index 000000000..086c91630 --- /dev/null +++ b/src/boost/tools/auto_index/include/auto_index_helpers.qbk @@ -0,0 +1,19 @@ + + +[template index[] +'''<index/>''' +] + +[template named_index[type title] +'''<index type="'''[type]'''"><title>'''[title]'''</title></index>''' +] + +[template AutoIndex [Args] '''<?BoostAutoIndex ''' [Args]'''?>'''] + +[template indexterm1 [primary] '''<indexterm><primary>'''[primary]'''</primary></indexterm>'''] +[template indexterm2 [primary secondary] '''<indexterm><primary>'''[primary]'''</primary><secondary>'''[secondary]'''</secondary></indexterm>'''] +[template indexterm3 [primary secondary tertiary] '''<indexterm><primary>'''[primary]'''</primary><secondary>'''[secondary]'''</secondary><tertiary>'''[tertiary]'''</tertiary></indexterm>'''] + +[template typed_indexterm1 [type primary] '''<indexterm type="'''[type]'''"><primary>'''[primary]'''</primary></indexterm>'''] +[template typed_indexterm2 [type primary secondary] '''<indexterm type="'''[type]'''"><primary>'''[primary]'''</primary><secondary>'''[secondary]'''</secondary></indexterm>'''] +[template typed_indexterm3 [type primary secondary tertiary] '''<indexterm type="'''[type]'''"><primary>'''[primary]'''</primary><secondary>'''[secondary]'''</secondary><tertiary>'''[tertiary]'''</tertiary></indexterm>'''] diff --git a/src/boost/tools/auto_index/index.html b/src/boost/tools/auto_index/index.html new file mode 100644 index 000000000..df7430bd0 --- /dev/null +++ b/src/boost/tools/auto_index/index.html @@ -0,0 +1,15 @@ +<html> + <head> + <meta http-equiv="refresh" content="0; URL=doc/html/index.html"> + </head> + <body> + <P> + Automatic redirection failed, please go to <a href="doc/html/index.html">doc/html/index.html</a>. + </P> + <P>Copyright John Maddock 2001</P> + <P>Distributed under the Boost Software License, Version 1.0. (See accompanying file <A href="../../LICENSE_1_0.txt"> + LICENSE_1_0.txt</A> or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</A>).</P> + </body> +</html> + + diff --git a/src/boost/tools/auto_index/src/auto_index.cpp b/src/boost/tools/auto_index/src/auto_index.cpp new file mode 100644 index 000000000..e8d5db201 --- /dev/null +++ b/src/boost/tools/auto_index/src/auto_index.cpp @@ -0,0 +1,783 @@ +// Copyright 2008 John Maddock +// +// Use, modification and distribution are subject to 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) + +#include <set> +#include <cstring> +#include <boost/array.hpp> +#include <boost/exception/all.hpp> +#include <boost/program_options.hpp> +#include "auto_index.hpp" + +std::string infile, outfile, prefix, last_primary, last_secondary, last_tertiary; +std::set<index_info> index_terms; +std::set<std::pair<std::string, std::string> > found_terms; +bool no_duplicates = false; +bool verbose = false; +bool use_section_names = true; +index_entry_set index_entries; +boost::tiny_xml::element_list indexes; +std::list<id_rewrite_rule> id_rewrite_list; +bool internal_indexes = false; +std::string internal_index_type = "section"; +boost::regex debug; +file_scanner_set_type file_scanner_set; + +int help() +{ + std::cout << "Please refer to the documentation for the correct command line syntax" << std::endl; + return 1; +} + +void eat_block(std::string& result, std::istream & is) +{ + // + // everything until we get to a closing '>': + // + char c; + while(is.get(c) && c != '>') + { + result += c; + if(c == '\\') + { + is.get(c); + result += c; + } + } + result += c; +} + +std::string get_header(std::istream & is) +{ + // + // We need to get any leading <? and <! elements: + // + std::string result; + is >> std::ws; + if(is.get() != '<') + throw std::runtime_error("Invalid leading markup in XML file found"); + char c = is.peek(); + while((c == '?') || (c == '!')) + { + std::string temp; + std::getline(is, temp, '>'); + result += '<' + temp + '>'; + is >> std::ws; + if(is.get() != '<') + throw std::runtime_error("Invalid leading markup in XML file found"); + c = is.peek(); + result += '\n'; + } + return result; +} +// +// Find attribute named "name" in node "node": +// +const std::string* find_attr(boost::tiny_xml::element_ptr node, const char* name) +{ + for(boost::tiny_xml::attribute_list::const_iterator i = node->attributes.begin(); + i != node->attributes.end(); ++i) + { + if(i->name == name) + return &(i->value); + } + return 0; +} +// +// Get the ID of the current block scope, basically +// move up the XML tree until we find a valid ID: +// +const std::string* get_current_block_id(node_id const* id) +{ + while((id->id == 0) && (id->prev)) + id = id->prev; + if(!id->id) + BOOST_THROW_EXCEPTION(std::runtime_error("Current XML block has no enclosing ID: XML is not valid Boostbook?")); + return id->id; +} +// +// Get the title of the current block scope, basically +// move up the XML tree until we find a valid title: +// +const std::string& get_current_block_title(title_info const* id) +{ + while((id->title.size() == 0) && (id->prev)) + id = id->prev; + return id->title; +} +// +// Get all the content under this node, with any inline XML +// stripped out: +// +std::string get_consolidated_content(boost::tiny_xml::element_ptr node) +{ + std::string result(node->content); + for(boost::tiny_xml::element_list::const_iterator i = node->elements.begin(); + i != node->elements.end(); ++i) + { + result += " "; + result += get_consolidated_content(*i); + } + static const boost::regex e("(^[[:space:]]+)|([[:space:]]+)|([[:space:]]+$)"); + return regex_replace(result, e, "(?2 )", boost::regex_constants::format_all); +} +// +// Rewrite a title based on any rewrite rules we may have: +// +std::string rewrite_title(const std::string& title, const std::string& id) +{ + for(std::list<id_rewrite_rule>::const_iterator i = id_rewrite_list.begin(); i != id_rewrite_list.end(); ++i) + { + if(i->base_on_id) + { + if(regex_match(id, i->id)) + return i->new_name; + } + else + { + if(regex_match(title, i->id)) + return regex_replace(title, i->id, i->new_name); + } + } + return title; +} + +struct string_cmp +{ + bool operator()(const char* a, const char* b)const + { + return std::strcmp(a, b) < 0; + } +}; +// +// Discover whether this node can contain a <title> or not, if not +// we don't want to link to it, or the XSL HTML stylesheets may do strange +// things, and at least emit copious messages. See https://sourceforge.net/tracker/?func=detail&aid=3325153&group_id=21935&atid=373747 +// +bool can_contain_title(const char* name) +{ + static const boost::array<const char*, 103> names = + { { + "abstract", "appendix", "appendixinfo", "article", "articleinfo", "authorblurb", "bibliodiv", "biblioentry", "bibliography", + "bibliographyinfo", "bibliolist", "bibliomixed", "bibliomset", "biblioset", "blockinfo", "blockquote", "book", "bookinfo", + "calloutlist", "caution", "chapter", "chapterinfo", "colophon", "constraintdef", "dedication", "equation", "example", "figure", + "formalpara", "glossary", "glossaryinfo", "glossdiv", "glosslist", "important", "index", "indexdiv", "indexinfo", "itemizedlist", + "legalnotice", "lot", "msg", "msgexplan", "msgmain", "msgrel", "msgset", "msgsub", "note", "objectinfo", "orderedlist", "part", + "partinfo", "partintro", "personblurb", "preface", "prefaceinfo", "procedure", "productionset", "qandadiv", "qandaset", + "refentryinfo", "reference", "referenceinfo", "refsect1", "refsect1info", "refsect2", "refsect2info", "refsect3", "refsect3info", + "refsection", "refsectioninfo", "refsynopsisdiv", "refsynopsisdivinfo", "sect1", "sect1info", "sect2", "sect2info", "sect3", + "sect3info", "sect4", "sect4info", "sect5", "sect5info", "section", "sectioninfo", "segmentedlist", "set", "setindex", + "setindexinfo", "setinfo", "sidebar", "sidebarinfo", "simplesect", "step", "table", "task", "taskprerequisites", + "taskrelated", "tasksummary", "tip", "toc", "variablelist", "warning", "refentry" + } }; + static std::set<const char*, string_cmp> permitted; + + if(permitted.empty()) + permitted.insert(names.begin(), names.end()); + + return 0 != permitted.count(name); +} +// +// Determine whether this node can contain an indexterm or not: +// +bool can_contain_indexterm(const char* name) +{ + static const boost::array<const char*, 257> names = + { { + "abbrev", "accel", "ackno", "acronym", "action", "answer", "appendix", "appendixinfo", "application", + "article", "articleinfo", "artpagenums", "attribution", "authorinitials", "bibliocoverage", "bibliodiv", + "biblioentry", "bibliography", "bibliographyinfo", "biblioid", "bibliomisc", "bibliomixed", "bibliomset", + "bibliorelation", "biblioset", "bibliosource", "blockinfo", "blockquote", "bookinfo", "bridgehead", "callout", + "caution", "chapter", "chapterinfo", "citation", "citebiblioid", "citetitle", "city", "classname", "classsynopsisinfo", + "code", "collabname", "command", "computeroutput", "confdates", "confnum", "confsponsor", "conftitle", "constant", + "constraintdef", "contractnum", "contractsponsor", "contrib", "corpauthor", "corpcredit", "corpname", "country", + "database", "date", "dedication", "edition", "email", "emphasis", "entry", "envar", "errorcode", "errorname", "errortext", + "errortype", "example", "exceptionname", "fax", "figure", "filename", "firstname", "firstterm", "foreignphrase", + "formalpara", "funcparams", "funcsynopsisinfo", "function", "glossary", "glossaryinfo", "glossdef", "glossdiv", + "glossentry", "glosssee", "glossseealso", "glossterm", "guibutton", "guiicon", "guilabel", "guimenu", "guimenuitem", + "guisubmenu", "hardware", "highlights", "holder", "honorific", "important", "index", "indexinfo", "informalexample", + "informalfigure", "initializer", "interface", "interfacename", "invpartnumber", "isbn", "issn", "issuenum", "itemizedlist", + "itermset", "jobtitle", "keycap", "keycode", "keysym", "label", "legalnotice", "lineage", "lineannotation", + /*"link", */"listitem", "literal", "literallayout", "lotentry", "manvolnum", "markup", "medialabel", "member", + "methodname", "modespec", "modifier", "mousebutton", "msgaud", "msgexplan", "msglevel", "msgorig", "msgtext", "note", + "objectinfo", "olink", "option", "optional", "orderedlist", "orgdiv", "orgname", "otheraddr", "othername", "package", + "pagenums", "para", "parameter", "partinfo", "partintro", "phone", "phrase", "pob", "postcode", "preface", "prefaceinfo", + "procedure", "productname", "productnumber", "programlisting", "prompt", "property", "pubdate", "publishername", + "pubsnumber", "qandadiv", "qandaset", "question", "quote", "refentry", "refentryinfo", "refentrytitle", "referenceinfo", + "refmeta", "refmiscinfo", "refpurpose", "refsect1", "refsect1info", "refsect2", "refsect2info", "refsect3", "refsect3info", + "refsection", "refsectioninfo", "refsynopsisdiv", "refsynopsisdivinfo", "releaseinfo", "remark", "returnvalue", + "revdescription", "revnumber", "revremark", "screen", "screeninfo", "sect1", "sect1info", "sect2", "sect2info", "sect3", + "sect3info", "sect4", "sect4info", "sect5", "sect5info", "section", "sectioninfo", "seg", "segtitle", "seriesvolnums", + "setindex", "setindexinfo", "setinfo", "sgmltag", "shortaffil", "sidebar", "sidebarinfo", "simpara", "simplesect", + "state", "step", "street", "structfield", "structname", "subtitle", "surname", "symbol", "synopsis", "systemitem", + "table", "task", "taskprerequisites", "taskrelated", "tasksummary", "td", "term", "termdef", "th", "tip", /*"title",*/ + "titleabbrev", "tocback", "tocentry", "tocfront", "token", "type", "ulink", "uri", "userinput", "variablelist", + "varname", "volumenum", "warning", "wordasword", "year" + } }; + static std::set<const char*, string_cmp> permitted; + + if(permitted.empty()) + permitted.insert(names.begin(), names.end()); + + return 0 != permitted.count(name); +} +// +// Decide whether to flatten this node for searching purposes: +// +bool should_flatten_node(const char* name) +{ + // + // The list of nodes to flatten is basically the list of elements that + // can appear inside a <section> - see http://www.docbook.org/tdg/en/html/section.html. + // In other words basically anything at the level of a paragraph/table/listing etc. + // + static const boost::array<const char*, 57> names = + { { + "title", "subtitle", "titleabbrev", + "toc", "lot", "glossary", "bibliography", + /*"calloutlist", "glosslist", "bibliolist", "itemizedlist", "orderedlist", + "segmentedlist", "simplelist", "variablelist",*/ "caution", "important", "note", + "tip", "warning", "literallayout", "programlisting", "programlistingco", + "screen", "screenco", "screenshot", "synopsis", "cmdsynopsis", "funcsynopsis", + "classsynopsis", "fieldsynopsis", "constructorsynopsis", + "destructorsynopsis", "methodsynopsis", "formalpara", "para", "simpara", + "address", "blockquote", "graphic", "graphicco", "mediaobject", + "mediaobjectco", "informalequation", "informalexample", "informalfigure", + "informaltable", "equation", "example", "figure", "table", "msgset", "procedure", + "sidebar", "qandaset", "task", "productionset", "constraintdef", "anchor", + "bridgehead", "remark", "highlights", "abstract", "authorblurb", "epigraph" + /*"biblioentry", "bibliomixed", "callout", "glossentry", "listitem", "seg", "seglistitem", "member", + "term", */ + } }; + static std::set<const char*, string_cmp> terminals; + + if(terminals.empty()) + terminals.insert(names.begin(), names.end()); + return 0 != terminals.count(name); +} +std::string unescape_xml(const std::string& s) +{ + boost::regex e("&(?:(quot)|(amp)|(apos)|(lt)|(gt));"); + return regex_replace(s, e, "(?1\")(?2&)(?3\')(?4<)(?5>)", boost::regex_constants::format_all); +} +// +// Exception classes to propagate processing instruction info: +// +struct ignore_section{}; +struct ignore_block{}; +// +// Check if we're in a section (or chapter etc) or not: +// +bool is_section(const std::string& name) +{ + static const boost::array<const char*, 19> data = + {{ + "dedication", "toc", "lot", "glossary", "bibliography", "preface", "chapter", + "reference", "part", "article", "appendix", "index", "setindex", "colophon", + "sect1", "refentry", "simplesect", "section", "partintro" + }}; + std::set<std::string> names; + if(names.empty()) + names.insert(data.begin(), data.end()); + return 0 != names.count(name); +} +// +// Check if we're in a block/paragraph or not: +// +bool is_block(const std::string& name) +{ + static const boost::array<const char*, 58> data = + {{ + "calloutlist", "glosslist", "bibliolist", "itemizedlist", "orderedlist", + "segmentedlist", "simplelist", "variablelist", "caution", "important", "note", + "tip", "warning", "literallayout", "programlisting", "programlistingco", + "screen", "screenco", "screenshot", "synopsis", "cmdsynopsis", "funcsynopsis", + "classsynopsis", "fieldsynopsis", "constructorsynopsis", + "destructorsynopsis", "methodsynopsis", "formalpara", "para", "simpara", + "address", "blockquote", "graphic", "graphicco", "mediaobject", + "mediaobjectco", "informalequation", "informalexample", "informalfigure", + "informaltable", "equation", "example", "figure", "table", "msgset", "procedure", + "sidebar", "qandaset", "task", "productionset", "constraintdef", "anchor", + "bridgehead", "remark", "highlights", "abstract", "authorblurb", "epigraph" + }}; + std::set<std::string> names; + if(names.empty()) + names.insert(data.begin(), data.end()); + return 0 != names.count(name); +} +// +// Helper proc to recurse through children: +// +void process_node(boost::tiny_xml::element_ptr node, node_id* prev, title_info* pt, bool seen); +bool recurse_through_children(boost::tiny_xml::element_ptr node, node_id* id, title_info* pt, bool seen) +{ + try + { + for(boost::tiny_xml::element_list::const_iterator i = node->elements.begin(); + i != node->elements.end(); ++i) + { + process_node(*i, id, pt, seen); + } + } + catch(const ignore_section&) + { + if(is_section(node->name)) + return false; + else + throw; + } + catch(const ignore_block&) + { + if(is_block(node->name) || is_section(node->name)) + return false; + else + throw; + } + return true; +} +// +// This does most of the work: process the node pointed to, and any children +// that it may have: +// +void process_node(boost::tiny_xml::element_ptr node, node_id* prev, title_info* pt, bool seen = false) +{ + // + // Store the current ID and title as nested scoped objects: + // + node_id id = { 0, prev }; + if(can_contain_title(node->name.c_str())) + { + // Only set the ID to link to if the block can contain a title, see + // can_contain_title above for rationale. + id.id = find_attr(node, "id"); + } + title_info title = { "", pt}; + bool flatten = should_flatten_node(node->name.c_str()); + + if(node->name.size() && node->name[0] == '?') + { + if(node->name == "?BoostAutoIndex") + { + if(node->content == "IgnoreSection") + { + throw ignore_section(); + } + else if(node->content == "IgnoreBlock") + { + throw ignore_block(); + } + } + return; // Ignore processing instructions + } + else if((node->name == "title") && (id.prev->id)) + { + // + // This actually sets the title of the enclosing scope, + // not this tag itself: + // + title.prev->title = get_consolidated_content(node); + if(verbose) + std::cout << "Indexing section: " << title.prev->title << std::endl; + } + else if((node->name == "refentrytitle") && (id.prev->prev->id)) + { + // + // This actually sets the title of the enclosing refentry scope, + // not this tag itself: + // + title.prev->prev->title = get_consolidated_content(node); + if(verbose) + std::cout << "Indexing refentry: " << title.prev->prev->title << std::endl; + } + if(node->name == "anchor") + { + if(node->parent.lock()->name == "title") + { + // We have a title with a nested anchor ID, change the ID of our parents parent to match: + id.prev->prev->id = id.id; + } + } + else if(node->name == "index") + { + // Keep track of all the indexes we see: + indexes.push_back(node); + if(node->parent.lock()->name == "para") + node->parent.lock()->name = ""; + } + else if(node->name == "primary") + { + last_primary = get_consolidated_content(node); + } + else if(node->name == "secondary") + { + last_secondary = get_consolidated_content(node); + } + else if(node->name == "tertiary") + { + last_tertiary = get_consolidated_content(node); + } + else if((node->name == "see") && internal_indexes) + { + std::cerr << "WARNING: <see> in XML source will be ignored for the index generation" << std::endl; + } + else if((node->name == "seealso") && internal_indexes) + { + std::cerr << "WARNING: <seealso> in XML source will be ignored for the index generation" << std::endl; + } + + std::string flattenned_text; + const std::string* ptext; + if(flatten) + { + flattenned_text = unescape_xml(get_consolidated_content(node)); + ptext = &flattenned_text; + // + // Recurse through children here if we're going to flatten the text, that way we see any processing instructions first: + // + if(!recurse_through_children(node, &id, &title, flatten || seen)) + return; + } + else + { + ptext = &(node->content); + } + + // + // Search content for items: we only search if the content is not empty, + // and the content is not whitespace alone, and we haven't already searched this + // text in one of our parent nodes that got flattened. + // + static const boost::regex space_re("[[:space:]]+"); + if(!seen && ptext->size() && !regex_match(*ptext, space_re)) + { + // Save block ID and title in case we find some hits: + const std::string* pid = get_current_block_id(&id); + const std::string& rtitle = get_current_block_title(&title); + const std::string simple_title = rewrite_title(rtitle, *pid); + // Scan for each index term: + for(std::set<index_info>::const_iterator i = index_terms.begin(); + i != index_terms.end(); ++i) + { + if(regex_search(*ptext, i->search_text)) + { + // + // We need to check to see if this term has already been indexed + // in this zone, in order to prevent duplicate entries, also check + // that any constrait placed on the term's ID is satisfied: + // + std::pair<std::string, std::string> item_index(*pid, i->term); + if(((no_duplicates == false) || (0 == found_terms.count(item_index))) + && (i->search_id.empty() || regex_match(*pid, i->search_id))) + { + // We have something to index! + found_terms.insert(item_index); + + if(!debug.empty() && (regex_match(i->term, debug) || regex_match(rtitle, debug) || regex_match(simple_title, debug))) + { + std::cout << "Debug term found, in block with ID: " << *pid << std::endl; + std::cout << "Current section title is: " << rtitle << std::endl; + std::cout << "The main index entry will be : " << simple_title << std::endl; + std::cout << "The indexed term is: " << i->term << std::endl; + std::cout << "The search regex is: " << i->search_text << std::endl; + std::cout << "The section constraint is: " << i->search_id << std::endl; + std::cout << "The index type for this entry is: " << i->category << std::endl; + } + + if(use_section_names && (simple_title != i->term)) + { + // + // First off insert index entry with primary term + // consisting of the section title, and secondary term the + // actual index term, this gets skipped if the title and index + // term are the same: + // + if(internal_indexes == false) + { + // Insert an <indexterm> into the XML: + boost::tiny_xml::element_ptr p(new boost::tiny_xml::element()); + p->name = "indexterm"; + boost::tiny_xml::element_ptr prim(new boost::tiny_xml::element()); + prim->name = "primary"; + prim->elements.push_front(boost::tiny_xml::element_ptr(new boost::tiny_xml::element())); + prim->elements.front()->content = simple_title; + p->elements.push_front(prim); + + boost::tiny_xml::element_ptr sec(new boost::tiny_xml::element()); + sec->name = "secondary"; + sec->elements.push_front(boost::tiny_xml::element_ptr(new boost::tiny_xml::element())); + sec->elements.front()->content = i->term; + p->elements.push_back(sec); + try{ + // Insert the Indexterm: + boost::tiny_xml::element_ptr parent(node->parent); + while(!can_contain_indexterm(parent->name.c_str())) + parent = parent->parent.lock(); + parent->elements.push_front(p); + } + catch(const std::exception&) + { + std::cerr << "Unable to find location to insert <indexterm>" << std::endl; + } + } + // Track the entry in our internal index: + index_entry_ptr item1(new index_entry(simple_title)); + index_entry_ptr item2(new index_entry(i->term, *pid)); + index_entry_set::iterator pos = index_entries.insert(item1).first; + (**pos).sub_keys.insert(item2); + } + // + // Now insert another index entry with the index term + // as the primary key, and the section title as the + // secondary key, this one gets assigned to the + // appropriate index category if there is one: + // + bool preferred_term = false; + if(internal_indexes == false) + { + // Insert <indexterm> into the XML: + boost::tiny_xml::element_ptr p2(new boost::tiny_xml::element()); + p2->name = "indexterm"; + if(i->category.size()) + { + p2->attributes.push_back(boost::tiny_xml::attribute("type", i->category)); + } + boost::tiny_xml::element_ptr prim2(new boost::tiny_xml::element()); + prim2->name = "primary"; + prim2->elements.push_front(boost::tiny_xml::element_ptr(new boost::tiny_xml::element())); + prim2->elements.front()->content = i->term; + p2->elements.push_front(prim2); + + boost::tiny_xml::element_ptr sec2(new boost::tiny_xml::element()); + sec2->name = "secondary"; + sec2->elements.push_front(boost::tiny_xml::element_ptr(new boost::tiny_xml::element())); + sec2->elements.front()->content = rtitle; + p2->elements.push_back(sec2); + try{ + // Insert the Indexterm: + boost::tiny_xml::element_ptr parent(node->parent); + while(!can_contain_indexterm(parent->name.c_str())) + { + // If the search text was found in a title then make it a preferred term: + if(parent->name == "title") + preferred_term = true; + parent = parent->parent.lock(); + } + if(preferred_term) + { + boost::tiny_xml::attribute a("significance", "preferred"); + p2->attributes.push_back(a); + } + parent->elements.push_front(p2); + } + catch(const std::exception&) + { + std::cerr << "Unable to find location to insert <indexterm>" << std::endl; + } + } + + // Track the entry in our internal index: + try{ + // figure out if it's preferred or not: + boost::tiny_xml::element_ptr parent(node->parent); + while(!can_contain_indexterm(parent->name.c_str())) + { + // If the search text was found in a title then make it a preferred term: + if(parent->name == "title") + { + preferred_term = true; + } + parent = parent->parent.lock(); + if(!parent) + break; + } + } + catch(const std::exception&){} + + index_entry_ptr item3(new index_entry(i->term)); + if(i->category.size()) + item3->category = i->category; + index_entry_ptr item4(new index_entry(rtitle, *pid)); + item4->preferred = preferred_term; + index_entry_set::iterator pos = index_entries.insert(item3).first; + (**pos).sub_keys.insert(item4); + } + } + } + } + // + // Recurse through children, if not done already: + // + if(!flatten) + recurse_through_children(node, &id, &title, flatten || seen); + // + // Process manual index entries last of all: + // + if(node->name == "indexterm") + { + // Track the entry in our internal index: + const std::string* pid = get_current_block_id(&id); + const std::string* attr = find_attr(node, "type"); + const std::string& rtitle = get_current_block_title(&title); + const std::string simple_title = rewrite_title(rtitle, *pid); + index_entry_ptr item1(new index_entry(last_primary, "", attr ? *attr : "")); + index_entry_set* parent = &((*index_entries.insert(item1).first)->sub_keys); + + if(last_secondary.size()) + { + item1.reset(new index_entry(last_secondary, "", attr ? *attr : "")); + parent = &((*parent->insert(item1).first)->sub_keys); + } + if(last_tertiary.size()) + { + item1.reset(new index_entry(last_tertiary, "", attr ? *attr : "")); + parent = &((*parent->insert(item1).first)->sub_keys); + } + item1.reset(new index_entry(simple_title, *pid, attr ? *attr : "")); + parent->insert(item1); + + last_primary = ""; + last_secondary = ""; + last_tertiary = ""; + } +} + +void process_nodes(boost::tiny_xml::element_ptr node) +{ + node_id id = { 0, }; + title_info t = { "", 0 }; + process_node(node, &id, &t); +} + +int main(int argc, char* argv[]) +{ + try{ + + namespace po = boost::program_options; + po::options_description desc("AutoIndex Allowed Options"); + desc.add_options() + ("help", "Print help message") + ("in", po::value<std::string>(), "Set the input XML file.") + ("out", po::value<std::string>(), "Set output input XML file.") + ("scan", po::value<std::string>(), "Scan the specified file for terms to try and index.") + ("script", po::value<std::string>(), "Specifies the script file to use.") + ("no-duplicates", "Prevents duplicate index entries within the same section.") + ("no-section-names", "Suppresses use of section names as index entries.") + ("internal-index", "Causes AutoIndex to generate the index itself, rather than relying on the XSL stylesheets.") + ("verbose", "Turns on verbose mode.") + ("prefix", po::value<std::string>(), "Sets the prefix to be prepended to all file names and paths in the script file.") + ("index-type", po::value<std::string>(), "Sets the XML container type to use the index.") + ; + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + // + // Process arguments: + // + if(vm.count("help")) + { + std::cout << desc; + return 0; + } + if(vm.count("in")) + { + infile = vm["in"].as<std::string>(); + } + else + { + std::cerr << "No input XML file specified" << std::endl; + return 1; + } + if(vm.count("out")) + { + outfile = vm["out"].as<std::string>(); + } + else + { + std::cerr << "No output XML file specified" << std::endl; + return 1; + } + if(vm.count("verbose")) + { + verbose = true; + } + if(vm.count("prefix")) + { + prefix = vm["prefix"].as<std::string>(); + } + if(vm.count("scan")) + { + std::string f = vm["scan"].as<std::string>(); + if(!exists(boost::filesystem::path(f))) + throw std::runtime_error("Error the file requested for scanning does not exist: " + f); + scan_file(f); + } + if(vm.count("script")) + { + process_script(vm["script"].as<std::string>()); + } + if(vm.count("no-duplicates")) + { + no_duplicates = true; + } + if(vm.count("no-section-names")) + { + use_section_names = false; + } + if(vm.count("internal-index")) + { + internal_indexes = true; + } + if(vm.count("index-type")) + { + internal_index_type = vm["index-type"].as<std::string>(); + } + + std::ifstream is(infile.c_str()); + if((0 == is.peek()) || !is.good()) + { + std::cerr << "Unable to open XML data file " << argv[1] << std::endl; + return 1; + } + // + // We need to skip any leading <? and <! elements: + // + std::string header = get_header(is); + boost::tiny_xml::element_ptr xml = boost::tiny_xml::parse(is, ""); + is.close(); + + std::cout << "Indexing " << index_terms.size() << " terms..." << std::endl; + + process_nodes(xml); + + if(internal_indexes) + generate_indexes(); + + std::ofstream os(outfile.c_str()); + os << header << std::endl; + boost::tiny_xml::write(*xml, os); + std::cout << index_entries.size() << " Index entries were created." << std::endl; + + } + catch(boost::exception& e) + { + std::cerr << diagnostic_information(e); + return 1; + } + catch(const std::exception& e) + { + std::cerr << e.what() << std::endl; + return 1; + } + catch(const std::string& s) + { + std::cerr << s << std::endl; + return 1; + } + + return 0; +} diff --git a/src/boost/tools/auto_index/src/auto_index.hpp b/src/boost/tools/auto_index/src/auto_index.hpp new file mode 100644 index 000000000..255b8575f --- /dev/null +++ b/src/boost/tools/auto_index/src/auto_index.hpp @@ -0,0 +1,137 @@ +// Copyright 2008 John Maddock +// +// Use, modification and distribution are subject to 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) + +#ifndef BOOST_AUTO_INDEX_HPP +#define BOOST_AUTO_INDEX_HPP + +#include <boost/version.hpp> + +#if BOOST_VERSION < 104400 +# error "This tool requires Boost 1.44 or later to build." +#endif + +#define BOOST_FILESYSTEM_VERSION 3 + +#include "tiny_xml.hpp" +#include <boost/regex.hpp> +#include <boost/filesystem.hpp> +#include <boost/algorithm/string/case_conv.hpp> +#include <fstream> +#include <cctype> +#include <map> +#include <set> +#include <sstream> + +struct index_info +{ + std::string term; // The term goes in the index entry + boost::regex search_text; // What to search for when indexing the term. + boost::regex search_id; // What id's this term may be indexed in. + std::string category; // Index category (function, class, macro etc). +}; +inline bool operator < (const index_info& a, const index_info& b) +{ + return (a.term != b.term) ? (a.term < b.term) : (a.category < b.category); +} + + +struct index_entry; +typedef boost::shared_ptr<index_entry> index_entry_ptr; +bool operator < (const index_entry_ptr& a, const index_entry_ptr& b); +typedef std::set<index_entry_ptr> index_entry_set; + +struct index_entry +{ + std::string key; // The index term. + std::string sort_key; // upper case version of term used for sorting. + std::string id; // The id of the block that we will link to. + std::string category; // The category of this entry (function, class, macro etc). + index_entry_set sub_keys; // All our sub-keys. + bool preferred; // This entry is the preferred one for this key + + index_entry() : preferred(false) {} + index_entry(const std::string& k) : key(k), sort_key(k), preferred(false) { boost::to_upper(sort_key); } + index_entry(const std::string& k, const std::string& i) : key(k), sort_key(k), id(i), preferred(false) { boost::to_upper(sort_key); } + index_entry(const std::string& k, const std::string& i, const std::string& c) : key(k), sort_key(k), id(i), category(c), preferred(false) { boost::to_upper(sort_key); } +}; + + +inline bool operator < (const index_entry_ptr& a, const index_entry_ptr& b) +{ + return ((a->sort_key != b->sort_key) ? (a->sort_key < b->sort_key) : (a->category < b->category)); +} + +struct id_rewrite_rule +{ + bool base_on_id; // rewrite the title if "id" matches the section id, otherwise rewrite if title matches "id". + boost::regex id; // regex for the id or title to match + std::string new_name; // either literal string or format string for the new name. + + id_rewrite_rule(const std::string& i, const std::string& n, bool b) + : base_on_id(b), id(i), new_name(n) {} +}; + +struct node_id +{ + const std::string* id; + node_id* prev; +}; + +struct title_info +{ + std::string title; + title_info* prev; +}; + +struct file_scanner +{ + boost::regex scanner, file_name_filter, section_filter; + std::string format_string, type, term_formatter; +}; + +inline bool operator < (const file_scanner & a, const file_scanner& b) +{ + return a.type < b.type; +} + +typedef std::multiset<file_scanner> file_scanner_set_type; + +void process_script(const std::string& script); +void scan_dir(const std::string& dir, const std::string& mask, bool recurse); +void scan_file(const std::string& file); +void generate_indexes(); +const std::string* find_attr(boost::tiny_xml::element_ptr node, const char* name); + +extern file_scanner_set_type file_scanner_set; + +inline void add_file_scanner(const std::string& type, const std::string& scanner, const std::string& format, const std::string& term_formatter, const std::string& id_filter, const std::string& file_filter) +{ + file_scanner s; + s.type = type; + s.scanner = scanner; + s.format_string = format; + s.term_formatter = term_formatter; + if(file_filter.size()) + s.file_name_filter = file_filter; + if(id_filter.size()) + s.section_filter = id_filter; + file_scanner_set.insert(s); +} + +extern std::set<index_info> index_terms; +extern std::set<std::pair<std::string, std::string> > found_terms; +extern bool no_duplicates; +extern bool verbose; +extern index_entry_set index_entries; +extern boost::tiny_xml::element_list indexes; +extern std::list<id_rewrite_rule> id_rewrite_list; +extern bool internal_indexes; +extern std::string prefix; +extern std::string internal_index_type; +extern boost::regex debug; + +#endif diff --git a/src/boost/tools/auto_index/src/file_scanning.cpp b/src/boost/tools/auto_index/src/file_scanning.cpp new file mode 100644 index 000000000..f6c2209c6 --- /dev/null +++ b/src/boost/tools/auto_index/src/file_scanning.cpp @@ -0,0 +1,495 @@ +// Copyright 2008 John Maddock +// +// Use, modification and distribution are subject to 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) + +#include "auto_index.hpp" + +bool need_defaults = true; + +void install_default_scanners() +{ + need_defaults = false; + // + // Set the default scanners if they're not defined already: + // + file_scanner s; + s.type = "class_name"; + if(file_scanner_set.find(s) == file_scanner_set.end()) + { + add_file_scanner( + "class_name", // Index type + // Header file scanner regex: + // possibly leading whitespace: + "^[[:space:]]*" + // possible template declaration: + "(template[[:space:]]*<[^;:{]+>[[:space:]]*)?" + // class or struct: + "(class|struct)[[:space:]]*" + // leading declspec macros etc: + "(" + "\\<\\w+\\>" + "(" + "[[:blank:]]*\\([^)]*\\)" + ")?" + "[[:space:]]*" + ")*" + // the class name + "(\\<\\w*\\>)[[:space:]]*" + // template specialisation parameters + "(<[^;:{]+>)?[[:space:]]*" + // terminate in { or : + "(\\{|:[^;\\{()]*\\{)", + + "(?:class|struct)[^;{]+\\\\<\\5\\\\>[^;{]+\\\\{", // Format string to create indexing regex. + "\\5", // Format string to create index term. + "", // Filter regex for section id's. + "" // Filter regex for filenames. + ); + } + + s.type = "typedef_name"; + if(file_scanner_set.find(s) == file_scanner_set.end()) + { + add_file_scanner( + "typedef_name", // Index type + "typedef[^;{}#]+?(\\w+)\\s*;", // scanner regex + "typedef[^;]+\\\\<\\1\\\\>\\\\s*;", // Format string to create indexing regex. + "\\1", // Format string to create index term. + "", // Filter regex for section id's. + "" // Filter regex for filenames. + ); + } + + s.type = "macro_name"; + if(file_scanner_set.find(s) == file_scanner_set.end()) + { + add_file_scanner( + "macro_name", // Index type + "^\\s*#\\s*define\\s+(\\w+)", // scanner regex + "\\\\<\\1\\\\>", // Format string to create indexing regex. + "\\1", // Format string to create index term. + "", // Filter regex for section id's. + "" // Filter regex for filenames. + ); + } + + s.type = "function_name"; + if(file_scanner_set.find(s) == file_scanner_set.end()) + { + add_file_scanner( + "function_name", // Index type + "\\w++(?:\\s*+<[^>]++>)?[\\s&*]+?(\\w+)\\s*(?:BOOST_[[:upper:]_]+\\s*)?\\([^;{}]*\\)\\s*[;{]", // scanner regex + "\\\\<\\\\w+\\\\>(?:\\\\s+<[^>]*>)*[\\\\s&*]+\\\\<\\1\\\\>\\\\s*\\\\([^;{]*\\\\)", // Format string to create indexing regex. + "\\1", // Format string to create index term. + "", // Filter regex for section id's. + "" // Filter regex for filenames. + ); + } +} + +// +// Helper to dump file contents into a std::string: +// +void load_file(std::string& s, std::istream& is) +{ + s.erase(); + if(is.bad()) return; + s.reserve(is.rdbuf()->in_avail()); + char c; + while(is.get(c)) + { + if(s.capacity() == s.size()) + s.reserve(s.capacity() * 3); + s.append(1, c); + } +} +// +// Helper to convert string from external source into valid XML: +// +std::string escape_to_xml(const std::string& in) +{ + std::string result; + for(std::string::size_type i = 0; i < in.size(); ++i) + { + switch(in[i]) + { + case '&': + result.append("&"); + break; + case '<': + result.append("<"); + break; + case '>': + result.append(">"); + break; + case '"': + result.append("""); + break; + default: + result.append(1, in[i]); + } + } + return result; +} +// +// Scan a source file for things to index: +// +void scan_file(const std::string& file) +{ + if(need_defaults) + install_default_scanners(); + if(verbose) + std::cout << "Scanning file... " << file << std::endl; + std::string text; + std::ifstream is(file.c_str()); + if(!is.peek() || !is.good()) + throw std::runtime_error(std::string("Unable to read from file: ") + file); + load_file(text, is); + + for(file_scanner_set_type::iterator pscan = file_scanner_set.begin(); pscan != file_scanner_set.end(); ++pscan) + { + bool need_debug = false; + if(!debug.empty() && regex_match(pscan->type, ::debug)) + { + need_debug = true; + std::cout << "Processing scanner " << pscan->type << " on file " << file << std::endl; + std::cout << "Scanner regex:" << pscan->scanner << std::endl; + std::cout << "Scanner formatter (search regex):" << pscan->format_string << std::endl; + std::cout << "Scanner formatter (index term):" << pscan->term_formatter << std::endl; + std::cout << "Scanner file name filter:" << pscan->file_name_filter << std::endl; + std::cout << "Scanner section id filter:" << pscan->section_filter << std::endl; + } + if(!pscan->file_name_filter.empty()) + { + if(!regex_match(file, pscan->file_name_filter)) + { + if(need_debug) + { + std::cout << "File failed to match file name filter, this file will be skipped..." << std::endl; + } + continue; // skip this file + } + } + if(verbose && !need_debug) + std::cout << "Scanning for type \"" << (*pscan).type << "\" ... " << std::endl; + boost::sregex_iterator i(text.begin(), text.end(), (*pscan).scanner), j; + while(i != j) + { + try + { + index_info info; + info.term = escape_to_xml(i->format(pscan->term_formatter)); + info.search_text = i->format(pscan->format_string); + info.category = pscan->type; + if(!pscan->section_filter.empty()) + info.search_id = pscan->section_filter; + std::pair<std::set<index_info>::iterator, bool> pos = index_terms.insert(info); + if(pos.second) + { + if(verbose || need_debug) + std::cout << "Indexing " << info.term << " as type " << info.category << std::endl; + if(need_debug) + std::cout << "Search regex will be: \"" << info.search_text << "\"" << + " ID constraint is: \"" << info.search_id << "\"" + << "Found text was: " << i->str() << std::endl; + if(pos.first->search_text != info.search_text) + { + // + // Merge the search terms: + // + const_cast<boost::regex&>(pos.first->search_text) = + "(?:" + pos.first->search_text.str() + ")|(?:" + info.search_text.str() + ")"; + } + if(pos.first->search_id != info.search_id) + { + // + // Merge the ID constraints: + // + const_cast<boost::regex&>(pos.first->search_id) = + "(?:" + pos.first->search_id.str() + ")|(?:" + info.search_id.str() + ")"; + } + } + } + catch(const boost::regex_error& e) + { + std::cerr << "Unable to create regular expression from found index term:\"" + << i->format(pscan->term_formatter) << "\" In file " << file << std::endl; + std::cerr << e.what() << std::endl; + } + catch(const std::exception& e) + { + std::cerr << "Unable to create index term:\"" + << i->format(pscan->term_formatter) << "\" In file " << file << std::endl; + std::cerr << e.what() << std::endl; + throw; + } + ++i; + } + } +} +// +// Scan a whole directory for files to search: +// +void scan_dir(const std::string& dir, const std::string& mask, bool recurse) +{ + using namespace boost::filesystem; + boost::regex e(mask); + directory_iterator i(dir), j; + + while(i != j) + { + if(regex_match(i->path().filename().string(), e)) + { + scan_file(i->path().string()); + } + else if(recurse && is_directory(i->status())) + { + scan_dir(i->path().string(), mask, recurse); + } + ++i; + } +} +// +// Remove quotes from a string: +// +std::string unquote(const std::string& s) +{ + std::string result(s); + if((s.size() >= 2) && (*s.begin() == '\"') && (*s.rbegin() == '\"')) + { + result.erase(result.begin()); + result.erase(result.end() - 1); + } + return result; +} +// +// Load and process a script file: +// +void process_script(const std::string& script) +{ + static const boost::regex comment_parser( + "\\s*(?:#.*)?$" + ); + static const boost::regex scan_parser( + "!scan[[:space:]]+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")\\s*" + ); + static const boost::regex scan_dir_parser( + "!scan-path[[:space:]]+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")" + "[[:space:]]+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")" + "(?:" + "[[:space:]]+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")" + ")?\\s*" + ); + static const boost::regex entry_parser( + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")" + "(?:" + "[[:space:]]+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)*\")" + "(?:" + "[[:space:]]+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)*\")" + "(?:" + "[[:space:]]+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)*\")" + ")?" + ")?" + ")?" + "[[:space:]]*"); + static const boost::regex rewrite_parser( + "!(rewrite-name|rewrite-id)\\s+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")\\s+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")\\s*" + ); + static const boost::regex debug_parser( + "!debug\\s+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")\\s*" + ); + static const boost::regex define_scanner_parser( + "!define-scanner\\s+" + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")\\s+" // type, index 1 + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")\\s+" // scanner regex, index 2 + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")\\s+" // format string, index 3 + "([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")" // format string for name, index 4 + "(?:" + "\\s+([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")" // id-filter, index 5 + "(?:" + "\\s+([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")" // filename-filter, index 6 + ")?" + ")?" + "\\s*" + ); + static const boost::regex error_parser("!.*"); + + if(verbose) + std::cout << "Processing script " << script << std::endl; + boost::smatch what; + std::string line; + std::ifstream is(script.c_str()); + if(is.bad() || !exists(boost::filesystem::path(script))) + { + throw std::runtime_error(std::string("Could not open script file: ") + script); + } + while(std::getline(is, line).good()) + { + if(regex_match(line, what, comment_parser)) + { + // Nothing to do here... + } + else if(regex_match(line, what, scan_parser)) + { + std::string f = unquote(what[1].str()); + if(!boost::filesystem::path(f).is_complete()) + { + if(prefix.size()) + { + boost::filesystem::path base(prefix); + base /= f; + f = base.string(); + } + else + { + boost::filesystem::path base(script); + base.remove_filename(); + base /= f; + f = base.string(); + } + } + if(!exists(boost::filesystem::path(f))) + throw std::runtime_error("Error the file requested for scanning does not exist: " + f); + scan_file(f); + } + else if(regex_match(line, what, debug_parser)) + { + debug = unquote(what[1].str()); + } + else if(regex_match(line, what, define_scanner_parser)) + { + add_file_scanner(unquote(what.str(1)), unquote(what.str(2)), unquote(what.str(3)), + unquote(what.str(4)), unquote(what.str(5)), unquote(what.str(6))); + } + else if(regex_match(line, what, scan_dir_parser)) + { + std::string d = unquote(what[1].str()); + std::string m = unquote(what[2].str()); + bool r = unquote(what[3].str()) == "true"; + if(!boost::filesystem::path(d).is_complete()) + { + if(prefix.size()) + { + boost::filesystem::path base(prefix); + base /= d; + d = base.string(); + } + else + { + boost::filesystem::path base(script); + base.remove_filename(); + base /= d; + d = base.string(); + } + } + if(verbose) + std::cout << "Scanning directory " << d << std::endl; + if(!exists(boost::filesystem::path(d))) + throw std::runtime_error("Error the path requested for scanning does not exist: " + d); + scan_dir(d, m, r); + } + else if(regex_match(line, what, rewrite_parser)) + { + bool id = what[1] == "rewrite-id"; + std::string a = unquote(what[2].str()); + std::string b = unquote(what[3].str()); + id_rewrite_list.push_back(id_rewrite_rule(a, b, id)); + } + else if(line.compare(0, 9, "!exclude ") == 0) + { + static const boost::regex delim("([^\"[:space:]]+|\"(?:[^\"\\\\]|\\\\.)+\")"); + boost::sregex_token_iterator i(line.begin() + 9, line.end(), delim, 0), j; + while(i != j) + { + index_info info; + info.term = escape_to_xml(unquote(*i)); + // Erase all entries that have a category in our scanner set, + // plus any entry with no category at all: + index_terms.erase(info); + for(file_scanner_set_type::iterator pscan = file_scanner_set.begin(); pscan != file_scanner_set.end(); ++pscan) + { + info.category = (*pscan).type; + index_terms.erase(info); + } + ++i; + } + } + else if(regex_match(line, error_parser)) + { + std::cerr << "Error: Unable to process line: " << line << std::endl; + } + else if(regex_match(line, what, entry_parser)) + { + try{ + // what[1] is the Index entry + // what[2] is the regex to search for (optional) + // what[3] is a section id that must be matched + // in order for the term to be indexed (optional) + // what[4] is the index category to place the term in (optional). + index_info info; + info.term = escape_to_xml(unquote(what.str(1))); + std::string s = unquote(what.str(2)); + if(s.size()) + info.search_text = boost::regex(s, boost::regex::icase|boost::regex::perl); + else + info.search_text = boost::regex("\\<" + what.str(1) + "\\>", boost::regex::icase|boost::regex::perl); + + s = unquote(what.str(3)); + if(s.size()) + info.search_id = s; + if(what[4].matched) + info.category = unquote(what.str(4)); + std::pair<std::set<index_info>::iterator, bool> pos = index_terms.insert(info); + if(pos.second) + { + if(pos.first->search_text != info.search_text) + { + // + // Merge the search terms: + // + const_cast<boost::regex&>(pos.first->search_text) = + "(?:" + pos.first->search_text.str() + ")|(?:" + info.search_text.str() + ")"; + } + if(pos.first->search_id != info.search_id) + { + // + // Merge the ID constraints: + // + const_cast<boost::regex&>(pos.first->search_id) = + "(?:" + pos.first->search_id.str() + ")|(?:" + info.search_id.str() + ")"; + } + } + } + catch(const boost::regex_error&) + { + std::cerr << "Unable to process regular expression in script line:\n \"" + << line << "\"" << std::endl; + throw; + } + catch(const std::exception&) + { + std::cerr << "Unable to process script line:\n \"" + << line << "\"" << std::endl; + throw; + } + } + else + { + std::cerr << "Error: Unable to process line: " << line << std::endl; + } + } +} + diff --git a/src/boost/tools/auto_index/src/index_generator.cpp b/src/boost/tools/auto_index/src/index_generator.cpp new file mode 100644 index 000000000..1b65f63c9 --- /dev/null +++ b/src/boost/tools/auto_index/src/index_generator.cpp @@ -0,0 +1,327 @@ +// Copyright 2008 John Maddock +// +// Use, modification and distribution are subject to 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) + +#include "auto_index.hpp" +#include <boost/range.hpp> +#include <boost/format.hpp> + +// +// Get a numerical ID for the next item: +// +std::string get_next_index_id() +{ + static int index_id_count = 0; + std::stringstream s; + s << "idx_id_" << index_id_count; + ++index_id_count; + return s.str(); +} + +void raise_invalid_xml(const std::string& parent, const std::string& child) +{ + throw std::runtime_error("Error: element " + child + " can not appear inside the container " + parent + ": try using a different value for property \"auto-index-type\"."); +} +// +// Validate that the container for the Index is in a valid place: +// +void check_index_type_and_placement(const std::string& parent, const std::string& container) +{ + if(container == "section") + { + if((parent != "appendix") + && (parent != "article") + && (parent != "chapter") + && (parent != "partintro") + && (parent != "preface") + && (parent != "section")) + raise_invalid_xml(parent, container); + } + else if(container == "appendix") + { + if((parent != "article") + && (parent != "book") + && (parent != "part")) + raise_invalid_xml(parent, container); + } + else if(container == "index") + { + if((parent != "appendix") + && (parent != "article") + && (parent != "book") + && (parent != "chapter") + && (parent != "part") + && (parent != "preface") + && (parent != "sect1") + && (parent != "sect2") + && (parent != "sect3") + && (parent != "sect4") + && (parent != "sect5") + && (parent != "section") + ) + raise_invalid_xml(parent, container); + } + else if((container == "article") || (container == "chapter") || (container == "reference")) + { + if((parent != "book") + && (parent != "part")) + raise_invalid_xml(parent, container); + } + else if(container == "part") + { + if(parent != "book") + raise_invalid_xml(parent, container); + } + else if(container == "refsect1") + { + if(parent != "refentry") + raise_invalid_xml(parent, container); + } + else if(container == "refsect2") + { + if(parent != "refsect1") + raise_invalid_xml(parent, container); + } + else if(container == "refsect3") + { + if(parent != "refsect2") + raise_invalid_xml(parent, container); + } + else if(container == "refsection") + { + if((parent != "refsection") && (parent != "refentry")) + raise_invalid_xml(parent, container); + } + else if(container == "sect1") + { + if((parent != "appendix") + && (parent != "article") + && (parent != "chapter") + && (parent != "partintro") + && (parent != "preface") + ) + raise_invalid_xml(parent, container); + } + else if(container == "sect2") + { + if(parent != "sect1") + raise_invalid_xml(parent, container); + } + else if(container == "sect3") + { + if(parent != "sect2") + raise_invalid_xml(parent, container); + } + else if(container == "sect4") + { + if(parent != "sect3") + raise_invalid_xml(parent, container); + } + else if(container == "sect5") + { + if(parent != "sect4") + raise_invalid_xml(parent, container); + } + else + { + throw std::runtime_error("Error: element " + container + " is unknown, and can not be used as a container for an index: try using a different value for property \"auto-index-type\"."); + } +} + +boost::tiny_xml::element_ptr make_element(const std::string& name) +{ + boost::tiny_xml::element_ptr result(new boost::tiny_xml::element); + result->name = name; + return result; +} + +boost::tiny_xml::element_ptr add_attribute(boost::tiny_xml::element_ptr ptr, const std::string& name, const std::string& value) +{ + boost::tiny_xml::attribute attr; + attr.name = name; + attr.value = value; + ptr->attributes.push_back(attr); + return ptr; +} + +boost::regex make_primary_key_matcher(const std::string& s) +{ + static const boost::regex e("[-_[:space:]]+|([.\\[{}()\\*+?|^$])"); + static const char* format = "(?1\\\\$1:[-_[:space:]]+)"; + return boost::regex(regex_replace(s, e, format, boost::regex_constants::format_all), boost::regex::icase|boost::regex::perl); +} + +// +// Generate an index entry using our own internal method: +// +template <class Range> +boost::tiny_xml::element_ptr generate_entry(const Range& range, const std::string* pcategory, int level = 0, const boost::regex* primary_key = 0) +{ + boost::tiny_xml::element_ptr list = add_attribute(add_attribute(::add_attribute(make_element("itemizedlist"), "mark", "none"), "spacing", "compact"), "role", "index"); + + for(typename boost::range_iterator<Range>::type i = boost::begin(range); i != boost::end(range);) + { + std::string key = (*i)->key; + index_entry_set entries; + bool preferred = false; + std::string id; + bool collapse = false; + + // + // Create a regular expression for comparing key to other key's: + // + boost::regex key_regex; + if(level == 0) + { + key_regex = make_primary_key_matcher(key); + primary_key = &key_regex; + } + // + // Begin by consolidating entries with identical keys but possibly different categories: + // + while((i != boost::end(range)) && ((*i)->key == key)) + { + if((0 == pcategory) || (pcategory->size() == 0) || (pcategory && (**i).category == *pcategory)) + { + entries.insert((*i)->sub_keys.begin(), (*i)->sub_keys.end()); + if((*i)->preferred) + preferred = true; + if((*i)->id.size()) + { + if(id.size()) + { + std::cerr << "WARNING: two identical index terms have different link destinations!!" << std::endl; + } + id = (*i)->id; + } + } + ++i; + } + // + // Only actually generate content if we have anything in the entries set: + // + if(entries.size() || id.size()) + { + // + // See if we can collapse any sub-entries into this one: + // + if(entries.size() == 1) + { + if((regex_match((*entries.begin())->key, *primary_key) || ((*entries.begin())->key == key)) + && ((*entries.begin())->id.size()) + && ((*entries.begin())->id != id)) + { + collapse = true; + id = (*entries.begin())->id; + } + } + // + // See if this key is the same as the primary key, if it is then make it prefered: + // + if(level && regex_match(key, *primary_key)) + { + preferred = true; + } + boost::tiny_xml::element_ptr item = make_element("listitem"); + boost::tiny_xml::element_ptr para = make_element("para"); + item->elements.push_back(para); + list->elements.push_back(item); + if(preferred) + { + para->elements.push_back(add_attribute(make_element("emphasis"), "role", "bold")); + para = para->elements.back(); + } + if(id.size()) + { + boost::tiny_xml::element_ptr link = add_attribute(make_element("link"), "linkend", id); + para->elements.push_back(link); + para = link; + } + std::string classname = (boost::format("index-entry-level-%1%") % level).str(); + para->elements.push_back(add_attribute(make_element("phrase"), "role", classname)); + para = para->elements.back(); + para->content = key; + if(!collapse && entries.size()) + { + std::pair<index_entry_set::const_iterator, index_entry_set::const_iterator> subrange(entries.begin(), entries.end()); + item->elements.push_back(generate_entry(subrange, 0, level+1, primary_key)); + } + } + } + return list; +} +// +// Generate indexes using our own internal method: +// +void generate_indexes() +{ + for(boost::tiny_xml::element_list::const_iterator i = indexes.begin(); i != indexes.end(); ++i) + { + boost::tiny_xml::element_ptr node = *i; + const std::string* category = find_attr(node, "type"); + bool has_title = false; + + for(boost::tiny_xml::element_list::const_iterator k = (*i)->elements.begin(); k != (*i)->elements.end(); ++k) + { + if((**k).name == "title") + { + has_title = true; + break; + } + } + + boost::tiny_xml::element_ptr navbar = make_element("para"); + node->elements.push_back(navbar); + + index_entry_set::const_iterator m = index_entries.begin(); + index_entry_set::const_iterator n = m; + boost::tiny_xml::element_ptr vlist = make_element("variablelist"); + node->elements.push_back(vlist); + while(n != index_entries.end()) + { + char current_letter = std::toupper((*n)->key[0]); + std::string id_name = get_next_index_id(); + boost::tiny_xml::element_ptr entry = add_attribute(make_element("varlistentry"), "id", id_name); + boost::tiny_xml::element_ptr term = make_element("term"); + term->content = std::string(1, current_letter); + entry->elements.push_back(term); + boost::tiny_xml::element_ptr item = make_element("listitem"); + entry->elements.push_back(item); + while((n != index_entries.end()) && (std::toupper((*n)->key[0]) == current_letter)) + ++n; + std::pair<index_entry_set::const_iterator, index_entry_set::const_iterator> range(m, n); + item->elements.push_back(generate_entry(range, category)); + if(item->elements.size() && (*item->elements.begin())->elements.size()) + { + vlist->elements.push_back(entry); + boost::tiny_xml::element_ptr p = make_element(""); + p->content = " "; + if(navbar->elements.size()) + { + navbar->elements.push_back(p); + } + p = add_attribute(make_element("link"), "linkend", id_name); + p->content = current_letter; + navbar->elements.push_back(p); + } + m = n; + } + + node->name = internal_index_type; + boost::tiny_xml::element_ptr p(node->parent); + while(p->name.empty()) + p = boost::tiny_xml::element_ptr(p->parent); + check_index_type_and_placement(p->name, node->name); + node->attributes.clear(); + if(!has_title) + { + boost::tiny_xml::element_ptr t = make_element("title"); + t->content = "Index"; + node->elements.push_front(t); + } + } +} + diff --git a/src/boost/tools/auto_index/src/tiny_xml.cpp b/src/boost/tools/auto_index/src/tiny_xml.cpp new file mode 100644 index 000000000..81b3b26d9 --- /dev/null +++ b/src/boost/tools/auto_index/src/tiny_xml.cpp @@ -0,0 +1,257 @@ +// tiny XML sub-set tools implementation -----------------------------------// + +// (C) Copyright Beman Dawes 2002. 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) + +#include "tiny_xml.hpp" +#include <cassert> +#include <cstring> + +namespace +{ + + inline void eat_whitespace( char & c, std::istream & in ) + { + while ( c == ' ' || c == '\r' || c == '\n' || c == '\t' ) + in.get( c ); + } + + void eat_comment( char & c, std::istream & in ) + { + in.get(c); + if(c != '-') + throw std::string("Invalid comment in XML"); + in.get(c); + if(c != '-') + throw std::string("Invalid comment in XML"); + do{ + while(in.get(c) && (c != '-')); + in.get(c); + if(c != '-') + continue; + in.get(c); + if(c != '>') + continue; + else + break; + } + while(true); + } + + std::string get_name( char & c, std::istream & in ) + { + std::string result; + eat_whitespace( c, in ); + while ( std::strchr( + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.:", c ) + != 0 ) + { + result += c; + if(!in.get( c )) + throw std::string("xml: unexpected eof"); + } + return result; + } + + void eat_delim( char & c, std::istream & in, + char delim, const std::string & msg ) + { + eat_whitespace( c, in ); + if ( c != delim ) + throw std::string("xml syntax error, expected ") + delim + + " (" + msg + ")"; + in.get( c ); + } + + std::string get_value( char & c, std::istream & in ) + { + std::string result; + while ( c != '\"' ) + { + result += c; + in.get( c ); + } + in.get( c ); + return result; + } + +} + +namespace boost +{ + namespace tiny_xml + { + + // parse -----------------------------------------------------------------// + + element_ptr parse( std::istream & in, const std::string & msg ) + { + char c = 0; // current character + element_ptr e( new element ); + + if(!in.get( c )) + throw std::string("xml: unexpected eof"); + if ( c == '<' ) + if(!in.get( c )) + throw std::string("xml: unexpected eof"); + + if(c == '!') + { + eat_comment(c, in); + return e; + } + if(c == '?') + { + // XML processing instruction. + e->name += c; + if(!in.get( c )) // next char + throw std::string("xml: unexpected eof"); + e->name += get_name(c, in); + in >> std::ws; + if(!in.get( c )) // next char + throw std::string("xml: unexpected eof"); + while(c != '?') + { + e->content += c; + if(!in.get( c )) // next char + throw std::string("xml: unexpected eof"); + } + if(!in.get( c )) // next char + throw std::string("xml: unexpected eof"); + if(c != '>') + throw std::string("Invalid XML processing instruction."); + return e; + } + + e->name = get_name( c, in ); + eat_whitespace( c, in ); + + // attributes + while ( (c != '>') && (c != '/') ) + { + attribute a; + a.name = get_name( c, in ); + + eat_delim( c, in, '=', msg ); + eat_delim( c, in, '\"', msg ); + + a.value = get_value( c, in ); + + e->attributes.push_back( a ); + eat_whitespace( c, in ); + } + if(c == '/') + { + if(!in.get( c )) // next after '/' + throw std::string("xml: unexpected eof"); + eat_whitespace( c, in ); + if(c != '>') + throw std::string("xml: unexpected /"); + return e; + } + if(!in.get( c )) // next after '>' + throw std::string("xml: unexpected eof"); + + //eat_whitespace( c, in ); + + do{ + // sub-elements + while ( c == '<' ) + { + if ( in.peek() == '/' ) + break; + element_ptr child(parse( in, msg )); + child->parent = e; + e->elements.push_back(child); + in.get( c ); // next after '>' + //eat_whitespace( c, in ); + } + if (( in.peek() == '/' ) && (c == '<')) + break; + + // content + if ( (c != '<') ) + { + element_ptr sub( new element ); + while ( c != '<' ) + { + sub->content += c; + if(!in.get( c )) + throw std::string("xml: unexpected eof"); + } + sub->parent = e; + e->elements.push_back( sub ); + } + + assert( c == '<' ); + if( in.peek() == '/' ) + break; + }while(true); + + in.get(c); + eat_delim( c, in, '/', msg ); + std::string end_name( get_name( c, in ) ); + if ( e->name != end_name ) + throw std::string("xml syntax error: beginning name ") + + e->name + " did not match end name " + end_name + + " (" + msg + ")"; + + eat_delim( c, in, '>', msg ); + if(c != '>') + { + // we've eaten one character past the >, put it back: + if(!in.putback(c)) + throw std::string("Unable to put back character"); + } + return e; + } + + // write ---------------------------------------------------------------// + + void write( const element & e, std::ostream & out ) + { + if(e.name.size()) + { + out << "<" << e.name; + if ( !e.attributes.empty() ) + { + for( attribute_list::const_iterator itr = e.attributes.begin(); + itr != e.attributes.end(); ++itr ) + { + out << " " << itr->name << "=\"" << itr->value << "\""; + } + } + if(e.name[0] == '?') + { + out << " " << e.content << "?>"; + return; + } + if(e.elements.empty() && e.content.empty()) + { + out << "/>"; + return; + } + out << ">"; + } + if ( !e.elements.empty() ) + { + for( element_list::const_iterator itr = e.elements.begin(); + itr != e.elements.end(); ++itr ) + { + write( **itr, out ); + } + } + if ( !e.content.empty() ) + { + out << e.content; + } + if(e.name.size() && (e.name[0] != '?')) + { + out << "</" << e.name << ">"; + } + } + + } // namespace tiny_xml +} // namespace boost + diff --git a/src/boost/tools/auto_index/src/tiny_xml.hpp b/src/boost/tools/auto_index/src/tiny_xml.hpp new file mode 100644 index 000000000..5ecbd4ce2 --- /dev/null +++ b/src/boost/tools/auto_index/src/tiny_xml.hpp @@ -0,0 +1,83 @@ +// tiny XML sub-set tools --------------------------------------------------// + +// (C) Copyright Beman Dawes 2002. 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) + +// Provides self-contained tools for this XML sub-set: +// +// element ::= { "<" name { name "=" "\"" value "\"" } ">" +// {element} [contents] "</" name ">" } +// +// The point of "self-contained" is to minimize tool-chain dependencies. + +#ifndef BOOST_TINY_XML_H +#define BOOST_TINY_XML_H + +#include "boost/smart_ptr.hpp" // for shared_ptr +#include "boost/utility.hpp" // for noncopyable +#include <list> +#include <iostream> +#include <string> + +namespace boost +{ + namespace tiny_xml + { + class element; + struct attribute + { + std::string name; + std::string value; + + attribute(){} + attribute( const std::string & name, const std::string & value ) + : name(name), value(value) {} + }; + typedef boost::shared_ptr< element > element_ptr; + typedef boost::weak_ptr< element > weak_element_ptr; + typedef std::list< element_ptr > element_list; + typedef std::list< attribute > attribute_list; + + class element + : private boost::noncopyable // because deep copy semantics would be required + { + public: + // The name of the XML element, or "" if this is inline content, + // or begins with '?' if this is a processing instruction. + std::string name; + // List of attributes applied to this element + attribute_list attributes; + // List of sub-elements, this will be empty if the name is empty + // or starts with a '?'. Plain text content will be inside + // anonymous elements in this list - this preserves the order of + // plain text mixed with true XML <elements>. + element_list elements; + // The plain text content of this element, only present if the name is "" + // or if this is a processing instruction in which case it is the content + // after the name of the instruction. + std::string content; + // Pointer to our parent + weak_element_ptr parent; + + element() {} + explicit element( const std::string & name ) : name(name) {} + }; + + // Precondition: stream positioned at either the initial "<" + // or the first character after the initial "<". + // Postcondition: stream positioned at the first character after final + // ">" (or eof). + // Returns: an element_ptr to an element representing the parsed stream. + // Throws: std::string on syntax error. msg appended to what() string. + element_ptr parse( std::istream & in, const std::string & msg ); + + void write( const element & e, std::ostream & out ); + + } +} + +#endif // BOOST_TINY_XML_H + + + diff --git a/src/boost/tools/auto_index/test/Jamfile.v2 b/src/boost/tools/auto_index/test/Jamfile.v2 new file mode 100644 index 000000000..4b1e60b56 --- /dev/null +++ b/src/boost/tools/auto_index/test/Jamfile.v2 @@ -0,0 +1,62 @@ + +import feature ; +import generators ; +import modules ; +import project ; +import targets ; +import testing ; +import toolset ; +import type ; + +alias line_compare_tool : ../../quickbook/test/src//line-compare-tool ; + +rule auto-index-test ( target-name : input-file : output-file ? : options * ) +{ + local project = [ project.current ] ; + + local t = + [ targets.create-typed-target RUN + : $(project) + : $(target-name) + : [ alias autoindex : ../build//auto_index : release ] + : $(requirements) + <location-prefix>$(target-name).test + <testing.arg>--prefix=../../.. + <testing.arg>$(options) + <testing.arg>--in=$(input-file) + <testing.arg>--out=$(target-name).out + <preserve-test-targets>on + <dependency>Jamfile.v2 + <dependency>$(input-file) + ] + ; + + t += + [ targets.create-typed-target RUN + : $(project) + : $(target-name)_check + : .//line_compare_tool + : $(requirements) + <location-prefix>$(target-name).test + <testing.arg>$(target-name).out + <testing.arg>$(target-name).gold + <preserve-test-targets>on + <dependency>$(target_name) + <implicit-dependency>$(target_name) + <dependency>Jamfile.v2 + <dependency>$(input-file) + ] + ; + + modules.poke testing : .all-tests : \$\(all-tests\) $(t) ; + + return $(t) ; +} + +auto-index-test test1 : type_traits.docbook : : --script=index.idx ; +auto-index-test test2 : type_traits.docbook : : --internal-index --script=index.idx ; +auto-index-test test3 : type_traits.docbook : : --internal-index --index-type=index --script=index.idx ; + + + + diff --git a/src/boost/tools/auto_index/test/index.idx b/src/boost/tools/auto_index/test/index.idx new file mode 100644 index 000000000..52507c28a --- /dev/null +++ b/src/boost/tools/auto_index/test/index.idx @@ -0,0 +1,26 @@ + +!define-scanner class_name "BOOST_TT_AUX_TYPE_TRAIT_DEF\d\s*\(\s*(\w+)\s*[,)]" "(?:class|struct)[^;{]+\\<\1\\>[^;{]+\\{" \1 +!define-scanner class_name "BOOST_TT_AUX_BOOL_TRAIT_DEF\d\s*\(\s*(\w+)\s*[,)]" "(?:class|struct)[^;{]+\\<\1\\>[^;{]+\\{" \1 +!define-scanner class_name "BOOST_TT_AUX_SIZE_T_TRAIT_DEF\d\s*\(\s*(\w+)\s*[,)]" "(?:class|struct)[^;{]+\\<\1\\>[^;{]+\\{" \1 + +!define-scanner class_name "^[[:space:]]*(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\<\w+\>([[:blank:]]*\([^)]*\))?[[:space:]]*)*(\<\w*\>)[[:space:]]*(<[^;:{]+>)?[[:space:]]*(\{|:[^;\{()]*\{)" "(?:class|struct)[^;{]+\\<\5\\>[^;{]+\\{" \5 +!define-scanner typedef_name "typedef[^;{}#]+?(\w+)\s*;" "typedef[^;]+\\<\1\\>\\s*;" "\1" +!define-scanner "macro_name" "^\s*#\s*define\s+(\w+)" "\\<\1\\>" "\1" +!define-scanner "function_name" "\w+\s+(\w+)\s*\([^\)]*\)\s*[;{]" "\\<\\w+\\>\\s+\\<\1\\>\\s*\\([^;{]*\\)\\s*[;{]" "\1" + +!scan-path boost/type_traits .*\.hpp true +!scan boost/aligned_storage.hpp +!scan boost/type_traits.hpp + +!exclude type arg1_type arg2_type arg3_type arg4_type arg5_type B D +!exclude result + +!rewrite-name "(?:A|An|The)\s+(.*)" "\1" + +"Constrained Index Term" add_const "boost_typetraits\.reference.*" class_name +"This term should not appear anywhere because of the ID constraint" strlen "(?!boost_typetraits.background).*" function_name + + +type-traits "" ".*.intro" test_index_1 +type-traits "" ".*.background" test_index_2 + diff --git a/src/boost/tools/auto_index/test/test1.gold b/src/boost/tools/auto_index/test/test1.gold new file mode 100644 index 000000000..ec051ab96 --- /dev/null +++ b/src/boost/tools/auto_index/test/test1.gold @@ -0,0 +1,6671 @@ +<?xml version="1.0"?> +<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> +<!-- + +This file is based upon the type traits docs, but has had additional XML elements added to it +to ensure complete testing. + +--> + +<chapter xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" id="boost_typetraits" rev:last-revision="$Date: 2008-11-28 12:41:45 +0000 (Fri, 28 Nov 2008) $"> + <chapterinfo><author> + <firstname>various</firstname> <surname>authors</surname> + </author><copyright> + <year>2000</year> <year>2006</year> <holder>Adobe Systems Inc, David Abrahams, + Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat + Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert + Ramey and Jeremy Siek</holder> + </copyright><legalnotice> + <para> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>) + </para> + </legalnotice></chapterinfo> + <title>Boost.TypeTraits</title> + <para> + A printer-friendly <ulink url="http://svn.boost.org/svn/boost/sandbox/pdf/type_traits/release/type_traits.pdf">PDF + version of this manual is also available</ulink>. + </para> + <section id="boost_typetraits.intro"><indexterm type="test_index_1"><primary>type-traits</primary><secondary>Introduction</secondary></indexterm><indexterm><primary>Introduction</primary><secondary>type-traits</secondary></indexterm><indexterm type="test_index_1"><primary>type-traits</primary><secondary>Introduction</secondary></indexterm><indexterm><primary>Introduction</primary><secondary>type-traits</secondary></indexterm><indexterm type="test_index_1"><primary>type-traits</primary><secondary>Introduction</secondary></indexterm><indexterm><primary>Introduction</primary><secondary>type-traits</secondary></indexterm> + <title><link linkend="boost_typetraits.intro"> Introduction</link></title> + <para> + The Boost type-traits library contains a set of very specific traits classes, + each of which encapsulate a single trait from the C++ type system; for example, + is a type a pointer or a reference type? Or does a type have a trivial constructor, + or a const-qualifier? + </para> + <para> + The type-traits classes share a unified design: each class inherits from a + the type <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the type has the specified property and inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link> + otherwise. + </para> + <para> + The type-traits library also contains a set of classes that perform a specific + transformation on a type; for example, they can remove a top-level const or + volatile qualifier from a type. Each class that performs a transformation defines + a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of the transformation. + </para> + </section> + <section id="boost_typetraits.background"><indexterm type="test_index_2"><primary>type-traits</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>type-traits</secondary></indexterm><indexterm type="test_index_2"><primary>type-traits</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>type-traits</secondary></indexterm><indexterm type="class_name"><primary>remove_extent</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>remove_extent</secondary></indexterm><indexterm type="class_name"><primary>is_pointer</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>is_pointer</secondary></indexterm><indexterm type="class_name"><primary>is_void</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>is_void</secondary></indexterm><indexterm type="test_index_2"><primary>type-traits</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>type-traits</secondary></indexterm><indexterm type="test_index_2"><primary>type-traits</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>type-traits</secondary></indexterm><indexterm type="test_index_2"><primary>type-traits</primary><secondary>Background and Tutorial</secondary></indexterm><indexterm><primary>Background and Tutorial</primary><secondary>type-traits</secondary></indexterm> + <title><link linkend="boost_typetraits.background"> Background and Tutorial</link></title> + <para> + The following is an updated version of the article "C++ Type traits" + by John Maddock and Steve Cleary that appeared in the October 2000 issue of + <ulink url="http://www.ddj.com">Dr Dobb's Journal</ulink>. + </para> + <para> + Generic programming (writing code which works with any data type meeting a + set of requirements) has become the method of choice for providing reusable + code. However, there are times in generic programming when "generic" + just isn't good enough - sometimes the differences between types are too large + for an efficient generic implementation. This is when the traits technique + becomes important - by encapsulating those properties that need to be considered + on a type by type basis inside a traits class, we can minimize the amount of + code that has to differ from one type to another, and maximize the amount of + generic code. + </para> + <?dbfo keep-together="auto" ?> + <para> + <indexterm> + <primary>Foo1</primary> + </indexterm> + Consider an example: when working with character strings, one common operation + is to determine the length of a null terminated string. Clearly it's possible + to write generic code that can do this, but it turns out that there are much + more efficient methods available: for example, the C library functions <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">strlen</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">wcslen</phrase></computeroutput> + are usually written in assembler, and with suitable hardware support can be + considerably faster than a generic version written in C++. The authors of the + C++ standard library realized this, and abstracted the properties of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">wchar_t</phrase></computeroutput> + into the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput>. + Generic code that works with character strings can simply use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase><phrase role="special"><>::</phrase><phrase role="identifier">length</phrase></computeroutput> to determine the length of a null + terminated string, safe in the knowledge that specializations of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput> will use the most appropriate + method available to them. + </para> + <anchor id="boost_typetraits.background.type_traits"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.type_traits">Type Traits</link> + </bridgehead> + <para> + Class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput> is a classic + example of a collection of type specific properties wrapped up in a single + class - what Nathan Myers termed a <emphasis>baggage class</emphasis><link linkend="background.references">[1]</link>. In the Boost type-traits library, + we<link linkend="background.references">[2]</link> have written a set of very + specific traits classes, each of which encapsulate a single trait from the + C++ type system; for example, is a type a pointer or a reference type? Or does + a type have a trivial constructor, or a const-qualifier? The type-traits classes + share a unified design: each class inherits from a the type <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the type has the specified property and inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link> + otherwise. As we will show, these classes can be used in generic programming + to determine the properties of a given type and introduce optimizations that + are appropriate for that case. + </para> + <para> + The type-traits library also contains a set of classes that perform a specific + transformation on a type; for example, they can remove a top-level const or + volatile qualifier from a type. Each class that performs a transformation defines + a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of the transformation. All of the type-traits classes are + defined inside namespace <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase></computeroutput>; + for brevity, namespace-qualification is omitted in most of the code samples + given. + </para> + <anchor id="boost_typetraits.background.implementation"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.implementation">Implementation</link> + </bridgehead> + <para> + There are far too many separate classes contained in the type-traits library + to give a full implementation here - see the source code in the Boost library + for the full details - however, most of the implementation is fairly repetitive + anyway, so here we will just give you a flavor for how some of the classes + are implemented. Beginning with possibly the simplest class in the library, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput> inherits + from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + only if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> +</programlisting> + <para> + Here we define a primary version of the template class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_void">is_void</link></computeroutput>, + and provide a full-specialization when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. While full specialization + of a template class is an important technique, sometimes we need a solution + that is halfway between a fully generic solution, and a full specialization. + This is exactly the situation for which the standards committee defined partial + template-class specialization. As an example, consider the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput>: + here we needed a primary version that handles all the cases where T is not + a pointer, and a partial specialization to handle all the cases where T is + a pointer: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">*></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> +</programlisting> + <para> + The syntax for partial specialization is somewhat arcane and could easily occupy + an article in its own right; like full specialization, in order to write a + partial specialization for a class, you must first declare the primary template. + The partial specialization contains an extra <...> after the class name + that contains the partial specialization parameters; these define the types + that will bind to that partial specialization rather than the default template. + The rules for what can appear in a partial specialization are somewhat convoluted, + but as a rule of thumb if you can legally write two function overloads of the + form: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">);</phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase><phrase role="identifier">U</phrase><phrase role="special">);</phrase> +</programlisting> + <para> + Then you can also write a partial specialization of the form: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">class</phrase> <phrase role="identifier">c</phrase><phrase role="special">{</phrase> <phrase role="comment">/*details*/</phrase> <phrase role="special">};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">class</phrase> <phrase role="identifier">c</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">>{</phrase> <phrase role="comment">/*details*/</phrase> <phrase role="special">};</phrase> +</programlisting> + <para> + This rule is by no means foolproof, but it is reasonably simple to remember + and close enough to the actual rule to be useful for everyday use. + </para> + <para> + As a more complex example of partial specialization consider the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput>. This + class defines a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the same type as T but with any top-level array bounds removed; this + is an example of a traits class that performs a transformation on a type: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link> +<phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">N</phrase><phrase role="special">]></phrase> +<phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> +</programlisting> + <para> + The aim of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.remove_extent">remove_extent</link></computeroutput> + is this: imagine a generic algorithm that is passed an array type as a template + parameter, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.remove_extent">remove_extent</link></computeroutput> + provides a means of determining the underlying type of the array. For example + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">][</phrase><phrase role="number">5</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> would evaluate to the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">5</phrase><phrase role="special">]</phrase></computeroutput>. This example also shows that the number of + template parameters in a partial specialization does not have to match the + number in the default template. However, the number of parameters that appear + after the class name do have to match the number and type of the parameters + in the default template. + </para> + <anchor id="boost_typetraits.background.optimized_copy"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.optimized_copy">Optimized copy</link> + </bridgehead> + <para> + As an example of how the type traits classes can be used, consider the standard + library algorithm copy: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iter1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Iter2</phrase><phrase role="special">></phrase> +<phrase role="identifier">Iter2</phrase> <phrase role="identifier">copy</phrase><phrase role="special">(</phrase><phrase role="identifier">Iter1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter2</phrase> <phrase role="identifier">out</phrase><phrase role="special">);</phrase> +</programlisting> + <para> + Obviously, there's no problem writing a generic version of copy that works + for all iterator types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput>; however, there are + some circumstances when the copy operation can best be performed by a call + to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. In order to implement + copy in terms of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> all + of the following conditions need to be met: + </para> + <itemizedlist> + <listitem> + Both of the iterator types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput> must be pointers. + </listitem> + <listitem> + Both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput> must point to the same type - excluding + const and volatile-qualifiers. + </listitem> + <listitem> + The type pointed to by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + must have a trivial assignment operator. + </listitem> + </itemizedlist> + <para> + By trivial assignment operator we mean that the type is either a scalar type<link linkend="background.references">[3]</link> or: + </para> + <itemizedlist> + <listitem> + The type has no user defined assignment operator. + </listitem> + <listitem> + The type does not have any data members that are references. + </listitem> + <listitem> + All base classes, and all data member objects must have trivial assignment + operators. + </listitem> + </itemizedlist> + <para> + If all these conditions are met then a type can be copied using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> rather than using a compiler generated + assignment operator. The type-traits library provides a class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput>, + such that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is true only if T has a trivial assignment + operator. This class "just works" for scalar types, but has to be + explicitly specialised for class/struct types that also happen to have a trivial + assignment operator. In other words if <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link> + gives the wrong answer, it will give the "safe" wrong answer - that + trivial assignment is not allowable. + </para> + <para> + The code for an optimized version of copy that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> + where appropriate is given in <link linkend="boost_typetraits.examples.copy">the + examples</link>. The code begins by defining a template function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">do_copy</phrase></computeroutput> that performs a "slow but safe" + copy. The last parameter passed to this function may be either a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + or a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">false_type</link></computeroutput>. + Following that there is an overload of do<emphasis role="underline">copy that + uses `memcpy`: this time the iterators are required to actually be pointers + to the same type, and the final parameter must be a `</emphasis>_true_type<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase> <phrase role="identifier">Finally</phrase><phrase role="special">,</phrase> <phrase role="identifier">the</phrase> <phrase role="identifier">version</phrase> + <phrase role="identifier">of</phrase> </computeroutput>copy<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="identifier">calls</phrase> + </computeroutput>do<emphasis role="underline">copy`, passing `</emphasis>_has_trivial_assign<value_type>()` + as the final parameter: this will dispatch to the optimized version where appropriate, + otherwise it will call the "slow but safe version". + </para> + <anchor id="boost_typetraits.background.was_it_worth_it_"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.was_it_worth_it_">Was it worth it?</link> + </bridgehead> + <para> + It has often been repeated in these columns that "premature optimization + is the root of all evil" <link linkend="background.references">[4]</link>. + So the question must be asked: was our optimization premature? To put this + in perspective the timings for our version of copy compared a conventional + generic copy<link linkend="background.references">[5]</link> are shown in table + 1. + </para> + <para> + Clearly the optimization makes a difference in this case; but, to be fair, + the timings are loaded to exclude cache miss effects - without this accurate + comparison between algorithms becomes difficult. However, perhaps we can add + a couple of caveats to the premature optimization rule: + </para> + <itemizedlist> + <listitem> + If you use the right algorithm for the job in the first place then optimization + will not be required; in some cases, memcpy is the right algorithm. + </listitem> + <listitem> + If a component is going to be reused in many places by many people then optimizations + may well be worthwhile where they would not be so for a single case - in + other words, the likelihood that the optimization will be absolutely necessary + somewhere, sometime is that much higher. Just as importantly the perceived + value of the stock implementation will be higher: there is no point standardizing + an algorithm if users reject it on the grounds that there are better, more + heavily optimized versions available. + </listitem> + </itemizedlist> + <table frame="all"> <title>Time taken to copy 1000 elements using `copy<const + T*, T*>` (times in micro-seconds)</title> + <tgroup cols="3"> + <thead> + <row> + <entry> + <para> + Version + </para> + </entry><entry> + <para> + T + </para> + </entry><entry> + <para> + Time + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + "Optimized" copy + </para> + </entry><entry> + <para> + char + </para> + </entry><entry> + <para> + 0.99 + </para> + </entry> + </row> + <row> + <entry> + <para> + Conventional copy + </para> + </entry><entry> + <para> + char + </para> + </entry><entry> + <para> + 8.07 + </para> + </entry> + </row> + <row> + <entry> + <para> + "Optimized" copy + </para> + </entry><entry> + <para> + int + </para> + </entry><entry> + <para> + 2.52 + </para> + </entry> + </row> + <row> + <entry> + <para> + Conventional copy + </para> + </entry><entry> + <para> + int + </para> + </entry><entry> + <para> + 8.02 + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> <anchor id="boost_typetraits.background.pair_of_references"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.pair_of_references">Pair of References</link> + </bridgehead> + <para> + The optimized copy example shows how type traits may be used to perform optimization + decisions at compile-time. Another important usage of type traits is to allow + code to compile that otherwise would not do so unless excessive partial specialization + is used. This is possible by delegating partial specialization to the type + traits classes. Our example for this form of usage is a pair that can hold + references <link linkend="background.references">[6]</link>. + </para> + <para> + First, let us examine the definition of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase></computeroutput>, omitting + the comparison operators, default constructor, and template copy constructor + for simplicity: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T2</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">pair</phrase> +<phrase role="special">{</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T1</phrase> <phrase role="identifier">first_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T2</phrase> <phrase role="identifier">second_type</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">T1</phrase> <phrase role="identifier">first</phrase><phrase role="special">;</phrase> +<phrase role="identifier">T2</phrase> <phrase role="identifier">second</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">pair</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase> <phrase role="special">&</phrase> <phrase role="identifier">nfirst</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T2</phrase> <phrase role="special">&</phrase> <phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> +<phrase role="special">:</phrase><phrase role="identifier">first</phrase><phrase role="special">(</phrase><phrase role="identifier">nfirst</phrase><phrase role="special">),</phrase> <phrase role="identifier">second</phrase><phrase role="special">(</phrase><phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + Now, this "pair" cannot hold references as it currently stands, because + the constructor would require taking a reference to a reference, which is currently + illegal <link linkend="background.references">[7]</link>. Let us consider what + the constructor's parameters would have to be in order to allow "pair" + to hold non-reference types, references, and constant references: + </para> + <table frame="all"> <title>Required Constructor Argument Types</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of parameter to initializing constructor + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + T + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + <row> + <entry> + <para> + T & + </para> + </entry><entry> + <para> + T & + </para> + </entry> + </row> + <row> + <entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + <para> + A little familiarity with the type traits classes allows us to construct a + single mapping that allows us to determine the type of parameter from the type + of the contained class. The type traits classes provide a transformation <link linkend="boost_typetraits.reference.add_reference">add_reference</link>, which + adds a reference to its type, unless it is already a reference. + </para> + <table frame="all"> <title>Using add_reference to synthesize the correct constructor + type</title> + <tgroup cols="3"> + <thead> + <row> + <entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + T + </para> + </entry><entry> + <para> + const T + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + <row> + <entry> + <para> + T & + </para> + </entry><entry> + <para> + T & [8] + </para> + </entry><entry> + <para> + T & + </para> + </entry> + </row> + <row> + <entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + <para> + This allows us to build a primary template definition for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput> + that can contain non-reference types, reference types, and constant reference + types: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T2</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">pair</phrase> +<phrase role="special">{</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T1</phrase> <phrase role="identifier">first_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T2</phrase> <phrase role="identifier">second_type</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">T1</phrase> <phrase role="identifier">first</phrase><phrase role="special">;</phrase> +<phrase role="identifier">T2</phrase> <phrase role="identifier">second</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">pair</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">nfirst</phrase><phrase role="special">,</phrase> + <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T2</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> +<phrase role="special">:</phrase><phrase role="identifier">first</phrase><phrase role="special">(</phrase><phrase role="identifier">nfirst</phrase><phrase role="special">),</phrase> <phrase role="identifier">second</phrase><phrase role="special">(</phrase><phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + Add back in the standard comparison operators, default constructor, and template + copy constructor (which are all the same), and you have a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase></computeroutput> that + can hold reference types! + </para> + <para> + This same extension could have been done using partial template specialization + of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput>, but to specialize + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput> in this way would require + three partial specializations, plus the primary template. Type traits allows + us to define a single primary template that adjusts itself auto-magically to + any of these partial specializations, instead of a brute-force partial specialization + approach. Using type traits in this fashion allows programmers to delegate + partial specialization to the type traits classes, resulting in code that is + easier to maintain and easier to understand. + </para> + <anchor id="boost_typetraits.background.conclusion"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.conclusion">Conclusion</link> + </bridgehead> + <para> + We hope that in this article we have been able to give you some idea of what + type-traits are all about. A more complete listing of the available classes + are in the boost documentation, along with further examples using type traits. + Templates have enabled C++ uses to take the advantage of the code reuse that + generic programming brings; hopefully this article has shown that generic programming + does not have to sink to the lowest common denominator, and that templates + can be optimal as well as generic. + </para> + <anchor id="boost_typetraits.background.acknowledgements"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.acknowledgements">Acknowledgements</link> + </bridgehead> + <para> + The authors would like to thank Beman Dawes and Howard Hinnant for their helpful + comments when preparing this article. + </para> + <anchor id="background.references"/> <anchor id="boost_typetraits.background.references"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.references">References</link> + </bridgehead> + <orderedlist inheritnum="ignore" continuation="restarts"> + <listitem> + Nathan C. Myers, C++ Report, June 1995. + </listitem> + <listitem> + The type traits library is based upon contributions by Steve Cleary, Beman + Dawes, Howard Hinnant and John Maddock: it can be found at www.boost.org. + </listitem> + <listitem> + A scalar type is an arithmetic type (i.e. a built-in integer or floating + point type), an enumeration type, a pointer, a pointer to member, or a const- + or volatile-qualified version of one of these types. + </listitem> + <listitem> + This quote is from Donald Knuth, ACM Computing Surveys, December 1974, pg + 268. + </listitem> + <listitem> + The test code is available as part of the boost utility library (see algo_opt_examples.cpp), + the code was compiled with gcc 2.95 with all optimisations turned on, tests + were conducted on a 400MHz Pentium II machine running Microsoft Windows 98. + </listitem> + <listitem> + John Maddock and Howard Hinnant have submitted a "compressed_pair" + library to Boost, which uses a technique similar to the one described here + to hold references. Their pair also uses type traits to determine if any + of the types are empty, and will derive instead of contain to conserve space + -- hence the name "compressed". + </listitem> + <listitem> + This is actually an issue with the C++ Core Language Working Group (issue + #106), submitted by Bjarne Stroustrup. The tentative resolution is to allow + a "reference to a reference to T" to mean the same thing as a "reference + to T", but only in template instantiation, in a method similar to multiple + cv-qualifiers. + </listitem> + <listitem> + For those of you who are wondering why this shouldn't be const-qualified, + remember that references are always implicitly constant (for example, you + can't re-assign a reference). Remember also that "const T &" + is something completely different. For this reason, cv-qualifiers on template + type arguments that are references are ignored. + </listitem> + </orderedlist> + </section> + <section id="boost_typetraits.category"> + <title><link linkend="boost_typetraits.category"> Type Traits by Category</link></title> + <section id="boost_typetraits.category.value_traits"> + <title><link linkend="boost_typetraits.category.value_traits"> Type Traits + that Describe the Properties of a Type</link></title> + <para> + <indexterm> + <primary>Foo2</primary> + <secondary>Bar2</secondary> + </indexterm> + These traits are all <emphasis>value traits</emphasis>, which is to say the + traits classes all inherit from <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link>, + and are used to access some numerical property of a type. Often this is a + simple true or false Boolean value, but in a few cases may be some other + integer value (for example when dealing with type alignments, or array bounds: + see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.alignment_of">alignment_of</link></computeroutput>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.rank">rank</link></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.extent">extent</link></computeroutput>). + </para> + <section id="boost_typetraits.category.value_traits.primary"> + <title><link linkend="boost_typetraits.category.value_traits.primary"> Categorizing + a Type</link></title> + <para> + These traits identify what "kind" of type some type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is. These are split into two groups: + primary traits which are all mutually exclusive, and composite traits that + are compositions of one or more primary traits. + </para> + <para> + For any given type, exactly one primary type trait will inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + and all the others will inherit from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>, + in other words these traits are mutually exclusive. + </para> + <para> + This means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_integral">is_integral</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + will only ever be true for built-in types; if you want to check for a user-defined + class type that behaves "as if" it is an integral or floating + point type, then use the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase> + <phrase role="keyword">template</phrase></computeroutput> instead. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_array">is_array</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_class">is_class</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_complex">is_complex</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_enum">is_enum</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_function">is_function</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_integral">is_integral</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_object_pointer">is_member_object_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_union">is_union</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link><phrase role="special">;</phrase> +</programlisting> + <para> + The following traits are made up of the union of one or more type categorizations. + A type may belong to more than one of these categories, in addition to + one of the primary categories. + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_arithmetic">is_arithmetic</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_compound">is_compound</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_fundamental">is_fundamental</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_object">is_object</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_scalar">is_scalar</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.value_traits.properties"> + <title><link linkend="boost_typetraits.category.value_traits.properties"> + General Type Properties</link></title> + <para> + The following templates describe the general properties of a type. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.alignment_of">alignment_of</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_assign">has_nothrow_assign</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_default_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_default_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_virtual_destructor">has_virtual_destructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_abstract">is_abstract</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_const">is_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_empty">is_empty</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_stateless">is_stateless</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_signed">is_signed</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_unsigned">is_unsigned</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_volatile">is_volatile</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.extent">extent</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.rank">rank</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.value_traits.relate"> + <title><link linkend="boost_typetraits.category.value_traits.relate"> Relationships + Between Two Types</link></title> + <para> + These templates determine the whether there is a relationship between two + types: + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_base_of">is_base_of</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">U</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_same">is_same</link><phrase role="special">;</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.category.transform"><indexterm type="macro_name"><primary>BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</primary><secondary>Type Traits that Transform One Type to Another</secondary></indexterm><indexterm><primary>Type Traits that Transform One Type to Another</primary><secondary>BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</primary><secondary>Type Traits that Transform One Type to Another</secondary></indexterm><indexterm><primary>Type Traits that Transform One Type to Another</primary><secondary>BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</secondary></indexterm> + <title><link linkend="boost_typetraits.category.transform"> Type Traits that + Transform One Type to Another</link></title> + <para> + The following templates transform one type to another, based upon some well-defined + rule. Each template has a single member called <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of applying the transformation to the template argument + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_const">add_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_cv">add_cv</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_pointer">add_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_volatile">add_volatile</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.decay">decay</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.floating_point_promotion">floating_point_promotion</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.integral_promotion">integral_promotion</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.make_signed">make_signed</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.make_unsigned">make_unsigned</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.promote">promote</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_all_extents">remove_all_extents</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_const">remove_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_cv">remove_cv</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_reference">remove_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_volatile">remove_volatile</link><phrase role="special">;</phrase> +</programlisting> + <anchor id="boost_typetraits.category.transform.broken_compiler_workarounds_"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">Broken + Compiler Workarounds:</link> + </bridgehead> + <para> + For all of these templates support for partial specialization of class templates + is required to correctly implement the transformation. On the other hand, + practice shows that many of the templates from this category are very useful, + and often essential for implementing some generic libraries. Lack of these + templates is often one of the major limiting factors in porting those libraries + to compilers that do not yet support this language feature. As some of these + compilers are going to be around for a while, and at least one of them is + very wide-spread, it was decided that the library should provide workarounds + where possible. + </para> + <para> + The basic idea behind the workaround is to manually define full specializations + of all type transformation templates for all fundamental types, and all their + 1st and 2nd rank cv-[un]qualified derivative pointer types, and to provide + a user-level macro that will define all the explicit specializations needed + for any user-defined type T. + </para> + <para> + The first part guarantees the successful compilation of something like this: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="special">...</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +</programlisting> + <para> + and the second part provides the library's users with a mechanism to make + the above code work not only for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> or other built-in type, + but for their own types as well: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">myspace</phrase><phrase role="special">{</phrase> + <phrase role="keyword">struct</phrase> <phrase role="identifier">MyClass</phrase> <phrase role="special">{};</phrase> +<phrase role="special">}</phrase> +<phrase role="comment">// declare this at global scope: +</phrase><phrase role="identifier">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase><phrase role="special">(</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">)</phrase> +<phrase role="comment">// transformations on myspace::MyClass now work: +</phrase><phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="comment">// etc. +</phrase></programlisting> + <para> + Note that the macro BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION evaluates + to nothing on those compilers that <emphasis role="bold">do</emphasis> support + partial specialization. + </para> + </section> + <section id="boost_typetraits.category.alignment"> + <title><link linkend="boost_typetraits.category.alignment"> Synthesizing Types + with Specific Alignments</link></title> + <para> + Some low level memory management routines need to synthesize a POD type with + specific alignment properties. The template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.type_with_alignment">type_with_alignment</link></computeroutput> + finds the smallest type with a specified alignment, while template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.aligned_storage">aligned_storage</link></computeroutput> + creates a type with a specific size and alignment. + </para> + <para> + <emphasis role="bold">Synopsis</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.type_with_alignment">type_with_alignment</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.aligned_storage">aligned_storage</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.function"> + <title><link linkend="boost_typetraits.category.function"> Decomposing Function + Types</link></title> + <para> + The class template <link linkend="boost_typetraits.reference.function_traits">function_traits</link> + extracts information from function types (see also <link linkend="boost_typetraits.reference.is_function">is_function</link>). + This traits class allows you to tell how many arguments a function takes, + what those argument types are, and what the return type is. + </para> + <para> + <emphasis role="bold">Synopsis</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.function_traits">function_traits</link><phrase role="special">;</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.user_defined"><indexterm type="class_name"><primary>is_union</primary><secondary>User Defined Specializations</secondary></indexterm><indexterm><primary>User Defined Specializations</primary><secondary>is_union</secondary></indexterm><indexterm type="class_name"><primary>is_class</primary><secondary>User Defined Specializations</secondary></indexterm><indexterm><primary>User Defined Specializations</primary><secondary>is_class</secondary></indexterm> + <title><link linkend="boost_typetraits.user_defined"> User Defined Specializations</link></title> + <para> + Occationally the end user may need to provide their own specialization for + one of the type traits - typically where intrinsic compiler support is required + to implement a specific trait fully. These specializations should derive from + boost::<link linkend="boost_typetraits.reference.integral_constant">true_type</link> + or boost::<link linkend="boost_typetraits.reference.integral_constant">false_type</link> + as appropriate: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pod</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> +<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_class</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> +<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_union</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> + +<phrase role="keyword">struct</phrase> <phrase role="identifier">my_pod</phrase><phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">my_union</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">char</phrase> <phrase role="identifier">c</phrase><phrase role="special">;</phrase> + <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> + +<phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special"><</phrase><phrase role="identifier">my_pod</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_union">is_union</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_class">is_class</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.intrinsics"><indexterm type="macro_name"><primary>BOOST_IS_UNION</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_UNION</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_POLYMORPHIC</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_POLYMORPHIC</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_POD</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_POD</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_ENUM</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_ENUM</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_EMPTY</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_EMPTY</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_CONVERTIBLE</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_CONVERTIBLE</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_CLASS</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_CLASS</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_BASE_OF</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_BASE_OF</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_IS_ABSTRACT</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_IS_ABSTRACT</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_VIRTUAL_DESTRUCTOR</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_VIRTUAL_DESTRUCTOR</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_TRIVIAL_DESTRUCTOR</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_TRIVIAL_DESTRUCTOR</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_TRIVIAL_COPY</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_TRIVIAL_COPY</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_TRIVIAL_CONSTRUCTOR</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_TRIVIAL_CONSTRUCTOR</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_TRIVIAL_ASSIGN</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_TRIVIAL_ASSIGN</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_NOTHROW_COPY</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_NOTHROW_COPY</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_NOTHROW_CONSTRUCTOR</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_NOTHROW_CONSTRUCTOR</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_HAS_NOTHROW_ASSIGN</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_HAS_NOTHROW_ASSIGN</secondary></indexterm><indexterm type="macro_name"><primary>BOOST_ALIGNMENT_OF</primary><secondary>Support for Compiler Intrinsics</secondary></indexterm><indexterm><primary>Support for Compiler Intrinsics</primary><secondary>BOOST_ALIGNMENT_OF</secondary></indexterm> + <title><link linkend="boost_typetraits.intrinsics"> Support for Compiler Intrinsics</link></title> + <para> + There are some traits that can not be implemented within the current C++ language: + to make these traits "just work" with user defined types, some kind + of additional help from the compiler is required. Currently (April 2008) Visual + C++ 8 and 9, GNU GCC 4.3 and MWCW 9 provide the necessary intrinsics, and other + compilers will no doubt follow in due course. + </para> + <para> + The Following traits classes always need compiler support to do the right thing + for all types (but all have safe fallback positions if this support is unavailable): + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_union">is_union</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_pod">is_pod</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_assign">has_nothrow_assign</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_virtual_destructor">has_virtual_destructor</link> + </listitem> + </itemizedlist> + <para> + The following traits classes can't be portably implemented in the C++ language, + although in practice, the implementations do in fact do the right thing on + all the compilers we know about: + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_empty">is_empty</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link> + </listitem> + </itemizedlist> + <para> + The following traits classes are dependent on one or more of the above: + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_class">is_class</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_stateless">is_stateless</link> + </listitem> + </itemizedlist> + <para> + The hooks for compiler-intrinsic support are defined in <ulink url="../../../../boost/type_traits/intrinsics.hpp">boost/type_traits/intrinsics.hpp</ulink>, + adding support for new compilers is simply a matter of defining one of more + of the following macros: + </para> + <table frame="all"> <title>Macros for Compiler Intrinsics</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + BOOST_IS_UNION(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a union type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + BOOST_IS_POD(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a POD type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_EMPTY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is an empty struct or union + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if the default constructor for T is trivial (i.e. + has no effect) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_COPY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial copy constructor (and can + therefore be replaced by a call to memcpy) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_ASSIGN(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial assignment operator (and can + therefore be replaced by a call to memcpy) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_DESTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial destructor (i.e. ~T() has + no effect) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_CONSTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="identifier">x</phrase><phrase role="special">;</phrase></computeroutput> + can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_COPY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase><phrase role="special">(</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase></computeroutput> can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_ASSIGN(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="identifier">t</phrase><phrase role="special">,</phrase> + <phrase role="identifier">u</phrase><phrase role="special">;</phrase> + <phrase role="identifier">t</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">u</phrase></computeroutput> can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_VIRTUAL_DESTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true T has a virtual destructor + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_ABSTRACT(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is an abstract type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_BASE_OF(T,U) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a base class of U + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_CLASS(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a class type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_CONVERTIBLE(T,U) + </para> + </entry><entry> + <para> + Should evaluate to true if T is convertible to U + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_ENUM(T) + </para> + </entry><entry> + <para> + Should evaluate to true is T is an enum + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_POLYMORPHIC(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a polymorphic type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_ALIGNMENT_OF(T) + </para> + </entry><entry> + <para> + Should evaluate to the alignment requirements of type T. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.mpl"> + <title><link linkend="boost_typetraits.mpl"> MPL Interoperability</link></title> + <para> + All the value based traits in this library conform to MPL's requirements for + an <ulink url="../../../../libs/mpl/doc/refmanual/integral-constant.html">Integral + Constant type</ulink>: that includes a number of rather intrusive workarounds + for broken compilers. + </para> + <para> + Purely as an implementation detail, this means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/bool.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">true_</phrase></computeroutput></ulink>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">false_type</link></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/bool.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">false_</phrase></computeroutput></ulink>, + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> + <phrase role="identifier">v</phrase><phrase role="special">></phrase></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/integral-c.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">integral_c</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">v</phrase><phrase role="special">></phrase></computeroutput></ulink> + (provided <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>) + </para> + </section> + <section id="boost_typetraits.examples"> + <title><link linkend="boost_typetraits.examples"> Examples</link></title> + <section id="boost_typetraits.examples.copy"><indexterm type="typedef_name"><primary>value_type</primary><secondary>An Optimized Version of std::copy</secondary></indexterm><indexterm><primary>Optimized Version of std::copy</primary><secondary>value_type</secondary></indexterm> + <title><link linkend="boost_typetraits.examples.copy"> An Optimized Version + of std::copy</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">copy</phrase></computeroutput> + that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput> + to determine whether to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> + to optimise the copy operation (see <ulink url="../../examples/copy_example.cpp">copy_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// opt::copy +</phrase><phrase role="comment">// same semantics as std::copy +</phrase><phrase role="comment">// calls memcpy where appropriate. +</phrase><phrase role="comment">// +</phrase> +<phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase><phrase role="special">></phrase> +<phrase role="identifier">I2</phrase> <phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="identifier">b</phrase><phrase role="special">>&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="special">*</phrase><phrase role="identifier">out</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">out</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">out</phrase><phrase role="special">;</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">memcpy</phrase><phrase role="special">(</phrase><phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="special">(</phrase><phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">)*</phrase><phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">));</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">out</phrase><phrase role="special">+(</phrase><phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">copy</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">out</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// We can copy with memcpy if T has a trivial assignment operator, +</phrase> <phrase role="comment">// and if the iterator arguments are actually pointers (this last +</phrase> <phrase role="comment">// requirement we detect with overload resolution): +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I1</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special"><</phrase><phrase role="identifier">value_type</phrase><phrase role="special">>());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.fill"> + <title><link linkend="boost_typetraits.examples.fill"> An Optimised Version + of std::fill</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">fill</phrase></computeroutput> + that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput> + to determine whether to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memset</phrase></computeroutput> + to optimise the fill operation (see <ulink url="../../examples/fill_example.cpp">fill_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// fill +</phrase><phrase role="comment">// same as std::fill, but uses memset where appropriate +</phrase><phrase role="comment">// +</phrase><phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="identifier">b</phrase><phrase role="special">>&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="special">*</phrase><phrase role="identifier">first</phrase> <phrase role="special">=</phrase> <phrase role="identifier">val</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">memset</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">I</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">fill</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// We can do an optimised fill if T has a trivial assignment +</phrase> <phrase role="comment">// operator and if it's size is one: +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> + <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> <phrase role="special">&&</phrase> <phrase role="special">(</phrase><phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">)></phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">;</phrase> + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.destruct"> + <title><link linkend="boost_typetraits.examples.destruct"> An Example that + Omits Destructor Calls For Types with Trivial Destructors</link></title> + <para> + Demonstrates a simple algorithm that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">__has_trivial_destruct</phrase></computeroutput> + to determine whether to destructors need to be called (see <ulink url="../../examples/trivial_destructor_example.cpp">trivial_destructor_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// algorithm destroy_array: +</phrase><phrase role="comment">// The reverse of std::unitialized_copy, takes a block of +</phrase><phrase role="comment">// initialized memory and calls destructors on all objects therein. +</phrase><phrase role="comment">// +</phrase> +<phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="identifier">first</phrase><phrase role="special">->~</phrase><phrase role="identifier">T</phrase><phrase role="special">();</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> <phrase role="comment">// namespace detail +</phrase> +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">p1</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">p2</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">p1</phrase><phrase role="special">,</phrase> <phrase role="identifier">p2</phrase><phrase role="special">,</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.iter"> + <title><link linkend="boost_typetraits.examples.iter"> An improved Version + of std::iter_swap</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iter_swap</phrase></computeroutput> + that use type traits to determine whether an it's arguments are proxying + iterators or not, if they're not then it just does a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">swap</phrase></computeroutput> + of it's dereferenced arguments (the same as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iter_swap</phrase></computeroutput> + does), however if they are proxying iterators then takes special care over + the swap to ensure that the algorithm works correctly for both proxying iterators, + and even iterators of different types (see <ulink url="../../examples/iter_swap_example.cpp">iter_swap_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// iter_swap: +</phrase><phrase role="comment">// tests whether iterator is a proxying iterator or not, and +</phrase><phrase role="comment">// uses optimal form accordingly: +</phrase><phrase role="comment">// +</phrase><phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">></phrase> +<phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">v_t</phrase><phrase role="special">;</phrase> + <phrase role="identifier">v_t</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">one</phrase><phrase role="special">;</phrase> + <phrase role="special">*</phrase><phrase role="identifier">one</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">two</phrase><phrase role="special">;</phrase> + <phrase role="special">*</phrase><phrase role="identifier">two</phrase> <phrase role="special">=</phrase> <phrase role="identifier">v</phrase><phrase role="special">;</phrase> +<phrase role="special">}</phrase> +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">></phrase> +<phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">using</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">swap</phrase><phrase role="special">;</phrase> + <phrase role="identifier">swap</phrase><phrase role="special">(*</phrase><phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase><phrase role="identifier">two</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">iter_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">two</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// See is both arguments are non-proxying iterators, +</phrase> <phrase role="comment">// and if both iterator the same type: +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I1</phrase><phrase role="special">>::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">r1_t</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I2</phrase><phrase role="special">>::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">r2_t</phrase><phrase role="special">;</phrase> + + <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> + <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special"><</phrase><phrase role="identifier">r1_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special"><</phrase><phrase role="identifier">r2_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_same">is_same</link><phrase role="special"><</phrase><phrase role="identifier">r1_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">r2_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">></phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">;</phrase> + + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.to_double"> + <title><link linkend="boost_typetraits.examples.to_double"> Convert Numeric + Types and Enums to double</link></title> + <para> + Demonstrates a conversion of <ulink url="../../../../libs/numeric/conversion/doc/html/boost_numericconversion/definitions.html#boost_numericconversion.definitions.numeric_types">Numeric + Types</ulink> and enum types to double: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">double</phrase> <phrase role="identifier">to_double</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">promoted</phrase><phrase role="special">;</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric</phrase><phrase role="special">::</phrase><phrase role="identifier">converter</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase><phrase role="identifier">promoted</phrase><phrase role="special">>::</phrase><phrase role="identifier">convert</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.reference"> + <title><link linkend="boost_typetraits.reference"> Alphabetical Reference</link></title> + <section id="boost_typetraits.reference.add_const"><indexterm type="class_name"><primary>Constrained Index Term</primary><secondary>add_const</secondary></indexterm><indexterm><primary>add_const</primary><secondary>Constrained Index Term</secondary></indexterm><indexterm type="class_name"><primary>Constrained Index Term</primary><secondary>add_const</secondary></indexterm><indexterm><primary>add_const</primary><secondary>Constrained Index Term</secondary></indexterm><indexterm type="class_name"><primary>add_const</primary><secondary>add_const</secondary></indexterm><indexterm type="class_name"><primary>Constrained Index Term</primary><secondary>add_const</secondary></indexterm><indexterm><primary>add_const</primary><secondary>Constrained Index Term</secondary></indexterm><indexterm type="class_name"><primary>Constrained Index Term</primary><secondary>add_const</secondary></indexterm><indexterm><primary>add_const</primary><secondary>Constrained Index Term</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.add_const"> add_const</link></title> + <indexterm type="class_name"> + <primary>one</primary> + <secondary>two</secondary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">const</phrase></computeroutput> for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_cv"><indexterm type="class_name"><primary>add_cv</primary><secondary>add_cv</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.add_cv"> add_cv</link></title> + <indexterm type="class_name"> + <primary>one</primary> + <secondary>two</secondary> + <tertiary>three</tertiary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_cv</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_cv</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_pointer"><indexterm type="class_name"><primary>add_pointer</primary><secondary>add_pointer</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.add_pointer"> add_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_pointer</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">*</phrase></computeroutput>. + </para> + <para> + The rationale for this template is that it produces the same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">TYPEOF</phrase><phrase role="special">(&</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase></computeroutput>, where + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t</phrase></computeroutput> is an object of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.1. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">**</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">**</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_reference"><indexterm type="class_name"><primary>add_reference</primary><secondary>add_reference</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.add_reference"> add_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_reference</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is not a reference type then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase><phrase role="special">&</phrase></computeroutput>, otherwise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_volatile"><indexterm type="class_name"><primary>add_volatile</primary><secondary>add_volatile</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.add_volatile"> add_volatile</link></title> + <indexterm type="class_name"> + <primary>one</primary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.aligned_storage"><indexterm type="class_name"><primary>aligned_storage</primary><secondary>aligned_storage</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.aligned_storage"> aligned_storage</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">aligned_storage</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> a built-in or POD type with size + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Size</phrase></computeroutput> and an alignment that + is a multiple of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Align</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">aligned_storage</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.alignment_of"><indexterm type="class_name"><primary>integral_constant</primary><secondary>alignment_of</secondary></indexterm><indexterm><primary>alignment_of</primary><secondary>integral_constant</secondary></indexterm><indexterm type="class_name"><primary>alignment_of</primary><secondary>alignment_of</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.alignment_of"> alignment_of</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">alignment_of</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template alignment<emphasis role="underline">of inherits from `</emphasis>_integral_constant<std::size_t, + ALIGNOF(T)><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">,</phrase> <phrase role="identifier">where</phrase> + </computeroutput>ALIGNOF(T)` is the alignment of type T. + </para> + <para> + <emphasis>Note: strictly speaking you should only rely on the value of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> being + a multiple of the true alignment of T, although in practice it does compute + the correct value in all the cases we know about.</emphasis> + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">alignment_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase><phrase role="special">)></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + with value <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.decay"><indexterm type="class_name"><primary>decay</primary><secondary>decay</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.decay"> decay</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">decay</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> Let <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> + be the result of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>, then if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> + is an array type, the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">>*</phrase></computeroutput>, + otherwise if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> is a function + type then the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase><phrase role="special">*</phrase></computeroutput>, otherwise the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">decay</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">(&)[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">(&)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.extent"><indexterm type="class_name"><primary>integral_constant</primary><secondary>extent</secondary></indexterm><indexterm><primary>extent</primary><secondary>integral_constant</secondary></indexterm><indexterm type="class_name"><primary>extent</primary><secondary>extent</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.extent"> extent</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">extent</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template extent inherits + from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)></phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)</phrase></computeroutput> is the number of elements in the N'th array + dimention of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not an array type, + or if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">N</phrase> <phrase role="special">></phrase> + <link linkend="boost_typetraits.reference.rank">rank</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>, or if the N'th array bound is incomplete, + then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)</phrase></computeroutput> is zero. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">extent</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">],</phrase> + <phrase role="number">1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>4</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">],</phrase> <phrase role="number">1</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>2</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.floating_point_promotion"><indexterm type="class_name"><primary>floating_point_promotion</primary><secondary>floating_point_promotion</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.floating_point_promotion"> + floating_point_promotion</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">floating_point_promotion</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If floating point promotion can be + applied to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + then applies floating point promotion to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">floating_point_promotion</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">float</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.function_traits"><indexterm type="typedef_name"><primary>result_type</primary><secondary>function_traits</secondary></indexterm><indexterm><primary>function_traits</primary><secondary>result_type</secondary></indexterm><indexterm type="class_name"><primary>function_traits</primary><secondary>function_traits</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.function_traits"> function_traits</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">F</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">function_traits</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">arity</phrase> <phrase role="special">=</phrase> <replaceable>see-below</replaceable><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">result_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> arg<replaceable>N</replaceable>_type<phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + The class template function_traits will only compile if: + </para> + <itemizedlist> + <listitem> + The compiler supports partial specialization of class templates. + </listitem> + <listitem> + The template argument <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput> + is a <emphasis>function type</emphasis>, note that this <emphasis><emphasis role="bold">is not</emphasis></emphasis> the same thing as a <emphasis>pointer + to a function</emphasis>. + </listitem> + </itemizedlist> + <tip> + <para> + function_traits is intended to introspect only C++ functions of the form + R (), R( A1 ), R ( A1, ... etc. ) and not function pointers or class member + functions. To convert a function pointer type to a suitable type use <link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link>. + </para> + </tip> + <table frame="all"> <title>Function Traits Members</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Member + </para> + </entry><entry> + <para> + Description + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that gives the number of arguments + accepted by the function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type returned by function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase>arg<replaceable>N</replaceable>_type</computeroutput> + </para> + </entry><entry> + <para> + The <replaceable>N</replaceable>th argument type of function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase> <phrase role="special"><=</phrase> + <phrase role="identifier">N</phrase> <phrase role="special"><=</phrase> + <phrase role="identifier">arity</phrase></computeroutput> of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 0. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 1. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 4. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">long</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arg1_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arg4_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase><phrase role="special">*</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arg5_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A compiler error: there is no <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">arg5_type</phrase></computeroutput> + since there are only four arguments. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + A compiler error: argument type is a <emphasis>function pointer</emphasis>, + and not a <emphasis>function type</emphasis>. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.has_nothrow_assign"><indexterm type="class_name"><primary>has_nothrow_assign</primary><secondary>has_nothrow_assign</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.has_nothrow_assign"> has_nothrow_assign</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_assign</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing assignment-operator then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_assign</phrase></computeroutput> + will never report that a class or struct has a non-throwing assignment-operator; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler support to ensure that this trait "just + works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_assign</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_constructor"><indexterm type="class_name"><primary>has_nothrow_default_constructor</primary><secondary>has_nothrow_constructor</secondary></indexterm><indexterm><primary>has_nothrow_constructor</primary><secondary>has_nothrow_default_constructor</secondary></indexterm><indexterm type="class_name"><primary>has_nothrow_constructor</primary><secondary>has_nothrow_constructor</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.has_nothrow_constructor"> + has_nothrow_constructor</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_default_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing default-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_constructor</phrase></computeroutput> + will never report that a class or struct has a non-throwing default-constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to ensure that this trait "just works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_constructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_copy"><indexterm type="class_name"><primary>has_nothrow_copy_constructor</primary><secondary>has_nothrow_copy</secondary></indexterm><indexterm><primary>has_nothrow_copy</primary><secondary>has_nothrow_copy_constructor</secondary></indexterm><indexterm type="class_name"><primary>has_nothrow_copy</primary><secondary>has_nothrow_copy</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.has_nothrow_copy"> has_nothrow_copy</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_copy</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_copy_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing copy-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_copy</phrase></computeroutput> + will never report that a class or struct has a non-throwing copy-constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to ensure that this trait "just works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_copy</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_cp_cons"> + <title><link linkend="boost_typetraits.reference.has_nothrow_cp_cons"> has_nothrow_copy_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_no_throw_def_cons"> + <title><link linkend="boost_typetraits.reference.has_no_throw_def_cons"> has_nothrow_default_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_assign"><indexterm type="class_name"><primary>has_trivial_assign</primary><secondary>has_trivial_assign</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.has_trivial_assign"> has_trivial_assign</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_assign</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial assignment-operator then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + If a type has a trivial assignment-operator then the operator has the same + effect as copying the bits of one object to the other: calls to the operator + can be safely replaced with a call to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_assign + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.8p11. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_assign</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_constructor"><indexterm type="class_name"><primary>has_trivial_default_constructor</primary><secondary>has_trivial_constructor</secondary></indexterm><indexterm><primary>has_trivial_constructor</primary><secondary>has_trivial_default_constructor</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.has_trivial_constructor"> + has_trivial_constructor</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_default_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial default-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + If a type has a trivial default-constructor then the constructor have no + effect: calls to the constructor can be safely omitted. Note that using meta-programming + to omit a call to a single trivial-constructor call is of no benefit whatsoever. + However, if loops and/or exception handling code can also be omitted, then + some benefit in terms of code size and speed can be obtained. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_constructor + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.1p6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_copy"><indexterm type="class_name"><primary>has_trivial_copy_constructor</primary><secondary>has_trivial_copy</secondary></indexterm><indexterm><primary>has_trivial_copy</primary><secondary>has_trivial_copy_constructor</secondary></indexterm><indexterm type="class_name"><primary>has_trivial_copy</primary><secondary>has_trivial_copy</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.has_trivial_copy"> has_trivial_copy</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_copy</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_copy_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial copy-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + If a type has a trivial copy-constructor then the constructor has the same + effect as copying the bits of one object to the other: calls to the constructor + can be safely replaced with a call to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_copy + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.8p6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_copy</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_cp_cons"> + <title><link linkend="boost_typetraits.reference.has_trivial_cp_cons"> has_trivial_copy_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_def_cons"> + <title><link linkend="boost_typetraits.reference.has_trivial_def_cons"> has_trivial_default_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_destructor"><indexterm type="class_name"><primary>has_trivial_destructor</primary><secondary>has_trivial_destructor</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.has_trivial_destructor"> has_trivial_destructor</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_destructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial destructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + If a type has a trivial destructor then the destructor has no effect: calls + to the destructor can be safely omitted. Note that using meta-programming + to omit a call to a single trivial-constructor call is of no benefit whatsoever. + However, if loops and/or exception handling code can also be omitted, then + some benefit in terms of code size and speed can be obtained. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_destructor + will never report that a user-defined class or struct has a trivial destructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.4p3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_virtual_destructor"><indexterm type="class_name"><primary>has_virtual_destructor</primary><secondary>has_virtual_destructor</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.has_virtual_destructor"> has_virtual_destructor</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_virtual_destructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a virtual destructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> This trait is provided + for completeness, since it's part of the Technical Report on C++ Library + Extensions. However, there is currently no way to portably implement this + trait. The default version provided always inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>, + and has to be explicitly specialized for types with virtual destructors unless + the compiler used has compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + that enable the trait to do the right thing: currently (May 2005) only Visual + C++ 8 and GCC-4.3 have the necessary <link linkend="boost_typetraits.intrinsics">intrinsics</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.4. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_virtual_destructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.integral_constant"><indexterm type="typedef_name"><primary>value_type</primary><secondary>integral_constant</secondary></indexterm><indexterm><primary>integral_constant</primary><secondary>value_type</secondary></indexterm><indexterm type="typedef_name"><primary>true_type</primary><secondary>integral_constant</secondary></indexterm><indexterm><primary>integral_constant</primary><secondary>true_type</secondary></indexterm><indexterm type="class_name"><primary>integral_constant</primary><secondary>integral_constant</secondary></indexterm><indexterm type="typedef_name"><primary>false_type</primary><secondary>integral_constant</secondary></indexterm><indexterm><primary>integral_constant</primary><secondary>false_type</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.integral_constant"> integral_constant</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">val</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">integral_constant</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">></phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">val</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> + +<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="keyword">true</phrase><phrase role="special">></phrase> <phrase role="identifier">true_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="keyword">false</phrase><phrase role="special">></phrase> <phrase role="identifier">false_type</phrase><phrase role="special">;</phrase> +</programlisting> + <para> + Class template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_constant</phrase></computeroutput> + is the common base class for all the value-based type traits. The two typedef's + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">true_type</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">false_type</phrase></computeroutput> are provided for convenience: + most of the value traits are Boolean properties and so will inherit from + one of these. + </para> + </section> + <section id="boost_typetraits.reference.integral_promotion"><indexterm type="class_name"><primary>integral_promotion</primary><secondary>integral_promotion</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.integral_promotion"> integral_promotion</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">integral_promotion</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If integral promotion can be applied + to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, then + applies integral promotion to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.5 except 4.5/3 + (integral bit-field). + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">integral_promotion</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">enum</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">float_round_style</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.is_abstract"><indexterm type="class_name"><primary>is_abstract</primary><secondary>is_abstract</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_abstract"> is_abstract</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_abstract</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + abstract type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_abstract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> The compiler must + support DR337 (as of April 2005: GCC 3.4, VC++ 7.1 (and later), Intel C++ + 7 (and later), and Comeau 4.3.2). Otherwise behaves the same as <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link>; + this is the "safe fallback position" for which polymorphic types + are always regarded as potentially abstract. The macro BOOST_NO_IS_ABSTRACT + is used to signify that the implementation is buggy, users should check for + this in their own code if the "safe fallback" is not suitable for + their particular use-case. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">abc</phrase><phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">abc</phrase><phrase role="special">()</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_arithmetic"><indexterm type="class_name"><primary>is_arithmetic</primary><secondary>is_arithmetic</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_arithmetic"> is_arithmetic</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_arithmetic</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + arithmetic type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Arithmetic types include integral and floating point types (see also <link linkend="boost_typetraits.reference.is_integral">is_integral</link> and + <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link>). + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p8. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_arithmetic</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_array"><indexterm type="class_name"><primary>is_array</primary><secondary>is_array</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_array"> is_array</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_array</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + array type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.4. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_array</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can give the wrong result with function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_base_of"><indexterm type="class_name"><primary>is_base_of</primary><secondary>is_base_of</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_base_of"> is_base_of</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_base_of</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If Base is base class of type + Derived or if both types are the same then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + This template will detect non-public base classes, and ambiguous base classes. + </para> + <para> + Note that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">X</phrase><phrase role="special">,</phrase><phrase role="identifier">X</phrase><phrase role="special">></phrase></computeroutput> will always inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>. + <emphasis role="bold">This is the case even if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">X</phrase></computeroutput> + is not a class type</emphasis>. This is a change in behaviour from Boost-1.33 + in order to track the Technical Report on C++ Library Extensions. + </para> + <para> + Types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput> must not be incomplete types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_base_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. There are some older compilers which + will produce compiler errors if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> + is a private base class of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput>, + or if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> is an ambiguous + base of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput>. These compilers + include Borland C++, older versions of Sun Forte C++, Digital Mars C++, and + older versions of EDG based compilers. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">{};</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase> <phrase role="special">:</phrase> + <phrase role="keyword">public</phrase> <phrase role="identifier">Base</phrase><phrase role="special">{};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Base</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>: a class is regarded as it's + own base. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_class"><indexterm type="class_name"><primary>is_class</primary><secondary>is_class</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_class"> is_class</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_class</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + class type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 9.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_class</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Without (some as + yet unspecified) help from the compiler, we cannot distinguish between union + and class types, as a result this type will erroneously inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link> for + union types. See also <link linkend="boost_typetraits.reference.is_union">is_union</link>. + Currently (May 2005) only Visual C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to correctly identify union types, and therefore make is_class function correctly. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">MyClass</phrase><phrase role="special">;</phrase></computeroutput> then: + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_complex"><indexterm type="class_name"><primary>is_complex</primary><secondary>is_complex</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_complex"> is_complex</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_complex</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is a complex number type then true (of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">complex</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">></phrase></computeroutput> + for some type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>), otherwise + false. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 26.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_complex</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.is_compound"><indexterm type="class_name"><primary>is_compound</primary><secondary>is_compound</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_compound"> is_compound</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_compound</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + compound type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Any type that is not a fundamental type is a compound type (see also <link linkend="boost_typetraits.reference.is_fundamental">is_fundamental</link>). + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_compound</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">MyEnum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_const"><indexterm type="class_name"><primary>is_const</primary><secondary>is_const</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_const"> is_const</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_const</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (top level) const-qualified + type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the const-qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the const-qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_convertible"><indexterm type="class_name"><primary>is_convertible</primary><secondary>is_convertible</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_convertible"> is_convertible</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_convertible</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If an imaginary lvalue of type + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">From</phrase></computeroutput> is convertible to type + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + Type From must not be an incomplete type. + </para> + <para> + Type To must not be an incomplete, or function type. + </para> + <para> + No types are considered to be convertible to array types or abstract-class + types. + </para> + <para> + This template can not detect whether a converting-constructor is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> or not: if type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> + has a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput> converting constructor + from type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">From</phrase></computeroutput> then instantiating + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase></computeroutput> + will produce a compiler error. For this reason <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase></computeroutput> + can not be used to determine whether a type has a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> + copy-constructor or not. + </para> + <para> + This template will also produce compiler errors if the conversion is ambiguous, + for example: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">B</phrase> <phrase role="special">:</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">C</phrase> <phrase role="special">:</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">D</phrase> <phrase role="special">:</phrase> <phrase role="identifier">B</phrase><phrase role="special">,</phrase> <phrase role="identifier">C</phrase> <phrase role="special">{};</phrase> +<phrase role="comment">// This produces a compiler error, the conversion is ambiguous: +</phrase><phrase role="keyword">bool</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">y</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">D</phrase><phrase role="special">*,</phrase><phrase role="identifier">A</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase><phrase role="special">;</phrase> +</programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4 and 8.5. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> This template is + currently broken with Borland C++ Builder 5 (and earlier), for constructor-based + conversions, and for the Metrowerks 7 (and earlier) compiler in all cases. + If the compiler does not support <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_abstract">is_abstract</link></computeroutput>, + then the template parameter <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> + must not be an abstract type. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_convertible</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the conversion would require a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const_cast</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&,</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_empty"><indexterm type="class_name"><primary>is_empty</primary><secondary>is_empty</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_empty"> is_empty</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_empty</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an empty class type then + inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10p5. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_empty</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> In order to correctly + detect empty classes this trait relies on either: + </para> + <itemizedlist> + <listitem> + the compiler implementing zero sized empty base classes, or + </listitem> + <listitem> + the compiler providing <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect empty classes. + </listitem> + </itemizedlist> + <para> + Can not be used with incomplete types. + </para> + <para> + Can not be used with union types, until is_union can be made to work. + </para> + <para> + If the compiler does not support partial-specialization of class templates, + then this template can not be used with abstract types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">empty_class</phrase> + <phrase role="special">{};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_enum"><indexterm type="class_name"><primary>is_enum</primary><secondary>is_enum</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_enum"> is_enum</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_enum</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + enum type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_enum</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Requires a correctly + functioning <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link> + template; this means that is_enum is currently broken under Borland C++ Builder + 5, and for the Metrowerks compiler prior to version 8, other compilers should + handle this template just fine. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">enum</phrase> <phrase role="identifier">my_enum</phrase> + <phrase role="special">{</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">two</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_floating_point"><indexterm type="class_name"><primary>is_floating_point</primary><secondary>is_floating_point</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_floating_point"> is_floating_point</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_floating_point</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + floating point type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p8. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_floating_point</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_function"><indexterm type="class_name"><primary>is_function</primary><secondary>is_function</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_function"> is_function</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_function</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + function type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Note that this template does not detect <emphasis>pointers to functions</emphasis>, + or <emphasis>references to functions</emphasis>, these are detected by <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link> and <link linkend="boost_typetraits.reference.is_reference">is_reference</link> respectively: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">f1</phrase><phrase role="special">();</phrase> <phrase role="comment">// f1 is of function type. +</phrase><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">f2</phrase><phrase role="special">*)();</phrase> <phrase role="comment">// f2 is a pointer to a function. +</phrase><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">f3</phrase><phrase role="special">&)();</phrase> <phrase role="comment">// f3 is a reference to a function. +</phrase></programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2p1 and 8.3.5. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_function</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a pointer type, not a function type. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(&)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a reference to a function, not a function type. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a pointer to a member function. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + <tip> + <para> + Don't confuse function-types with pointers to functions: + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> + <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">);</phrase></computeroutput> + </para> + <para> + defines a function type, + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase> <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + declares a prototype for a function of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase></computeroutput>, + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase><phrase role="special">*</phrase> + <phrase role="identifier">pf</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase><phrase role="special">&</phrase> + <phrase role="identifier">fr</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + declares a pointer and a reference to the function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">foo</phrase></computeroutput>. + </para> + <para> + If you want to detect whether some type is a pointer-to-function then use: + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_function">is_function</link><phrase role="special"><</phrase><link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + </para> + <para> + or for pointers to member functions you can just use <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link> + directly. + </para> + </tip> + </section> + <section id="boost_typetraits.reference.is_fundamental"><indexterm type="class_name"><primary>is_fundamental</primary><secondary>is_fundamental</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_fundamental"> is_fundamental</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_fundamental</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + fundamental type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Fundamental types include integral, floating point and void types (see also + <link linkend="boost_typetraits.reference.is_integral">is_integral</link>, + <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link> + and <link linkend="boost_typetraits.reference.is_void">is_void</link>) + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_fundamental</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_integral"><indexterm type="class_name"><primary>is_integral</primary><secondary>is_integral</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_integral"> is_integral</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_integral</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + integral type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p7. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_integral</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_function_pointer"><indexterm type="class_name"><primary>is_member_function_pointer</primary><secondary>is_member_function_pointer</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_member_function_pointer"> + is_member_function_pointer</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_function_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member function then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the argument in this case is a pointer to a data member and not a member + function, see <link linkend="boost_typetraits.reference.is_member_object_pointer">is_member_object_pointer</link> + and <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_object_pointer"><indexterm type="class_name"><primary>is_member_object_pointer</primary><secondary>is_member_object_pointer</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_member_object_pointer"> + is_member_object_pointer</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_object_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member object (a data member) then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the argument in this case is a pointer to a member function and not a + member object, see <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link> + and <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_pointer"><indexterm type="class_name"><primary>is_member_pointer</primary><secondary>is_member_pointer</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_member_pointer"> is_member_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member (either a function or a data member) then inherits from + <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_object"><indexterm type="class_name"><primary>is_object</primary><secondary>is_object</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_object"> is_object</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_object</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + object type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + All types are object types except references, void, and function types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p9. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_object</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: reference types are not + objects + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: function types are not + objects + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + void is not an object type + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_pod"> + <title><link linkend="boost_typetraits.reference.is_pod"> is_pod</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_pod</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + POD type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + POD stands for "Plain old data". Arithmetic types, and enumeration + types, a pointers and pointer to members are all PODs. Classes and unions + can also be POD's if they have no non-static data members that are of reference + or non-POD type, no user defined constructors, no user defined assignment + operators, no private or protected non-static data members, no virtual functions + and no base classes. Finally, a cv-qualified POD is still a POD, as is an + array of PODs. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10 and 9p4 (Note + that POD's are also aggregates, see 8.5.1). + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, is<emphasis role="underline">pod + will never report that a class or struct is a POD; this is always safe, if + possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8 have + the necessary compiler-</emphasis>_intrinsics. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pod</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_pointer"><indexterm type="class_name"><primary>is_pointer</primary><secondary>is_pointer</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_pointer"> is_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer type (includes function pointers, but excludes pointers to members) + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2p2 and 8.3.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + <important> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase></computeroutput> detects "real" + pointer types only, and <emphasis>not</emphasis> smart pointers. Users + should not specialise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase></computeroutput> + for smart pointer types, as doing so may cause Boost (and other third party) + code to fail to function correctly. Users wanting a trait to detect smart + pointers should create their own. However, note that there is no way in + general to auto-magically detect smart pointer types, so such a trait would + have to be partially specialised for each supported smart pointer type. + </para> + </important> + </section> + <section id="boost_typetraits.reference.is_polymorphic"><indexterm type="class_name"><primary>is_polymorphic</primary><secondary>is_polymorphic</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_polymorphic"> is_polymorphic</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_polymorphic</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + polymorphic type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> The implementation + requires some knowledge of the compilers ABI, it does actually seem to work + with the majority of compilers though. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_polymorphic</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">poly</phrase><phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">poly</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_same"><indexterm type="class_name"><primary>is_same</primary><secondary>is_same</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_same"> is_same</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">U</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_same</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T and U are the same types + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_same</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with abstract, incomplete or function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_scalar"><indexterm type="class_name"><primary>is_scalar</primary><secondary>is_scalar</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_scalar"> is_scalar</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_scalar</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + scalar type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Scalar types include integral, floating point, enumeration, pointer, and + pointer-to-member types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_scalar</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_signed"><indexterm type="class_name"><primary>is_signed</primary><secondary>is_signed</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_signed"> is_signed</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_signed</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an signed integer type + or an enumerated type with an underlying signed integer type, then inherits + from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1, 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_signed</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">myclass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + whose value depends upon the signedness of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_stateless"> + <title><link linkend="boost_typetraits.reference.is_stateless"> is_stateless</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_stateless</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Ff T is a stateless type then + inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + Type T must be a complete type. + </para> + <para> + A stateless type is a type that has no storage and whose constructors and + destructors are trivial. That means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_stateless</phrase></computeroutput> + only inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the following expression is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput>: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +</programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_stateless</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, is_stateless will + never report that a class or struct is stateless; this is always safe, if + possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8 have + the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to make this template work automatically. + </para> + </section> + <section id="boost_typetraits.reference.is_reference"><indexterm type="class_name"><primary>is_reference</primary><secondary>is_reference</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_reference"> is_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_reference</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a reference pointer type + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + may report the wrong result for function types, and for types that are both + const and volatile qualified. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(&)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis> (the argument in this case + is a reference to a function). + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_union"><indexterm type="class_name"><primary>is_union</primary><secondary>is_union</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_union"> is_union</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_union</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + union type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Currently requires some kind of compiler support, otherwise unions are identified + as classes. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 9.5. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Without (some as + yet unspecified) help from the compiler, we cannot distinguish between union + and class types using only standard C++, as a result this type will never + inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + unless the user explicitly specializes the template for their user-defined + union types, or unless the compiler supplies some unspecified intrinsic that + implements this functionality. Currently (May 2005) only Visual C++ 8 has + the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to make this trait "just work" without user intervention. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_union</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_unsigned"><indexterm type="class_name"><primary>is_unsigned</primary><secondary>is_unsigned</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_unsigned"> is_unsigned</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_unsigned</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an unsigned integer type + or an enumerated type with an underlying unsigned integer type, then inherits + from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1, 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_unsigned</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="identifier">myclass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + whose value depends upon the signedness of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">long</phrase> + <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_void"><indexterm type="class_name"><primary>is_void</primary><secondary>is_void</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_void"> is_void</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_void</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + void type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p9. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_void</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_volatile"><indexterm type="class_name"><primary>is_volatile</primary><secondary>is_volatile</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.is_volatile"> is_volatile</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_volatile</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (top level) volatile-qualified + type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">volatile</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase> + <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the volatile qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.make_signed"><indexterm type="class_name"><primary>make_signed</primary><secondary>make_signed</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.make_signed"> make_signed</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">make_signed</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If T is a signed integer type then + the same type as T, if T is an unsigned integer type then the corresponding + signed type. Otherwise if T is an enumerated or character type (char or wchar_t) + then a signed integer type with the same width as T. + </para> + <para> + If T has any cv-qualifiers then these are also present on the result type. + </para> + <para> + <emphasis role="bold">Requires:</emphasis> T must be an integer or enumerated + type, and must not be the type bool. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">make_signed</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">long</phrase> + <phrase role="keyword">long</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A signed integer type with the same width as the enum. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">wchar_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A signed integer type with the same width as wchar_t. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.make_unsigned"><indexterm type="class_name"><primary>make_unsigned</primary><secondary>make_unsigned</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.make_unsigned"> make_unsigned</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">make_unsigned</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If T is a unsigned integer type then + the same type as T, if T is an signed integer type then the corresponding + unsigned type. Otherwise if T is an enumerated or character type (char or + wchar_t) then an unsigned integer type with the same width as T. + </para> + <para> + If T has any cv-qualifiers then these are also present on the result type. + </para> + <para> + <emphasis role="bold">Requires:</emphasis> T must be an integer or enumerated + type, and must not be the type bool. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">make_unsigned</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + An unsigned integer type with the same width as the enum. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">wchar_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + An unsigned integer type with the same width as wchar_t. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.promote"><indexterm type="class_name"><primary>promote</primary><secondary>promote</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.promote"> promote</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">promote</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If integral or floating point promotion + can be applied to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + then applies integral and floating point promotions to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + See also <link linkend="boost_typetraits.reference.integral_promotion">integral_promotion</link> + and <link linkend="boost_typetraits.reference.floating_point_promotion">floating_point_promotion</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.5 except 4.5/3 + (integral bit-field) and 4.6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">promote</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.rank"><indexterm type="class_name"><primary>integral_constant</primary><secondary>rank</secondary></indexterm><indexterm><primary>rank</primary><secondary>integral_constant</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.rank"> rank</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">rank</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template rank inherits from + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> is the + number of array dimensions in type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not an array type, + then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> is zero. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">rank</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[]></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>1</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>2</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.remove_all_extents"><indexterm type="class_name"><primary>remove_all_extents</primary><secondary>remove_all_extents</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.remove_all_extents"> remove_all_extents</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_all_extents</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is an array type, then removes all of the array bounds on <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.4. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_all_extents</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_const"><indexterm type="class_name"><primary>remove_const</primary><secondary>remove_const</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.remove_const"> remove_const</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> const-qualifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_cv"><indexterm type="class_name"><primary>remove_cv</primary><secondary>remove_cv</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.remove_cv"> remove_cv</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_cv</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> cv-qualifiers removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_cv</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_extent"><indexterm type="class_name"><primary>remove_extent</primary><secondary>remove_extent</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.remove_extent"> remove_extent</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_extent</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is an array type, then removes the topmost array bound, otherwise leaves + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.4. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_extent</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_pointer"><indexterm type="class_name"><primary>remove_pointer</primary><secondary>remove_pointer</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.remove_pointer"> remove_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_pointer</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any pointer modifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.1. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">**>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_reference"><indexterm type="class_name"><primary>remove_reference</primary><secondary>remove_reference</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.remove_reference"> remove_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_reference</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any reference modifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_volatile"><indexterm type="class_name"><primary>remove_volatile</primary><secondary>remove_volatile</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.remove_volatile"> remove_volatile</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> volatile-qualifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.type_with_alignment"><indexterm type="class_name"><primary>type_with_alignment</primary><secondary>type_with_alignment</secondary></indexterm> + <title><link linkend="boost_typetraits.reference.type_with_alignment"> type_with_alignment</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">type_with_alignment</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> a built-in or POD type with an alignment + that is a multiple of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Align</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">type_with_alignment</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + </section> + <section id="boost_typetraits.credits"> + <title><link linkend="boost_typetraits.credits"> Credits</link></title> + <para> + This documentation was pulled together by John Maddock, using <ulink url="../../../../doc/html/quickbook.html">Boost.Quickbook</ulink> + and <ulink url="../../../../doc/html/boostbook.html">Boost.DocBook</ulink>. + </para> + <para> + The original version of this library was created by Steve Cleary, Beman Dawes, + Howard Hinnant, and John Maddock. John Maddock is the current maintainer of + the library. + </para> + <para> + This version of type traits library is based on contributions by Adobe Systems + Inc, David Abrahams, Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, + Jesse Jones, Mat Marcus, Itay Maman, John Maddock, Thorsten Ottosen, Robert + Ramey and Jeremy Siek. + </para> + <para> + Mat Marcus and Jesse Jones invented, and <ulink url="http://opensource.adobe.com/project4/project.shtml">published + a paper describing</ulink>, the partial specialization workarounds used in + this library. + </para> + <para> + Aleksey Gurtovoy added MPL integration to the library. + </para> + <para> + The <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link> + template is based on code originally devised by Andrei Alexandrescu, see "<ulink url="http://www.cuj.com/experts/1810/alexandr.htm?topic=experts">Generic<Programming>: + Mappings between Types and Values</ulink>". + </para> + <para> + The latest version of this library and documentation can be found at <ulink url="http://www.boost.org">www.boost.org</ulink>. Bugs, suggestions and discussion + should be directed to boost@lists.boost.org (see <ulink url="http://www.boost.org/more/mailing_lists.htm#main">www.boost.org/more/mailing_lists.htm#main</ulink> + for subscription details). + </para> + </section> + + <section id="boost_typetraits.ignored_section"> + <title>This section must not be indexed.</title> + <?BoostAutoIndex IgnoreSection?> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + </section> + + <section id="boost_typetraits.ignored_block"><indexterm type="class_name"><primary>add_volatile</primary><secondary>This section contains one block that must not be indexed and one that should be.</secondary></indexterm><indexterm><primary>This section contains one block that must not be indexed and one that should be.</primary><secondary>add_volatile</secondary></indexterm> + <title>This section contains one block that must not be indexed and one that should be.</title> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword"> + <?BoostAutoIndex IgnoreBlock?> + template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword"> + template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + </section> + + + <index type="class_name"> + <title>Class Index</title> + </index> + <index type="typedef_name"> + <title>Typedef Index</title> + </index> + <index type="macro_name"> + <title>Macro Index</title> + </index> + <index type="test_index_1"> + <title>Index Test 1</title> + </index> + <index type="test_index_2"> + <title>Index Test 2</title> + </index> + <index/> + +</chapter>
\ No newline at end of file diff --git a/src/boost/tools/auto_index/test/test2.gold b/src/boost/tools/auto_index/test/test2.gold new file mode 100644 index 000000000..b4f7c4eab --- /dev/null +++ b/src/boost/tools/auto_index/test/test2.gold @@ -0,0 +1,6671 @@ +<?xml version="1.0"?> +<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> +<!-- + +This file is based upon the type traits docs, but has had additional XML elements added to it +to ensure complete testing. + +--> + +<chapter xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" id="boost_typetraits" rev:last-revision="$Date: 2008-11-28 12:41:45 +0000 (Fri, 28 Nov 2008) $"> + <chapterinfo><author> + <firstname>various</firstname> <surname>authors</surname> + </author><copyright> + <year>2000</year> <year>2006</year> <holder>Adobe Systems Inc, David Abrahams, + Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat + Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert + Ramey and Jeremy Siek</holder> + </copyright><legalnotice> + <para> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>) + </para> + </legalnotice></chapterinfo> + <title>Boost.TypeTraits</title> + <para> + A printer-friendly <ulink url="http://svn.boost.org/svn/boost/sandbox/pdf/type_traits/release/type_traits.pdf">PDF + version of this manual is also available</ulink>. + </para> + <section id="boost_typetraits.intro"> + <title><link linkend="boost_typetraits.intro"> Introduction</link></title> + <para> + The Boost type-traits library contains a set of very specific traits classes, + each of which encapsulate a single trait from the C++ type system; for example, + is a type a pointer or a reference type? Or does a type have a trivial constructor, + or a const-qualifier? + </para> + <para> + The type-traits classes share a unified design: each class inherits from a + the type <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the type has the specified property and inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link> + otherwise. + </para> + <para> + The type-traits library also contains a set of classes that perform a specific + transformation on a type; for example, they can remove a top-level const or + volatile qualifier from a type. Each class that performs a transformation defines + a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of the transformation. + </para> + </section> + <section id="boost_typetraits.background"> + <title><link linkend="boost_typetraits.background"> Background and Tutorial</link></title> + <para> + The following is an updated version of the article "C++ Type traits" + by John Maddock and Steve Cleary that appeared in the October 2000 issue of + <ulink url="http://www.ddj.com">Dr Dobb's Journal</ulink>. + </para> + <para> + Generic programming (writing code which works with any data type meeting a + set of requirements) has become the method of choice for providing reusable + code. However, there are times in generic programming when "generic" + just isn't good enough - sometimes the differences between types are too large + for an efficient generic implementation. This is when the traits technique + becomes important - by encapsulating those properties that need to be considered + on a type by type basis inside a traits class, we can minimize the amount of + code that has to differ from one type to another, and maximize the amount of + generic code. + </para> + <?dbfo keep-together="auto" ?> + <para> + <indexterm> + <primary>Foo1</primary> + </indexterm> + Consider an example: when working with character strings, one common operation + is to determine the length of a null terminated string. Clearly it's possible + to write generic code that can do this, but it turns out that there are much + more efficient methods available: for example, the C library functions <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">strlen</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">wcslen</phrase></computeroutput> + are usually written in assembler, and with suitable hardware support can be + considerably faster than a generic version written in C++. The authors of the + C++ standard library realized this, and abstracted the properties of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">wchar_t</phrase></computeroutput> + into the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput>. + Generic code that works with character strings can simply use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase><phrase role="special"><>::</phrase><phrase role="identifier">length</phrase></computeroutput> to determine the length of a null + terminated string, safe in the knowledge that specializations of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput> will use the most appropriate + method available to them. + </para> + <anchor id="boost_typetraits.background.type_traits"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.type_traits">Type Traits</link> + </bridgehead> + <para> + Class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput> is a classic + example of a collection of type specific properties wrapped up in a single + class - what Nathan Myers termed a <emphasis>baggage class</emphasis><link linkend="background.references">[1]</link>. In the Boost type-traits library, + we<link linkend="background.references">[2]</link> have written a set of very + specific traits classes, each of which encapsulate a single trait from the + C++ type system; for example, is a type a pointer or a reference type? Or does + a type have a trivial constructor, or a const-qualifier? The type-traits classes + share a unified design: each class inherits from a the type <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the type has the specified property and inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link> + otherwise. As we will show, these classes can be used in generic programming + to determine the properties of a given type and introduce optimizations that + are appropriate for that case. + </para> + <para> + The type-traits library also contains a set of classes that perform a specific + transformation on a type; for example, they can remove a top-level const or + volatile qualifier from a type. Each class that performs a transformation defines + a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of the transformation. All of the type-traits classes are + defined inside namespace <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase></computeroutput>; + for brevity, namespace-qualification is omitted in most of the code samples + given. + </para> + <anchor id="boost_typetraits.background.implementation"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.implementation">Implementation</link> + </bridgehead> + <para> + There are far too many separate classes contained in the type-traits library + to give a full implementation here - see the source code in the Boost library + for the full details - however, most of the implementation is fairly repetitive + anyway, so here we will just give you a flavor for how some of the classes + are implemented. Beginning with possibly the simplest class in the library, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput> inherits + from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + only if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> +</programlisting> + <para> + Here we define a primary version of the template class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_void">is_void</link></computeroutput>, + and provide a full-specialization when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. While full specialization + of a template class is an important technique, sometimes we need a solution + that is halfway between a fully generic solution, and a full specialization. + This is exactly the situation for which the standards committee defined partial + template-class specialization. As an example, consider the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput>: + here we needed a primary version that handles all the cases where T is not + a pointer, and a partial specialization to handle all the cases where T is + a pointer: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">*></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> +</programlisting> + <para> + The syntax for partial specialization is somewhat arcane and could easily occupy + an article in its own right; like full specialization, in order to write a + partial specialization for a class, you must first declare the primary template. + The partial specialization contains an extra <...> after the class name + that contains the partial specialization parameters; these define the types + that will bind to that partial specialization rather than the default template. + The rules for what can appear in a partial specialization are somewhat convoluted, + but as a rule of thumb if you can legally write two function overloads of the + form: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">);</phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase><phrase role="identifier">U</phrase><phrase role="special">);</phrase> +</programlisting> + <para> + Then you can also write a partial specialization of the form: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">class</phrase> <phrase role="identifier">c</phrase><phrase role="special">{</phrase> <phrase role="comment">/*details*/</phrase> <phrase role="special">};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">class</phrase> <phrase role="identifier">c</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">>{</phrase> <phrase role="comment">/*details*/</phrase> <phrase role="special">};</phrase> +</programlisting> + <para> + This rule is by no means foolproof, but it is reasonably simple to remember + and close enough to the actual rule to be useful for everyday use. + </para> + <para> + As a more complex example of partial specialization consider the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput>. This + class defines a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the same type as T but with any top-level array bounds removed; this + is an example of a traits class that performs a transformation on a type: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link> +<phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">N</phrase><phrase role="special">]></phrase> +<phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> +</programlisting> + <para> + The aim of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.remove_extent">remove_extent</link></computeroutput> + is this: imagine a generic algorithm that is passed an array type as a template + parameter, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.remove_extent">remove_extent</link></computeroutput> + provides a means of determining the underlying type of the array. For example + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">][</phrase><phrase role="number">5</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> would evaluate to the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">5</phrase><phrase role="special">]</phrase></computeroutput>. This example also shows that the number of + template parameters in a partial specialization does not have to match the + number in the default template. However, the number of parameters that appear + after the class name do have to match the number and type of the parameters + in the default template. + </para> + <anchor id="boost_typetraits.background.optimized_copy"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.optimized_copy">Optimized copy</link> + </bridgehead> + <para> + As an example of how the type traits classes can be used, consider the standard + library algorithm copy: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iter1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Iter2</phrase><phrase role="special">></phrase> +<phrase role="identifier">Iter2</phrase> <phrase role="identifier">copy</phrase><phrase role="special">(</phrase><phrase role="identifier">Iter1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter2</phrase> <phrase role="identifier">out</phrase><phrase role="special">);</phrase> +</programlisting> + <para> + Obviously, there's no problem writing a generic version of copy that works + for all iterator types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput>; however, there are + some circumstances when the copy operation can best be performed by a call + to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. In order to implement + copy in terms of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> all + of the following conditions need to be met: + </para> + <itemizedlist> + <listitem> + Both of the iterator types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput> must be pointers. + </listitem> + <listitem> + Both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput> must point to the same type - excluding + const and volatile-qualifiers. + </listitem> + <listitem> + The type pointed to by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + must have a trivial assignment operator. + </listitem> + </itemizedlist> + <para> + By trivial assignment operator we mean that the type is either a scalar type<link linkend="background.references">[3]</link> or: + </para> + <itemizedlist> + <listitem> + The type has no user defined assignment operator. + </listitem> + <listitem> + The type does not have any data members that are references. + </listitem> + <listitem> + All base classes, and all data member objects must have trivial assignment + operators. + </listitem> + </itemizedlist> + <para> + If all these conditions are met then a type can be copied using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> rather than using a compiler generated + assignment operator. The type-traits library provides a class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput>, + such that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is true only if T has a trivial assignment + operator. This class "just works" for scalar types, but has to be + explicitly specialised for class/struct types that also happen to have a trivial + assignment operator. In other words if <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link> + gives the wrong answer, it will give the "safe" wrong answer - that + trivial assignment is not allowable. + </para> + <para> + The code for an optimized version of copy that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> + where appropriate is given in <link linkend="boost_typetraits.examples.copy">the + examples</link>. The code begins by defining a template function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">do_copy</phrase></computeroutput> that performs a "slow but safe" + copy. The last parameter passed to this function may be either a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + or a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">false_type</link></computeroutput>. + Following that there is an overload of do<emphasis role="underline">copy that + uses `memcpy`: this time the iterators are required to actually be pointers + to the same type, and the final parameter must be a `</emphasis>_true_type<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase> <phrase role="identifier">Finally</phrase><phrase role="special">,</phrase> <phrase role="identifier">the</phrase> <phrase role="identifier">version</phrase> + <phrase role="identifier">of</phrase> </computeroutput>copy<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="identifier">calls</phrase> + </computeroutput>do<emphasis role="underline">copy`, passing `</emphasis>_has_trivial_assign<value_type>()` + as the final parameter: this will dispatch to the optimized version where appropriate, + otherwise it will call the "slow but safe version". + </para> + <anchor id="boost_typetraits.background.was_it_worth_it_"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.was_it_worth_it_">Was it worth it?</link> + </bridgehead> + <para> + It has often been repeated in these columns that "premature optimization + is the root of all evil" <link linkend="background.references">[4]</link>. + So the question must be asked: was our optimization premature? To put this + in perspective the timings for our version of copy compared a conventional + generic copy<link linkend="background.references">[5]</link> are shown in table + 1. + </para> + <para> + Clearly the optimization makes a difference in this case; but, to be fair, + the timings are loaded to exclude cache miss effects - without this accurate + comparison between algorithms becomes difficult. However, perhaps we can add + a couple of caveats to the premature optimization rule: + </para> + <itemizedlist> + <listitem> + If you use the right algorithm for the job in the first place then optimization + will not be required; in some cases, memcpy is the right algorithm. + </listitem> + <listitem> + If a component is going to be reused in many places by many people then optimizations + may well be worthwhile where they would not be so for a single case - in + other words, the likelihood that the optimization will be absolutely necessary + somewhere, sometime is that much higher. Just as importantly the perceived + value of the stock implementation will be higher: there is no point standardizing + an algorithm if users reject it on the grounds that there are better, more + heavily optimized versions available. + </listitem> + </itemizedlist> + <table frame="all"> <title>Time taken to copy 1000 elements using `copy<const + T*, T*>` (times in micro-seconds)</title> + <tgroup cols="3"> + <thead> + <row> + <entry> + <para> + Version + </para> + </entry><entry> + <para> + T + </para> + </entry><entry> + <para> + Time + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + "Optimized" copy + </para> + </entry><entry> + <para> + char + </para> + </entry><entry> + <para> + 0.99 + </para> + </entry> + </row> + <row> + <entry> + <para> + Conventional copy + </para> + </entry><entry> + <para> + char + </para> + </entry><entry> + <para> + 8.07 + </para> + </entry> + </row> + <row> + <entry> + <para> + "Optimized" copy + </para> + </entry><entry> + <para> + int + </para> + </entry><entry> + <para> + 2.52 + </para> + </entry> + </row> + <row> + <entry> + <para> + Conventional copy + </para> + </entry><entry> + <para> + int + </para> + </entry><entry> + <para> + 8.02 + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> <anchor id="boost_typetraits.background.pair_of_references"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.pair_of_references">Pair of References</link> + </bridgehead> + <para> + The optimized copy example shows how type traits may be used to perform optimization + decisions at compile-time. Another important usage of type traits is to allow + code to compile that otherwise would not do so unless excessive partial specialization + is used. This is possible by delegating partial specialization to the type + traits classes. Our example for this form of usage is a pair that can hold + references <link linkend="background.references">[6]</link>. + </para> + <para> + First, let us examine the definition of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase></computeroutput>, omitting + the comparison operators, default constructor, and template copy constructor + for simplicity: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T2</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">pair</phrase> +<phrase role="special">{</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T1</phrase> <phrase role="identifier">first_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T2</phrase> <phrase role="identifier">second_type</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">T1</phrase> <phrase role="identifier">first</phrase><phrase role="special">;</phrase> +<phrase role="identifier">T2</phrase> <phrase role="identifier">second</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">pair</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase> <phrase role="special">&</phrase> <phrase role="identifier">nfirst</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T2</phrase> <phrase role="special">&</phrase> <phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> +<phrase role="special">:</phrase><phrase role="identifier">first</phrase><phrase role="special">(</phrase><phrase role="identifier">nfirst</phrase><phrase role="special">),</phrase> <phrase role="identifier">second</phrase><phrase role="special">(</phrase><phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + Now, this "pair" cannot hold references as it currently stands, because + the constructor would require taking a reference to a reference, which is currently + illegal <link linkend="background.references">[7]</link>. Let us consider what + the constructor's parameters would have to be in order to allow "pair" + to hold non-reference types, references, and constant references: + </para> + <table frame="all"> <title>Required Constructor Argument Types</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of parameter to initializing constructor + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + T + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + <row> + <entry> + <para> + T & + </para> + </entry><entry> + <para> + T & + </para> + </entry> + </row> + <row> + <entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + <para> + A little familiarity with the type traits classes allows us to construct a + single mapping that allows us to determine the type of parameter from the type + of the contained class. The type traits classes provide a transformation <link linkend="boost_typetraits.reference.add_reference">add_reference</link>, which + adds a reference to its type, unless it is already a reference. + </para> + <table frame="all"> <title>Using add_reference to synthesize the correct constructor + type</title> + <tgroup cols="3"> + <thead> + <row> + <entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + T + </para> + </entry><entry> + <para> + const T + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + <row> + <entry> + <para> + T & + </para> + </entry><entry> + <para> + T & [8] + </para> + </entry><entry> + <para> + T & + </para> + </entry> + </row> + <row> + <entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + <para> + This allows us to build a primary template definition for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput> + that can contain non-reference types, reference types, and constant reference + types: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T2</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">pair</phrase> +<phrase role="special">{</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T1</phrase> <phrase role="identifier">first_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T2</phrase> <phrase role="identifier">second_type</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">T1</phrase> <phrase role="identifier">first</phrase><phrase role="special">;</phrase> +<phrase role="identifier">T2</phrase> <phrase role="identifier">second</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">pair</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">nfirst</phrase><phrase role="special">,</phrase> + <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T2</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> +<phrase role="special">:</phrase><phrase role="identifier">first</phrase><phrase role="special">(</phrase><phrase role="identifier">nfirst</phrase><phrase role="special">),</phrase> <phrase role="identifier">second</phrase><phrase role="special">(</phrase><phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + Add back in the standard comparison operators, default constructor, and template + copy constructor (which are all the same), and you have a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase></computeroutput> that + can hold reference types! + </para> + <para> + This same extension could have been done using partial template specialization + of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput>, but to specialize + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput> in this way would require + three partial specializations, plus the primary template. Type traits allows + us to define a single primary template that adjusts itself auto-magically to + any of these partial specializations, instead of a brute-force partial specialization + approach. Using type traits in this fashion allows programmers to delegate + partial specialization to the type traits classes, resulting in code that is + easier to maintain and easier to understand. + </para> + <anchor id="boost_typetraits.background.conclusion"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.conclusion">Conclusion</link> + </bridgehead> + <para> + We hope that in this article we have been able to give you some idea of what + type-traits are all about. A more complete listing of the available classes + are in the boost documentation, along with further examples using type traits. + Templates have enabled C++ uses to take the advantage of the code reuse that + generic programming brings; hopefully this article has shown that generic programming + does not have to sink to the lowest common denominator, and that templates + can be optimal as well as generic. + </para> + <anchor id="boost_typetraits.background.acknowledgements"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.acknowledgements">Acknowledgements</link> + </bridgehead> + <para> + The authors would like to thank Beman Dawes and Howard Hinnant for their helpful + comments when preparing this article. + </para> + <anchor id="background.references"/> <anchor id="boost_typetraits.background.references"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.references">References</link> + </bridgehead> + <orderedlist inheritnum="ignore" continuation="restarts"> + <listitem> + Nathan C. Myers, C++ Report, June 1995. + </listitem> + <listitem> + The type traits library is based upon contributions by Steve Cleary, Beman + Dawes, Howard Hinnant and John Maddock: it can be found at www.boost.org. + </listitem> + <listitem> + A scalar type is an arithmetic type (i.e. a built-in integer or floating + point type), an enumeration type, a pointer, a pointer to member, or a const- + or volatile-qualified version of one of these types. + </listitem> + <listitem> + This quote is from Donald Knuth, ACM Computing Surveys, December 1974, pg + 268. + </listitem> + <listitem> + The test code is available as part of the boost utility library (see algo_opt_examples.cpp), + the code was compiled with gcc 2.95 with all optimisations turned on, tests + were conducted on a 400MHz Pentium II machine running Microsoft Windows 98. + </listitem> + <listitem> + John Maddock and Howard Hinnant have submitted a "compressed_pair" + library to Boost, which uses a technique similar to the one described here + to hold references. Their pair also uses type traits to determine if any + of the types are empty, and will derive instead of contain to conserve space + -- hence the name "compressed". + </listitem> + <listitem> + This is actually an issue with the C++ Core Language Working Group (issue + #106), submitted by Bjarne Stroustrup. The tentative resolution is to allow + a "reference to a reference to T" to mean the same thing as a "reference + to T", but only in template instantiation, in a method similar to multiple + cv-qualifiers. + </listitem> + <listitem> + For those of you who are wondering why this shouldn't be const-qualified, + remember that references are always implicitly constant (for example, you + can't re-assign a reference). Remember also that "const T &" + is something completely different. For this reason, cv-qualifiers on template + type arguments that are references are ignored. + </listitem> + </orderedlist> + </section> + <section id="boost_typetraits.category"> + <title><link linkend="boost_typetraits.category"> Type Traits by Category</link></title> + <section id="boost_typetraits.category.value_traits"> + <title><link linkend="boost_typetraits.category.value_traits"> Type Traits + that Describe the Properties of a Type</link></title> + <para> + <indexterm> + <primary>Foo2</primary> + <secondary>Bar2</secondary> + </indexterm> + These traits are all <emphasis>value traits</emphasis>, which is to say the + traits classes all inherit from <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link>, + and are used to access some numerical property of a type. Often this is a + simple true or false Boolean value, but in a few cases may be some other + integer value (for example when dealing with type alignments, or array bounds: + see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.alignment_of">alignment_of</link></computeroutput>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.rank">rank</link></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.extent">extent</link></computeroutput>). + </para> + <section id="boost_typetraits.category.value_traits.primary"> + <title><link linkend="boost_typetraits.category.value_traits.primary"> Categorizing + a Type</link></title> + <para> + These traits identify what "kind" of type some type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is. These are split into two groups: + primary traits which are all mutually exclusive, and composite traits that + are compositions of one or more primary traits. + </para> + <para> + For any given type, exactly one primary type trait will inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + and all the others will inherit from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>, + in other words these traits are mutually exclusive. + </para> + <para> + This means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_integral">is_integral</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + will only ever be true for built-in types; if you want to check for a user-defined + class type that behaves "as if" it is an integral or floating + point type, then use the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase> + <phrase role="keyword">template</phrase></computeroutput> instead. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_array">is_array</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_class">is_class</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_complex">is_complex</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_enum">is_enum</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_function">is_function</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_integral">is_integral</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_object_pointer">is_member_object_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_union">is_union</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link><phrase role="special">;</phrase> +</programlisting> + <para> + The following traits are made up of the union of one or more type categorizations. + A type may belong to more than one of these categories, in addition to + one of the primary categories. + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_arithmetic">is_arithmetic</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_compound">is_compound</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_fundamental">is_fundamental</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_object">is_object</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_scalar">is_scalar</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.value_traits.properties"> + <title><link linkend="boost_typetraits.category.value_traits.properties"> + General Type Properties</link></title> + <para> + The following templates describe the general properties of a type. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.alignment_of">alignment_of</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_assign">has_nothrow_assign</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_default_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_default_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_virtual_destructor">has_virtual_destructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_abstract">is_abstract</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_const">is_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_empty">is_empty</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_stateless">is_stateless</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_signed">is_signed</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_unsigned">is_unsigned</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_volatile">is_volatile</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.extent">extent</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.rank">rank</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.value_traits.relate"> + <title><link linkend="boost_typetraits.category.value_traits.relate"> Relationships + Between Two Types</link></title> + <para> + These templates determine the whether there is a relationship between two + types: + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_base_of">is_base_of</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">U</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_same">is_same</link><phrase role="special">;</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.category.transform"> + <title><link linkend="boost_typetraits.category.transform"> Type Traits that + Transform One Type to Another</link></title> + <para> + The following templates transform one type to another, based upon some well-defined + rule. Each template has a single member called <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of applying the transformation to the template argument + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_const">add_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_cv">add_cv</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_pointer">add_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_volatile">add_volatile</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.decay">decay</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.floating_point_promotion">floating_point_promotion</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.integral_promotion">integral_promotion</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.make_signed">make_signed</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.make_unsigned">make_unsigned</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.promote">promote</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_all_extents">remove_all_extents</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_const">remove_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_cv">remove_cv</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_reference">remove_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_volatile">remove_volatile</link><phrase role="special">;</phrase> +</programlisting> + <anchor id="boost_typetraits.category.transform.broken_compiler_workarounds_"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">Broken + Compiler Workarounds:</link> + </bridgehead> + <para> + For all of these templates support for partial specialization of class templates + is required to correctly implement the transformation. On the other hand, + practice shows that many of the templates from this category are very useful, + and often essential for implementing some generic libraries. Lack of these + templates is often one of the major limiting factors in porting those libraries + to compilers that do not yet support this language feature. As some of these + compilers are going to be around for a while, and at least one of them is + very wide-spread, it was decided that the library should provide workarounds + where possible. + </para> + <para> + The basic idea behind the workaround is to manually define full specializations + of all type transformation templates for all fundamental types, and all their + 1st and 2nd rank cv-[un]qualified derivative pointer types, and to provide + a user-level macro that will define all the explicit specializations needed + for any user-defined type T. + </para> + <para> + The first part guarantees the successful compilation of something like this: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="special">...</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +</programlisting> + <para> + and the second part provides the library's users with a mechanism to make + the above code work not only for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> or other built-in type, + but for their own types as well: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">myspace</phrase><phrase role="special">{</phrase> + <phrase role="keyword">struct</phrase> <phrase role="identifier">MyClass</phrase> <phrase role="special">{};</phrase> +<phrase role="special">}</phrase> +<phrase role="comment">// declare this at global scope: +</phrase><phrase role="identifier">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase><phrase role="special">(</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">)</phrase> +<phrase role="comment">// transformations on myspace::MyClass now work: +</phrase><phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="comment">// etc. +</phrase></programlisting> + <para> + Note that the macro BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION evaluates + to nothing on those compilers that <emphasis role="bold">do</emphasis> support + partial specialization. + </para> + </section> + <section id="boost_typetraits.category.alignment"> + <title><link linkend="boost_typetraits.category.alignment"> Synthesizing Types + with Specific Alignments</link></title> + <para> + Some low level memory management routines need to synthesize a POD type with + specific alignment properties. The template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.type_with_alignment">type_with_alignment</link></computeroutput> + finds the smallest type with a specified alignment, while template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.aligned_storage">aligned_storage</link></computeroutput> + creates a type with a specific size and alignment. + </para> + <para> + <emphasis role="bold">Synopsis</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.type_with_alignment">type_with_alignment</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.aligned_storage">aligned_storage</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.function"> + <title><link linkend="boost_typetraits.category.function"> Decomposing Function + Types</link></title> + <para> + The class template <link linkend="boost_typetraits.reference.function_traits">function_traits</link> + extracts information from function types (see also <link linkend="boost_typetraits.reference.is_function">is_function</link>). + This traits class allows you to tell how many arguments a function takes, + what those argument types are, and what the return type is. + </para> + <para> + <emphasis role="bold">Synopsis</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.function_traits">function_traits</link><phrase role="special">;</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.user_defined"> + <title><link linkend="boost_typetraits.user_defined"> User Defined Specializations</link></title> + <para> + Occationally the end user may need to provide their own specialization for + one of the type traits - typically where intrinsic compiler support is required + to implement a specific trait fully. These specializations should derive from + boost::<link linkend="boost_typetraits.reference.integral_constant">true_type</link> + or boost::<link linkend="boost_typetraits.reference.integral_constant">false_type</link> + as appropriate: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pod</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> +<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_class</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> +<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_union</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> + +<phrase role="keyword">struct</phrase> <phrase role="identifier">my_pod</phrase><phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">my_union</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">char</phrase> <phrase role="identifier">c</phrase><phrase role="special">;</phrase> + <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> + +<phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special"><</phrase><phrase role="identifier">my_pod</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_union">is_union</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_class">is_class</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.intrinsics"> + <title><link linkend="boost_typetraits.intrinsics"> Support for Compiler Intrinsics</link></title> + <para> + There are some traits that can not be implemented within the current C++ language: + to make these traits "just work" with user defined types, some kind + of additional help from the compiler is required. Currently (April 2008) Visual + C++ 8 and 9, GNU GCC 4.3 and MWCW 9 provide the necessary intrinsics, and other + compilers will no doubt follow in due course. + </para> + <para> + The Following traits classes always need compiler support to do the right thing + for all types (but all have safe fallback positions if this support is unavailable): + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_union">is_union</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_pod">is_pod</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_assign">has_nothrow_assign</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_virtual_destructor">has_virtual_destructor</link> + </listitem> + </itemizedlist> + <para> + The following traits classes can't be portably implemented in the C++ language, + although in practice, the implementations do in fact do the right thing on + all the compilers we know about: + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_empty">is_empty</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link> + </listitem> + </itemizedlist> + <para> + The following traits classes are dependent on one or more of the above: + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_class">is_class</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_stateless">is_stateless</link> + </listitem> + </itemizedlist> + <para> + The hooks for compiler-intrinsic support are defined in <ulink url="../../../../boost/type_traits/intrinsics.hpp">boost/type_traits/intrinsics.hpp</ulink>, + adding support for new compilers is simply a matter of defining one of more + of the following macros: + </para> + <table frame="all"> <title>Macros for Compiler Intrinsics</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + BOOST_IS_UNION(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a union type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + BOOST_IS_POD(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a POD type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_EMPTY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is an empty struct or union + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if the default constructor for T is trivial (i.e. + has no effect) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_COPY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial copy constructor (and can + therefore be replaced by a call to memcpy) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_ASSIGN(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial assignment operator (and can + therefore be replaced by a call to memcpy) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_DESTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial destructor (i.e. ~T() has + no effect) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_CONSTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="identifier">x</phrase><phrase role="special">;</phrase></computeroutput> + can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_COPY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase><phrase role="special">(</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase></computeroutput> can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_ASSIGN(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="identifier">t</phrase><phrase role="special">,</phrase> + <phrase role="identifier">u</phrase><phrase role="special">;</phrase> + <phrase role="identifier">t</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">u</phrase></computeroutput> can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_VIRTUAL_DESTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true T has a virtual destructor + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_ABSTRACT(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is an abstract type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_BASE_OF(T,U) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a base class of U + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_CLASS(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a class type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_CONVERTIBLE(T,U) + </para> + </entry><entry> + <para> + Should evaluate to true if T is convertible to U + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_ENUM(T) + </para> + </entry><entry> + <para> + Should evaluate to true is T is an enum + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_POLYMORPHIC(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a polymorphic type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_ALIGNMENT_OF(T) + </para> + </entry><entry> + <para> + Should evaluate to the alignment requirements of type T. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.mpl"> + <title><link linkend="boost_typetraits.mpl"> MPL Interoperability</link></title> + <para> + All the value based traits in this library conform to MPL's requirements for + an <ulink url="../../../../libs/mpl/doc/refmanual/integral-constant.html">Integral + Constant type</ulink>: that includes a number of rather intrusive workarounds + for broken compilers. + </para> + <para> + Purely as an implementation detail, this means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/bool.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">true_</phrase></computeroutput></ulink>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">false_type</link></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/bool.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">false_</phrase></computeroutput></ulink>, + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> + <phrase role="identifier">v</phrase><phrase role="special">></phrase></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/integral-c.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">integral_c</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">v</phrase><phrase role="special">></phrase></computeroutput></ulink> + (provided <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>) + </para> + </section> + <section id="boost_typetraits.examples"> + <title><link linkend="boost_typetraits.examples"> Examples</link></title> + <section id="boost_typetraits.examples.copy"> + <title><link linkend="boost_typetraits.examples.copy"> An Optimized Version + of std::copy</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">copy</phrase></computeroutput> + that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput> + to determine whether to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> + to optimise the copy operation (see <ulink url="../../examples/copy_example.cpp">copy_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// opt::copy +</phrase><phrase role="comment">// same semantics as std::copy +</phrase><phrase role="comment">// calls memcpy where appropriate. +</phrase><phrase role="comment">// +</phrase> +<phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase><phrase role="special">></phrase> +<phrase role="identifier">I2</phrase> <phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="identifier">b</phrase><phrase role="special">>&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="special">*</phrase><phrase role="identifier">out</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">out</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">out</phrase><phrase role="special">;</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">memcpy</phrase><phrase role="special">(</phrase><phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="special">(</phrase><phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">)*</phrase><phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">));</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">out</phrase><phrase role="special">+(</phrase><phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">copy</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">out</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// We can copy with memcpy if T has a trivial assignment operator, +</phrase> <phrase role="comment">// and if the iterator arguments are actually pointers (this last +</phrase> <phrase role="comment">// requirement we detect with overload resolution): +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I1</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special"><</phrase><phrase role="identifier">value_type</phrase><phrase role="special">>());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.fill"> + <title><link linkend="boost_typetraits.examples.fill"> An Optimised Version + of std::fill</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">fill</phrase></computeroutput> + that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput> + to determine whether to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memset</phrase></computeroutput> + to optimise the fill operation (see <ulink url="../../examples/fill_example.cpp">fill_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// fill +</phrase><phrase role="comment">// same as std::fill, but uses memset where appropriate +</phrase><phrase role="comment">// +</phrase><phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="identifier">b</phrase><phrase role="special">>&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="special">*</phrase><phrase role="identifier">first</phrase> <phrase role="special">=</phrase> <phrase role="identifier">val</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">memset</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">I</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">fill</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// We can do an optimised fill if T has a trivial assignment +</phrase> <phrase role="comment">// operator and if it's size is one: +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> + <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> <phrase role="special">&&</phrase> <phrase role="special">(</phrase><phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">)></phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">;</phrase> + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.destruct"> + <title><link linkend="boost_typetraits.examples.destruct"> An Example that + Omits Destructor Calls For Types with Trivial Destructors</link></title> + <para> + Demonstrates a simple algorithm that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">__has_trivial_destruct</phrase></computeroutput> + to determine whether to destructors need to be called (see <ulink url="../../examples/trivial_destructor_example.cpp">trivial_destructor_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// algorithm destroy_array: +</phrase><phrase role="comment">// The reverse of std::unitialized_copy, takes a block of +</phrase><phrase role="comment">// initialized memory and calls destructors on all objects therein. +</phrase><phrase role="comment">// +</phrase> +<phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="identifier">first</phrase><phrase role="special">->~</phrase><phrase role="identifier">T</phrase><phrase role="special">();</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> <phrase role="comment">// namespace detail +</phrase> +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">p1</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">p2</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">p1</phrase><phrase role="special">,</phrase> <phrase role="identifier">p2</phrase><phrase role="special">,</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.iter"> + <title><link linkend="boost_typetraits.examples.iter"> An improved Version + of std::iter_swap</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iter_swap</phrase></computeroutput> + that use type traits to determine whether an it's arguments are proxying + iterators or not, if they're not then it just does a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">swap</phrase></computeroutput> + of it's dereferenced arguments (the same as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iter_swap</phrase></computeroutput> + does), however if they are proxying iterators then takes special care over + the swap to ensure that the algorithm works correctly for both proxying iterators, + and even iterators of different types (see <ulink url="../../examples/iter_swap_example.cpp">iter_swap_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// iter_swap: +</phrase><phrase role="comment">// tests whether iterator is a proxying iterator or not, and +</phrase><phrase role="comment">// uses optimal form accordingly: +</phrase><phrase role="comment">// +</phrase><phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">></phrase> +<phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">v_t</phrase><phrase role="special">;</phrase> + <phrase role="identifier">v_t</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">one</phrase><phrase role="special">;</phrase> + <phrase role="special">*</phrase><phrase role="identifier">one</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">two</phrase><phrase role="special">;</phrase> + <phrase role="special">*</phrase><phrase role="identifier">two</phrase> <phrase role="special">=</phrase> <phrase role="identifier">v</phrase><phrase role="special">;</phrase> +<phrase role="special">}</phrase> +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">></phrase> +<phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">using</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">swap</phrase><phrase role="special">;</phrase> + <phrase role="identifier">swap</phrase><phrase role="special">(*</phrase><phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase><phrase role="identifier">two</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">iter_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">two</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// See is both arguments are non-proxying iterators, +</phrase> <phrase role="comment">// and if both iterator the same type: +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I1</phrase><phrase role="special">>::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">r1_t</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I2</phrase><phrase role="special">>::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">r2_t</phrase><phrase role="special">;</phrase> + + <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> + <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special"><</phrase><phrase role="identifier">r1_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special"><</phrase><phrase role="identifier">r2_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_same">is_same</link><phrase role="special"><</phrase><phrase role="identifier">r1_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">r2_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">></phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">;</phrase> + + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.to_double"> + <title><link linkend="boost_typetraits.examples.to_double"> Convert Numeric + Types and Enums to double</link></title> + <para> + Demonstrates a conversion of <ulink url="../../../../libs/numeric/conversion/doc/html/boost_numericconversion/definitions.html#boost_numericconversion.definitions.numeric_types">Numeric + Types</ulink> and enum types to double: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">double</phrase> <phrase role="identifier">to_double</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">promoted</phrase><phrase role="special">;</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric</phrase><phrase role="special">::</phrase><phrase role="identifier">converter</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase><phrase role="identifier">promoted</phrase><phrase role="special">>::</phrase><phrase role="identifier">convert</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.reference"> + <title><link linkend="boost_typetraits.reference"> Alphabetical Reference</link></title> + <section id="boost_typetraits.reference.add_const"> + <title><link linkend="boost_typetraits.reference.add_const"> add_const</link></title> + <indexterm type="class_name"> + <primary>one</primary> + <secondary>two</secondary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">const</phrase></computeroutput> for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_cv"> + <title><link linkend="boost_typetraits.reference.add_cv"> add_cv</link></title> + <indexterm type="class_name"> + <primary>one</primary> + <secondary>two</secondary> + <tertiary>three</tertiary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_cv</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_cv</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_pointer"> + <title><link linkend="boost_typetraits.reference.add_pointer"> add_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_pointer</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">*</phrase></computeroutput>. + </para> + <para> + The rationale for this template is that it produces the same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">TYPEOF</phrase><phrase role="special">(&</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase></computeroutput>, where + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t</phrase></computeroutput> is an object of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.1. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">**</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">**</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_reference"> + <title><link linkend="boost_typetraits.reference.add_reference"> add_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_reference</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is not a reference type then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase><phrase role="special">&</phrase></computeroutput>, otherwise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_volatile"> + <title><link linkend="boost_typetraits.reference.add_volatile"> add_volatile</link></title> + <indexterm type="class_name"> + <primary>one</primary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.aligned_storage"> + <title><link linkend="boost_typetraits.reference.aligned_storage"> aligned_storage</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">aligned_storage</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> a built-in or POD type with size + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Size</phrase></computeroutput> and an alignment that + is a multiple of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Align</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">aligned_storage</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.alignment_of"> + <title><link linkend="boost_typetraits.reference.alignment_of"> alignment_of</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">alignment_of</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template alignment<emphasis role="underline">of inherits from `</emphasis>_integral_constant<std::size_t, + ALIGNOF(T)><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">,</phrase> <phrase role="identifier">where</phrase> + </computeroutput>ALIGNOF(T)` is the alignment of type T. + </para> + <para> + <emphasis>Note: strictly speaking you should only rely on the value of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> being + a multiple of the true alignment of T, although in practice it does compute + the correct value in all the cases we know about.</emphasis> + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">alignment_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase><phrase role="special">)></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + with value <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.decay"> + <title><link linkend="boost_typetraits.reference.decay"> decay</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">decay</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> Let <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> + be the result of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>, then if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> + is an array type, the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">>*</phrase></computeroutput>, + otherwise if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> is a function + type then the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase><phrase role="special">*</phrase></computeroutput>, otherwise the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">decay</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">(&)[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">(&)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.extent"> + <title><link linkend="boost_typetraits.reference.extent"> extent</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">extent</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template extent inherits + from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)></phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)</phrase></computeroutput> is the number of elements in the N'th array + dimention of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not an array type, + or if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">N</phrase> <phrase role="special">></phrase> + <link linkend="boost_typetraits.reference.rank">rank</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>, or if the N'th array bound is incomplete, + then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)</phrase></computeroutput> is zero. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">extent</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">],</phrase> + <phrase role="number">1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>4</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">],</phrase> <phrase role="number">1</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>2</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.floating_point_promotion"> + <title><link linkend="boost_typetraits.reference.floating_point_promotion"> + floating_point_promotion</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">floating_point_promotion</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If floating point promotion can be + applied to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + then applies floating point promotion to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">floating_point_promotion</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">float</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.function_traits"> + <title><link linkend="boost_typetraits.reference.function_traits"> function_traits</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">F</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">function_traits</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">arity</phrase> <phrase role="special">=</phrase> <replaceable>see-below</replaceable><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">result_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> arg<replaceable>N</replaceable>_type<phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + The class template function_traits will only compile if: + </para> + <itemizedlist> + <listitem> + The compiler supports partial specialization of class templates. + </listitem> + <listitem> + The template argument <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput> + is a <emphasis>function type</emphasis>, note that this <emphasis><emphasis role="bold">is not</emphasis></emphasis> the same thing as a <emphasis>pointer + to a function</emphasis>. + </listitem> + </itemizedlist> + <tip> + <para> + function_traits is intended to introspect only C++ functions of the form + R (), R( A1 ), R ( A1, ... etc. ) and not function pointers or class member + functions. To convert a function pointer type to a suitable type use <link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link>. + </para> + </tip> + <table frame="all"> <title>Function Traits Members</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Member + </para> + </entry><entry> + <para> + Description + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that gives the number of arguments + accepted by the function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type returned by function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase>arg<replaceable>N</replaceable>_type</computeroutput> + </para> + </entry><entry> + <para> + The <replaceable>N</replaceable>th argument type of function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase> <phrase role="special"><=</phrase> + <phrase role="identifier">N</phrase> <phrase role="special"><=</phrase> + <phrase role="identifier">arity</phrase></computeroutput> of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 0. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 1. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 4. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">long</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arg1_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arg4_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase><phrase role="special">*</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arg5_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A compiler error: there is no <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">arg5_type</phrase></computeroutput> + since there are only four arguments. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + A compiler error: argument type is a <emphasis>function pointer</emphasis>, + and not a <emphasis>function type</emphasis>. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.has_nothrow_assign"> + <title><link linkend="boost_typetraits.reference.has_nothrow_assign"> has_nothrow_assign</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_assign</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing assignment-operator then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_assign</phrase></computeroutput> + will never report that a class or struct has a non-throwing assignment-operator; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler support to ensure that this trait "just + works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_assign</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_constructor"> + <title><link linkend="boost_typetraits.reference.has_nothrow_constructor"> + has_nothrow_constructor</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_default_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing default-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_constructor</phrase></computeroutput> + will never report that a class or struct has a non-throwing default-constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to ensure that this trait "just works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_constructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_copy"> + <title><link linkend="boost_typetraits.reference.has_nothrow_copy"> has_nothrow_copy</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_copy</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_copy_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing copy-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_copy</phrase></computeroutput> + will never report that a class or struct has a non-throwing copy-constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to ensure that this trait "just works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_copy</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_cp_cons"> + <title><link linkend="boost_typetraits.reference.has_nothrow_cp_cons"> has_nothrow_copy_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_no_throw_def_cons"> + <title><link linkend="boost_typetraits.reference.has_no_throw_def_cons"> has_nothrow_default_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_assign"> + <title><link linkend="boost_typetraits.reference.has_trivial_assign"> has_trivial_assign</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_assign</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial assignment-operator then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + If a type has a trivial assignment-operator then the operator has the same + effect as copying the bits of one object to the other: calls to the operator + can be safely replaced with a call to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_assign + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.8p11. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_assign</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_constructor"> + <title><link linkend="boost_typetraits.reference.has_trivial_constructor"> + has_trivial_constructor</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_default_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial default-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + If a type has a trivial default-constructor then the constructor have no + effect: calls to the constructor can be safely omitted. Note that using meta-programming + to omit a call to a single trivial-constructor call is of no benefit whatsoever. + However, if loops and/or exception handling code can also be omitted, then + some benefit in terms of code size and speed can be obtained. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_constructor + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.1p6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_copy"> + <title><link linkend="boost_typetraits.reference.has_trivial_copy"> has_trivial_copy</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_copy</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_copy_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial copy-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + If a type has a trivial copy-constructor then the constructor has the same + effect as copying the bits of one object to the other: calls to the constructor + can be safely replaced with a call to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_copy + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.8p6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_copy</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_cp_cons"> + <title><link linkend="boost_typetraits.reference.has_trivial_cp_cons"> has_trivial_copy_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_def_cons"> + <title><link linkend="boost_typetraits.reference.has_trivial_def_cons"> has_trivial_default_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_destructor"> + <title><link linkend="boost_typetraits.reference.has_trivial_destructor"> has_trivial_destructor</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_destructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial destructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + If a type has a trivial destructor then the destructor has no effect: calls + to the destructor can be safely omitted. Note that using meta-programming + to omit a call to a single trivial-constructor call is of no benefit whatsoever. + However, if loops and/or exception handling code can also be omitted, then + some benefit in terms of code size and speed can be obtained. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_destructor + will never report that a user-defined class or struct has a trivial destructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.4p3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_virtual_destructor"> + <title><link linkend="boost_typetraits.reference.has_virtual_destructor"> has_virtual_destructor</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_virtual_destructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a virtual destructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> This trait is provided + for completeness, since it's part of the Technical Report on C++ Library + Extensions. However, there is currently no way to portably implement this + trait. The default version provided always inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>, + and has to be explicitly specialized for types with virtual destructors unless + the compiler used has compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + that enable the trait to do the right thing: currently (May 2005) only Visual + C++ 8 and GCC-4.3 have the necessary <link linkend="boost_typetraits.intrinsics">intrinsics</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.4. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_virtual_destructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.integral_constant"> + <title><link linkend="boost_typetraits.reference.integral_constant"> integral_constant</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">val</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">integral_constant</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">></phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">val</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> + +<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="keyword">true</phrase><phrase role="special">></phrase> <phrase role="identifier">true_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="keyword">false</phrase><phrase role="special">></phrase> <phrase role="identifier">false_type</phrase><phrase role="special">;</phrase> +</programlisting> + <para> + Class template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_constant</phrase></computeroutput> + is the common base class for all the value-based type traits. The two typedef's + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">true_type</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">false_type</phrase></computeroutput> are provided for convenience: + most of the value traits are Boolean properties and so will inherit from + one of these. + </para> + </section> + <section id="boost_typetraits.reference.integral_promotion"> + <title><link linkend="boost_typetraits.reference.integral_promotion"> integral_promotion</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">integral_promotion</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If integral promotion can be applied + to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, then + applies integral promotion to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.5 except 4.5/3 + (integral bit-field). + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">integral_promotion</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">enum</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">float_round_style</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.is_abstract"> + <title><link linkend="boost_typetraits.reference.is_abstract"> is_abstract</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_abstract</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + abstract type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_abstract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> The compiler must + support DR337 (as of April 2005: GCC 3.4, VC++ 7.1 (and later), Intel C++ + 7 (and later), and Comeau 4.3.2). Otherwise behaves the same as <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link>; + this is the "safe fallback position" for which polymorphic types + are always regarded as potentially abstract. The macro BOOST_NO_IS_ABSTRACT + is used to signify that the implementation is buggy, users should check for + this in their own code if the "safe fallback" is not suitable for + their particular use-case. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">abc</phrase><phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">abc</phrase><phrase role="special">()</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_arithmetic"> + <title><link linkend="boost_typetraits.reference.is_arithmetic"> is_arithmetic</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_arithmetic</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + arithmetic type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Arithmetic types include integral and floating point types (see also <link linkend="boost_typetraits.reference.is_integral">is_integral</link> and + <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link>). + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p8. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_arithmetic</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_array"> + <title><link linkend="boost_typetraits.reference.is_array"> is_array</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_array</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + array type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.4. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_array</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can give the wrong result with function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_base_of"> + <title><link linkend="boost_typetraits.reference.is_base_of"> is_base_of</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_base_of</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If Base is base class of type + Derived or if both types are the same then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + This template will detect non-public base classes, and ambiguous base classes. + </para> + <para> + Note that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">X</phrase><phrase role="special">,</phrase><phrase role="identifier">X</phrase><phrase role="special">></phrase></computeroutput> will always inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>. + <emphasis role="bold">This is the case even if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">X</phrase></computeroutput> + is not a class type</emphasis>. This is a change in behaviour from Boost-1.33 + in order to track the Technical Report on C++ Library Extensions. + </para> + <para> + Types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput> must not be incomplete types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_base_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. There are some older compilers which + will produce compiler errors if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> + is a private base class of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput>, + or if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> is an ambiguous + base of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput>. These compilers + include Borland C++, older versions of Sun Forte C++, Digital Mars C++, and + older versions of EDG based compilers. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">{};</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase> <phrase role="special">:</phrase> + <phrase role="keyword">public</phrase> <phrase role="identifier">Base</phrase><phrase role="special">{};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Base</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>: a class is regarded as it's + own base. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_class"> + <title><link linkend="boost_typetraits.reference.is_class"> is_class</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_class</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + class type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 9.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_class</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Without (some as + yet unspecified) help from the compiler, we cannot distinguish between union + and class types, as a result this type will erroneously inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link> for + union types. See also <link linkend="boost_typetraits.reference.is_union">is_union</link>. + Currently (May 2005) only Visual C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to correctly identify union types, and therefore make is_class function correctly. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">MyClass</phrase><phrase role="special">;</phrase></computeroutput> then: + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_complex"> + <title><link linkend="boost_typetraits.reference.is_complex"> is_complex</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_complex</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is a complex number type then true (of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">complex</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">></phrase></computeroutput> + for some type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>), otherwise + false. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 26.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_complex</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.is_compound"> + <title><link linkend="boost_typetraits.reference.is_compound"> is_compound</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_compound</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + compound type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Any type that is not a fundamental type is a compound type (see also <link linkend="boost_typetraits.reference.is_fundamental">is_fundamental</link>). + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_compound</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">MyEnum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_const"> + <title><link linkend="boost_typetraits.reference.is_const"> is_const</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_const</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (top level) const-qualified + type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the const-qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the const-qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_convertible"> + <title><link linkend="boost_typetraits.reference.is_convertible"> is_convertible</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_convertible</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If an imaginary lvalue of type + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">From</phrase></computeroutput> is convertible to type + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + Type From must not be an incomplete type. + </para> + <para> + Type To must not be an incomplete, or function type. + </para> + <para> + No types are considered to be convertible to array types or abstract-class + types. + </para> + <para> + This template can not detect whether a converting-constructor is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> or not: if type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> + has a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput> converting constructor + from type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">From</phrase></computeroutput> then instantiating + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase></computeroutput> + will produce a compiler error. For this reason <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase></computeroutput> + can not be used to determine whether a type has a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> + copy-constructor or not. + </para> + <para> + This template will also produce compiler errors if the conversion is ambiguous, + for example: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">B</phrase> <phrase role="special">:</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">C</phrase> <phrase role="special">:</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">D</phrase> <phrase role="special">:</phrase> <phrase role="identifier">B</phrase><phrase role="special">,</phrase> <phrase role="identifier">C</phrase> <phrase role="special">{};</phrase> +<phrase role="comment">// This produces a compiler error, the conversion is ambiguous: +</phrase><phrase role="keyword">bool</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">y</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">D</phrase><phrase role="special">*,</phrase><phrase role="identifier">A</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase><phrase role="special">;</phrase> +</programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4 and 8.5. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> This template is + currently broken with Borland C++ Builder 5 (and earlier), for constructor-based + conversions, and for the Metrowerks 7 (and earlier) compiler in all cases. + If the compiler does not support <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_abstract">is_abstract</link></computeroutput>, + then the template parameter <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> + must not be an abstract type. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_convertible</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the conversion would require a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const_cast</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&,</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_empty"> + <title><link linkend="boost_typetraits.reference.is_empty"> is_empty</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_empty</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an empty class type then + inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10p5. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_empty</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> In order to correctly + detect empty classes this trait relies on either: + </para> + <itemizedlist> + <listitem> + the compiler implementing zero sized empty base classes, or + </listitem> + <listitem> + the compiler providing <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect empty classes. + </listitem> + </itemizedlist> + <para> + Can not be used with incomplete types. + </para> + <para> + Can not be used with union types, until is_union can be made to work. + </para> + <para> + If the compiler does not support partial-specialization of class templates, + then this template can not be used with abstract types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">empty_class</phrase> + <phrase role="special">{};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_enum"> + <title><link linkend="boost_typetraits.reference.is_enum"> is_enum</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_enum</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + enum type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_enum</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Requires a correctly + functioning <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link> + template; this means that is_enum is currently broken under Borland C++ Builder + 5, and for the Metrowerks compiler prior to version 8, other compilers should + handle this template just fine. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">enum</phrase> <phrase role="identifier">my_enum</phrase> + <phrase role="special">{</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">two</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_floating_point"> + <title><link linkend="boost_typetraits.reference.is_floating_point"> is_floating_point</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_floating_point</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + floating point type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p8. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_floating_point</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_function"> + <title><link linkend="boost_typetraits.reference.is_function"> is_function</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_function</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + function type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Note that this template does not detect <emphasis>pointers to functions</emphasis>, + or <emphasis>references to functions</emphasis>, these are detected by <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link> and <link linkend="boost_typetraits.reference.is_reference">is_reference</link> respectively: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">f1</phrase><phrase role="special">();</phrase> <phrase role="comment">// f1 is of function type. +</phrase><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">f2</phrase><phrase role="special">*)();</phrase> <phrase role="comment">// f2 is a pointer to a function. +</phrase><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">f3</phrase><phrase role="special">&)();</phrase> <phrase role="comment">// f3 is a reference to a function. +</phrase></programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2p1 and 8.3.5. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_function</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a pointer type, not a function type. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(&)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a reference to a function, not a function type. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a pointer to a member function. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + <tip> + <para> + Don't confuse function-types with pointers to functions: + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> + <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">);</phrase></computeroutput> + </para> + <para> + defines a function type, + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase> <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + declares a prototype for a function of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase></computeroutput>, + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase><phrase role="special">*</phrase> + <phrase role="identifier">pf</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase><phrase role="special">&</phrase> + <phrase role="identifier">fr</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + declares a pointer and a reference to the function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">foo</phrase></computeroutput>. + </para> + <para> + If you want to detect whether some type is a pointer-to-function then use: + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_function">is_function</link><phrase role="special"><</phrase><link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + </para> + <para> + or for pointers to member functions you can just use <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link> + directly. + </para> + </tip> + </section> + <section id="boost_typetraits.reference.is_fundamental"> + <title><link linkend="boost_typetraits.reference.is_fundamental"> is_fundamental</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_fundamental</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + fundamental type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Fundamental types include integral, floating point and void types (see also + <link linkend="boost_typetraits.reference.is_integral">is_integral</link>, + <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link> + and <link linkend="boost_typetraits.reference.is_void">is_void</link>) + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_fundamental</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_integral"> + <title><link linkend="boost_typetraits.reference.is_integral"> is_integral</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_integral</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + integral type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p7. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_integral</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_function_pointer"> + <title><link linkend="boost_typetraits.reference.is_member_function_pointer"> + is_member_function_pointer</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_function_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member function then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the argument in this case is a pointer to a data member and not a member + function, see <link linkend="boost_typetraits.reference.is_member_object_pointer">is_member_object_pointer</link> + and <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_object_pointer"> + <title><link linkend="boost_typetraits.reference.is_member_object_pointer"> + is_member_object_pointer</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_object_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member object (a data member) then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the argument in this case is a pointer to a member function and not a + member object, see <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link> + and <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_pointer"> + <title><link linkend="boost_typetraits.reference.is_member_pointer"> is_member_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member (either a function or a data member) then inherits from + <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_object"> + <title><link linkend="boost_typetraits.reference.is_object"> is_object</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_object</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + object type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + All types are object types except references, void, and function types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p9. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_object</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: reference types are not + objects + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: function types are not + objects + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + void is not an object type + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_pod"> + <title><link linkend="boost_typetraits.reference.is_pod"> is_pod</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_pod</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + POD type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + POD stands for "Plain old data". Arithmetic types, and enumeration + types, a pointers and pointer to members are all PODs. Classes and unions + can also be POD's if they have no non-static data members that are of reference + or non-POD type, no user defined constructors, no user defined assignment + operators, no private or protected non-static data members, no virtual functions + and no base classes. Finally, a cv-qualified POD is still a POD, as is an + array of PODs. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10 and 9p4 (Note + that POD's are also aggregates, see 8.5.1). + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, is<emphasis role="underline">pod + will never report that a class or struct is a POD; this is always safe, if + possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8 have + the necessary compiler-</emphasis>_intrinsics. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pod</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_pointer"> + <title><link linkend="boost_typetraits.reference.is_pointer"> is_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer type (includes function pointers, but excludes pointers to members) + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2p2 and 8.3.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + <important> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase></computeroutput> detects "real" + pointer types only, and <emphasis>not</emphasis> smart pointers. Users + should not specialise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase></computeroutput> + for smart pointer types, as doing so may cause Boost (and other third party) + code to fail to function correctly. Users wanting a trait to detect smart + pointers should create their own. However, note that there is no way in + general to auto-magically detect smart pointer types, so such a trait would + have to be partially specialised for each supported smart pointer type. + </para> + </important> + </section> + <section id="boost_typetraits.reference.is_polymorphic"> + <title><link linkend="boost_typetraits.reference.is_polymorphic"> is_polymorphic</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_polymorphic</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + polymorphic type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> The implementation + requires some knowledge of the compilers ABI, it does actually seem to work + with the majority of compilers though. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_polymorphic</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">poly</phrase><phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">poly</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_same"> + <title><link linkend="boost_typetraits.reference.is_same"> is_same</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">U</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_same</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T and U are the same types + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_same</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with abstract, incomplete or function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_scalar"> + <title><link linkend="boost_typetraits.reference.is_scalar"> is_scalar</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_scalar</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + scalar type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Scalar types include integral, floating point, enumeration, pointer, and + pointer-to-member types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_scalar</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_signed"> + <title><link linkend="boost_typetraits.reference.is_signed"> is_signed</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_signed</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an signed integer type + or an enumerated type with an underlying signed integer type, then inherits + from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1, 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_signed</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">myclass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + whose value depends upon the signedness of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_stateless"> + <title><link linkend="boost_typetraits.reference.is_stateless"> is_stateless</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_stateless</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Ff T is a stateless type then + inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + Type T must be a complete type. + </para> + <para> + A stateless type is a type that has no storage and whose constructors and + destructors are trivial. That means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_stateless</phrase></computeroutput> + only inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the following expression is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput>: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +</programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_stateless</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, is_stateless will + never report that a class or struct is stateless; this is always safe, if + possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8 have + the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to make this template work automatically. + </para> + </section> + <section id="boost_typetraits.reference.is_reference"> + <title><link linkend="boost_typetraits.reference.is_reference"> is_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_reference</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a reference pointer type + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + may report the wrong result for function types, and for types that are both + const and volatile qualified. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(&)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis> (the argument in this case + is a reference to a function). + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_union"> + <title><link linkend="boost_typetraits.reference.is_union"> is_union</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_union</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + union type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Currently requires some kind of compiler support, otherwise unions are identified + as classes. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 9.5. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Without (some as + yet unspecified) help from the compiler, we cannot distinguish between union + and class types using only standard C++, as a result this type will never + inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + unless the user explicitly specializes the template for their user-defined + union types, or unless the compiler supplies some unspecified intrinsic that + implements this functionality. Currently (May 2005) only Visual C++ 8 has + the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to make this trait "just work" without user intervention. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_union</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_unsigned"> + <title><link linkend="boost_typetraits.reference.is_unsigned"> is_unsigned</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_unsigned</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an unsigned integer type + or an enumerated type with an underlying unsigned integer type, then inherits + from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1, 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_unsigned</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="identifier">myclass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + whose value depends upon the signedness of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">long</phrase> + <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_void"> + <title><link linkend="boost_typetraits.reference.is_void"> is_void</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_void</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + void type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p9. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_void</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_volatile"> + <title><link linkend="boost_typetraits.reference.is_volatile"> is_volatile</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_volatile</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (top level) volatile-qualified + type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">volatile</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase> + <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the volatile qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.make_signed"> + <title><link linkend="boost_typetraits.reference.make_signed"> make_signed</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">make_signed</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If T is a signed integer type then + the same type as T, if T is an unsigned integer type then the corresponding + signed type. Otherwise if T is an enumerated or character type (char or wchar_t) + then a signed integer type with the same width as T. + </para> + <para> + If T has any cv-qualifiers then these are also present on the result type. + </para> + <para> + <emphasis role="bold">Requires:</emphasis> T must be an integer or enumerated + type, and must not be the type bool. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">make_signed</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">long</phrase> + <phrase role="keyword">long</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A signed integer type with the same width as the enum. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">wchar_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A signed integer type with the same width as wchar_t. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.make_unsigned"> + <title><link linkend="boost_typetraits.reference.make_unsigned"> make_unsigned</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">make_unsigned</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If T is a unsigned integer type then + the same type as T, if T is an signed integer type then the corresponding + unsigned type. Otherwise if T is an enumerated or character type (char or + wchar_t) then an unsigned integer type with the same width as T. + </para> + <para> + If T has any cv-qualifiers then these are also present on the result type. + </para> + <para> + <emphasis role="bold">Requires:</emphasis> T must be an integer or enumerated + type, and must not be the type bool. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">make_unsigned</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + An unsigned integer type with the same width as the enum. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">wchar_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + An unsigned integer type with the same width as wchar_t. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.promote"> + <title><link linkend="boost_typetraits.reference.promote"> promote</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">promote</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If integral or floating point promotion + can be applied to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + then applies integral and floating point promotions to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + See also <link linkend="boost_typetraits.reference.integral_promotion">integral_promotion</link> + and <link linkend="boost_typetraits.reference.floating_point_promotion">floating_point_promotion</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.5 except 4.5/3 + (integral bit-field) and 4.6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">promote</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.rank"> + <title><link linkend="boost_typetraits.reference.rank"> rank</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">rank</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template rank inherits from + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> is the + number of array dimensions in type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not an array type, + then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> is zero. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">rank</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[]></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>1</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>2</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.remove_all_extents"> + <title><link linkend="boost_typetraits.reference.remove_all_extents"> remove_all_extents</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_all_extents</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is an array type, then removes all of the array bounds on <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.4. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_all_extents</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_const"> + <title><link linkend="boost_typetraits.reference.remove_const"> remove_const</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> const-qualifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_cv"> + <title><link linkend="boost_typetraits.reference.remove_cv"> remove_cv</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_cv</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> cv-qualifiers removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_cv</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_extent"> + <title><link linkend="boost_typetraits.reference.remove_extent"> remove_extent</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_extent</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is an array type, then removes the topmost array bound, otherwise leaves + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.4. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_extent</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_pointer"> + <title><link linkend="boost_typetraits.reference.remove_pointer"> remove_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_pointer</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any pointer modifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.1. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">**>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_reference"> + <title><link linkend="boost_typetraits.reference.remove_reference"> remove_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_reference</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any reference modifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_volatile"> + <title><link linkend="boost_typetraits.reference.remove_volatile"> remove_volatile</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> volatile-qualifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.type_with_alignment"> + <title><link linkend="boost_typetraits.reference.type_with_alignment"> type_with_alignment</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">type_with_alignment</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> a built-in or POD type with an alignment + that is a multiple of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Align</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">type_with_alignment</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + </section> + <section id="boost_typetraits.credits"> + <title><link linkend="boost_typetraits.credits"> Credits</link></title> + <para> + This documentation was pulled together by John Maddock, using <ulink url="../../../../doc/html/quickbook.html">Boost.Quickbook</ulink> + and <ulink url="../../../../doc/html/boostbook.html">Boost.DocBook</ulink>. + </para> + <para> + The original version of this library was created by Steve Cleary, Beman Dawes, + Howard Hinnant, and John Maddock. John Maddock is the current maintainer of + the library. + </para> + <para> + This version of type traits library is based on contributions by Adobe Systems + Inc, David Abrahams, Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, + Jesse Jones, Mat Marcus, Itay Maman, John Maddock, Thorsten Ottosen, Robert + Ramey and Jeremy Siek. + </para> + <para> + Mat Marcus and Jesse Jones invented, and <ulink url="http://opensource.adobe.com/project4/project.shtml">published + a paper describing</ulink>, the partial specialization workarounds used in + this library. + </para> + <para> + Aleksey Gurtovoy added MPL integration to the library. + </para> + <para> + The <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link> + template is based on code originally devised by Andrei Alexandrescu, see "<ulink url="http://www.cuj.com/experts/1810/alexandr.htm?topic=experts">Generic<Programming>: + Mappings between Types and Values</ulink>". + </para> + <para> + The latest version of this library and documentation can be found at <ulink url="http://www.boost.org">www.boost.org</ulink>. Bugs, suggestions and discussion + should be directed to boost@lists.boost.org (see <ulink url="http://www.boost.org/more/mailing_lists.htm#main">www.boost.org/more/mailing_lists.htm#main</ulink> + for subscription details). + </para> + </section> + + <section id="boost_typetraits.ignored_section"> + <title>This section must not be indexed.</title> + <?BoostAutoIndex IgnoreSection?> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + </section> + + <section id="boost_typetraits.ignored_block"> + <title>This section contains one block that must not be indexed and one that should be.</title> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword"> + <?BoostAutoIndex IgnoreBlock?> + template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword"> + template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + </section> + + + <section> + <title>Class Index</title> + <para><link linkend="idx_id_0">A</link> <link linkend="idx_id_2">C</link> <link linkend="idx_id_3">D</link> <link linkend="idx_id_4">E</link> <link linkend="idx_id_5">F</link> <link linkend="idx_id_6">H</link> <link linkend="idx_id_7">I</link> <link linkend="idx_id_8">M</link> <link linkend="idx_id_9">O</link> <link linkend="idx_id_10">P</link> <link linkend="idx_id_11">R</link> <link linkend="idx_id_13">T</link></para><variablelist><varlistentry id="idx_id_0"><term>A</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-0">add_const</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_cv"><phrase role="index-entry-level-0">add_cv</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_pointer"><phrase role="index-entry-level-0">add_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_reference"><phrase role="index-entry-level-0">add_reference</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">add_volatile</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.add_volatile"><phrase role="index-entry-level-1">add_volatile</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.ignored_block"><phrase role="index-entry-level-1">This section contains one block that must not be indexed and one that should be.</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.aligned_storage"><phrase role="index-entry-level-0">aligned_storage</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.alignment_of"><phrase role="index-entry-level-0">alignment_of</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_2"><term>C</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">Constrained Index Term</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-1">add_const</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_3"><term>D</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.decay"><phrase role="index-entry-level-0">decay</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_4"><term>E</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.extent"><phrase role="index-entry-level-0">extent</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_5"><term>F</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.floating_point_promotion"><phrase role="index-entry-level-0">floating_point_promotion</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.function_traits"><phrase role="index-entry-level-0">function_traits</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_6"><term>H</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_assign"><phrase role="index-entry-level-0">has_nothrow_assign</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_constructor"><phrase role="index-entry-level-0">has_nothrow_constructor</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_copy"><phrase role="index-entry-level-0">has_nothrow_copy</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_copy_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_copy"><phrase role="index-entry-level-1">has_nothrow_copy</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_default_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_constructor"><phrase role="index-entry-level-1">has_nothrow_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_assign"><phrase role="index-entry-level-0">has_trivial_assign</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_copy"><phrase role="index-entry-level-0">has_trivial_copy</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_copy_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_trivial_copy"><phrase role="index-entry-level-1">has_trivial_copy</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_default_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_trivial_constructor"><phrase role="index-entry-level-1">has_trivial_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_destructor"><phrase role="index-entry-level-0">has_trivial_destructor</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_virtual_destructor"><phrase role="index-entry-level-0">has_virtual_destructor</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_7"><term>I</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">integral_constant</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.alignment_of"><phrase role="index-entry-level-1">alignment_of</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.extent"><phrase role="index-entry-level-1">extent</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.rank"><phrase role="index-entry-level-1">rank</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_promotion"><phrase role="index-entry-level-0">integral_promotion</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_abstract"><phrase role="index-entry-level-0">is_abstract</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_arithmetic"><phrase role="index-entry-level-0">is_arithmetic</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_array"><phrase role="index-entry-level-0">is_array</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_base_of"><phrase role="index-entry-level-0">is_base_of</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_class</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_class"><phrase role="index-entry-level-1">is_class</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">User Defined Specializations</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_complex"><phrase role="index-entry-level-0">is_complex</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_compound"><phrase role="index-entry-level-0">is_compound</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_const"><phrase role="index-entry-level-0">is_const</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_convertible"><phrase role="index-entry-level-0">is_convertible</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_empty"><phrase role="index-entry-level-0">is_empty</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_enum"><phrase role="index-entry-level-0">is_enum</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_floating_point"><phrase role="index-entry-level-0">is_floating_point</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_function"><phrase role="index-entry-level-0">is_function</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_fundamental"><phrase role="index-entry-level-0">is_fundamental</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_integral"><phrase role="index-entry-level-0">is_integral</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_function_pointer"><phrase role="index-entry-level-0">is_member_function_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_object_pointer"><phrase role="index-entry-level-0">is_member_object_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_pointer"><phrase role="index-entry-level-0">is_member_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_object"><phrase role="index-entry-level-0">is_object</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_pointer</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_pointer"><phrase role="index-entry-level-1">is_pointer</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_polymorphic"><phrase role="index-entry-level-0">is_polymorphic</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_reference"><phrase role="index-entry-level-0">is_reference</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_same"><phrase role="index-entry-level-0">is_same</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_scalar"><phrase role="index-entry-level-0">is_scalar</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_signed"><phrase role="index-entry-level-0">is_signed</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_union</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_union"><phrase role="index-entry-level-1">is_union</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">User Defined Specializations</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_unsigned"><phrase role="index-entry-level-0">is_unsigned</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_void</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_void"><phrase role="index-entry-level-1">is_void</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_volatile"><phrase role="index-entry-level-0">is_volatile</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_8"><term>M</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.make_signed"><phrase role="index-entry-level-0">make_signed</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.make_unsigned"><phrase role="index-entry-level-0">make_unsigned</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_9"><term>O</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">one</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_volatile"><phrase role="index-entry-level-1">add_volatile</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-1">two</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-2">add_const</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-2">three</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_cv"><phrase role="index-entry-level-3">add_cv</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_10"><term>P</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.promote"><phrase role="index-entry-level-0">promote</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_11"><term>R</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.remove_all_extents"><phrase role="index-entry-level-0">remove_all_extents</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_const"><phrase role="index-entry-level-0">remove_const</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_cv"><phrase role="index-entry-level-0">remove_cv</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">remove_extent</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.remove_extent"><phrase role="index-entry-level-1">remove_extent</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_pointer"><phrase role="index-entry-level-0">remove_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_reference"><phrase role="index-entry-level-0">remove_reference</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_volatile"><phrase role="index-entry-level-0">remove_volatile</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_13"><term>T</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.type_with_alignment"><phrase role="index-entry-level-0">type_with_alignment</phrase></link></para></listitem></itemizedlist></listitem></varlistentry></variablelist></section> + <section> + <title>Typedef Index</title> + <para><link linkend="idx_id_21">F</link> <link linkend="idx_id_27">R</link> <link linkend="idx_id_29">T</link> <link linkend="idx_id_31">V</link></para><variablelist><varlistentry id="idx_id_21"><term>F</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">false_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_27"><term>R</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">result_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.function_traits"><phrase role="index-entry-level-1">function_traits</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_29"><term>T</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">true_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_31"><term>V</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">value_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.examples.copy"><phrase role="index-entry-level-1">An Optimized Version of std::copy</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry></variablelist></section> + <section> + <title>Macro Index</title> + <para><link linkend="idx_id_33">B</link></para><variablelist><varlistentry id="idx_id_33"><term>B</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">BOOST_ALIGNMENT_OF</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.category.transform"><phrase role="index-entry-level-1">Type Traits that Transform One Type to Another</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_ASSIGN</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_CONSTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_COPY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_ASSIGN</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_CONSTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_COPY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_DESTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_VIRTUAL_DESTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_ABSTRACT</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_BASE_OF</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_CLASS</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_CONVERTIBLE</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_EMPTY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_ENUM</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_POD</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_POLYMORPHIC</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_UNION</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry></variablelist></section> + <section> + <title>Index Test 1</title> + <para><link linkend="idx_id_61">T</link></para><variablelist><varlistentry id="idx_id_61"><term>T</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">type-traits</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intro"><phrase role="index-entry-level-1">Introduction</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry></variablelist></section> + <section> + <title>Index Test 2</title> + <para><link linkend="idx_id_77">T</link></para><variablelist><varlistentry id="idx_id_77"><term>T</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">type-traits</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry></variablelist></section> + <section><title>Index</title><para><link linkend="idx_id_80">A</link> <link linkend="idx_id_81">B</link> <link linkend="idx_id_82">C</link> <link linkend="idx_id_83">D</link> <link linkend="idx_id_84">E</link> <link linkend="idx_id_85">F</link> <link linkend="idx_id_86">H</link> <link linkend="idx_id_87">I</link> <link linkend="idx_id_88">M</link> <link linkend="idx_id_89">O</link> <link linkend="idx_id_90">P</link> <link linkend="idx_id_91">R</link> <link linkend="idx_id_92">S</link> <link linkend="idx_id_93">T</link> <link linkend="idx_id_94">U</link> <link linkend="idx_id_95">V</link></para><variablelist><varlistentry id="idx_id_80"><term>A</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">add_const</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-1">add_const</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-1">Constrained Index Term</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.add_cv"><phrase role="index-entry-level-0">add_cv</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_pointer"><phrase role="index-entry-level-0">add_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_reference"><phrase role="index-entry-level-0">add_reference</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">add_volatile</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.add_volatile"><phrase role="index-entry-level-1">add_volatile</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.ignored_block"><phrase role="index-entry-level-1">This section contains one block that must not be indexed and one that should be.</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.aligned_storage"><phrase role="index-entry-level-0">aligned_storage</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">alignment_of</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.alignment_of"><phrase role="index-entry-level-1">alignment_of</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.alignment_of"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_81"><term>B</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">Background and Tutorial</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">is_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">is_void</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">remove_extent</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">type-traits</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_ALIGNMENT_OF</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.category.transform"><phrase role="index-entry-level-1">Type Traits that Transform One Type to Another</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_ASSIGN</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_CONSTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_COPY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_ASSIGN</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_CONSTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_COPY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_DESTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_VIRTUAL_DESTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_ABSTRACT</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_BASE_OF</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_CLASS</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_CONVERTIBLE</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_EMPTY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_ENUM</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_POD</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_POLYMORPHIC</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_UNION</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_82"><term>C</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">Constrained Index Term</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-1">add_const</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_83"><term>D</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.decay"><phrase role="index-entry-level-0">decay</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_84"><term>E</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">extent</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.extent"><phrase role="index-entry-level-1">extent</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.extent"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_85"><term>F</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">false_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.floating_point_promotion"><phrase role="index-entry-level-0">floating_point_promotion</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">Foo1</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">Foo2</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-1">Bar2</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.category.value_traits"><phrase role="index-entry-level-2">Type Traits that Describe the Properties of a Type</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">function_traits</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.function_traits"><phrase role="index-entry-level-1">function_traits</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.function_traits"><phrase role="index-entry-level-1">result_type</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_86"><term>H</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_assign"><phrase role="index-entry-level-0">has_nothrow_assign</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.has_nothrow_constructor"><phrase role="index-entry-level-1">has_nothrow_constructor</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_constructor"><phrase role="index-entry-level-1">has_nothrow_default_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_copy</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.has_nothrow_copy"><phrase role="index-entry-level-1">has_nothrow_copy</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_copy"><phrase role="index-entry-level-1">has_nothrow_copy_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_copy_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_copy"><phrase role="index-entry-level-1">has_nothrow_copy</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_default_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_constructor"><phrase role="index-entry-level-1">has_nothrow_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_assign"><phrase role="index-entry-level-0">has_trivial_assign</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_trivial_constructor"><phrase role="index-entry-level-1">has_trivial_default_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_copy</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.has_trivial_copy"><phrase role="index-entry-level-1">has_trivial_copy</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_copy"><phrase role="index-entry-level-1">has_trivial_copy_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_copy_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_trivial_copy"><phrase role="index-entry-level-1">has_trivial_copy</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_default_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_trivial_constructor"><phrase role="index-entry-level-1">has_trivial_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_destructor"><phrase role="index-entry-level-0">has_trivial_destructor</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_virtual_destructor"><phrase role="index-entry-level-0">has_virtual_destructor</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_87"><term>I</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">integral_constant</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.alignment_of"><phrase role="index-entry-level-1">alignment_of</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.extent"><phrase role="index-entry-level-1">extent</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">false_type</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.rank"><phrase role="index-entry-level-1">rank</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">true_type</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">value_type</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_promotion"><phrase role="index-entry-level-0">integral_promotion</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">Introduction</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intro"><phrase role="index-entry-level-1">type-traits</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_abstract"><phrase role="index-entry-level-0">is_abstract</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_arithmetic"><phrase role="index-entry-level-0">is_arithmetic</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_array"><phrase role="index-entry-level-0">is_array</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_base_of"><phrase role="index-entry-level-0">is_base_of</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_class</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_class"><phrase role="index-entry-level-1">is_class</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">User Defined Specializations</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_complex"><phrase role="index-entry-level-0">is_complex</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_compound"><phrase role="index-entry-level-0">is_compound</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_const"><phrase role="index-entry-level-0">is_const</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_convertible"><phrase role="index-entry-level-0">is_convertible</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_empty"><phrase role="index-entry-level-0">is_empty</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_enum"><phrase role="index-entry-level-0">is_enum</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_floating_point"><phrase role="index-entry-level-0">is_floating_point</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_function"><phrase role="index-entry-level-0">is_function</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_fundamental"><phrase role="index-entry-level-0">is_fundamental</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_integral"><phrase role="index-entry-level-0">is_integral</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_function_pointer"><phrase role="index-entry-level-0">is_member_function_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_object_pointer"><phrase role="index-entry-level-0">is_member_object_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_pointer"><phrase role="index-entry-level-0">is_member_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_object"><phrase role="index-entry-level-0">is_object</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_pointer</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_pointer"><phrase role="index-entry-level-1">is_pointer</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_polymorphic"><phrase role="index-entry-level-0">is_polymorphic</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_reference"><phrase role="index-entry-level-0">is_reference</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_same"><phrase role="index-entry-level-0">is_same</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_scalar"><phrase role="index-entry-level-0">is_scalar</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_signed"><phrase role="index-entry-level-0">is_signed</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_union</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_union"><phrase role="index-entry-level-1">is_union</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">User Defined Specializations</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_unsigned"><phrase role="index-entry-level-0">is_unsigned</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_void</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_void"><phrase role="index-entry-level-1">is_void</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_volatile"><phrase role="index-entry-level-0">is_volatile</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_88"><term>M</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.make_signed"><phrase role="index-entry-level-0">make_signed</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.make_unsigned"><phrase role="index-entry-level-0">make_unsigned</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_89"><term>O</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">one</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_volatile"><phrase role="index-entry-level-1">add_volatile</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-1">two</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-2">add_const</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-2">three</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_cv"><phrase role="index-entry-level-3">add_cv</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">Optimized Version of std::copy</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.examples.copy"><phrase role="index-entry-level-1">value_type</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_90"><term>P</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.promote"><phrase role="index-entry-level-0">promote</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_91"><term>R</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">rank</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.rank"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_all_extents"><phrase role="index-entry-level-0">remove_all_extents</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_const"><phrase role="index-entry-level-0">remove_const</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_cv"><phrase role="index-entry-level-0">remove_cv</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">remove_extent</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.remove_extent"><phrase role="index-entry-level-1">remove_extent</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_pointer"><phrase role="index-entry-level-0">remove_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_reference"><phrase role="index-entry-level-0">remove_reference</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_volatile"><phrase role="index-entry-level-0">remove_volatile</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">result_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.function_traits"><phrase role="index-entry-level-1">function_traits</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_92"><term>S</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">Support for Compiler Intrinsics</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_ALIGNMENT_OF</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_NOTHROW_ASSIGN</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_NOTHROW_CONSTRUCTOR</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_NOTHROW_COPY</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_TRIVIAL_ASSIGN</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_TRIVIAL_CONSTRUCTOR</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_TRIVIAL_COPY</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_TRIVIAL_DESTRUCTOR</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_VIRTUAL_DESTRUCTOR</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_ABSTRACT</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_BASE_OF</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_CLASS</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_CONVERTIBLE</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_EMPTY</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_ENUM</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_POD</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_POLYMORPHIC</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_UNION</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_93"><term>T</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">This section contains one block that must not be indexed and one that should be.</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.ignored_block"><phrase role="index-entry-level-1">add_volatile</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">true_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">Type Traits that Transform One Type to Another</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.category.transform"><phrase role="index-entry-level-1">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">type-traits</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intro"><phrase role="index-entry-level-1">Introduction</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.type_with_alignment"><phrase role="index-entry-level-0">type_with_alignment</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_94"><term>U</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">User Defined Specializations</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">is_class</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">is_union</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_95"><term>V</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">value_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.examples.copy"><phrase role="index-entry-level-1">An Optimized Version of std::copy</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry></variablelist></section> + +</chapter>
\ No newline at end of file diff --git a/src/boost/tools/auto_index/test/test3.gold b/src/boost/tools/auto_index/test/test3.gold new file mode 100644 index 000000000..2da88c93d --- /dev/null +++ b/src/boost/tools/auto_index/test/test3.gold @@ -0,0 +1,6671 @@ +<?xml version="1.0"?> +<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> +<!-- + +This file is based upon the type traits docs, but has had additional XML elements added to it +to ensure complete testing. + +--> + +<chapter xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" id="boost_typetraits" rev:last-revision="$Date: 2008-11-28 12:41:45 +0000 (Fri, 28 Nov 2008) $"> + <chapterinfo><author> + <firstname>various</firstname> <surname>authors</surname> + </author><copyright> + <year>2000</year> <year>2006</year> <holder>Adobe Systems Inc, David Abrahams, + Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat + Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert + Ramey and Jeremy Siek</holder> + </copyright><legalnotice> + <para> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>) + </para> + </legalnotice></chapterinfo> + <title>Boost.TypeTraits</title> + <para> + A printer-friendly <ulink url="http://svn.boost.org/svn/boost/sandbox/pdf/type_traits/release/type_traits.pdf">PDF + version of this manual is also available</ulink>. + </para> + <section id="boost_typetraits.intro"> + <title><link linkend="boost_typetraits.intro"> Introduction</link></title> + <para> + The Boost type-traits library contains a set of very specific traits classes, + each of which encapsulate a single trait from the C++ type system; for example, + is a type a pointer or a reference type? Or does a type have a trivial constructor, + or a const-qualifier? + </para> + <para> + The type-traits classes share a unified design: each class inherits from a + the type <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the type has the specified property and inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link> + otherwise. + </para> + <para> + The type-traits library also contains a set of classes that perform a specific + transformation on a type; for example, they can remove a top-level const or + volatile qualifier from a type. Each class that performs a transformation defines + a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of the transformation. + </para> + </section> + <section id="boost_typetraits.background"> + <title><link linkend="boost_typetraits.background"> Background and Tutorial</link></title> + <para> + The following is an updated version of the article "C++ Type traits" + by John Maddock and Steve Cleary that appeared in the October 2000 issue of + <ulink url="http://www.ddj.com">Dr Dobb's Journal</ulink>. + </para> + <para> + Generic programming (writing code which works with any data type meeting a + set of requirements) has become the method of choice for providing reusable + code. However, there are times in generic programming when "generic" + just isn't good enough - sometimes the differences between types are too large + for an efficient generic implementation. This is when the traits technique + becomes important - by encapsulating those properties that need to be considered + on a type by type basis inside a traits class, we can minimize the amount of + code that has to differ from one type to another, and maximize the amount of + generic code. + </para> + <?dbfo keep-together="auto" ?> + <para> + <indexterm> + <primary>Foo1</primary> + </indexterm> + Consider an example: when working with character strings, one common operation + is to determine the length of a null terminated string. Clearly it's possible + to write generic code that can do this, but it turns out that there are much + more efficient methods available: for example, the C library functions <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">strlen</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">wcslen</phrase></computeroutput> + are usually written in assembler, and with suitable hardware support can be + considerably faster than a generic version written in C++. The authors of the + C++ standard library realized this, and abstracted the properties of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">wchar_t</phrase></computeroutput> + into the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput>. + Generic code that works with character strings can simply use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase><phrase role="special"><>::</phrase><phrase role="identifier">length</phrase></computeroutput> to determine the length of a null + terminated string, safe in the knowledge that specializations of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput> will use the most appropriate + method available to them. + </para> + <anchor id="boost_typetraits.background.type_traits"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.type_traits">Type Traits</link> + </bridgehead> + <para> + Class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput> is a classic + example of a collection of type specific properties wrapped up in a single + class - what Nathan Myers termed a <emphasis>baggage class</emphasis><link linkend="background.references">[1]</link>. In the Boost type-traits library, + we<link linkend="background.references">[2]</link> have written a set of very + specific traits classes, each of which encapsulate a single trait from the + C++ type system; for example, is a type a pointer or a reference type? Or does + a type have a trivial constructor, or a const-qualifier? The type-traits classes + share a unified design: each class inherits from a the type <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the type has the specified property and inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link> + otherwise. As we will show, these classes can be used in generic programming + to determine the properties of a given type and introduce optimizations that + are appropriate for that case. + </para> + <para> + The type-traits library also contains a set of classes that perform a specific + transformation on a type; for example, they can remove a top-level const or + volatile qualifier from a type. Each class that performs a transformation defines + a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of the transformation. All of the type-traits classes are + defined inside namespace <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase></computeroutput>; + for brevity, namespace-qualification is omitted in most of the code samples + given. + </para> + <anchor id="boost_typetraits.background.implementation"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.implementation">Implementation</link> + </bridgehead> + <para> + There are far too many separate classes contained in the type-traits library + to give a full implementation here - see the source code in the Boost library + for the full details - however, most of the implementation is fairly repetitive + anyway, so here we will just give you a flavor for how some of the classes + are implemented. Beginning with possibly the simplest class in the library, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput> inherits + from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + only if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> +</programlisting> + <para> + Here we define a primary version of the template class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_void">is_void</link></computeroutput>, + and provide a full-specialization when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. While full specialization + of a template class is an important technique, sometimes we need a solution + that is halfway between a fully generic solution, and a full specialization. + This is exactly the situation for which the standards committee defined partial + template-class specialization. As an example, consider the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput>: + here we needed a primary version that handles all the cases where T is not + a pointer, and a partial specialization to handle all the cases where T is + a pointer: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">*></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> +</programlisting> + <para> + The syntax for partial specialization is somewhat arcane and could easily occupy + an article in its own right; like full specialization, in order to write a + partial specialization for a class, you must first declare the primary template. + The partial specialization contains an extra <...> after the class name + that contains the partial specialization parameters; these define the types + that will bind to that partial specialization rather than the default template. + The rules for what can appear in a partial specialization are somewhat convoluted, + but as a rule of thumb if you can legally write two function overloads of the + form: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">);</phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase><phrase role="identifier">U</phrase><phrase role="special">);</phrase> +</programlisting> + <para> + Then you can also write a partial specialization of the form: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">class</phrase> <phrase role="identifier">c</phrase><phrase role="special">{</phrase> <phrase role="comment">/*details*/</phrase> <phrase role="special">};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">class</phrase> <phrase role="identifier">c</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">>{</phrase> <phrase role="comment">/*details*/</phrase> <phrase role="special">};</phrase> +</programlisting> + <para> + This rule is by no means foolproof, but it is reasonably simple to remember + and close enough to the actual rule to be useful for everyday use. + </para> + <para> + As a more complex example of partial specialization consider the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput>. This + class defines a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the same type as T but with any top-level array bounds removed; this + is an example of a traits class that performs a transformation on a type: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link> +<phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">N</phrase><phrase role="special">]></phrase> +<phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> +</programlisting> + <para> + The aim of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.remove_extent">remove_extent</link></computeroutput> + is this: imagine a generic algorithm that is passed an array type as a template + parameter, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.remove_extent">remove_extent</link></computeroutput> + provides a means of determining the underlying type of the array. For example + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">][</phrase><phrase role="number">5</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> would evaluate to the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">5</phrase><phrase role="special">]</phrase></computeroutput>. This example also shows that the number of + template parameters in a partial specialization does not have to match the + number in the default template. However, the number of parameters that appear + after the class name do have to match the number and type of the parameters + in the default template. + </para> + <anchor id="boost_typetraits.background.optimized_copy"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.optimized_copy">Optimized copy</link> + </bridgehead> + <para> + As an example of how the type traits classes can be used, consider the standard + library algorithm copy: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iter1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Iter2</phrase><phrase role="special">></phrase> +<phrase role="identifier">Iter2</phrase> <phrase role="identifier">copy</phrase><phrase role="special">(</phrase><phrase role="identifier">Iter1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter2</phrase> <phrase role="identifier">out</phrase><phrase role="special">);</phrase> +</programlisting> + <para> + Obviously, there's no problem writing a generic version of copy that works + for all iterator types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput>; however, there are + some circumstances when the copy operation can best be performed by a call + to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. In order to implement + copy in terms of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> all + of the following conditions need to be met: + </para> + <itemizedlist> + <listitem> + Both of the iterator types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput> must be pointers. + </listitem> + <listitem> + Both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput> must point to the same type - excluding + const and volatile-qualifiers. + </listitem> + <listitem> + The type pointed to by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + must have a trivial assignment operator. + </listitem> + </itemizedlist> + <para> + By trivial assignment operator we mean that the type is either a scalar type<link linkend="background.references">[3]</link> or: + </para> + <itemizedlist> + <listitem> + The type has no user defined assignment operator. + </listitem> + <listitem> + The type does not have any data members that are references. + </listitem> + <listitem> + All base classes, and all data member objects must have trivial assignment + operators. + </listitem> + </itemizedlist> + <para> + If all these conditions are met then a type can be copied using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> rather than using a compiler generated + assignment operator. The type-traits library provides a class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput>, + such that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is true only if T has a trivial assignment + operator. This class "just works" for scalar types, but has to be + explicitly specialised for class/struct types that also happen to have a trivial + assignment operator. In other words if <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link> + gives the wrong answer, it will give the "safe" wrong answer - that + trivial assignment is not allowable. + </para> + <para> + The code for an optimized version of copy that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> + where appropriate is given in <link linkend="boost_typetraits.examples.copy">the + examples</link>. The code begins by defining a template function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">do_copy</phrase></computeroutput> that performs a "slow but safe" + copy. The last parameter passed to this function may be either a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + or a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">false_type</link></computeroutput>. + Following that there is an overload of do<emphasis role="underline">copy that + uses `memcpy`: this time the iterators are required to actually be pointers + to the same type, and the final parameter must be a `</emphasis>_true_type<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase> <phrase role="identifier">Finally</phrase><phrase role="special">,</phrase> <phrase role="identifier">the</phrase> <phrase role="identifier">version</phrase> + <phrase role="identifier">of</phrase> </computeroutput>copy<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="identifier">calls</phrase> + </computeroutput>do<emphasis role="underline">copy`, passing `</emphasis>_has_trivial_assign<value_type>()` + as the final parameter: this will dispatch to the optimized version where appropriate, + otherwise it will call the "slow but safe version". + </para> + <anchor id="boost_typetraits.background.was_it_worth_it_"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.was_it_worth_it_">Was it worth it?</link> + </bridgehead> + <para> + It has often been repeated in these columns that "premature optimization + is the root of all evil" <link linkend="background.references">[4]</link>. + So the question must be asked: was our optimization premature? To put this + in perspective the timings for our version of copy compared a conventional + generic copy<link linkend="background.references">[5]</link> are shown in table + 1. + </para> + <para> + Clearly the optimization makes a difference in this case; but, to be fair, + the timings are loaded to exclude cache miss effects - without this accurate + comparison between algorithms becomes difficult. However, perhaps we can add + a couple of caveats to the premature optimization rule: + </para> + <itemizedlist> + <listitem> + If you use the right algorithm for the job in the first place then optimization + will not be required; in some cases, memcpy is the right algorithm. + </listitem> + <listitem> + If a component is going to be reused in many places by many people then optimizations + may well be worthwhile where they would not be so for a single case - in + other words, the likelihood that the optimization will be absolutely necessary + somewhere, sometime is that much higher. Just as importantly the perceived + value of the stock implementation will be higher: there is no point standardizing + an algorithm if users reject it on the grounds that there are better, more + heavily optimized versions available. + </listitem> + </itemizedlist> + <table frame="all"> <title>Time taken to copy 1000 elements using `copy<const + T*, T*>` (times in micro-seconds)</title> + <tgroup cols="3"> + <thead> + <row> + <entry> + <para> + Version + </para> + </entry><entry> + <para> + T + </para> + </entry><entry> + <para> + Time + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + "Optimized" copy + </para> + </entry><entry> + <para> + char + </para> + </entry><entry> + <para> + 0.99 + </para> + </entry> + </row> + <row> + <entry> + <para> + Conventional copy + </para> + </entry><entry> + <para> + char + </para> + </entry><entry> + <para> + 8.07 + </para> + </entry> + </row> + <row> + <entry> + <para> + "Optimized" copy + </para> + </entry><entry> + <para> + int + </para> + </entry><entry> + <para> + 2.52 + </para> + </entry> + </row> + <row> + <entry> + <para> + Conventional copy + </para> + </entry><entry> + <para> + int + </para> + </entry><entry> + <para> + 8.02 + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> <anchor id="boost_typetraits.background.pair_of_references"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.pair_of_references">Pair of References</link> + </bridgehead> + <para> + The optimized copy example shows how type traits may be used to perform optimization + decisions at compile-time. Another important usage of type traits is to allow + code to compile that otherwise would not do so unless excessive partial specialization + is used. This is possible by delegating partial specialization to the type + traits classes. Our example for this form of usage is a pair that can hold + references <link linkend="background.references">[6]</link>. + </para> + <para> + First, let us examine the definition of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase></computeroutput>, omitting + the comparison operators, default constructor, and template copy constructor + for simplicity: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T2</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">pair</phrase> +<phrase role="special">{</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T1</phrase> <phrase role="identifier">first_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T2</phrase> <phrase role="identifier">second_type</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">T1</phrase> <phrase role="identifier">first</phrase><phrase role="special">;</phrase> +<phrase role="identifier">T2</phrase> <phrase role="identifier">second</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">pair</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase> <phrase role="special">&</phrase> <phrase role="identifier">nfirst</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T2</phrase> <phrase role="special">&</phrase> <phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> +<phrase role="special">:</phrase><phrase role="identifier">first</phrase><phrase role="special">(</phrase><phrase role="identifier">nfirst</phrase><phrase role="special">),</phrase> <phrase role="identifier">second</phrase><phrase role="special">(</phrase><phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + Now, this "pair" cannot hold references as it currently stands, because + the constructor would require taking a reference to a reference, which is currently + illegal <link linkend="background.references">[7]</link>. Let us consider what + the constructor's parameters would have to be in order to allow "pair" + to hold non-reference types, references, and constant references: + </para> + <table frame="all"> <title>Required Constructor Argument Types</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of parameter to initializing constructor + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + T + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + <row> + <entry> + <para> + T & + </para> + </entry><entry> + <para> + T & + </para> + </entry> + </row> + <row> + <entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + <para> + A little familiarity with the type traits classes allows us to construct a + single mapping that allows us to determine the type of parameter from the type + of the contained class. The type traits classes provide a transformation <link linkend="boost_typetraits.reference.add_reference">add_reference</link>, which + adds a reference to its type, unless it is already a reference. + </para> + <table frame="all"> <title>Using add_reference to synthesize the correct constructor + type</title> + <tgroup cols="3"> + <thead> + <row> + <entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + T + </para> + </entry><entry> + <para> + const T + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + <row> + <entry> + <para> + T & + </para> + </entry><entry> + <para> + T & [8] + </para> + </entry><entry> + <para> + T & + </para> + </entry> + </row> + <row> + <entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + <para> + This allows us to build a primary template definition for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput> + that can contain non-reference types, reference types, and constant reference + types: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T2</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">pair</phrase> +<phrase role="special">{</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T1</phrase> <phrase role="identifier">first_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T2</phrase> <phrase role="identifier">second_type</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">T1</phrase> <phrase role="identifier">first</phrase><phrase role="special">;</phrase> +<phrase role="identifier">T2</phrase> <phrase role="identifier">second</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">pair</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">nfirst</phrase><phrase role="special">,</phrase> + <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T2</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> +<phrase role="special">:</phrase><phrase role="identifier">first</phrase><phrase role="special">(</phrase><phrase role="identifier">nfirst</phrase><phrase role="special">),</phrase> <phrase role="identifier">second</phrase><phrase role="special">(</phrase><phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + Add back in the standard comparison operators, default constructor, and template + copy constructor (which are all the same), and you have a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase></computeroutput> that + can hold reference types! + </para> + <para> + This same extension could have been done using partial template specialization + of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput>, but to specialize + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput> in this way would require + three partial specializations, plus the primary template. Type traits allows + us to define a single primary template that adjusts itself auto-magically to + any of these partial specializations, instead of a brute-force partial specialization + approach. Using type traits in this fashion allows programmers to delegate + partial specialization to the type traits classes, resulting in code that is + easier to maintain and easier to understand. + </para> + <anchor id="boost_typetraits.background.conclusion"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.conclusion">Conclusion</link> + </bridgehead> + <para> + We hope that in this article we have been able to give you some idea of what + type-traits are all about. A more complete listing of the available classes + are in the boost documentation, along with further examples using type traits. + Templates have enabled C++ uses to take the advantage of the code reuse that + generic programming brings; hopefully this article has shown that generic programming + does not have to sink to the lowest common denominator, and that templates + can be optimal as well as generic. + </para> + <anchor id="boost_typetraits.background.acknowledgements"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.acknowledgements">Acknowledgements</link> + </bridgehead> + <para> + The authors would like to thank Beman Dawes and Howard Hinnant for their helpful + comments when preparing this article. + </para> + <anchor id="background.references"/> <anchor id="boost_typetraits.background.references"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.references">References</link> + </bridgehead> + <orderedlist inheritnum="ignore" continuation="restarts"> + <listitem> + Nathan C. Myers, C++ Report, June 1995. + </listitem> + <listitem> + The type traits library is based upon contributions by Steve Cleary, Beman + Dawes, Howard Hinnant and John Maddock: it can be found at www.boost.org. + </listitem> + <listitem> + A scalar type is an arithmetic type (i.e. a built-in integer or floating + point type), an enumeration type, a pointer, a pointer to member, or a const- + or volatile-qualified version of one of these types. + </listitem> + <listitem> + This quote is from Donald Knuth, ACM Computing Surveys, December 1974, pg + 268. + </listitem> + <listitem> + The test code is available as part of the boost utility library (see algo_opt_examples.cpp), + the code was compiled with gcc 2.95 with all optimisations turned on, tests + were conducted on a 400MHz Pentium II machine running Microsoft Windows 98. + </listitem> + <listitem> + John Maddock and Howard Hinnant have submitted a "compressed_pair" + library to Boost, which uses a technique similar to the one described here + to hold references. Their pair also uses type traits to determine if any + of the types are empty, and will derive instead of contain to conserve space + -- hence the name "compressed". + </listitem> + <listitem> + This is actually an issue with the C++ Core Language Working Group (issue + #106), submitted by Bjarne Stroustrup. The tentative resolution is to allow + a "reference to a reference to T" to mean the same thing as a "reference + to T", but only in template instantiation, in a method similar to multiple + cv-qualifiers. + </listitem> + <listitem> + For those of you who are wondering why this shouldn't be const-qualified, + remember that references are always implicitly constant (for example, you + can't re-assign a reference). Remember also that "const T &" + is something completely different. For this reason, cv-qualifiers on template + type arguments that are references are ignored. + </listitem> + </orderedlist> + </section> + <section id="boost_typetraits.category"> + <title><link linkend="boost_typetraits.category"> Type Traits by Category</link></title> + <section id="boost_typetraits.category.value_traits"> + <title><link linkend="boost_typetraits.category.value_traits"> Type Traits + that Describe the Properties of a Type</link></title> + <para> + <indexterm> + <primary>Foo2</primary> + <secondary>Bar2</secondary> + </indexterm> + These traits are all <emphasis>value traits</emphasis>, which is to say the + traits classes all inherit from <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link>, + and are used to access some numerical property of a type. Often this is a + simple true or false Boolean value, but in a few cases may be some other + integer value (for example when dealing with type alignments, or array bounds: + see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.alignment_of">alignment_of</link></computeroutput>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.rank">rank</link></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.extent">extent</link></computeroutput>). + </para> + <section id="boost_typetraits.category.value_traits.primary"> + <title><link linkend="boost_typetraits.category.value_traits.primary"> Categorizing + a Type</link></title> + <para> + These traits identify what "kind" of type some type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is. These are split into two groups: + primary traits which are all mutually exclusive, and composite traits that + are compositions of one or more primary traits. + </para> + <para> + For any given type, exactly one primary type trait will inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + and all the others will inherit from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>, + in other words these traits are mutually exclusive. + </para> + <para> + This means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_integral">is_integral</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + will only ever be true for built-in types; if you want to check for a user-defined + class type that behaves "as if" it is an integral or floating + point type, then use the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase> + <phrase role="keyword">template</phrase></computeroutput> instead. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_array">is_array</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_class">is_class</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_complex">is_complex</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_enum">is_enum</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_function">is_function</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_integral">is_integral</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_object_pointer">is_member_object_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_union">is_union</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link><phrase role="special">;</phrase> +</programlisting> + <para> + The following traits are made up of the union of one or more type categorizations. + A type may belong to more than one of these categories, in addition to + one of the primary categories. + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_arithmetic">is_arithmetic</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_compound">is_compound</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_fundamental">is_fundamental</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_object">is_object</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_scalar">is_scalar</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.value_traits.properties"> + <title><link linkend="boost_typetraits.category.value_traits.properties"> + General Type Properties</link></title> + <para> + The following templates describe the general properties of a type. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.alignment_of">alignment_of</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_assign">has_nothrow_assign</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_default_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_default_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_virtual_destructor">has_virtual_destructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_abstract">is_abstract</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_const">is_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_empty">is_empty</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_stateless">is_stateless</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_signed">is_signed</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_unsigned">is_unsigned</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_volatile">is_volatile</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.extent">extent</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.rank">rank</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.value_traits.relate"> + <title><link linkend="boost_typetraits.category.value_traits.relate"> Relationships + Between Two Types</link></title> + <para> + These templates determine the whether there is a relationship between two + types: + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_base_of">is_base_of</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">U</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_same">is_same</link><phrase role="special">;</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.category.transform"> + <title><link linkend="boost_typetraits.category.transform"> Type Traits that + Transform One Type to Another</link></title> + <para> + The following templates transform one type to another, based upon some well-defined + rule. Each template has a single member called <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of applying the transformation to the template argument + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_const">add_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_cv">add_cv</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_pointer">add_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_volatile">add_volatile</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.decay">decay</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.floating_point_promotion">floating_point_promotion</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.integral_promotion">integral_promotion</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.make_signed">make_signed</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.make_unsigned">make_unsigned</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.promote">promote</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_all_extents">remove_all_extents</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_const">remove_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_cv">remove_cv</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_reference">remove_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_volatile">remove_volatile</link><phrase role="special">;</phrase> +</programlisting> + <anchor id="boost_typetraits.category.transform.broken_compiler_workarounds_"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">Broken + Compiler Workarounds:</link> + </bridgehead> + <para> + For all of these templates support for partial specialization of class templates + is required to correctly implement the transformation. On the other hand, + practice shows that many of the templates from this category are very useful, + and often essential for implementing some generic libraries. Lack of these + templates is often one of the major limiting factors in porting those libraries + to compilers that do not yet support this language feature. As some of these + compilers are going to be around for a while, and at least one of them is + very wide-spread, it was decided that the library should provide workarounds + where possible. + </para> + <para> + The basic idea behind the workaround is to manually define full specializations + of all type transformation templates for all fundamental types, and all their + 1st and 2nd rank cv-[un]qualified derivative pointer types, and to provide + a user-level macro that will define all the explicit specializations needed + for any user-defined type T. + </para> + <para> + The first part guarantees the successful compilation of something like this: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="special">...</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +</programlisting> + <para> + and the second part provides the library's users with a mechanism to make + the above code work not only for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> or other built-in type, + but for their own types as well: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">myspace</phrase><phrase role="special">{</phrase> + <phrase role="keyword">struct</phrase> <phrase role="identifier">MyClass</phrase> <phrase role="special">{};</phrase> +<phrase role="special">}</phrase> +<phrase role="comment">// declare this at global scope: +</phrase><phrase role="identifier">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase><phrase role="special">(</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">)</phrase> +<phrase role="comment">// transformations on myspace::MyClass now work: +</phrase><phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="comment">// etc. +</phrase></programlisting> + <para> + Note that the macro BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION evaluates + to nothing on those compilers that <emphasis role="bold">do</emphasis> support + partial specialization. + </para> + </section> + <section id="boost_typetraits.category.alignment"> + <title><link linkend="boost_typetraits.category.alignment"> Synthesizing Types + with Specific Alignments</link></title> + <para> + Some low level memory management routines need to synthesize a POD type with + specific alignment properties. The template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.type_with_alignment">type_with_alignment</link></computeroutput> + finds the smallest type with a specified alignment, while template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.aligned_storage">aligned_storage</link></computeroutput> + creates a type with a specific size and alignment. + </para> + <para> + <emphasis role="bold">Synopsis</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.type_with_alignment">type_with_alignment</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.aligned_storage">aligned_storage</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.function"> + <title><link linkend="boost_typetraits.category.function"> Decomposing Function + Types</link></title> + <para> + The class template <link linkend="boost_typetraits.reference.function_traits">function_traits</link> + extracts information from function types (see also <link linkend="boost_typetraits.reference.is_function">is_function</link>). + This traits class allows you to tell how many arguments a function takes, + what those argument types are, and what the return type is. + </para> + <para> + <emphasis role="bold">Synopsis</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.function_traits">function_traits</link><phrase role="special">;</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.user_defined"> + <title><link linkend="boost_typetraits.user_defined"> User Defined Specializations</link></title> + <para> + Occationally the end user may need to provide their own specialization for + one of the type traits - typically where intrinsic compiler support is required + to implement a specific trait fully. These specializations should derive from + boost::<link linkend="boost_typetraits.reference.integral_constant">true_type</link> + or boost::<link linkend="boost_typetraits.reference.integral_constant">false_type</link> + as appropriate: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pod</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> +<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_class</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> +<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_union</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> + +<phrase role="keyword">struct</phrase> <phrase role="identifier">my_pod</phrase><phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">my_union</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">char</phrase> <phrase role="identifier">c</phrase><phrase role="special">;</phrase> + <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> + +<phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special"><</phrase><phrase role="identifier">my_pod</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_union">is_union</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_class">is_class</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.intrinsics"> + <title><link linkend="boost_typetraits.intrinsics"> Support for Compiler Intrinsics</link></title> + <para> + There are some traits that can not be implemented within the current C++ language: + to make these traits "just work" with user defined types, some kind + of additional help from the compiler is required. Currently (April 2008) Visual + C++ 8 and 9, GNU GCC 4.3 and MWCW 9 provide the necessary intrinsics, and other + compilers will no doubt follow in due course. + </para> + <para> + The Following traits classes always need compiler support to do the right thing + for all types (but all have safe fallback positions if this support is unavailable): + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_union">is_union</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_pod">is_pod</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_assign">has_nothrow_assign</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_virtual_destructor">has_virtual_destructor</link> + </listitem> + </itemizedlist> + <para> + The following traits classes can't be portably implemented in the C++ language, + although in practice, the implementations do in fact do the right thing on + all the compilers we know about: + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_empty">is_empty</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link> + </listitem> + </itemizedlist> + <para> + The following traits classes are dependent on one or more of the above: + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_class">is_class</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_stateless">is_stateless</link> + </listitem> + </itemizedlist> + <para> + The hooks for compiler-intrinsic support are defined in <ulink url="../../../../boost/type_traits/intrinsics.hpp">boost/type_traits/intrinsics.hpp</ulink>, + adding support for new compilers is simply a matter of defining one of more + of the following macros: + </para> + <table frame="all"> <title>Macros for Compiler Intrinsics</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + BOOST_IS_UNION(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a union type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + BOOST_IS_POD(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a POD type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_EMPTY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is an empty struct or union + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if the default constructor for T is trivial (i.e. + has no effect) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_COPY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial copy constructor (and can + therefore be replaced by a call to memcpy) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_ASSIGN(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial assignment operator (and can + therefore be replaced by a call to memcpy) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_DESTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial destructor (i.e. ~T() has + no effect) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_CONSTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="identifier">x</phrase><phrase role="special">;</phrase></computeroutput> + can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_COPY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase><phrase role="special">(</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase></computeroutput> can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_ASSIGN(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="identifier">t</phrase><phrase role="special">,</phrase> + <phrase role="identifier">u</phrase><phrase role="special">;</phrase> + <phrase role="identifier">t</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">u</phrase></computeroutput> can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_VIRTUAL_DESTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true T has a virtual destructor + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_ABSTRACT(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is an abstract type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_BASE_OF(T,U) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a base class of U + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_CLASS(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a class type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_CONVERTIBLE(T,U) + </para> + </entry><entry> + <para> + Should evaluate to true if T is convertible to U + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_ENUM(T) + </para> + </entry><entry> + <para> + Should evaluate to true is T is an enum + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_POLYMORPHIC(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a polymorphic type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_ALIGNMENT_OF(T) + </para> + </entry><entry> + <para> + Should evaluate to the alignment requirements of type T. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.mpl"> + <title><link linkend="boost_typetraits.mpl"> MPL Interoperability</link></title> + <para> + All the value based traits in this library conform to MPL's requirements for + an <ulink url="../../../../libs/mpl/doc/refmanual/integral-constant.html">Integral + Constant type</ulink>: that includes a number of rather intrusive workarounds + for broken compilers. + </para> + <para> + Purely as an implementation detail, this means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/bool.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">true_</phrase></computeroutput></ulink>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">false_type</link></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/bool.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">false_</phrase></computeroutput></ulink>, + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> + <phrase role="identifier">v</phrase><phrase role="special">></phrase></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/integral-c.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">integral_c</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">v</phrase><phrase role="special">></phrase></computeroutput></ulink> + (provided <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>) + </para> + </section> + <section id="boost_typetraits.examples"> + <title><link linkend="boost_typetraits.examples"> Examples</link></title> + <section id="boost_typetraits.examples.copy"> + <title><link linkend="boost_typetraits.examples.copy"> An Optimized Version + of std::copy</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">copy</phrase></computeroutput> + that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput> + to determine whether to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> + to optimise the copy operation (see <ulink url="../../examples/copy_example.cpp">copy_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// opt::copy +</phrase><phrase role="comment">// same semantics as std::copy +</phrase><phrase role="comment">// calls memcpy where appropriate. +</phrase><phrase role="comment">// +</phrase> +<phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase><phrase role="special">></phrase> +<phrase role="identifier">I2</phrase> <phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="identifier">b</phrase><phrase role="special">>&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="special">*</phrase><phrase role="identifier">out</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">out</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">out</phrase><phrase role="special">;</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">memcpy</phrase><phrase role="special">(</phrase><phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="special">(</phrase><phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">)*</phrase><phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">));</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">out</phrase><phrase role="special">+(</phrase><phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">copy</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">out</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// We can copy with memcpy if T has a trivial assignment operator, +</phrase> <phrase role="comment">// and if the iterator arguments are actually pointers (this last +</phrase> <phrase role="comment">// requirement we detect with overload resolution): +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I1</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special"><</phrase><phrase role="identifier">value_type</phrase><phrase role="special">>());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.fill"> + <title><link linkend="boost_typetraits.examples.fill"> An Optimised Version + of std::fill</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">fill</phrase></computeroutput> + that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput> + to determine whether to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memset</phrase></computeroutput> + to optimise the fill operation (see <ulink url="../../examples/fill_example.cpp">fill_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// fill +</phrase><phrase role="comment">// same as std::fill, but uses memset where appropriate +</phrase><phrase role="comment">// +</phrase><phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="identifier">b</phrase><phrase role="special">>&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="special">*</phrase><phrase role="identifier">first</phrase> <phrase role="special">=</phrase> <phrase role="identifier">val</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">memset</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">I</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">fill</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// We can do an optimised fill if T has a trivial assignment +</phrase> <phrase role="comment">// operator and if it's size is one: +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> + <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> <phrase role="special">&&</phrase> <phrase role="special">(</phrase><phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">)></phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">;</phrase> + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.destruct"> + <title><link linkend="boost_typetraits.examples.destruct"> An Example that + Omits Destructor Calls For Types with Trivial Destructors</link></title> + <para> + Demonstrates a simple algorithm that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">__has_trivial_destruct</phrase></computeroutput> + to determine whether to destructors need to be called (see <ulink url="../../examples/trivial_destructor_example.cpp">trivial_destructor_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// algorithm destroy_array: +</phrase><phrase role="comment">// The reverse of std::unitialized_copy, takes a block of +</phrase><phrase role="comment">// initialized memory and calls destructors on all objects therein. +</phrase><phrase role="comment">// +</phrase> +<phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="identifier">first</phrase><phrase role="special">->~</phrase><phrase role="identifier">T</phrase><phrase role="special">();</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> <phrase role="comment">// namespace detail +</phrase> +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">p1</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">p2</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">p1</phrase><phrase role="special">,</phrase> <phrase role="identifier">p2</phrase><phrase role="special">,</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.iter"> + <title><link linkend="boost_typetraits.examples.iter"> An improved Version + of std::iter_swap</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iter_swap</phrase></computeroutput> + that use type traits to determine whether an it's arguments are proxying + iterators or not, if they're not then it just does a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">swap</phrase></computeroutput> + of it's dereferenced arguments (the same as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iter_swap</phrase></computeroutput> + does), however if they are proxying iterators then takes special care over + the swap to ensure that the algorithm works correctly for both proxying iterators, + and even iterators of different types (see <ulink url="../../examples/iter_swap_example.cpp">iter_swap_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// iter_swap: +</phrase><phrase role="comment">// tests whether iterator is a proxying iterator or not, and +</phrase><phrase role="comment">// uses optimal form accordingly: +</phrase><phrase role="comment">// +</phrase><phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">></phrase> +<phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">v_t</phrase><phrase role="special">;</phrase> + <phrase role="identifier">v_t</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">one</phrase><phrase role="special">;</phrase> + <phrase role="special">*</phrase><phrase role="identifier">one</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">two</phrase><phrase role="special">;</phrase> + <phrase role="special">*</phrase><phrase role="identifier">two</phrase> <phrase role="special">=</phrase> <phrase role="identifier">v</phrase><phrase role="special">;</phrase> +<phrase role="special">}</phrase> +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">></phrase> +<phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">using</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">swap</phrase><phrase role="special">;</phrase> + <phrase role="identifier">swap</phrase><phrase role="special">(*</phrase><phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase><phrase role="identifier">two</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">iter_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">two</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// See is both arguments are non-proxying iterators, +</phrase> <phrase role="comment">// and if both iterator the same type: +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I1</phrase><phrase role="special">>::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">r1_t</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I2</phrase><phrase role="special">>::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">r2_t</phrase><phrase role="special">;</phrase> + + <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> + <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special"><</phrase><phrase role="identifier">r1_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special"><</phrase><phrase role="identifier">r2_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_same">is_same</link><phrase role="special"><</phrase><phrase role="identifier">r1_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">r2_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">></phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">;</phrase> + + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.to_double"> + <title><link linkend="boost_typetraits.examples.to_double"> Convert Numeric + Types and Enums to double</link></title> + <para> + Demonstrates a conversion of <ulink url="../../../../libs/numeric/conversion/doc/html/boost_numericconversion/definitions.html#boost_numericconversion.definitions.numeric_types">Numeric + Types</ulink> and enum types to double: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">double</phrase> <phrase role="identifier">to_double</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">promoted</phrase><phrase role="special">;</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric</phrase><phrase role="special">::</phrase><phrase role="identifier">converter</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase><phrase role="identifier">promoted</phrase><phrase role="special">>::</phrase><phrase role="identifier">convert</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.reference"> + <title><link linkend="boost_typetraits.reference"> Alphabetical Reference</link></title> + <section id="boost_typetraits.reference.add_const"> + <title><link linkend="boost_typetraits.reference.add_const"> add_const</link></title> + <indexterm type="class_name"> + <primary>one</primary> + <secondary>two</secondary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">const</phrase></computeroutput> for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_cv"> + <title><link linkend="boost_typetraits.reference.add_cv"> add_cv</link></title> + <indexterm type="class_name"> + <primary>one</primary> + <secondary>two</secondary> + <tertiary>three</tertiary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_cv</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_cv</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_pointer"> + <title><link linkend="boost_typetraits.reference.add_pointer"> add_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_pointer</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">*</phrase></computeroutput>. + </para> + <para> + The rationale for this template is that it produces the same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">TYPEOF</phrase><phrase role="special">(&</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase></computeroutput>, where + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t</phrase></computeroutput> is an object of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.1. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">**</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">**</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_reference"> + <title><link linkend="boost_typetraits.reference.add_reference"> add_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_reference</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is not a reference type then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase><phrase role="special">&</phrase></computeroutput>, otherwise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_volatile"> + <title><link linkend="boost_typetraits.reference.add_volatile"> add_volatile</link></title> + <indexterm type="class_name"> + <primary>one</primary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.aligned_storage"> + <title><link linkend="boost_typetraits.reference.aligned_storage"> aligned_storage</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">aligned_storage</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> a built-in or POD type with size + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Size</phrase></computeroutput> and an alignment that + is a multiple of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Align</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">aligned_storage</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.alignment_of"> + <title><link linkend="boost_typetraits.reference.alignment_of"> alignment_of</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">alignment_of</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template alignment<emphasis role="underline">of inherits from `</emphasis>_integral_constant<std::size_t, + ALIGNOF(T)><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">,</phrase> <phrase role="identifier">where</phrase> + </computeroutput>ALIGNOF(T)` is the alignment of type T. + </para> + <para> + <emphasis>Note: strictly speaking you should only rely on the value of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> being + a multiple of the true alignment of T, although in practice it does compute + the correct value in all the cases we know about.</emphasis> + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">alignment_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase><phrase role="special">)></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + with value <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.decay"> + <title><link linkend="boost_typetraits.reference.decay"> decay</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">decay</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> Let <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> + be the result of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>, then if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> + is an array type, the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">>*</phrase></computeroutput>, + otherwise if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> is a function + type then the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase><phrase role="special">*</phrase></computeroutput>, otherwise the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">decay</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">(&)[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">(&)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.extent"> + <title><link linkend="boost_typetraits.reference.extent"> extent</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">extent</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template extent inherits + from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)></phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)</phrase></computeroutput> is the number of elements in the N'th array + dimention of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not an array type, + or if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">N</phrase> <phrase role="special">></phrase> + <link linkend="boost_typetraits.reference.rank">rank</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>, or if the N'th array bound is incomplete, + then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)</phrase></computeroutput> is zero. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">extent</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">],</phrase> + <phrase role="number">1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>4</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">],</phrase> <phrase role="number">1</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>2</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.floating_point_promotion"> + <title><link linkend="boost_typetraits.reference.floating_point_promotion"> + floating_point_promotion</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">floating_point_promotion</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If floating point promotion can be + applied to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + then applies floating point promotion to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">floating_point_promotion</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">float</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.function_traits"> + <title><link linkend="boost_typetraits.reference.function_traits"> function_traits</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">F</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">function_traits</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">arity</phrase> <phrase role="special">=</phrase> <replaceable>see-below</replaceable><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">result_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> arg<replaceable>N</replaceable>_type<phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + The class template function_traits will only compile if: + </para> + <itemizedlist> + <listitem> + The compiler supports partial specialization of class templates. + </listitem> + <listitem> + The template argument <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput> + is a <emphasis>function type</emphasis>, note that this <emphasis><emphasis role="bold">is not</emphasis></emphasis> the same thing as a <emphasis>pointer + to a function</emphasis>. + </listitem> + </itemizedlist> + <tip> + <para> + function_traits is intended to introspect only C++ functions of the form + R (), R( A1 ), R ( A1, ... etc. ) and not function pointers or class member + functions. To convert a function pointer type to a suitable type use <link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link>. + </para> + </tip> + <table frame="all"> <title>Function Traits Members</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Member + </para> + </entry><entry> + <para> + Description + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that gives the number of arguments + accepted by the function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type returned by function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase>arg<replaceable>N</replaceable>_type</computeroutput> + </para> + </entry><entry> + <para> + The <replaceable>N</replaceable>th argument type of function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase> <phrase role="special"><=</phrase> + <phrase role="identifier">N</phrase> <phrase role="special"><=</phrase> + <phrase role="identifier">arity</phrase></computeroutput> of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 0. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 1. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 4. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">long</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arg1_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arg4_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase><phrase role="special">*</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arg5_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A compiler error: there is no <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">arg5_type</phrase></computeroutput> + since there are only four arguments. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + A compiler error: argument type is a <emphasis>function pointer</emphasis>, + and not a <emphasis>function type</emphasis>. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.has_nothrow_assign"> + <title><link linkend="boost_typetraits.reference.has_nothrow_assign"> has_nothrow_assign</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_assign</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing assignment-operator then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_assign</phrase></computeroutput> + will never report that a class or struct has a non-throwing assignment-operator; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler support to ensure that this trait "just + works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_assign</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_constructor"> + <title><link linkend="boost_typetraits.reference.has_nothrow_constructor"> + has_nothrow_constructor</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_default_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing default-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_constructor</phrase></computeroutput> + will never report that a class or struct has a non-throwing default-constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to ensure that this trait "just works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_constructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_copy"> + <title><link linkend="boost_typetraits.reference.has_nothrow_copy"> has_nothrow_copy</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_copy</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_copy_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing copy-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_copy</phrase></computeroutput> + will never report that a class or struct has a non-throwing copy-constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to ensure that this trait "just works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_copy</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_cp_cons"> + <title><link linkend="boost_typetraits.reference.has_nothrow_cp_cons"> has_nothrow_copy_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_no_throw_def_cons"> + <title><link linkend="boost_typetraits.reference.has_no_throw_def_cons"> has_nothrow_default_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_assign"> + <title><link linkend="boost_typetraits.reference.has_trivial_assign"> has_trivial_assign</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_assign</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial assignment-operator then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + If a type has a trivial assignment-operator then the operator has the same + effect as copying the bits of one object to the other: calls to the operator + can be safely replaced with a call to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_assign + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.8p11. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_assign</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_constructor"> + <title><link linkend="boost_typetraits.reference.has_trivial_constructor"> + has_trivial_constructor</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_default_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial default-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + If a type has a trivial default-constructor then the constructor have no + effect: calls to the constructor can be safely omitted. Note that using meta-programming + to omit a call to a single trivial-constructor call is of no benefit whatsoever. + However, if loops and/or exception handling code can also be omitted, then + some benefit in terms of code size and speed can be obtained. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_constructor + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.1p6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_copy"> + <title><link linkend="boost_typetraits.reference.has_trivial_copy"> has_trivial_copy</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_copy</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_copy_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial copy-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + If a type has a trivial copy-constructor then the constructor has the same + effect as copying the bits of one object to the other: calls to the constructor + can be safely replaced with a call to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_copy + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.8p6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_copy</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_cp_cons"> + <title><link linkend="boost_typetraits.reference.has_trivial_cp_cons"> has_trivial_copy_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_def_cons"> + <title><link linkend="boost_typetraits.reference.has_trivial_def_cons"> has_trivial_default_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_destructor"> + <title><link linkend="boost_typetraits.reference.has_trivial_destructor"> has_trivial_destructor</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_destructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial destructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + If a type has a trivial destructor then the destructor has no effect: calls + to the destructor can be safely omitted. Note that using meta-programming + to omit a call to a single trivial-constructor call is of no benefit whatsoever. + However, if loops and/or exception handling code can also be omitted, then + some benefit in terms of code size and speed can be obtained. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_destructor + will never report that a user-defined class or struct has a trivial destructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.4p3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_virtual_destructor"> + <title><link linkend="boost_typetraits.reference.has_virtual_destructor"> has_virtual_destructor</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_virtual_destructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a virtual destructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> This trait is provided + for completeness, since it's part of the Technical Report on C++ Library + Extensions. However, there is currently no way to portably implement this + trait. The default version provided always inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>, + and has to be explicitly specialized for types with virtual destructors unless + the compiler used has compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + that enable the trait to do the right thing: currently (May 2005) only Visual + C++ 8 and GCC-4.3 have the necessary <link linkend="boost_typetraits.intrinsics">intrinsics</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.4. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_virtual_destructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.integral_constant"> + <title><link linkend="boost_typetraits.reference.integral_constant"> integral_constant</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">val</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">integral_constant</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">></phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">val</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> + +<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="keyword">true</phrase><phrase role="special">></phrase> <phrase role="identifier">true_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="keyword">false</phrase><phrase role="special">></phrase> <phrase role="identifier">false_type</phrase><phrase role="special">;</phrase> +</programlisting> + <para> + Class template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_constant</phrase></computeroutput> + is the common base class for all the value-based type traits. The two typedef's + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">true_type</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">false_type</phrase></computeroutput> are provided for convenience: + most of the value traits are Boolean properties and so will inherit from + one of these. + </para> + </section> + <section id="boost_typetraits.reference.integral_promotion"> + <title><link linkend="boost_typetraits.reference.integral_promotion"> integral_promotion</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">integral_promotion</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If integral promotion can be applied + to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, then + applies integral promotion to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.5 except 4.5/3 + (integral bit-field). + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">integral_promotion</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">enum</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">float_round_style</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.is_abstract"> + <title><link linkend="boost_typetraits.reference.is_abstract"> is_abstract</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_abstract</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + abstract type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_abstract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> The compiler must + support DR337 (as of April 2005: GCC 3.4, VC++ 7.1 (and later), Intel C++ + 7 (and later), and Comeau 4.3.2). Otherwise behaves the same as <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link>; + this is the "safe fallback position" for which polymorphic types + are always regarded as potentially abstract. The macro BOOST_NO_IS_ABSTRACT + is used to signify that the implementation is buggy, users should check for + this in their own code if the "safe fallback" is not suitable for + their particular use-case. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">abc</phrase><phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">abc</phrase><phrase role="special">()</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_arithmetic"> + <title><link linkend="boost_typetraits.reference.is_arithmetic"> is_arithmetic</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_arithmetic</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + arithmetic type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Arithmetic types include integral and floating point types (see also <link linkend="boost_typetraits.reference.is_integral">is_integral</link> and + <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link>). + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p8. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_arithmetic</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_array"> + <title><link linkend="boost_typetraits.reference.is_array"> is_array</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_array</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + array type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.4. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_array</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can give the wrong result with function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_base_of"> + <title><link linkend="boost_typetraits.reference.is_base_of"> is_base_of</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_base_of</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If Base is base class of type + Derived or if both types are the same then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + This template will detect non-public base classes, and ambiguous base classes. + </para> + <para> + Note that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">X</phrase><phrase role="special">,</phrase><phrase role="identifier">X</phrase><phrase role="special">></phrase></computeroutput> will always inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>. + <emphasis role="bold">This is the case even if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">X</phrase></computeroutput> + is not a class type</emphasis>. This is a change in behaviour from Boost-1.33 + in order to track the Technical Report on C++ Library Extensions. + </para> + <para> + Types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput> must not be incomplete types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_base_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. There are some older compilers which + will produce compiler errors if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> + is a private base class of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput>, + or if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> is an ambiguous + base of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput>. These compilers + include Borland C++, older versions of Sun Forte C++, Digital Mars C++, and + older versions of EDG based compilers. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">{};</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase> <phrase role="special">:</phrase> + <phrase role="keyword">public</phrase> <phrase role="identifier">Base</phrase><phrase role="special">{};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Base</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>: a class is regarded as it's + own base. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_class"> + <title><link linkend="boost_typetraits.reference.is_class"> is_class</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_class</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + class type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 9.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_class</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Without (some as + yet unspecified) help from the compiler, we cannot distinguish between union + and class types, as a result this type will erroneously inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link> for + union types. See also <link linkend="boost_typetraits.reference.is_union">is_union</link>. + Currently (May 2005) only Visual C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to correctly identify union types, and therefore make is_class function correctly. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">MyClass</phrase><phrase role="special">;</phrase></computeroutput> then: + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_complex"> + <title><link linkend="boost_typetraits.reference.is_complex"> is_complex</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_complex</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is a complex number type then true (of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">complex</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">></phrase></computeroutput> + for some type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>), otherwise + false. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 26.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_complex</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.is_compound"> + <title><link linkend="boost_typetraits.reference.is_compound"> is_compound</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_compound</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + compound type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Any type that is not a fundamental type is a compound type (see also <link linkend="boost_typetraits.reference.is_fundamental">is_fundamental</link>). + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_compound</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">MyEnum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_const"> + <title><link linkend="boost_typetraits.reference.is_const"> is_const</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_const</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (top level) const-qualified + type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the const-qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the const-qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_convertible"> + <title><link linkend="boost_typetraits.reference.is_convertible"> is_convertible</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_convertible</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If an imaginary lvalue of type + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">From</phrase></computeroutput> is convertible to type + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + Type From must not be an incomplete type. + </para> + <para> + Type To must not be an incomplete, or function type. + </para> + <para> + No types are considered to be convertible to array types or abstract-class + types. + </para> + <para> + This template can not detect whether a converting-constructor is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> or not: if type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> + has a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput> converting constructor + from type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">From</phrase></computeroutput> then instantiating + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase></computeroutput> + will produce a compiler error. For this reason <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase></computeroutput> + can not be used to determine whether a type has a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> + copy-constructor or not. + </para> + <para> + This template will also produce compiler errors if the conversion is ambiguous, + for example: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">B</phrase> <phrase role="special">:</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">C</phrase> <phrase role="special">:</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">D</phrase> <phrase role="special">:</phrase> <phrase role="identifier">B</phrase><phrase role="special">,</phrase> <phrase role="identifier">C</phrase> <phrase role="special">{};</phrase> +<phrase role="comment">// This produces a compiler error, the conversion is ambiguous: +</phrase><phrase role="keyword">bool</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">y</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">D</phrase><phrase role="special">*,</phrase><phrase role="identifier">A</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase><phrase role="special">;</phrase> +</programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4 and 8.5. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> This template is + currently broken with Borland C++ Builder 5 (and earlier), for constructor-based + conversions, and for the Metrowerks 7 (and earlier) compiler in all cases. + If the compiler does not support <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_abstract">is_abstract</link></computeroutput>, + then the template parameter <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> + must not be an abstract type. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_convertible</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the conversion would require a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const_cast</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&,</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_empty"> + <title><link linkend="boost_typetraits.reference.is_empty"> is_empty</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_empty</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an empty class type then + inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10p5. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_empty</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> In order to correctly + detect empty classes this trait relies on either: + </para> + <itemizedlist> + <listitem> + the compiler implementing zero sized empty base classes, or + </listitem> + <listitem> + the compiler providing <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect empty classes. + </listitem> + </itemizedlist> + <para> + Can not be used with incomplete types. + </para> + <para> + Can not be used with union types, until is_union can be made to work. + </para> + <para> + If the compiler does not support partial-specialization of class templates, + then this template can not be used with abstract types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">empty_class</phrase> + <phrase role="special">{};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_enum"> + <title><link linkend="boost_typetraits.reference.is_enum"> is_enum</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_enum</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + enum type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_enum</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Requires a correctly + functioning <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link> + template; this means that is_enum is currently broken under Borland C++ Builder + 5, and for the Metrowerks compiler prior to version 8, other compilers should + handle this template just fine. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">enum</phrase> <phrase role="identifier">my_enum</phrase> + <phrase role="special">{</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">two</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_floating_point"> + <title><link linkend="boost_typetraits.reference.is_floating_point"> is_floating_point</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_floating_point</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + floating point type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p8. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_floating_point</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_function"> + <title><link linkend="boost_typetraits.reference.is_function"> is_function</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_function</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + function type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Note that this template does not detect <emphasis>pointers to functions</emphasis>, + or <emphasis>references to functions</emphasis>, these are detected by <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link> and <link linkend="boost_typetraits.reference.is_reference">is_reference</link> respectively: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">f1</phrase><phrase role="special">();</phrase> <phrase role="comment">// f1 is of function type. +</phrase><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">f2</phrase><phrase role="special">*)();</phrase> <phrase role="comment">// f2 is a pointer to a function. +</phrase><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">f3</phrase><phrase role="special">&)();</phrase> <phrase role="comment">// f3 is a reference to a function. +</phrase></programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2p1 and 8.3.5. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_function</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a pointer type, not a function type. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(&)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a reference to a function, not a function type. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a pointer to a member function. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + <tip> + <para> + Don't confuse function-types with pointers to functions: + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> + <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">);</phrase></computeroutput> + </para> + <para> + defines a function type, + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase> <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + declares a prototype for a function of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase></computeroutput>, + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase><phrase role="special">*</phrase> + <phrase role="identifier">pf</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase><phrase role="special">&</phrase> + <phrase role="identifier">fr</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + declares a pointer and a reference to the function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">foo</phrase></computeroutput>. + </para> + <para> + If you want to detect whether some type is a pointer-to-function then use: + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_function">is_function</link><phrase role="special"><</phrase><link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + </para> + <para> + or for pointers to member functions you can just use <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link> + directly. + </para> + </tip> + </section> + <section id="boost_typetraits.reference.is_fundamental"> + <title><link linkend="boost_typetraits.reference.is_fundamental"> is_fundamental</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_fundamental</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + fundamental type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Fundamental types include integral, floating point and void types (see also + <link linkend="boost_typetraits.reference.is_integral">is_integral</link>, + <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link> + and <link linkend="boost_typetraits.reference.is_void">is_void</link>) + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_fundamental</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_integral"> + <title><link linkend="boost_typetraits.reference.is_integral"> is_integral</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_integral</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + integral type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p7. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_integral</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_function_pointer"> + <title><link linkend="boost_typetraits.reference.is_member_function_pointer"> + is_member_function_pointer</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_function_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member function then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the argument in this case is a pointer to a data member and not a member + function, see <link linkend="boost_typetraits.reference.is_member_object_pointer">is_member_object_pointer</link> + and <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_object_pointer"> + <title><link linkend="boost_typetraits.reference.is_member_object_pointer"> + is_member_object_pointer</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_object_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member object (a data member) then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the argument in this case is a pointer to a member function and not a + member object, see <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link> + and <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_pointer"> + <title><link linkend="boost_typetraits.reference.is_member_pointer"> is_member_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member (either a function or a data member) then inherits from + <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_object"> + <title><link linkend="boost_typetraits.reference.is_object"> is_object</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_object</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + object type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + All types are object types except references, void, and function types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p9. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_object</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: reference types are not + objects + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: function types are not + objects + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + void is not an object type + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_pod"> + <title><link linkend="boost_typetraits.reference.is_pod"> is_pod</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_pod</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + POD type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + POD stands for "Plain old data". Arithmetic types, and enumeration + types, a pointers and pointer to members are all PODs. Classes and unions + can also be POD's if they have no non-static data members that are of reference + or non-POD type, no user defined constructors, no user defined assignment + operators, no private or protected non-static data members, no virtual functions + and no base classes. Finally, a cv-qualified POD is still a POD, as is an + array of PODs. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10 and 9p4 (Note + that POD's are also aggregates, see 8.5.1). + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, is<emphasis role="underline">pod + will never report that a class or struct is a POD; this is always safe, if + possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8 have + the necessary compiler-</emphasis>_intrinsics. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pod</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_pointer"> + <title><link linkend="boost_typetraits.reference.is_pointer"> is_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer type (includes function pointers, but excludes pointers to members) + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2p2 and 8.3.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + <important> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase></computeroutput> detects "real" + pointer types only, and <emphasis>not</emphasis> smart pointers. Users + should not specialise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase></computeroutput> + for smart pointer types, as doing so may cause Boost (and other third party) + code to fail to function correctly. Users wanting a trait to detect smart + pointers should create their own. However, note that there is no way in + general to auto-magically detect smart pointer types, so such a trait would + have to be partially specialised for each supported smart pointer type. + </para> + </important> + </section> + <section id="boost_typetraits.reference.is_polymorphic"> + <title><link linkend="boost_typetraits.reference.is_polymorphic"> is_polymorphic</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_polymorphic</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + polymorphic type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> The implementation + requires some knowledge of the compilers ABI, it does actually seem to work + with the majority of compilers though. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_polymorphic</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">poly</phrase><phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">poly</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_same"> + <title><link linkend="boost_typetraits.reference.is_same"> is_same</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">U</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_same</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T and U are the same types + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_same</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with abstract, incomplete or function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_scalar"> + <title><link linkend="boost_typetraits.reference.is_scalar"> is_scalar</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_scalar</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + scalar type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Scalar types include integral, floating point, enumeration, pointer, and + pointer-to-member types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_scalar</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_signed"> + <title><link linkend="boost_typetraits.reference.is_signed"> is_signed</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_signed</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an signed integer type + or an enumerated type with an underlying signed integer type, then inherits + from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1, 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_signed</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">myclass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + whose value depends upon the signedness of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_stateless"> + <title><link linkend="boost_typetraits.reference.is_stateless"> is_stateless</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_stateless</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Ff T is a stateless type then + inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + Type T must be a complete type. + </para> + <para> + A stateless type is a type that has no storage and whose constructors and + destructors are trivial. That means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_stateless</phrase></computeroutput> + only inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the following expression is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput>: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +</programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_stateless</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, is_stateless will + never report that a class or struct is stateless; this is always safe, if + possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8 have + the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to make this template work automatically. + </para> + </section> + <section id="boost_typetraits.reference.is_reference"> + <title><link linkend="boost_typetraits.reference.is_reference"> is_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_reference</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a reference pointer type + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + may report the wrong result for function types, and for types that are both + const and volatile qualified. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(&)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis> (the argument in this case + is a reference to a function). + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_union"> + <title><link linkend="boost_typetraits.reference.is_union"> is_union</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_union</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + union type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Currently requires some kind of compiler support, otherwise unions are identified + as classes. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 9.5. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Without (some as + yet unspecified) help from the compiler, we cannot distinguish between union + and class types using only standard C++, as a result this type will never + inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + unless the user explicitly specializes the template for their user-defined + union types, or unless the compiler supplies some unspecified intrinsic that + implements this functionality. Currently (May 2005) only Visual C++ 8 has + the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to make this trait "just work" without user intervention. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_union</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_unsigned"> + <title><link linkend="boost_typetraits.reference.is_unsigned"> is_unsigned</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_unsigned</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an unsigned integer type + or an enumerated type with an underlying unsigned integer type, then inherits + from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1, 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_unsigned</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="identifier">myclass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + whose value depends upon the signedness of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">long</phrase> + <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_void"> + <title><link linkend="boost_typetraits.reference.is_void"> is_void</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_void</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + void type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p9. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_void</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_volatile"> + <title><link linkend="boost_typetraits.reference.is_volatile"> is_volatile</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_volatile</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (top level) volatile-qualified + type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">volatile</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase> + <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the volatile qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.make_signed"> + <title><link linkend="boost_typetraits.reference.make_signed"> make_signed</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">make_signed</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If T is a signed integer type then + the same type as T, if T is an unsigned integer type then the corresponding + signed type. Otherwise if T is an enumerated or character type (char or wchar_t) + then a signed integer type with the same width as T. + </para> + <para> + If T has any cv-qualifiers then these are also present on the result type. + </para> + <para> + <emphasis role="bold">Requires:</emphasis> T must be an integer or enumerated + type, and must not be the type bool. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">make_signed</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">long</phrase> + <phrase role="keyword">long</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A signed integer type with the same width as the enum. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">wchar_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A signed integer type with the same width as wchar_t. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.make_unsigned"> + <title><link linkend="boost_typetraits.reference.make_unsigned"> make_unsigned</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">make_unsigned</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If T is a unsigned integer type then + the same type as T, if T is an signed integer type then the corresponding + unsigned type. Otherwise if T is an enumerated or character type (char or + wchar_t) then an unsigned integer type with the same width as T. + </para> + <para> + If T has any cv-qualifiers then these are also present on the result type. + </para> + <para> + <emphasis role="bold">Requires:</emphasis> T must be an integer or enumerated + type, and must not be the type bool. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">make_unsigned</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + An unsigned integer type with the same width as the enum. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">wchar_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + An unsigned integer type with the same width as wchar_t. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.promote"> + <title><link linkend="boost_typetraits.reference.promote"> promote</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">promote</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If integral or floating point promotion + can be applied to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + then applies integral and floating point promotions to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + See also <link linkend="boost_typetraits.reference.integral_promotion">integral_promotion</link> + and <link linkend="boost_typetraits.reference.floating_point_promotion">floating_point_promotion</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.5 except 4.5/3 + (integral bit-field) and 4.6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">promote</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.rank"> + <title><link linkend="boost_typetraits.reference.rank"> rank</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">rank</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template rank inherits from + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> is the + number of array dimensions in type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not an array type, + then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> is zero. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">rank</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[]></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>1</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>2</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.remove_all_extents"> + <title><link linkend="boost_typetraits.reference.remove_all_extents"> remove_all_extents</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_all_extents</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is an array type, then removes all of the array bounds on <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.4. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_all_extents</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_const"> + <title><link linkend="boost_typetraits.reference.remove_const"> remove_const</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> const-qualifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_cv"> + <title><link linkend="boost_typetraits.reference.remove_cv"> remove_cv</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_cv</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> cv-qualifiers removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_cv</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_extent"> + <title><link linkend="boost_typetraits.reference.remove_extent"> remove_extent</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_extent</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is an array type, then removes the topmost array bound, otherwise leaves + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.4. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_extent</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_pointer"> + <title><link linkend="boost_typetraits.reference.remove_pointer"> remove_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_pointer</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any pointer modifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.1. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">**>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_reference"> + <title><link linkend="boost_typetraits.reference.remove_reference"> remove_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_reference</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any reference modifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_volatile"> + <title><link linkend="boost_typetraits.reference.remove_volatile"> remove_volatile</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> volatile-qualifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.type_with_alignment"> + <title><link linkend="boost_typetraits.reference.type_with_alignment"> type_with_alignment</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">type_with_alignment</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> a built-in or POD type with an alignment + that is a multiple of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Align</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">type_with_alignment</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + </section> + <section id="boost_typetraits.credits"> + <title><link linkend="boost_typetraits.credits"> Credits</link></title> + <para> + This documentation was pulled together by John Maddock, using <ulink url="../../../../doc/html/quickbook.html">Boost.Quickbook</ulink> + and <ulink url="../../../../doc/html/boostbook.html">Boost.DocBook</ulink>. + </para> + <para> + The original version of this library was created by Steve Cleary, Beman Dawes, + Howard Hinnant, and John Maddock. John Maddock is the current maintainer of + the library. + </para> + <para> + This version of type traits library is based on contributions by Adobe Systems + Inc, David Abrahams, Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, + Jesse Jones, Mat Marcus, Itay Maman, John Maddock, Thorsten Ottosen, Robert + Ramey and Jeremy Siek. + </para> + <para> + Mat Marcus and Jesse Jones invented, and <ulink url="http://opensource.adobe.com/project4/project.shtml">published + a paper describing</ulink>, the partial specialization workarounds used in + this library. + </para> + <para> + Aleksey Gurtovoy added MPL integration to the library. + </para> + <para> + The <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link> + template is based on code originally devised by Andrei Alexandrescu, see "<ulink url="http://www.cuj.com/experts/1810/alexandr.htm?topic=experts">Generic<Programming>: + Mappings between Types and Values</ulink>". + </para> + <para> + The latest version of this library and documentation can be found at <ulink url="http://www.boost.org">www.boost.org</ulink>. Bugs, suggestions and discussion + should be directed to boost@lists.boost.org (see <ulink url="http://www.boost.org/more/mailing_lists.htm#main">www.boost.org/more/mailing_lists.htm#main</ulink> + for subscription details). + </para> + </section> + + <section id="boost_typetraits.ignored_section"> + <title>This section must not be indexed.</title> + <?BoostAutoIndex IgnoreSection?> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + </section> + + <section id="boost_typetraits.ignored_block"> + <title>This section contains one block that must not be indexed and one that should be.</title> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword"> + <?BoostAutoIndex IgnoreBlock?> + template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword"> + template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + </section> + + + <index> + <title>Class Index</title> + <para><link linkend="idx_id_0">A</link> <link linkend="idx_id_2">C</link> <link linkend="idx_id_3">D</link> <link linkend="idx_id_4">E</link> <link linkend="idx_id_5">F</link> <link linkend="idx_id_6">H</link> <link linkend="idx_id_7">I</link> <link linkend="idx_id_8">M</link> <link linkend="idx_id_9">O</link> <link linkend="idx_id_10">P</link> <link linkend="idx_id_11">R</link> <link linkend="idx_id_13">T</link></para><variablelist><varlistentry id="idx_id_0"><term>A</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-0">add_const</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_cv"><phrase role="index-entry-level-0">add_cv</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_pointer"><phrase role="index-entry-level-0">add_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_reference"><phrase role="index-entry-level-0">add_reference</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">add_volatile</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.add_volatile"><phrase role="index-entry-level-1">add_volatile</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.ignored_block"><phrase role="index-entry-level-1">This section contains one block that must not be indexed and one that should be.</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.aligned_storage"><phrase role="index-entry-level-0">aligned_storage</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.alignment_of"><phrase role="index-entry-level-0">alignment_of</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_2"><term>C</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">Constrained Index Term</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-1">add_const</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_3"><term>D</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.decay"><phrase role="index-entry-level-0">decay</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_4"><term>E</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.extent"><phrase role="index-entry-level-0">extent</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_5"><term>F</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.floating_point_promotion"><phrase role="index-entry-level-0">floating_point_promotion</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.function_traits"><phrase role="index-entry-level-0">function_traits</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_6"><term>H</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_assign"><phrase role="index-entry-level-0">has_nothrow_assign</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_constructor"><phrase role="index-entry-level-0">has_nothrow_constructor</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_copy"><phrase role="index-entry-level-0">has_nothrow_copy</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_copy_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_copy"><phrase role="index-entry-level-1">has_nothrow_copy</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_default_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_constructor"><phrase role="index-entry-level-1">has_nothrow_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_assign"><phrase role="index-entry-level-0">has_trivial_assign</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_copy"><phrase role="index-entry-level-0">has_trivial_copy</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_copy_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_trivial_copy"><phrase role="index-entry-level-1">has_trivial_copy</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_default_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_trivial_constructor"><phrase role="index-entry-level-1">has_trivial_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_destructor"><phrase role="index-entry-level-0">has_trivial_destructor</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_virtual_destructor"><phrase role="index-entry-level-0">has_virtual_destructor</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_7"><term>I</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">integral_constant</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.alignment_of"><phrase role="index-entry-level-1">alignment_of</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.extent"><phrase role="index-entry-level-1">extent</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.rank"><phrase role="index-entry-level-1">rank</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_promotion"><phrase role="index-entry-level-0">integral_promotion</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_abstract"><phrase role="index-entry-level-0">is_abstract</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_arithmetic"><phrase role="index-entry-level-0">is_arithmetic</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_array"><phrase role="index-entry-level-0">is_array</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_base_of"><phrase role="index-entry-level-0">is_base_of</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_class</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_class"><phrase role="index-entry-level-1">is_class</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">User Defined Specializations</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_complex"><phrase role="index-entry-level-0">is_complex</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_compound"><phrase role="index-entry-level-0">is_compound</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_const"><phrase role="index-entry-level-0">is_const</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_convertible"><phrase role="index-entry-level-0">is_convertible</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_empty"><phrase role="index-entry-level-0">is_empty</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_enum"><phrase role="index-entry-level-0">is_enum</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_floating_point"><phrase role="index-entry-level-0">is_floating_point</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_function"><phrase role="index-entry-level-0">is_function</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_fundamental"><phrase role="index-entry-level-0">is_fundamental</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_integral"><phrase role="index-entry-level-0">is_integral</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_function_pointer"><phrase role="index-entry-level-0">is_member_function_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_object_pointer"><phrase role="index-entry-level-0">is_member_object_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_pointer"><phrase role="index-entry-level-0">is_member_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_object"><phrase role="index-entry-level-0">is_object</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_pointer</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_pointer"><phrase role="index-entry-level-1">is_pointer</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_polymorphic"><phrase role="index-entry-level-0">is_polymorphic</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_reference"><phrase role="index-entry-level-0">is_reference</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_same"><phrase role="index-entry-level-0">is_same</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_scalar"><phrase role="index-entry-level-0">is_scalar</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_signed"><phrase role="index-entry-level-0">is_signed</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_union</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_union"><phrase role="index-entry-level-1">is_union</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">User Defined Specializations</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_unsigned"><phrase role="index-entry-level-0">is_unsigned</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_void</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_void"><phrase role="index-entry-level-1">is_void</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_volatile"><phrase role="index-entry-level-0">is_volatile</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_8"><term>M</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.make_signed"><phrase role="index-entry-level-0">make_signed</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.make_unsigned"><phrase role="index-entry-level-0">make_unsigned</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_9"><term>O</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">one</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_volatile"><phrase role="index-entry-level-1">add_volatile</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-1">two</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-2">add_const</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-2">three</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_cv"><phrase role="index-entry-level-3">add_cv</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_10"><term>P</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.promote"><phrase role="index-entry-level-0">promote</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_11"><term>R</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.remove_all_extents"><phrase role="index-entry-level-0">remove_all_extents</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_const"><phrase role="index-entry-level-0">remove_const</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_cv"><phrase role="index-entry-level-0">remove_cv</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">remove_extent</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.remove_extent"><phrase role="index-entry-level-1">remove_extent</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_pointer"><phrase role="index-entry-level-0">remove_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_reference"><phrase role="index-entry-level-0">remove_reference</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_volatile"><phrase role="index-entry-level-0">remove_volatile</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_13"><term>T</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.type_with_alignment"><phrase role="index-entry-level-0">type_with_alignment</phrase></link></para></listitem></itemizedlist></listitem></varlistentry></variablelist></index> + <index> + <title>Typedef Index</title> + <para><link linkend="idx_id_21">F</link> <link linkend="idx_id_27">R</link> <link linkend="idx_id_29">T</link> <link linkend="idx_id_31">V</link></para><variablelist><varlistentry id="idx_id_21"><term>F</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">false_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_27"><term>R</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">result_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.function_traits"><phrase role="index-entry-level-1">function_traits</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_29"><term>T</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">true_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_31"><term>V</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">value_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.examples.copy"><phrase role="index-entry-level-1">An Optimized Version of std::copy</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry></variablelist></index> + <index> + <title>Macro Index</title> + <para><link linkend="idx_id_33">B</link></para><variablelist><varlistentry id="idx_id_33"><term>B</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">BOOST_ALIGNMENT_OF</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.category.transform"><phrase role="index-entry-level-1">Type Traits that Transform One Type to Another</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_ASSIGN</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_CONSTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_COPY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_ASSIGN</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_CONSTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_COPY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_DESTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_VIRTUAL_DESTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_ABSTRACT</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_BASE_OF</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_CLASS</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_CONVERTIBLE</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_EMPTY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_ENUM</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_POD</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_POLYMORPHIC</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_UNION</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry></variablelist></index> + <index> + <title>Index Test 1</title> + <para><link linkend="idx_id_61">T</link></para><variablelist><varlistentry id="idx_id_61"><term>T</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">type-traits</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intro"><phrase role="index-entry-level-1">Introduction</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry></variablelist></index> + <index> + <title>Index Test 2</title> + <para><link linkend="idx_id_77">T</link></para><variablelist><varlistentry id="idx_id_77"><term>T</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">type-traits</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry></variablelist></index> + <index><title>Index</title><para><link linkend="idx_id_80">A</link> <link linkend="idx_id_81">B</link> <link linkend="idx_id_82">C</link> <link linkend="idx_id_83">D</link> <link linkend="idx_id_84">E</link> <link linkend="idx_id_85">F</link> <link linkend="idx_id_86">H</link> <link linkend="idx_id_87">I</link> <link linkend="idx_id_88">M</link> <link linkend="idx_id_89">O</link> <link linkend="idx_id_90">P</link> <link linkend="idx_id_91">R</link> <link linkend="idx_id_92">S</link> <link linkend="idx_id_93">T</link> <link linkend="idx_id_94">U</link> <link linkend="idx_id_95">V</link></para><variablelist><varlistentry id="idx_id_80"><term>A</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">add_const</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-1">add_const</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-1">Constrained Index Term</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.add_cv"><phrase role="index-entry-level-0">add_cv</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_pointer"><phrase role="index-entry-level-0">add_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.add_reference"><phrase role="index-entry-level-0">add_reference</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">add_volatile</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.add_volatile"><phrase role="index-entry-level-1">add_volatile</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.ignored_block"><phrase role="index-entry-level-1">This section contains one block that must not be indexed and one that should be.</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.aligned_storage"><phrase role="index-entry-level-0">aligned_storage</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">alignment_of</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.alignment_of"><phrase role="index-entry-level-1">alignment_of</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.alignment_of"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_81"><term>B</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">Background and Tutorial</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">is_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">is_void</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">remove_extent</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">type-traits</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_ALIGNMENT_OF</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.category.transform"><phrase role="index-entry-level-1">Type Traits that Transform One Type to Another</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_ASSIGN</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_CONSTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_NOTHROW_COPY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_ASSIGN</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_CONSTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_COPY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_TRIVIAL_DESTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_HAS_VIRTUAL_DESTRUCTOR</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_ABSTRACT</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_BASE_OF</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_CLASS</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_CONVERTIBLE</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_EMPTY</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_ENUM</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_POD</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_POLYMORPHIC</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">BOOST_IS_UNION</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">Support for Compiler Intrinsics</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_82"><term>C</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">Constrained Index Term</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-1">add_const</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_83"><term>D</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.decay"><phrase role="index-entry-level-0">decay</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_84"><term>E</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">extent</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.extent"><phrase role="index-entry-level-1">extent</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.extent"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_85"><term>F</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">false_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.floating_point_promotion"><phrase role="index-entry-level-0">floating_point_promotion</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">Foo1</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">Foo2</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-1">Bar2</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.category.value_traits"><phrase role="index-entry-level-2">Type Traits that Describe the Properties of a Type</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">function_traits</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.function_traits"><phrase role="index-entry-level-1">function_traits</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.function_traits"><phrase role="index-entry-level-1">result_type</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_86"><term>H</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_assign"><phrase role="index-entry-level-0">has_nothrow_assign</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.has_nothrow_constructor"><phrase role="index-entry-level-1">has_nothrow_constructor</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_constructor"><phrase role="index-entry-level-1">has_nothrow_default_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_copy</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.has_nothrow_copy"><phrase role="index-entry-level-1">has_nothrow_copy</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_copy"><phrase role="index-entry-level-1">has_nothrow_copy_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_copy_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_copy"><phrase role="index-entry-level-1">has_nothrow_copy</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_nothrow_default_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_nothrow_constructor"><phrase role="index-entry-level-1">has_nothrow_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_assign"><phrase role="index-entry-level-0">has_trivial_assign</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_trivial_constructor"><phrase role="index-entry-level-1">has_trivial_default_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_copy</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.has_trivial_copy"><phrase role="index-entry-level-1">has_trivial_copy</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_copy"><phrase role="index-entry-level-1">has_trivial_copy_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_copy_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_trivial_copy"><phrase role="index-entry-level-1">has_trivial_copy</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">has_trivial_default_constructor</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.has_trivial_constructor"><phrase role="index-entry-level-1">has_trivial_constructor</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.has_trivial_destructor"><phrase role="index-entry-level-0">has_trivial_destructor</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.has_virtual_destructor"><phrase role="index-entry-level-0">has_virtual_destructor</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_87"><term>I</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">integral_constant</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.alignment_of"><phrase role="index-entry-level-1">alignment_of</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.extent"><phrase role="index-entry-level-1">extent</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">false_type</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.reference.rank"><phrase role="index-entry-level-1">rank</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">true_type</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">value_type</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_promotion"><phrase role="index-entry-level-0">integral_promotion</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">Introduction</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intro"><phrase role="index-entry-level-1">type-traits</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_abstract"><phrase role="index-entry-level-0">is_abstract</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_arithmetic"><phrase role="index-entry-level-0">is_arithmetic</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_array"><phrase role="index-entry-level-0">is_array</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_base_of"><phrase role="index-entry-level-0">is_base_of</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_class</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_class"><phrase role="index-entry-level-1">is_class</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">User Defined Specializations</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_complex"><phrase role="index-entry-level-0">is_complex</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_compound"><phrase role="index-entry-level-0">is_compound</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_const"><phrase role="index-entry-level-0">is_const</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_convertible"><phrase role="index-entry-level-0">is_convertible</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_empty"><phrase role="index-entry-level-0">is_empty</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_enum"><phrase role="index-entry-level-0">is_enum</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_floating_point"><phrase role="index-entry-level-0">is_floating_point</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_function"><phrase role="index-entry-level-0">is_function</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_fundamental"><phrase role="index-entry-level-0">is_fundamental</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_integral"><phrase role="index-entry-level-0">is_integral</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_function_pointer"><phrase role="index-entry-level-0">is_member_function_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_object_pointer"><phrase role="index-entry-level-0">is_member_object_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_member_pointer"><phrase role="index-entry-level-0">is_member_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_object"><phrase role="index-entry-level-0">is_object</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_pointer</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_pointer"><phrase role="index-entry-level-1">is_pointer</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_polymorphic"><phrase role="index-entry-level-0">is_polymorphic</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_reference"><phrase role="index-entry-level-0">is_reference</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_same"><phrase role="index-entry-level-0">is_same</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_scalar"><phrase role="index-entry-level-0">is_scalar</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.is_signed"><phrase role="index-entry-level-0">is_signed</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_union</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_union"><phrase role="index-entry-level-1">is_union</phrase></link></emphasis></para></listitem><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">User Defined Specializations</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_unsigned"><phrase role="index-entry-level-0">is_unsigned</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">is_void</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.is_void"><phrase role="index-entry-level-1">is_void</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.is_volatile"><phrase role="index-entry-level-0">is_volatile</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_88"><term>M</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.make_signed"><phrase role="index-entry-level-0">make_signed</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.make_unsigned"><phrase role="index-entry-level-0">make_unsigned</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_89"><term>O</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">one</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_volatile"><phrase role="index-entry-level-1">add_volatile</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-1">two</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_const"><phrase role="index-entry-level-2">add_const</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-2">three</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.add_cv"><phrase role="index-entry-level-3">add_cv</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">Optimized Version of std::copy</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.examples.copy"><phrase role="index-entry-level-1">value_type</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_90"><term>P</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.promote"><phrase role="index-entry-level-0">promote</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_91"><term>R</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">rank</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.rank"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_all_extents"><phrase role="index-entry-level-0">remove_all_extents</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_const"><phrase role="index-entry-level-0">remove_const</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_cv"><phrase role="index-entry-level-0">remove_cv</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">remove_extent</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><emphasis role="bold"><link linkend="boost_typetraits.reference.remove_extent"><phrase role="index-entry-level-1">remove_extent</phrase></link></emphasis></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_pointer"><phrase role="index-entry-level-0">remove_pointer</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_reference"><phrase role="index-entry-level-0">remove_reference</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.remove_volatile"><phrase role="index-entry-level-0">remove_volatile</phrase></link></para></listitem><listitem><para><phrase role="index-entry-level-0">result_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.function_traits"><phrase role="index-entry-level-1">function_traits</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_92"><term>S</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">Support for Compiler Intrinsics</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_ALIGNMENT_OF</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_NOTHROW_ASSIGN</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_NOTHROW_CONSTRUCTOR</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_NOTHROW_COPY</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_TRIVIAL_ASSIGN</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_TRIVIAL_CONSTRUCTOR</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_TRIVIAL_COPY</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_TRIVIAL_DESTRUCTOR</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_HAS_VIRTUAL_DESTRUCTOR</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_ABSTRACT</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_BASE_OF</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_CLASS</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_CONVERTIBLE</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_EMPTY</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_ENUM</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_POD</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_POLYMORPHIC</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intrinsics"><phrase role="index-entry-level-1">BOOST_IS_UNION</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_93"><term>T</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">This section contains one block that must not be indexed and one that should be.</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.ignored_block"><phrase role="index-entry-level-1">add_volatile</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">true_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">Type Traits that Transform One Type to Another</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.category.transform"><phrase role="index-entry-level-1">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><phrase role="index-entry-level-0">type-traits</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.background"><phrase role="index-entry-level-1">Background and Tutorial</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.intro"><phrase role="index-entry-level-1">Introduction</phrase></link></para></listitem></itemizedlist></listitem><listitem><para><link linkend="boost_typetraits.reference.type_with_alignment"><phrase role="index-entry-level-0">type_with_alignment</phrase></link></para></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_94"><term>U</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">User Defined Specializations</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">is_class</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.user_defined"><phrase role="index-entry-level-1">is_union</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry><varlistentry id="idx_id_95"><term>V</term><listitem><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><phrase role="index-entry-level-0">value_type</phrase></para><itemizedlist mark="none" spacing="compact" role="index"><listitem><para><link linkend="boost_typetraits.examples.copy"><phrase role="index-entry-level-1">An Optimized Version of std::copy</phrase></link></para></listitem><listitem><para><link linkend="boost_typetraits.reference.integral_constant"><phrase role="index-entry-level-1">integral_constant</phrase></link></para></listitem></itemizedlist></listitem></itemizedlist></listitem></varlistentry></variablelist></index> + +</chapter>
\ No newline at end of file diff --git a/src/boost/tools/auto_index/test/type_traits.docbook b/src/boost/tools/auto_index/test/type_traits.docbook new file mode 100644 index 000000000..64837d71a --- /dev/null +++ b/src/boost/tools/auto_index/test/type_traits.docbook @@ -0,0 +1,6673 @@ +<?xml version="1.0"?> +<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> + +<!-- + +This file is based upon the type traits docs, but has had additional XML elements added to it +to ensure complete testing. + +--> + +<chapter xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" id="boost_typetraits" rev:last-revision="$Date: 2008-11-28 12:41:45 +0000 (Fri, 28 Nov 2008) $"> + <chapterinfo><author> + <firstname>various</firstname> <surname>authors</surname> + </author><copyright> + <year>2000</year> <year>2006</year> <holder>Adobe Systems Inc, David Abrahams, + Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat + Marcus, Itay Maman, John Maddock, Alexander Nasonov, Thorsten Ottosen, Robert + Ramey and Jeremy Siek</holder> + </copyright><legalnotice> + <para> + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</ulink>) + </para> + </legalnotice></chapterinfo> + <title>Boost.TypeTraits</title> + <para> + A printer-friendly <ulink url="http://svn.boost.org/svn/boost/sandbox/pdf/type_traits/release/type_traits.pdf">PDF + version of this manual is also available</ulink>. + </para> + <section id="boost_typetraits.intro"> + <title><link linkend="boost_typetraits.intro"> Introduction</link></title> + <para> + The Boost type-traits library contains a set of very specific traits classes, + each of which encapsulate a single trait from the C++ type system; for example, + is a type a pointer or a reference type? Or does a type have a trivial constructor, + or a const-qualifier? + </para> + <para> + The type-traits classes share a unified design: each class inherits from a + the type <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the type has the specified property and inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link> + otherwise. + </para> + <para> + The type-traits library also contains a set of classes that perform a specific + transformation on a type; for example, they can remove a top-level const or + volatile qualifier from a type. Each class that performs a transformation defines + a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of the transformation. + </para> + </section> + <section id="boost_typetraits.background"> + <title><link linkend="boost_typetraits.background"> Background and Tutorial</link></title> + <para> + The following is an updated version of the article "C++ Type traits" + by John Maddock and Steve Cleary that appeared in the October 2000 issue of + <ulink url="http://www.ddj.com">Dr Dobb's Journal</ulink>. + </para> + <para> + Generic programming (writing code which works with any data type meeting a + set of requirements) has become the method of choice for providing reusable + code. However, there are times in generic programming when "generic" + just isn't good enough - sometimes the differences between types are too large + for an efficient generic implementation. This is when the traits technique + becomes important - by encapsulating those properties that need to be considered + on a type by type basis inside a traits class, we can minimize the amount of + code that has to differ from one type to another, and maximize the amount of + generic code. + </para> + <?dbfo keep-together="auto" ?> + <para> + <indexterm> + <primary>Foo1</primary> + </indexterm> + Consider an example: when working with character strings, one common operation + is to determine the length of a null terminated string. Clearly it's possible + to write generic code that can do this, but it turns out that there are much + more efficient methods available: for example, the C library functions <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">strlen</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">wcslen</phrase></computeroutput> + are usually written in assembler, and with suitable hardware support can be + considerably faster than a generic version written in C++. The authors of the + C++ standard library realized this, and abstracted the properties of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">wchar_t</phrase></computeroutput> + into the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput>. + Generic code that works with character strings can simply use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase><phrase role="special"><>::</phrase><phrase role="identifier">length</phrase></computeroutput> to determine the length of a null + terminated string, safe in the knowledge that specializations of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput> will use the most appropriate + method available to them. + </para> + <anchor id="boost_typetraits.background.type_traits"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.type_traits">Type Traits</link> + </bridgehead> + <para> + Class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">char_traits</phrase></computeroutput> is a classic + example of a collection of type specific properties wrapped up in a single + class - what Nathan Myers termed a <emphasis>baggage class</emphasis><link linkend="background.references">[1]</link>. In the Boost type-traits library, + we<link linkend="background.references">[2]</link> have written a set of very + specific traits classes, each of which encapsulate a single trait from the + C++ type system; for example, is a type a pointer or a reference type? Or does + a type have a trivial constructor, or a const-qualifier? The type-traits classes + share a unified design: each class inherits from a the type <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the type has the specified property and inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link> + otherwise. As we will show, these classes can be used in generic programming + to determine the properties of a given type and introduce optimizations that + are appropriate for that case. + </para> + <para> + The type-traits library also contains a set of classes that perform a specific + transformation on a type; for example, they can remove a top-level const or + volatile qualifier from a type. Each class that performs a transformation defines + a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of the transformation. All of the type-traits classes are + defined inside namespace <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase></computeroutput>; + for brevity, namespace-qualification is omitted in most of the code samples + given. + </para> + <anchor id="boost_typetraits.background.implementation"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.implementation">Implementation</link> + </bridgehead> + <para> + There are far too many separate classes contained in the type-traits library + to give a full implementation here - see the source code in the Boost library + for the full details - however, most of the implementation is fairly repetitive + anyway, so here we will just give you a flavor for how some of the classes + are implemented. Beginning with possibly the simplest class in the library, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput> inherits + from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + only if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> +</programlisting> + <para> + Here we define a primary version of the template class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_void">is_void</link></computeroutput>, + and provide a full-specialization when <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. While full specialization + of a template class is an important technique, sometimes we need a solution + that is halfway between a fully generic solution, and a full specialization. + This is exactly the situation for which the standards committee defined partial + template-class specialization. As an example, consider the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput>: + here we needed a primary version that handles all the cases where T is not + a pointer, and a partial specialization to handle all the cases where T is + a pointer: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">*></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> +</programlisting> + <para> + The syntax for partial specialization is somewhat arcane and could easily occupy + an article in its own right; like full specialization, in order to write a + partial specialization for a class, you must first declare the primary template. + The partial specialization contains an extra <...> after the class name + that contains the partial specialization parameters; these define the types + that will bind to that partial specialization rather than the default template. + The rules for what can appear in a partial specialization are somewhat convoluted, + but as a rule of thumb if you can legally write two function overloads of the + form: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">);</phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">foo</phrase><phrase role="special">(</phrase><phrase role="identifier">U</phrase><phrase role="special">);</phrase> +</programlisting> + <para> + Then you can also write a partial specialization of the form: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">class</phrase> <phrase role="identifier">c</phrase><phrase role="special">{</phrase> <phrase role="comment">/*details*/</phrase> <phrase role="special">};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">class</phrase> <phrase role="identifier">c</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">>{</phrase> <phrase role="comment">/*details*/</phrase> <phrase role="special">};</phrase> +</programlisting> + <para> + This rule is by no means foolproof, but it is reasonably simple to remember + and close enough to the actual rule to be useful for everyday use. + </para> + <para> + As a more complex example of partial specialization consider the class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">></phrase></computeroutput>. This + class defines a single typedef-member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the same type as T but with any top-level array bounds removed; this + is an example of a traits class that performs a transformation on a type: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link> +<phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">[</phrase><phrase role="identifier">N</phrase><phrase role="special">]></phrase> +<phrase role="special">{</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase> +</programlisting> + <para> + The aim of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.remove_extent">remove_extent</link></computeroutput> + is this: imagine a generic algorithm that is passed an array type as a template + parameter, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.remove_extent">remove_extent</link></computeroutput> + provides a means of determining the underlying type of the array. For example + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">][</phrase><phrase role="number">5</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> would evaluate to the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">5</phrase><phrase role="special">]</phrase></computeroutput>. This example also shows that the number of + template parameters in a partial specialization does not have to match the + number in the default template. However, the number of parameters that appear + after the class name do have to match the number and type of the parameters + in the default template. + </para> + <anchor id="boost_typetraits.background.optimized_copy"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.optimized_copy">Optimized copy</link> + </bridgehead> + <para> + As an example of how the type traits classes can be used, consider the standard + library algorithm copy: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">Iter1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">Iter2</phrase><phrase role="special">></phrase> +<phrase role="identifier">Iter2</phrase> <phrase role="identifier">copy</phrase><phrase role="special">(</phrase><phrase role="identifier">Iter1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">Iter2</phrase> <phrase role="identifier">out</phrase><phrase role="special">);</phrase> +</programlisting> + <para> + Obviously, there's no problem writing a generic version of copy that works + for all iterator types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput>; however, there are + some circumstances when the copy operation can best be performed by a call + to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. In order to implement + copy in terms of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> all + of the following conditions need to be met: + </para> + <itemizedlist> + <listitem> + Both of the iterator types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput> must be pointers. + </listitem> + <listitem> + Both <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter2</phrase></computeroutput> must point to the same type - excluding + const and volatile-qualifiers. + </listitem> + <listitem> + The type pointed to by <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Iter1</phrase></computeroutput> + must have a trivial assignment operator. + </listitem> + </itemizedlist> + <para> + By trivial assignment operator we mean that the type is either a scalar type<link linkend="background.references">[3]</link> or: + </para> + <itemizedlist> + <listitem> + The type has no user defined assignment operator. + </listitem> + <listitem> + The type does not have any data members that are references. + </listitem> + <listitem> + All base classes, and all data member objects must have trivial assignment + operators. + </listitem> + </itemizedlist> + <para> + If all these conditions are met then a type can be copied using <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> rather than using a compiler generated + assignment operator. The type-traits library provides a class <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput>, + such that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is true only if T has a trivial assignment + operator. This class "just works" for scalar types, but has to be + explicitly specialised for class/struct types that also happen to have a trivial + assignment operator. In other words if <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link> + gives the wrong answer, it will give the "safe" wrong answer - that + trivial assignment is not allowable. + </para> + <para> + The code for an optimized version of copy that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> + where appropriate is given in <link linkend="boost_typetraits.examples.copy">the + examples</link>. The code begins by defining a template function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">do_copy</phrase></computeroutput> that performs a "slow but safe" + copy. The last parameter passed to this function may be either a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + or a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">false_type</link></computeroutput>. + Following that there is an overload of do<emphasis role="underline">copy that + uses `memcpy`: this time the iterators are required to actually be pointers + to the same type, and the final parameter must be a `</emphasis>_true_type<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">.</phrase> <phrase role="identifier">Finally</phrase><phrase role="special">,</phrase> <phrase role="identifier">the</phrase> <phrase role="identifier">version</phrase> + <phrase role="identifier">of</phrase> </computeroutput>copy<computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="identifier">calls</phrase> + </computeroutput>do<emphasis role="underline">copy`, passing `</emphasis>_has_trivial_assign<value_type>()` + as the final parameter: this will dispatch to the optimized version where appropriate, + otherwise it will call the "slow but safe version". + </para> + <anchor id="boost_typetraits.background.was_it_worth_it_"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.was_it_worth_it_">Was it worth it?</link> + </bridgehead> + <para> + It has often been repeated in these columns that "premature optimization + is the root of all evil" <link linkend="background.references">[4]</link>. + So the question must be asked: was our optimization premature? To put this + in perspective the timings for our version of copy compared a conventional + generic copy<link linkend="background.references">[5]</link> are shown in table + 1. + </para> + <para> + Clearly the optimization makes a difference in this case; but, to be fair, + the timings are loaded to exclude cache miss effects - without this accurate + comparison between algorithms becomes difficult. However, perhaps we can add + a couple of caveats to the premature optimization rule: + </para> + <itemizedlist> + <listitem> + If you use the right algorithm for the job in the first place then optimization + will not be required; in some cases, memcpy is the right algorithm. + </listitem> + <listitem> + If a component is going to be reused in many places by many people then optimizations + may well be worthwhile where they would not be so for a single case - in + other words, the likelihood that the optimization will be absolutely necessary + somewhere, sometime is that much higher. Just as importantly the perceived + value of the stock implementation will be higher: there is no point standardizing + an algorithm if users reject it on the grounds that there are better, more + heavily optimized versions available. + </listitem> + </itemizedlist> + <table frame="all"> <title>Time taken to copy 1000 elements using `copy<const + T*, T*>` (times in micro-seconds)</title> + <tgroup cols="3"> + <thead> + <row> + <entry> + <para> + Version + </para> + </entry><entry> + <para> + T + </para> + </entry><entry> + <para> + Time + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + "Optimized" copy + </para> + </entry><entry> + <para> + char + </para> + </entry><entry> + <para> + 0.99 + </para> + </entry> + </row> + <row> + <entry> + <para> + Conventional copy + </para> + </entry><entry> + <para> + char + </para> + </entry><entry> + <para> + 8.07 + </para> + </entry> + </row> + <row> + <entry> + <para> + "Optimized" copy + </para> + </entry><entry> + <para> + int + </para> + </entry><entry> + <para> + 2.52 + </para> + </entry> + </row> + <row> + <entry> + <para> + Conventional copy + </para> + </entry><entry> + <para> + int + </para> + </entry><entry> + <para> + 8.02 + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> <anchor id="boost_typetraits.background.pair_of_references"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.pair_of_references">Pair of References</link> + </bridgehead> + <para> + The optimized copy example shows how type traits may be used to perform optimization + decisions at compile-time. Another important usage of type traits is to allow + code to compile that otherwise would not do so unless excessive partial specialization + is used. This is possible by delegating partial specialization to the type + traits classes. Our example for this form of usage is a pair that can hold + references <link linkend="background.references">[6]</link>. + </para> + <para> + First, let us examine the definition of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase></computeroutput>, omitting + the comparison operators, default constructor, and template copy constructor + for simplicity: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T2</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">pair</phrase> +<phrase role="special">{</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T1</phrase> <phrase role="identifier">first_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T2</phrase> <phrase role="identifier">second_type</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">T1</phrase> <phrase role="identifier">first</phrase><phrase role="special">;</phrase> +<phrase role="identifier">T2</phrase> <phrase role="identifier">second</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">pair</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase> <phrase role="special">&</phrase> <phrase role="identifier">nfirst</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T2</phrase> <phrase role="special">&</phrase> <phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> +<phrase role="special">:</phrase><phrase role="identifier">first</phrase><phrase role="special">(</phrase><phrase role="identifier">nfirst</phrase><phrase role="special">),</phrase> <phrase role="identifier">second</phrase><phrase role="special">(</phrase><phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + Now, this "pair" cannot hold references as it currently stands, because + the constructor would require taking a reference to a reference, which is currently + illegal <link linkend="background.references">[7]</link>. Let us consider what + the constructor's parameters would have to be in order to allow "pair" + to hold non-reference types, references, and constant references: + </para> + <table frame="all"> <title>Required Constructor Argument Types</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of parameter to initializing constructor + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + T + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + <row> + <entry> + <para> + T & + </para> + </entry><entry> + <para> + T & + </para> + </entry> + </row> + <row> + <entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + <para> + A little familiarity with the type traits classes allows us to construct a + single mapping that allows us to determine the type of parameter from the type + of the contained class. The type traits classes provide a transformation <link linkend="boost_typetraits.reference.add_reference">add_reference</link>, which + adds a reference to its type, unless it is already a reference. + </para> + <table frame="all"> <title>Using add_reference to synthesize the correct constructor + type</title> + <tgroup cols="3"> + <thead> + <row> + <entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase></computeroutput> + </para> + </entry><entry> + <para> + Type of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + T + </para> + </entry><entry> + <para> + const T + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + <row> + <entry> + <para> + T & + </para> + </entry><entry> + <para> + T & [8] + </para> + </entry><entry> + <para> + T & + </para> + </entry> + </row> + <row> + <entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry><entry> + <para> + const T & + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + <para> + This allows us to build a primary template definition for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput> + that can contain non-reference types, reference types, and constant reference + types: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T2</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">pair</phrase> +<phrase role="special">{</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T1</phrase> <phrase role="identifier">first_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">T2</phrase> <phrase role="identifier">second_type</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">T1</phrase> <phrase role="identifier">first</phrase><phrase role="special">;</phrase> +<phrase role="identifier">T2</phrase> <phrase role="identifier">second</phrase><phrase role="special">;</phrase> + +<phrase role="identifier">pair</phrase><phrase role="special">(</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">nfirst</phrase><phrase role="special">,</phrase> + <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T2</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> +<phrase role="special">:</phrase><phrase role="identifier">first</phrase><phrase role="special">(</phrase><phrase role="identifier">nfirst</phrase><phrase role="special">),</phrase> <phrase role="identifier">second</phrase><phrase role="special">(</phrase><phrase role="identifier">nsecond</phrase><phrase role="special">)</phrase> <phrase role="special">{</phrase> <phrase role="special">}</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + Add back in the standard comparison operators, default constructor, and template + copy constructor (which are all the same), and you have a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase></computeroutput> that + can hold reference types! + </para> + <para> + This same extension could have been done using partial template specialization + of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput>, but to specialize + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">pair</phrase></computeroutput> in this way would require + three partial specializations, plus the primary template. Type traits allows + us to define a single primary template that adjusts itself auto-magically to + any of these partial specializations, instead of a brute-force partial specialization + approach. Using type traits in this fashion allows programmers to delegate + partial specialization to the type traits classes, resulting in code that is + easier to maintain and easier to understand. + </para> + <anchor id="boost_typetraits.background.conclusion"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.conclusion">Conclusion</link> + </bridgehead> + <para> + We hope that in this article we have been able to give you some idea of what + type-traits are all about. A more complete listing of the available classes + are in the boost documentation, along with further examples using type traits. + Templates have enabled C++ uses to take the advantage of the code reuse that + generic programming brings; hopefully this article has shown that generic programming + does not have to sink to the lowest common denominator, and that templates + can be optimal as well as generic. + </para> + <anchor id="boost_typetraits.background.acknowledgements"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.acknowledgements">Acknowledgements</link> + </bridgehead> + <para> + The authors would like to thank Beman Dawes and Howard Hinnant for their helpful + comments when preparing this article. + </para> + <anchor id="background.references"/> <anchor id="boost_typetraits.background.references"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.background.references">References</link> + </bridgehead> + <orderedlist inheritnum="ignore" continuation="restarts"> + <listitem> + Nathan C. Myers, C++ Report, June 1995. + </listitem> + <listitem> + The type traits library is based upon contributions by Steve Cleary, Beman + Dawes, Howard Hinnant and John Maddock: it can be found at www.boost.org. + </listitem> + <listitem> + A scalar type is an arithmetic type (i.e. a built-in integer or floating + point type), an enumeration type, a pointer, a pointer to member, or a const- + or volatile-qualified version of one of these types. + </listitem> + <listitem> + This quote is from Donald Knuth, ACM Computing Surveys, December 1974, pg + 268. + </listitem> + <listitem> + The test code is available as part of the boost utility library (see algo_opt_examples.cpp), + the code was compiled with gcc 2.95 with all optimisations turned on, tests + were conducted on a 400MHz Pentium II machine running Microsoft Windows 98. + </listitem> + <listitem> + John Maddock and Howard Hinnant have submitted a "compressed_pair" + library to Boost, which uses a technique similar to the one described here + to hold references. Their pair also uses type traits to determine if any + of the types are empty, and will derive instead of contain to conserve space + -- hence the name "compressed". + </listitem> + <listitem> + This is actually an issue with the C++ Core Language Working Group (issue + #106), submitted by Bjarne Stroustrup. The tentative resolution is to allow + a "reference to a reference to T" to mean the same thing as a "reference + to T", but only in template instantiation, in a method similar to multiple + cv-qualifiers. + </listitem> + <listitem> + For those of you who are wondering why this shouldn't be const-qualified, + remember that references are always implicitly constant (for example, you + can't re-assign a reference). Remember also that "const T &" + is something completely different. For this reason, cv-qualifiers on template + type arguments that are references are ignored. + </listitem> + </orderedlist> + </section> + <section id="boost_typetraits.category"> + <title><link linkend="boost_typetraits.category"> Type Traits by Category</link></title> + <section id="boost_typetraits.category.value_traits"> + <title><link linkend="boost_typetraits.category.value_traits"> Type Traits + that Describe the Properties of a Type</link></title> + <para> + <indexterm> + <primary>Foo2</primary> + <secondary>Bar2</secondary> + </indexterm> + These traits are all <emphasis>value traits</emphasis>, which is to say the + traits classes all inherit from <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link>, + and are used to access some numerical property of a type. Often this is a + simple true or false Boolean value, but in a few cases may be some other + integer value (for example when dealing with type alignments, or array bounds: + see <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.alignment_of">alignment_of</link></computeroutput>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.rank">rank</link></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.extent">extent</link></computeroutput>). + </para> + <section id="boost_typetraits.category.value_traits.primary"> + <title><link linkend="boost_typetraits.category.value_traits.primary"> Categorizing + a Type</link></title> + <para> + These traits identify what "kind" of type some type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is. These are split into two groups: + primary traits which are all mutually exclusive, and composite traits that + are compositions of one or more primary traits. + </para> + <para> + For any given type, exactly one primary type trait will inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + and all the others will inherit from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>, + in other words these traits are mutually exclusive. + </para> + <para> + This means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_integral">is_integral</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + will only ever be true for built-in types; if you want to check for a user-defined + class type that behaves "as if" it is an integral or floating + point type, then use the <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric_limits</phrase> + <phrase role="keyword">template</phrase></computeroutput> instead. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_array">is_array</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_class">is_class</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_complex">is_complex</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_enum">is_enum</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_function">is_function</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_integral">is_integral</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_object_pointer">is_member_object_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_union">is_union</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_void">is_void</link><phrase role="special">;</phrase> +</programlisting> + <para> + The following traits are made up of the union of one or more type categorizations. + A type may belong to more than one of these categories, in addition to + one of the primary categories. + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_arithmetic">is_arithmetic</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_compound">is_compound</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_fundamental">is_fundamental</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_object">is_object</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_scalar">is_scalar</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.value_traits.properties"> + <title><link linkend="boost_typetraits.category.value_traits.properties"> + General Type Properties</link></title> + <para> + The following templates describe the general properties of a type. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.alignment_of">alignment_of</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_assign">has_nothrow_assign</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_default_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_default_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy_constructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.has_virtual_destructor">has_virtual_destructor</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_abstract">is_abstract</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_const">is_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_empty">is_empty</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_stateless">is_stateless</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_signed">is_signed</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_unsigned">is_unsigned</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_volatile">is_volatile</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.extent">extent</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.rank">rank</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.value_traits.relate"> + <title><link linkend="boost_typetraits.category.value_traits.relate"> Relationships + Between Two Types</link></title> + <para> + These templates determine the whether there is a relationship between two + types: + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_base_of">is_base_of</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">U</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_same">is_same</link><phrase role="special">;</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.category.transform"> + <title><link linkend="boost_typetraits.category.transform"> Type Traits that + Transform One Type to Another</link></title> + <para> + The following templates transform one type to another, based upon some well-defined + rule. Each template has a single member called <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + that is the result of applying the transformation to the template argument + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Synopsis:</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_const">add_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_cv">add_cv</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_pointer">add_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_reference">add_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.add_volatile">add_volatile</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.decay">decay</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.floating_point_promotion">floating_point_promotion</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.integral_promotion">integral_promotion</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.make_signed">make_signed</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.make_unsigned">make_unsigned</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.promote">promote</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_all_extents">remove_all_extents</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_const">remove_const</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_cv">remove_cv</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_extent">remove_extent</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_reference">remove_reference</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.remove_volatile">remove_volatile</link><phrase role="special">;</phrase> +</programlisting> + <anchor id="boost_typetraits.category.transform.broken_compiler_workarounds_"/> + <bridgehead renderas="sect4"> + <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">Broken + Compiler Workarounds:</link> + </bridgehead> + <para> + For all of these templates support for partial specialization of class templates + is required to correctly implement the transformation. On the other hand, + practice shows that many of the templates from this category are very useful, + and often essential for implementing some generic libraries. Lack of these + templates is often one of the major limiting factors in porting those libraries + to compilers that do not yet support this language feature. As some of these + compilers are going to be around for a while, and at least one of them is + very wide-spread, it was decided that the library should provide workarounds + where possible. + </para> + <para> + The basic idea behind the workaround is to manually define full specializations + of all type transformation templates for all fundamental types, and all their + 1st and 2nd rank cv-[un]qualified derivative pointer types, and to provide + a user-level macro that will define all the explicit specializations needed + for any user-defined type T. + </para> + <para> + The first part guarantees the successful compilation of something like this: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="special">...</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +</programlisting> + <para> + and the second part provides the library's users with a mechanism to make + the above code work not only for <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> or other built-in type, + but for their own types as well: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">namespace</phrase> <phrase role="identifier">myspace</phrase><phrase role="special">{</phrase> + <phrase role="keyword">struct</phrase> <phrase role="identifier">MyClass</phrase> <phrase role="special">{};</phrase> +<phrase role="special">}</phrase> +<phrase role="comment">// declare this at global scope: +</phrase><phrase role="identifier">BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION</phrase><phrase role="special">(</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">)</phrase> +<phrase role="comment">// transformations on myspace::MyClass now work: +</phrase><phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="identifier">BOOST_STATIC_ASSERT</phrase><phrase role="special">((</phrase><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">,</phrase> <phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="identifier">myspace</phrase><phrase role="special">::</phrase><phrase role="identifier">MyClass</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">));</phrase> +<phrase role="comment">// etc. +</phrase></programlisting> + <para> + Note that the macro BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION evaluates + to nothing on those compilers that <emphasis role="bold">do</emphasis> support + partial specialization. + </para> + </section> + <section id="boost_typetraits.category.alignment"> + <title><link linkend="boost_typetraits.category.alignment"> Synthesizing Types + with Specific Alignments</link></title> + <para> + Some low level memory management routines need to synthesize a POD type with + specific alignment properties. The template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.type_with_alignment">type_with_alignment</link></computeroutput> + finds the smallest type with a specified alignment, while template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.aligned_storage">aligned_storage</link></computeroutput> + creates a type with a specific size and alignment. + </para> + <para> + <emphasis role="bold">Synopsis</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.type_with_alignment">type_with_alignment</link><phrase role="special">;</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.aligned_storage">aligned_storage</link><phrase role="special">;</phrase> +</programlisting> + </section> + <section id="boost_typetraits.category.function"> + <title><link linkend="boost_typetraits.category.function"> Decomposing Function + Types</link></title> + <para> + The class template <link linkend="boost_typetraits.reference.function_traits">function_traits</link> + extracts information from function types (see also <link linkend="boost_typetraits.reference.is_function">is_function</link>). + This traits class allows you to tell how many arguments a function takes, + what those argument types are, and what the return type is. + </para> + <para> + <emphasis role="bold">Synopsis</emphasis> + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.function_traits">function_traits</link><phrase role="special">;</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.user_defined"> + <title><link linkend="boost_typetraits.user_defined"> User Defined Specializations</link></title> + <para> + Occationally the end user may need to provide their own specialization for + one of the type traits - typically where intrinsic compiler support is required + to implement a specific trait fully. These specializations should derive from + boost::<link linkend="boost_typetraits.reference.integral_constant">true_type</link> + or boost::<link linkend="boost_typetraits.reference.integral_constant">false_type</link> + as appropriate: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pod</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> +<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_class</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> +<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_union</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase> + +<phrase role="keyword">struct</phrase> <phrase role="identifier">my_pod</phrase><phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">my_union</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">char</phrase> <phrase role="identifier">c</phrase><phrase role="special">;</phrase> + <phrase role="keyword">int</phrase> <phrase role="identifier">i</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> + +<phrase role="keyword">namespace</phrase> <phrase role="identifier">boost</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special"><</phrase><phrase role="identifier">my_pod</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_pod">is_pod</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_union">is_union</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">{};</phrase> + + <phrase role="keyword">template</phrase><phrase role="special"><></phrase> + <phrase role="keyword">struct</phrase> <link linkend="boost_typetraits.reference.is_class">is_class</link><phrase role="special"><</phrase><phrase role="identifier">my_union</phrase><phrase role="special">></phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">{};</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.intrinsics"> + <title><link linkend="boost_typetraits.intrinsics"> Support for Compiler Intrinsics</link></title> + <para> + There are some traits that can not be implemented within the current C++ language: + to make these traits "just work" with user defined types, some kind + of additional help from the compiler is required. Currently (April 2008) Visual + C++ 8 and 9, GNU GCC 4.3 and MWCW 9 provide the necessary intrinsics, and other + compilers will no doubt follow in due course. + </para> + <para> + The Following traits classes always need compiler support to do the right thing + for all types (but all have safe fallback positions if this support is unavailable): + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_union">is_union</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_pod">is_pod</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_nothrow_assign">has_nothrow_assign</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.has_virtual_destructor">has_virtual_destructor</link> + </listitem> + </itemizedlist> + <para> + The following traits classes can't be portably implemented in the C++ language, + although in practice, the implementations do in fact do the right thing on + all the compilers we know about: + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_empty">is_empty</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link> + </listitem> + </itemizedlist> + <para> + The following traits classes are dependent on one or more of the above: + </para> + <itemizedlist> + <listitem> + <link linkend="boost_typetraits.reference.is_class">is_class</link> + </listitem> + <listitem> + <link linkend="boost_typetraits.reference.is_stateless">is_stateless</link> + </listitem> + </itemizedlist> + <para> + The hooks for compiler-intrinsic support are defined in <ulink url="../../../../boost/type_traits/intrinsics.hpp">boost/type_traits/intrinsics.hpp</ulink>, + adding support for new compilers is simply a matter of defining one of more + of the following macros: + </para> + <table frame="all"> <title>Macros for Compiler Intrinsics</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + BOOST_IS_UNION(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a union type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + BOOST_IS_POD(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a POD type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_EMPTY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is an empty struct or union + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if the default constructor for T is trivial (i.e. + has no effect) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_COPY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial copy constructor (and can + therefore be replaced by a call to memcpy) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_ASSIGN(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial assignment operator (and can + therefore be replaced by a call to memcpy) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_TRIVIAL_DESTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T has a trivial destructor (i.e. ~T() has + no effect) + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_CONSTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="identifier">x</phrase><phrase role="special">;</phrase></computeroutput> + can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_COPY(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase><phrase role="special">(</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase></computeroutput> can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_NOTHROW_ASSIGN(T) + </para> + </entry><entry> + <para> + Should evaluate to true if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="identifier">t</phrase><phrase role="special">,</phrase> + <phrase role="identifier">u</phrase><phrase role="special">;</phrase> + <phrase role="identifier">t</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">u</phrase></computeroutput> can not throw + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_HAS_VIRTUAL_DESTRUCTOR(T) + </para> + </entry><entry> + <para> + Should evaluate to true T has a virtual destructor + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_ABSTRACT(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is an abstract type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_BASE_OF(T,U) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a base class of U + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_CLASS(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a class type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_CONVERTIBLE(T,U) + </para> + </entry><entry> + <para> + Should evaluate to true if T is convertible to U + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_ENUM(T) + </para> + </entry><entry> + <para> + Should evaluate to true is T is an enum + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_IS_POLYMORPHIC(T) + </para> + </entry><entry> + <para> + Should evaluate to true if T is a polymorphic type + </para> + </entry> + </row> + <row> + <entry> + <para> + BOOST_ALIGNMENT_OF(T) + </para> + </entry><entry> + <para> + Should evaluate to the alignment requirements of type T. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.mpl"> + <title><link linkend="boost_typetraits.mpl"> MPL Interoperability</link></title> + <para> + All the value based traits in this library conform to MPL's requirements for + an <ulink url="../../../../libs/mpl/doc/refmanual/integral-constant.html">Integral + Constant type</ulink>: that includes a number of rather intrusive workarounds + for broken compilers. + </para> + <para> + Purely as an implementation detail, this means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/bool.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">true_</phrase></computeroutput></ulink>, + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">false_type</link></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/bool.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">false_</phrase></computeroutput></ulink>, + and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> + <phrase role="identifier">v</phrase><phrase role="special">></phrase></computeroutput> + inherits from <ulink url="../../../../libs/mpl/doc/refmanual/integral-c.html"><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mpl</phrase><phrase role="special">::</phrase><phrase role="identifier">integral_c</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">v</phrase><phrase role="special">></phrase></computeroutput></ulink> + (provided <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>) + </para> + </section> + <section id="boost_typetraits.examples"> + <title><link linkend="boost_typetraits.examples"> Examples</link></title> + <section id="boost_typetraits.examples.copy"> + <title><link linkend="boost_typetraits.examples.copy"> An Optimized Version + of std::copy</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">copy</phrase></computeroutput> + that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput> + to determine whether to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput> + to optimise the copy operation (see <ulink url="../../examples/copy_example.cpp">copy_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// opt::copy +</phrase><phrase role="comment">// same semantics as std::copy +</phrase><phrase role="comment">// calls memcpy where appropriate. +</phrase><phrase role="comment">// +</phrase> +<phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase><phrase role="special">></phrase> +<phrase role="identifier">I2</phrase> <phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="identifier">b</phrase><phrase role="special">>&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="special">*</phrase><phrase role="identifier">out</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">out</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">out</phrase><phrase role="special">;</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">memcpy</phrase><phrase role="special">(</phrase><phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="special">(</phrase><phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">)*</phrase><phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">));</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">out</phrase><phrase role="special">+(</phrase><phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">copy</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I1</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">out</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// We can copy with memcpy if T has a trivial assignment operator, +</phrase> <phrase role="comment">// and if the iterator arguments are actually pointers (this last +</phrase> <phrase role="comment">// requirement we detect with overload resolution): +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I1</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">copy_imp</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">out</phrase><phrase role="special">,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special"><</phrase><phrase role="identifier">value_type</phrase><phrase role="special">>());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.fill"> + <title><link linkend="boost_typetraits.examples.fill"> An Optimised Version + of std::fill</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">fill</phrase></computeroutput> + that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link></computeroutput> + to determine whether to use <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memset</phrase></computeroutput> + to optimise the fill operation (see <ulink url="../../examples/fill_example.cpp">fill_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// fill +</phrase><phrase role="comment">// same as std::fill, but uses memset where appropriate +</phrase><phrase role="comment">// +</phrase><phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase> <phrase role="identifier">b</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="identifier">b</phrase><phrase role="special">>&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="special">*</phrase><phrase role="identifier">first</phrase> <phrase role="special">=</phrase> <phrase role="identifier">val</phrase><phrase role="special">;</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">memset</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">-</phrase><phrase role="identifier">first</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">I</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">fill</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase><phrase role="special">&</phrase> <phrase role="identifier">val</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// We can do an optimised fill if T has a trivial assignment +</phrase> <phrase role="comment">// operator and if it's size is one: +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> + <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_assign">has_trivial_assign</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> <phrase role="special">&&</phrase> <phrase role="special">(</phrase><phrase role="keyword">sizeof</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase> <phrase role="special">==</phrase> <phrase role="number">1</phrase><phrase role="special">)></phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">;</phrase> + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_fill</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">,</phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.destruct"> + <title><link linkend="boost_typetraits.examples.destruct"> An Example that + Omits Destructor Calls For Types with Trivial Destructors</link></title> + <para> + Demonstrates a simple algorithm that uses <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">__has_trivial_destruct</phrase></computeroutput> + to determine whether to destructors need to be called (see <ulink url="../../examples/trivial_destructor_example.cpp">trivial_destructor_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// algorithm destroy_array: +</phrase><phrase role="comment">// The reverse of std::unitialized_copy, takes a block of +</phrase><phrase role="comment">// initialized memory and calls destructors on all objects therein. +</phrase><phrase role="comment">// +</phrase> +<phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">void</phrase> <phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">while</phrase><phrase role="special">(</phrase><phrase role="identifier">first</phrase> <phrase role="special">!=</phrase> <phrase role="identifier">last</phrase><phrase role="special">)</phrase> + <phrase role="special">{</phrase> + <phrase role="identifier">first</phrase><phrase role="special">->~</phrase><phrase role="identifier">T</phrase><phrase role="special">();</phrase> + <phrase role="special">++</phrase><phrase role="identifier">first</phrase><phrase role="special">;</phrase> + <phrase role="special">}</phrase> +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">first</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">last</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> <phrase role="comment">// namespace detail +</phrase> +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">p1</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase><phrase role="special">*</phrase> <phrase role="identifier">p2</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_destroy_array</phrase><phrase role="special">(</phrase><phrase role="identifier">p1</phrase><phrase role="special">,</phrase> <phrase role="identifier">p2</phrase><phrase role="special">,</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.has_trivial_destructor">has_trivial_destructor</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.iter"> + <title><link linkend="boost_typetraits.examples.iter"> An improved Version + of std::iter_swap</link></title> + <para> + Demonstrates a version of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iter_swap</phrase></computeroutput> + that use type traits to determine whether an it's arguments are proxying + iterators or not, if they're not then it just does a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">swap</phrase></computeroutput> + of it's dereferenced arguments (the same as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iter_swap</phrase></computeroutput> + does), however if they are proxying iterators then takes special care over + the swap to ensure that the algorithm works correctly for both proxying iterators, + and even iterators of different types (see <ulink url="../../examples/iter_swap_example.cpp">iter_swap_example.cpp</ulink>): + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="comment">// +</phrase><phrase role="comment">// iter_swap: +</phrase><phrase role="comment">// tests whether iterator is a proxying iterator or not, and +</phrase><phrase role="comment">// uses optimal form accordingly: +</phrase><phrase role="comment">// +</phrase><phrase role="keyword">namespace</phrase> <phrase role="identifier">detail</phrase><phrase role="special">{</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">></phrase> +<phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">false_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase> <phrase role="identifier">v_t</phrase><phrase role="special">;</phrase> + <phrase role="identifier">v_t</phrase> <phrase role="identifier">v</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">one</phrase><phrase role="special">;</phrase> + <phrase role="special">*</phrase><phrase role="identifier">one</phrase> <phrase role="special">=</phrase> <phrase role="special">*</phrase><phrase role="identifier">two</phrase><phrase role="special">;</phrase> + <phrase role="special">*</phrase><phrase role="identifier">two</phrase> <phrase role="special">=</phrase> <phrase role="identifier">v</phrase><phrase role="special">;</phrase> +<phrase role="special">}</phrase> +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I</phrase><phrase role="special">></phrase> +<phrase role="keyword">static</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">true_type</link><phrase role="special">&)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">using</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">swap</phrase><phrase role="special">;</phrase> + <phrase role="identifier">swap</phrase><phrase role="special">(*</phrase><phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="special">*</phrase><phrase role="identifier">two</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> + +<phrase role="special">}</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">typename</phrase> <phrase role="identifier">I1</phrase><phrase role="special">,</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">I2</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">void</phrase> <phrase role="identifier">iter_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">I1</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">I2</phrase> <phrase role="identifier">two</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="comment">// +</phrase> <phrase role="comment">// See is both arguments are non-proxying iterators, +</phrase> <phrase role="comment">// and if both iterator the same type: +</phrase> <phrase role="comment">// +</phrase> <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I1</phrase><phrase role="special">>::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">r1_t</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">iterator_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">I2</phrase><phrase role="special">>::</phrase><phrase role="identifier">reference</phrase> <phrase role="identifier">r2_t</phrase><phrase role="special">;</phrase> + + <phrase role="keyword">typedef</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> + <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special"><</phrase><phrase role="identifier">r1_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_reference">is_reference</link><phrase role="special"><</phrase><phrase role="identifier">r2_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><link linkend="boost_typetraits.reference.is_same">is_same</link><phrase role="special"><</phrase><phrase role="identifier">r1_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">r2_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase><phrase role="special">></phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">;</phrase> + + <phrase role="identifier">detail</phrase><phrase role="special">::</phrase><phrase role="identifier">do_swap</phrase><phrase role="special">(</phrase><phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">two</phrase><phrase role="special">,</phrase> <phrase role="identifier">truth_type</phrase><phrase role="special">());</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + <section id="boost_typetraits.examples.to_double"> + <title><link linkend="boost_typetraits.examples.to_double"> Convert Numeric + Types and Enums to double</link></title> + <para> + Demonstrates a conversion of <ulink url="../../../../libs/numeric/conversion/doc/html/boost_numericconversion/definitions.html#boost_numericconversion.definitions.numeric_types">Numeric + Types</ulink> and enum types to double: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase><phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">inline</phrase> <phrase role="keyword">double</phrase> <phrase role="identifier">to_double</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase> <phrase role="identifier">value</phrase><phrase role="special">)</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="keyword">typename</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase> <phrase role="identifier">promoted</phrase><phrase role="special">;</phrase> + <phrase role="keyword">return</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">numeric</phrase><phrase role="special">::</phrase><phrase role="identifier">converter</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase><phrase role="identifier">promoted</phrase><phrase role="special">>::</phrase><phrase role="identifier">convert</phrase><phrase role="special">(</phrase><phrase role="identifier">value</phrase><phrase role="special">);</phrase> +<phrase role="special">}</phrase> +</programlisting> + </section> + </section> + <section id="boost_typetraits.reference"> + <title><link linkend="boost_typetraits.reference"> Alphabetical Reference</link></title> + <section id="boost_typetraits.reference.add_const"> + <title><link linkend="boost_typetraits.reference.add_const"> add_const</link></title> + <indexterm type="class_name"> + <primary>one</primary> + <secondary>two</secondary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">const</phrase></computeroutput> for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_cv"> + <title><link linkend="boost_typetraits.reference.add_cv"> add_cv</link></title> + <indexterm type="class_name"> + <primary>one</primary> + <secondary>two</secondary> + <tertiary>three</tertiary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_cv</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_cv</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_pointer"> + <title><link linkend="boost_typetraits.reference.add_pointer"> add_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_pointer</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">*</phrase></computeroutput>. + </para> + <para> + The rationale for this template is that it produces the same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">TYPEOF</phrase><phrase role="special">(&</phrase><phrase role="identifier">t</phrase><phrase role="special">)</phrase></computeroutput>, where + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">t</phrase></computeroutput> is an object of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.1. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">**</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">**</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_reference"> + <title><link linkend="boost_typetraits.reference.add_reference"> add_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_reference</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is not a reference type then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase><phrase role="special">&</phrase></computeroutput>, otherwise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.add_volatile"> + <title><link linkend="boost_typetraits.reference.add_volatile"> add_volatile</link></title> + <indexterm type="class_name"> + <primary>one</primary> + </indexterm> + + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> for all <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">add_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">add_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.aligned_storage"> + <title><link linkend="boost_typetraits.reference.aligned_storage"> aligned_storage</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Size</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">aligned_storage</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> a built-in or POD type with size + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Size</phrase></computeroutput> and an alignment that + is a multiple of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Align</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">aligned_storage</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.alignment_of"> + <title><link linkend="boost_typetraits.reference.alignment_of"> alignment_of</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">alignment_of</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template alignment<emphasis role="underline">of inherits from `</emphasis>_integral_constant<std::size_t, + ALIGNOF(T)><computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">,</phrase> <phrase role="identifier">where</phrase> + </computeroutput>ALIGNOF(T)` is the alignment of type T. + </para> + <para> + <emphasis>Note: strictly speaking you should only rely on the value of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> being + a multiple of the true alignment of T, although in practice it does compute + the correct value in all the cases we know about.</emphasis> + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">alignment_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">char</phrase><phrase role="special">)></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + with value <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">ALIGNOF</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">alignment_of</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.decay"> + <title><link linkend="boost_typetraits.reference.decay"> decay</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">decay</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> Let <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> + be the result of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput>, then if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> + is an array type, the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">>*</phrase></computeroutput>, + otherwise if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput> is a function + type then the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase><phrase role="special">*</phrase></computeroutput>, otherwise the result is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">decay</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">(&)[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">decay</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">(&)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">)</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.extent"> + <title><link linkend="boost_typetraits.reference.extent"> extent</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">N</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">extent</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template extent inherits + from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)></phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)</phrase></computeroutput> is the number of elements in the N'th array + dimention of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not an array type, + or if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">N</phrase> <phrase role="special">></phrase> + <link linkend="boost_typetraits.reference.rank">rank</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput>, or if the N'th array bound is incomplete, + then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">EXTENT</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase><phrase role="identifier">N</phrase><phrase role="special">)</phrase></computeroutput> is zero. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">extent</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">],</phrase> + <phrase role="number">1</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>4</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">],</phrase> <phrase role="number">1</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>2</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">extent</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.floating_point_promotion"> + <title><link linkend="boost_typetraits.reference.floating_point_promotion"> + floating_point_promotion</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">floating_point_promotion</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If floating point promotion can be + applied to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + then applies floating point promotion to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">floating_point_promotion</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">float</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">floating_point_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.function_traits"> + <title><link linkend="boost_typetraits.reference.function_traits"> function_traits</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">F</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">function_traits</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">arity</phrase> <phrase role="special">=</phrase> <replaceable>see-below</replaceable><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">result_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> arg<replaceable>N</replaceable>_type<phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + The class template function_traits will only compile if: + </para> + <itemizedlist> + <listitem> + The compiler supports partial specialization of class templates. + </listitem> + <listitem> + The template argument <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput> + is a <emphasis>function type</emphasis>, note that this <emphasis><emphasis role="bold">is not</emphasis></emphasis> the same thing as a <emphasis>pointer + to a function</emphasis>. + </listitem> + </itemizedlist> + <tip> + <para> + function_traits is intended to introspect only C++ functions of the form + R (), R( A1 ), R ( A1, ... etc. ) and not function pointers or class member + functions. To convert a function pointer type to a suitable type use <link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link>. + </para> + </tip> + <table frame="all"> <title>Function Traits Members</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Member + </para> + </entry><entry> + <para> + Description + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that gives the number of arguments + accepted by the function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type returned by function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="identifier">F</phrase><phrase role="special">>::</phrase>arg<replaceable>N</replaceable>_type</computeroutput> + </para> + </entry><entry> + <para> + The <replaceable>N</replaceable>th argument type of function type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="number">1</phrase> <phrase role="special"><=</phrase> + <phrase role="identifier">N</phrase> <phrase role="special"><=</phrase> + <phrase role="identifier">arity</phrase></computeroutput> of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">F</phrase></computeroutput>. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 0. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 1. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + An integral constant expression that has the value 4. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">result_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">long</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arg1_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arg4_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + The type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">void</phrase><phrase role="special">*</phrase></computeroutput>. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">long</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">*)>::</phrase><phrase role="identifier">arg5_type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A compiler error: there is no <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">arg5_type</phrase></computeroutput> + since there are only four arguments. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">function_traits</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">arity</phrase></computeroutput> + </para> + </entry><entry> + <para> + A compiler error: argument type is a <emphasis>function pointer</emphasis>, + and not a <emphasis>function type</emphasis>. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.has_nothrow_assign"> + <title><link linkend="boost_typetraits.reference.has_nothrow_assign"> has_nothrow_assign</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_assign</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing assignment-operator then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_assign</phrase></computeroutput> + will never report that a class or struct has a non-throwing assignment-operator; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler support to ensure that this trait "just + works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_assign</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_constructor"> + <title><link linkend="boost_typetraits.reference.has_nothrow_constructor"> + has_nothrow_constructor</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_default_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing default-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_constructor</phrase></computeroutput> + will never report that a class or struct has a non-throwing default-constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to ensure that this trait "just works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_constructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_copy"> + <title><link linkend="boost_typetraits.reference.has_nothrow_copy"> has_nothrow_copy</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_copy</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_nothrow_copy_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a non-throwing copy-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_nothrow_copy</phrase></computeroutput> + will never report that a class or struct has a non-throwing copy-constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only Visual + C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to ensure that this trait "just works". + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_nothrow_copy</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.has_nothrow_cp_cons"> + <title><link linkend="boost_typetraits.reference.has_nothrow_cp_cons"> has_nothrow_copy_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_nothrow_copy">has_nothrow_copy</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_no_throw_def_cons"> + <title><link linkend="boost_typetraits.reference.has_no_throw_def_cons"> has_nothrow_default_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_nothrow_constructor">has_nothrow_constructor</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_assign"> + <title><link linkend="boost_typetraits.reference.has_trivial_assign"> has_trivial_assign</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_assign</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial assignment-operator then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + If a type has a trivial assignment-operator then the operator has the same + effect as copying the bits of one object to the other: calls to the operator + can be safely replaced with a call to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_assign + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.8p11. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_assign</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_assign</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_constructor"> + <title><link linkend="boost_typetraits.reference.has_trivial_constructor"> + has_trivial_constructor</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_default_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial default-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + If a type has a trivial default-constructor then the constructor have no + effect: calls to the constructor can be safely omitted. Note that using meta-programming + to omit a call to a single trivial-constructor call is of no benefit whatsoever. + However, if loops and/or exception handling code can also be omitted, then + some benefit in terms of code size and speed can be obtained. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_constructor + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.1p6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_copy"> + <title><link linkend="boost_typetraits.reference.has_trivial_copy"> has_trivial_copy</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_copy</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> + +<phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_copy_constructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial copy-constructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + These two traits are synonyms for each other. + </para> + <para> + If a type has a trivial copy-constructor then the constructor has the same + effect as copying the bits of one object to the other: calls to the constructor + can be safely replaced with a call to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">memcpy</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_copy + will never report that a user-defined class or struct has a trivial constructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.8p6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_copy</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_trivial_cp_cons"> + <title><link linkend="boost_typetraits.reference.has_trivial_cp_cons"> has_trivial_copy_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_trivial_copy">has_trivial_copy</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_def_cons"> + <title><link linkend="boost_typetraits.reference.has_trivial_def_cons"> has_trivial_default_constructor</link></title> + <para> + See <link linkend="boost_typetraits.reference.has_trivial_constructor">has_trivial_constructor</link>. + </para> + </section> + <section id="boost_typetraits.reference.has_trivial_destructor"> + <title><link linkend="boost_typetraits.reference.has_trivial_destructor"> has_trivial_destructor</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_trivial_destructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a trivial destructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + If a type has a trivial destructor then the destructor has no effect: calls + to the destructor can be safely omitted. Note that using meta-programming + to omit a call to a single trivial-constructor call is of no benefit whatsoever. + However, if loops and/or exception handling code can also be omitted, then + some benefit in terms of code size and speed can be obtained. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, has_trivial_destructor + will never report that a user-defined class or struct has a trivial destructor; + this is always safe, if possibly sub-optimal. Currently (May 2005) only MWCW + 9 and Visual C++ 8 have the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect user-defined classes with trivial constructors. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.4p3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.has_virtual_destructor"> + <title><link linkend="boost_typetraits.reference.has_virtual_destructor"> has_virtual_destructor</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">has_virtual_destructor</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + type with a virtual destructor then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> This trait is provided + for completeness, since it's part of the Technical Report on C++ Library + Extensions. However, there is currently no way to portably implement this + trait. The default version provided always inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>, + and has to be explicitly specialized for types with virtual destructors unless + the compiler used has compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + that enable the trait to do the right thing: currently (May 2005) only Visual + C++ 8 and GCC-4.3 have the necessary <link linkend="boost_typetraits.intrinsics">intrinsics</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 12.4. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">has_virtual_destructor</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.integral_constant"> + <title><link linkend="boost_typetraits.reference.integral_constant"> integral_constant</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">val</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">integral_constant</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="identifier">val</phrase><phrase role="special">></phrase> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">typedef</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value_type</phrase><phrase role="special">;</phrase> + <phrase role="keyword">static</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">T</phrase> <phrase role="identifier">value</phrase> <phrase role="special">=</phrase> <phrase role="identifier">val</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> + +<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="keyword">true</phrase><phrase role="special">></phrase> <phrase role="identifier">true_type</phrase><phrase role="special">;</phrase> +<phrase role="keyword">typedef</phrase> <phrase role="identifier">integral_constant</phrase><phrase role="special"><</phrase><phrase role="keyword">bool</phrase><phrase role="special">,</phrase> <phrase role="keyword">false</phrase><phrase role="special">></phrase> <phrase role="identifier">false_type</phrase><phrase role="special">;</phrase> +</programlisting> + <para> + Class template <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_constant</phrase></computeroutput> + is the common base class for all the value-based type traits. The two typedef's + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">true_type</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">false_type</phrase></computeroutput> are provided for convenience: + most of the value traits are Boolean properties and so will inherit from + one of these. + </para> + </section> + <section id="boost_typetraits.reference.integral_promotion"> + <title><link linkend="boost_typetraits.reference.integral_promotion"> integral_promotion</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">integral_promotion</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If integral promotion can be applied + to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, then + applies integral promotion to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.5 except 4.5/3 + (integral bit-field). + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">integral_promotion</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">integral_promotion</phrase><phrase role="special"><</phrase><phrase role="keyword">enum</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">float_round_style</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.is_abstract"> + <title><link linkend="boost_typetraits.reference.is_abstract"> is_abstract</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_abstract</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + abstract type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_abstract</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> The compiler must + support DR337 (as of April 2005: GCC 3.4, VC++ 7.1 (and later), Intel C++ + 7 (and later), and Comeau 4.3.2). Otherwise behaves the same as <link linkend="boost_typetraits.reference.is_polymorphic">is_polymorphic</link>; + this is the "safe fallback position" for which polymorphic types + are always regarded as potentially abstract. The macro BOOST_NO_IS_ABSTRACT + is used to signify that the implementation is buggy, users should check for + this in their own code if the "safe fallback" is not suitable for + their particular use-case. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">abc</phrase><phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">abc</phrase><phrase role="special">()</phrase> <phrase role="special">=</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">abc</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_abstract</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_arithmetic"> + <title><link linkend="boost_typetraits.reference.is_arithmetic"> is_arithmetic</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_arithmetic</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + arithmetic type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Arithmetic types include integral and floating point types (see also <link linkend="boost_typetraits.reference.is_integral">is_integral</link> and + <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link>). + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p8. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_arithmetic</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_arithmetic</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_array"> + <title><link linkend="boost_typetraits.reference.is_array"> is_array</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_array</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + array type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.4. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_array</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can give the wrong result with function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_array</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_base_of"> + <title><link linkend="boost_typetraits.reference.is_base_of"> is_base_of</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_base_of</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If Base is base class of type + Derived or if both types are the same then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + This template will detect non-public base classes, and ambiguous base classes. + </para> + <para> + Note that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">X</phrase><phrase role="special">,</phrase><phrase role="identifier">X</phrase><phrase role="special">></phrase></computeroutput> will always inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>. + <emphasis role="bold">This is the case even if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">X</phrase></computeroutput> + is not a class type</emphasis>. This is a change in behaviour from Boost-1.33 + in order to track the Technical Report on C++ Library Extensions. + </para> + <para> + Types <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> and <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput> must not be incomplete types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_base_of</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. There are some older compilers which + will produce compiler errors if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> + is a private base class of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput>, + or if <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Base</phrase></computeroutput> is an ambiguous + base of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Derived</phrase></computeroutput>. These compilers + include Borland C++, older versions of Sun Forte C++, Digital Mars C++, and + older versions of EDG based compilers. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="keyword">class</phrase> <phrase role="identifier">Base</phrase><phrase role="special">{};</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">Derived</phrase> <phrase role="special">:</phrase> + <phrase role="keyword">public</phrase> <phrase role="identifier">Base</phrase><phrase role="special">{};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Derived</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">Base</phrase><phrase role="special">,</phrase> <phrase role="identifier">Base</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>: a class is regarded as it's + own base. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_base_of</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_class"> + <title><link linkend="boost_typetraits.reference.is_class"> is_class</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_class</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + class type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 9.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_class</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Without (some as + yet unspecified) help from the compiler, we cannot distinguish between union + and class types, as a result this type will erroneously inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link> for + union types. See also <link linkend="boost_typetraits.reference.is_union">is_union</link>. + Currently (May 2005) only Visual C++ 8 has the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to correctly identify union types, and therefore make is_class function correctly. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">MyClass</phrase><phrase role="special">;</phrase></computeroutput> then: + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_complex"> + <title><link linkend="boost_typetraits.reference.is_complex"> is_complex</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_complex</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is a complex number type then true (of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">complex</phrase><phrase role="special"><</phrase><phrase role="identifier">U</phrase><phrase role="special">></phrase></computeroutput> + for some type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">U</phrase></computeroutput>), otherwise + false. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 26.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_complex</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + <section id="boost_typetraits.reference.is_compound"> + <title><link linkend="boost_typetraits.reference.is_compound"> is_compound</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_compound</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + compound type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Any type that is not a fundamental type is a compound type (see also <link linkend="boost_typetraits.reference.is_fundamental">is_fundamental</link>). + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_compound</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">MyEnum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_compound</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_const"> + <title><link linkend="boost_typetraits.reference.is_const"> is_const</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_const</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (top level) const-qualified + type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the const-qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the const-qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_const</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_convertible"> + <title><link linkend="boost_typetraits.reference.is_convertible"> is_convertible</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_convertible</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If an imaginary lvalue of type + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">From</phrase></computeroutput> is convertible to type + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + Type From must not be an incomplete type. + </para> + <para> + Type To must not be an incomplete, or function type. + </para> + <para> + No types are considered to be convertible to array types or abstract-class + types. + </para> + <para> + This template can not detect whether a converting-constructor is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> or not: if type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> + has a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">private</phrase></computeroutput> converting constructor + from type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">From</phrase></computeroutput> then instantiating + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">From</phrase><phrase role="special">,</phrase> <phrase role="identifier">To</phrase><phrase role="special">></phrase></computeroutput> + will produce a compiler error. For this reason <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase></computeroutput> + can not be used to determine whether a type has a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">public</phrase></computeroutput> + copy-constructor or not. + </para> + <para> + This template will also produce compiler errors if the conversion is ambiguous, + for example: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">B</phrase> <phrase role="special">:</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">C</phrase> <phrase role="special">:</phrase> <phrase role="identifier">A</phrase> <phrase role="special">{};</phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">D</phrase> <phrase role="special">:</phrase> <phrase role="identifier">B</phrase><phrase role="special">,</phrase> <phrase role="identifier">C</phrase> <phrase role="special">{};</phrase> +<phrase role="comment">// This produces a compiler error, the conversion is ambiguous: +</phrase><phrase role="keyword">bool</phrase> <phrase role="keyword">const</phrase> <phrase role="identifier">y</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">D</phrase><phrase role="special">*,</phrase><phrase role="identifier">A</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase><phrase role="special">;</phrase> +</programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4 and 8.5. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> This template is + currently broken with Borland C++ Builder 5 (and earlier), for constructor-based + conversions, and for the Metrowerks 7 (and earlier) compiler in all cases. + If the compiler does not support <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_abstract">is_abstract</link></computeroutput>, + then the template parameter <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">To</phrase></computeroutput> + must not be an abstract type. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_convertible</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*,</phrase> <phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the conversion would require a <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const_cast</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&,</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_convertible</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_empty"> + <title><link linkend="boost_typetraits.reference.is_empty"> is_empty</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_empty</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an empty class type then + inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10p5. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_empty</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> In order to correctly + detect empty classes this trait relies on either: + </para> + <itemizedlist> + <listitem> + the compiler implementing zero sized empty base classes, or + </listitem> + <listitem> + the compiler providing <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to detect empty classes. + </listitem> + </itemizedlist> + <para> + Can not be used with incomplete types. + </para> + <para> + Can not be used with union types, until is_union can be made to work. + </para> + <para> + If the compiler does not support partial-specialization of class templates, + then this template can not be used with abstract types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">struct</phrase> <phrase role="identifier">empty_class</phrase> + <phrase role="special">{};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">empty_class</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_enum"> + <title><link linkend="boost_typetraits.reference.is_enum"> is_enum</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_enum</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + enum type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_enum</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Requires a correctly + functioning <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link> + template; this means that is_enum is currently broken under Borland C++ Builder + 5, and for the Metrowerks compiler prior to version 8, other compilers should + handle this template just fine. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">enum</phrase> <phrase role="identifier">my_enum</phrase> + <phrase role="special">{</phrase> <phrase role="identifier">one</phrase><phrase role="special">,</phrase> <phrase role="identifier">two</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_enum</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_floating_point"> + <title><link linkend="boost_typetraits.reference.is_floating_point"> is_floating_point</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_floating_point</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + floating point type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p8. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_floating_point</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_floating_point</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_function"> + <title><link linkend="boost_typetraits.reference.is_function"> is_function</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_function</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + function type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Note that this template does not detect <emphasis>pointers to functions</emphasis>, + or <emphasis>references to functions</emphasis>, these are detected by <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link> and <link linkend="boost_typetraits.reference.is_reference">is_reference</link> respectively: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">f1</phrase><phrase role="special">();</phrase> <phrase role="comment">// f1 is of function type. +</phrase><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">f2</phrase><phrase role="special">*)();</phrase> <phrase role="comment">// f2 is a pointer to a function. +</phrase><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">f3</phrase><phrase role="special">&)();</phrase> <phrase role="comment">// f3 is a reference to a function. +</phrase></programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2p1 and 8.3.5. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_function</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="keyword">void</phrase><phrase role="special">)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a pointer type, not a function type. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(&)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a reference to a function, not a function type. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">double</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: the argument in this case + is a pointer to a member function. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_function</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + <tip> + <para> + Don't confuse function-types with pointers to functions: + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">typedef</phrase> <phrase role="keyword">int</phrase> + <phrase role="identifier">f</phrase><phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">);</phrase></computeroutput> + </para> + <para> + defines a function type, + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase> <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + declares a prototype for a function of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase></computeroutput>, + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase><phrase role="special">*</phrase> + <phrase role="identifier">pf</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">f</phrase><phrase role="special">&</phrase> + <phrase role="identifier">fr</phrase> <phrase role="special">=</phrase> + <phrase role="identifier">foo</phrase><phrase role="special">;</phrase></computeroutput> + </para> + <para> + declares a pointer and a reference to the function <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">foo</phrase></computeroutput>. + </para> + <para> + If you want to detect whether some type is a pointer-to-function then use: + </para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.is_function">is_function</link><phrase role="special"><</phrase><link linkend="boost_typetraits.reference.remove_pointer">remove_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> + <phrase role="special">&&</phrase> <link linkend="boost_typetraits.reference.is_pointer">is_pointer</link><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + </para> + <para> + or for pointers to member functions you can just use <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link> + directly. + </para> + </tip> + </section> + <section id="boost_typetraits.reference.is_fundamental"> + <title><link linkend="boost_typetraits.reference.is_fundamental"> is_fundamental</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_fundamental</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + fundamental type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Fundamental types include integral, floating point and void types (see also + <link linkend="boost_typetraits.reference.is_integral">is_integral</link>, + <link linkend="boost_typetraits.reference.is_floating_point">is_floating_point</link> + and <link linkend="boost_typetraits.reference.is_void">is_void</link>) + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_fundamental</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_fundamental</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_integral"> + <title><link linkend="boost_typetraits.reference.is_integral"> is_integral</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_integral</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + integral type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p7. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_integral</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_integral</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_function_pointer"> + <title><link linkend="boost_typetraits.reference.is_member_function_pointer"> + is_member_function_pointer</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_function_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member function then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the argument in this case is a pointer to a data member and not a member + function, see <link linkend="boost_typetraits.reference.is_member_object_pointer">is_member_object_pointer</link> + and <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_function_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_object_pointer"> + <title><link linkend="boost_typetraits.reference.is_member_object_pointer"> + is_member_object_pointer</link></title> +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_object_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member object (a data member) then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the argument in this case is a pointer to a member function and not a + member object, see <link linkend="boost_typetraits.reference.is_member_function_pointer">is_member_function_pointer</link> + and <link linkend="boost_typetraits.reference.is_member_pointer">is_member_pointer</link> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_object_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_member_pointer"> + <title><link linkend="boost_typetraits.reference.is_member_pointer"> is_member_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_member_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer to a member (either a function or a data member) then inherits from + <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_member_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">char</phrase><phrase role="special">)>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_member_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_object"> + <title><link linkend="boost_typetraits.reference.is_object"> is_object</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_object</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + object type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + All types are object types except references, void, and function types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p9. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_object</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">void</phrase><phrase role="special">)</phrase><phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">&>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: reference types are not + objects + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="keyword">double</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>: function types are not + objects + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + void is not an object type + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_object</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_pod"> + <title><link linkend="boost_typetraits.reference.is_pod"> is_pod</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_pod</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + POD type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + POD stands for "Plain old data". Arithmetic types, and enumeration + types, a pointers and pointer to members are all PODs. Classes and unions + can also be POD's if they have no non-static data members that are of reference + or non-POD type, no user defined constructors, no user defined assignment + operators, no private or protected non-static data members, no virtual functions + and no base classes. Finally, a cv-qualified POD is still a POD, as is an + array of PODs. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10 and 9p4 (Note + that POD's are also aggregates, see 8.5.1). + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, is<emphasis role="underline">pod + will never report that a class or struct is a POD; this is always safe, if + possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8 have + the necessary compiler-</emphasis>_intrinsics. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pod</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pod</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_pointer"> + <title><link linkend="boost_typetraits.reference.is_pointer"> is_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_pointer</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + pointer type (includes function pointers, but excludes pointers to members) + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2p2 and 8.3.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">*</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + <important> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase></computeroutput> detects "real" + pointer types only, and <emphasis>not</emphasis> smart pointers. Users + should not specialise <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_pointer</phrase></computeroutput> + for smart pointer types, as doing so may cause Boost (and other third party) + code to fail to function correctly. Users wanting a trait to detect smart + pointers should create their own. However, note that there is no way in + general to auto-magically detect smart pointer types, so such a trait would + have to be partially specialised for each supported smart pointer type. + </para> + </important> + </section> + <section id="boost_typetraits.reference.is_polymorphic"> + <title><link linkend="boost_typetraits.reference.is_polymorphic"> is_polymorphic</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_polymorphic</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + polymorphic type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> must be a complete + type. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 10.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> The implementation + requires some knowledge of the compilers ABI, it does actually seem to work + with the majority of compilers though. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_polymorphic</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + Given: <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">class</phrase> <phrase role="identifier">poly</phrase><phrase role="special">{</phrase> <phrase role="keyword">virtual</phrase> <phrase role="special">~</phrase><phrase role="identifier">poly</phrase><phrase role="special">();</phrase> <phrase role="special">};</phrase></computeroutput> + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">poly</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_polymorphic</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_same"> + <title><link linkend="boost_typetraits.reference.is_same"> is_same</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">,</phrase> <phrase role="keyword">class</phrase> <phrase role="identifier">U</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_same</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T and U are the same types + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_same</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with abstract, incomplete or function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&,</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_same</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_scalar"> + <title><link linkend="boost_typetraits.reference.is_scalar"> is_scalar</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_scalar</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + scalar type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Scalar types include integral, floating point, enumeration, pointer, and + pointer-to-member types. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_scalar</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(</phrase><phrase role="identifier">MyClass</phrase><phrase role="special">::*)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_scalar</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_signed"> + <title><link linkend="boost_typetraits.reference.is_signed"> is_signed</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_signed</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an signed integer type + or an enumerated type with an underlying signed integer type, then inherits + from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1, 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_signed</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">myclass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + whose value depends upon the signedness of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_stateless"> + <title><link linkend="boost_typetraits.reference.is_stateless"> is_stateless</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_stateless</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Ff T is a stateless type then + inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + Type T must be a complete type. + </para> + <para> + A stateless type is a type that has no storage and whose constructors and + destructors are trivial. That means that <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_stateless</phrase></computeroutput> + only inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link> + if the following expression is <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">true</phrase></computeroutput>: + </para> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_constructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_copy</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">has_trivial_destructor</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_class</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +<phrase role="special">&&</phrase> <phrase role="special">::</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">is_empty</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase> +</programlisting> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9p10. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_stateless</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + can not be used with function types. + </para> + <para> + Without some (as yet unspecified) help from the compiler, is_stateless will + never report that a class or struct is stateless; this is always safe, if + possibly sub-optimal. Currently (May 2005) only MWCW 9 and Visual C++ 8 have + the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to make this template work automatically. + </para> + </section> + <section id="boost_typetraits.reference.is_reference"> + <title><link linkend="boost_typetraits.reference.is_reference"> is_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_reference</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a reference pointer type + then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial-specialization of class templates, then this template + may report the wrong result for function types, and for types that are both + const and volatile qualified. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="special">(&)(</phrase><phrase role="keyword">long</phrase><phrase role="special">)>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis> (the argument in this case + is a reference to a function). + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_reference</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_union"> + <title><link linkend="boost_typetraits.reference.is_union"> is_union</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_union</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + union type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + Currently requires some kind of compiler support, otherwise unions are identified + as classes. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.2 and 9.5. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> Without (some as + yet unspecified) help from the compiler, we cannot distinguish between union + and class types using only standard C++, as a result this type will never + inherit from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + unless the user explicitly specializes the template for their user-defined + union types, or unless the compiler supplies some unspecified intrinsic that + implements this functionality. Currently (May 2005) only Visual C++ 8 has + the necessary compiler <link linkend="boost_typetraits.intrinsics">intrinsics</link> + to make this trait "just work" without user intervention. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_union</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_union</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_unsigned"> + <title><link linkend="boost_typetraits.reference.is_unsigned"> is_unsigned</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_unsigned</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is an unsigned integer type + or an enumerated type with an underlying unsigned integer type, then inherits + from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1, 7.2. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_unsigned</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="identifier">myclass</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">char</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + whose value depends upon the signedness of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">char</phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">long</phrase> + <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_unsigned</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_void"> + <title><link linkend="boost_typetraits.reference.is_void"> is_void</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_void</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (possibly cv-qualified) + void type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1p9. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_void</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="keyword">void</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>false</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_void</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.is_volatile"> + <title><link linkend="boost_typetraits.reference.is_volatile"> is_volatile</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">is_volatile</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <replaceable><link linkend="boost_typetraits.reference.integral_constant">true_type</link>-or-<link linkend="boost_typetraits.reference.integral_constant">false_type</link></replaceable> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> If T is a (top level) volatile-qualified + type then inherits from <link linkend="boost_typetraits.reference.integral_constant">true_type</link>, + otherwise inherits from <link linkend="boost_typetraits.reference.integral_constant">false_type</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">is_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">volatile</phrase> <phrase role="keyword">int</phrase><phrase role="special">></phrase></computeroutput> inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">volatile</phrase> + <phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">true_type</link></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>true</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>false</emphasis>: + the volatile qualifier is not at the top level in this case. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">is_volatile</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">bool</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.make_signed"> + <title><link linkend="boost_typetraits.reference.make_signed"> make_signed</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">make_signed</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If T is a signed integer type then + the same type as T, if T is an unsigned integer type then the corresponding + signed type. Otherwise if T is an enumerated or character type (char or wchar_t) + then a signed integer type with the same width as T. + </para> + <para> + If T has any cv-qualifiers then these are also present on the result type. + </para> + <para> + <emphasis role="bold">Requires:</emphasis> T must be an integer or enumerated + type, and must not be the type bool. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">make_signed</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">long</phrase> + <phrase role="keyword">long</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A signed integer type with the same width as the enum. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">wchar_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + A signed integer type with the same width as wchar_t. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.make_unsigned"> + <title><link linkend="boost_typetraits.reference.make_unsigned"> make_unsigned</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">make_unsigned</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If T is a unsigned integer type then + the same type as T, if T is an signed integer type then the corresponding + unsigned type. Otherwise if T is an enumerated or character type (char or + wchar_t) then an unsigned integer type with the same width as T. + </para> + <para> + If T has any cv-qualifiers then these are also present on the result type. + </para> + <para> + <emphasis role="bold">Requires:</emphasis> T must be an integer or enumerated + type, and must not be the type bool. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.1. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">make_unsigned</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">unsigned</phrase> <phrase role="keyword">int</phrase> + <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">const</phrase> <phrase role="keyword">unsigned</phrase> + <phrase role="keyword">long</phrase> <phrase role="keyword">long</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="identifier">my_enum</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + An unsigned integer type with the same width as the enum. + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">make_signed</phrase><phrase role="special"><</phrase><phrase role="keyword">wchar_t</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + An unsigned integer type with the same width as wchar_t. + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.promote"> + <title><link linkend="boost_typetraits.reference.promote"> promote</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">promote</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If integral or floating point promotion + can be applied to an rvalue of type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + then applies integral and floating point promotions to <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + and keeps cv-qualifiers of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + See also <link linkend="boost_typetraits.reference.integral_promotion">integral_promotion</link> + and <link linkend="boost_typetraits.reference.floating_point_promotion">floating_point_promotion</link>. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 4.5 except 4.5/3 + (integral bit-field) and 4.6. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">promote</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">float</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">double</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">promote</phrase><phrase role="special"><</phrase><phrase role="keyword">short</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">short</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.rank"> + <title><link linkend="boost_typetraits.reference.rank"> rank</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">rank</phrase> <phrase role="special">:</phrase> <phrase role="keyword">public</phrase> <link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase> <phrase role="special">{};</phrase> +</programlisting> + <para> + <emphasis role="bold">Inherits:</emphasis> Class template rank inherits from + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)></phrase></computeroutput>, + where <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> is the + number of array dimensions in type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>. + </para> + <para> + If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> is not an array type, + then <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">RANK</phrase><phrase role="special">(</phrase><phrase role="identifier">T</phrase><phrase role="special">)</phrase></computeroutput> is zero. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">rank</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <para> + <emphasis role="bold">Examples:</emphasis> + </para> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[]></phrase></computeroutput> + inherits from <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">1</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">double</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><link linkend="boost_typetraits.reference.integral_constant">integral_constant</link><phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase><phrase role="special">,</phrase> <phrase role="number">3</phrase><phrase role="special">></phrase></computeroutput>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">1</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> + is an integral constant expression that evaluates to <emphasis>1</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>2</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">value</phrase></computeroutput> is an integral constant expression + that evaluates to <emphasis>0</emphasis>. + </para> + </para> + </blockquote> + <blockquote> + <para> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">rank</phrase><phrase role="special"><</phrase><phrase role="identifier">T</phrase><phrase role="special">>::</phrase><phrase role="identifier">value_type</phrase></computeroutput> is the type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase></computeroutput>. + </para> + </para> + </blockquote> + </section> + <section id="boost_typetraits.reference.remove_all_extents"> + <title><link linkend="boost_typetraits.reference.remove_all_extents"> remove_all_extents</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_all_extents</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is an array type, then removes all of the array bounds on <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + otherwise leaves <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.4. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_all_extents</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">3</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_all_extents</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_const"> + <title><link linkend="boost_typetraits.reference.remove_const"> remove_const</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> const-qualifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_const</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_const</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_cv"> + <title><link linkend="boost_typetraits.reference.remove_cv"> remove_cv</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_cv</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> cv-qualifiers removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_cv</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_cv</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_extent"> + <title><link linkend="boost_typetraits.reference.remove_extent"> remove_extent</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_extent</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> If <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + is an array type, then removes the topmost array bound, otherwise leaves + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> unchanged. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.4. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_extent</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">][</phrase><phrase role="number">4</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">4</phrase><phrase role="special">]</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">[][</phrase><phrase role="number">2</phrase><phrase role="special">]>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">[</phrase><phrase role="number">2</phrase><phrase role="special">]</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_extent</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_pointer"> + <title><link linkend="boost_typetraits.reference.remove_pointer"> remove_pointer</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_pointer</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any pointer modifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.1. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_pointer</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">**>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_pointer</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*&</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_reference"> + <title><link linkend="boost_typetraits.reference.remove_reference"> remove_reference</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_reference</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any reference modifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 8.3.2. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_reference</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_reference</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">*&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.remove_volatile"> + <title><link linkend="boost_typetraits.reference.remove_volatile"> remove_volatile</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">remove_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> The same type as <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput>, + but with any <emphasis>top level</emphasis> volatile-qualifier removed. + </para> + <para> + <emphasis role="bold">C++ Standard Reference:</emphasis> 3.9.3. + </para> + <para> + <emphasis role="bold">Compiler Compatibility:</emphasis> If the compiler + does not support partial specialization of class-templates then this template + will compile, but the member <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">type</phrase></computeroutput> + will always be the same as type <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">T</phrase></computeroutput> + except where <link linkend="boost_typetraits.category.transform.broken_compiler_workarounds_">compiler + workarounds</link> have been applied. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">remove_volatile</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + <table frame="all"> <title>Examples</title> + <tgroup cols="2"> + <thead> + <row> + <entry> + <para> + Expression + </para> + </entry><entry> + <para> + Result Type + </para> + </entry> + </row> + </thead> + <tbody> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase> + <phrase role="keyword">volatile</phrase><phrase role="special">>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">&>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">&</phrase></computeroutput> + </para> + </entry> + </row> + <row> + <entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">remove_volatile</phrase><phrase role="special"><</phrase><phrase role="keyword">int</phrase> <phrase role="keyword">volatile</phrase><phrase role="special">*>::</phrase><phrase role="identifier">type</phrase></computeroutput> + </para> + </entry><entry> + <para> + <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">int</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase></computeroutput> + </para> + </entry> + </row> + </tbody> + </tgroup> + </table> + </section> + <section id="boost_typetraits.reference.type_with_alignment"> + <title><link linkend="boost_typetraits.reference.type_with_alignment"> type_with_alignment</link></title> + +<programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">Align</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">type_with_alignment</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <para> + <emphasis role="bold">type:</emphasis> a built-in or POD type with an alignment + that is a multiple of <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="identifier">Align</phrase></computeroutput>. + </para> + <para> + <emphasis role="bold">Header:</emphasis> <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> + <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">/</phrase><phrase role="identifier">type_with_alignment</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + or <computeroutput xmlns:xi="http://www.w3.org/2001/XInclude"> <phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">type_traits</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase></computeroutput> + </para> + </section> + </section> + <section id="boost_typetraits.credits"> + <title><link linkend="boost_typetraits.credits"> Credits</link></title> + <para> + This documentation was pulled together by John Maddock, using <ulink url="../../../../doc/html/quickbook.html">Boost.Quickbook</ulink> + and <ulink url="../../../../doc/html/boostbook.html">Boost.DocBook</ulink>. + </para> + <para> + The original version of this library was created by Steve Cleary, Beman Dawes, + Howard Hinnant, and John Maddock. John Maddock is the current maintainer of + the library. + </para> + <para> + This version of type traits library is based on contributions by Adobe Systems + Inc, David Abrahams, Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, + Jesse Jones, Mat Marcus, Itay Maman, John Maddock, Thorsten Ottosen, Robert + Ramey and Jeremy Siek. + </para> + <para> + Mat Marcus and Jesse Jones invented, and <ulink url="http://opensource.adobe.com/project4/project.shtml">published + a paper describing</ulink>, the partial specialization workarounds used in + this library. + </para> + <para> + Aleksey Gurtovoy added MPL integration to the library. + </para> + <para> + The <link linkend="boost_typetraits.reference.is_convertible">is_convertible</link> + template is based on code originally devised by Andrei Alexandrescu, see "<ulink url="http://www.cuj.com/experts/1810/alexandr.htm?topic=experts">Generic<Programming>: + Mappings between Types and Values</ulink>". + </para> + <para> + The latest version of this library and documentation can be found at <ulink url="http://www.boost.org">www.boost.org</ulink>. Bugs, suggestions and discussion + should be directed to boost@lists.boost.org (see <ulink url="http://www.boost.org/more/mailing_lists.htm#main">www.boost.org/more/mailing_lists.htm#main</ulink> + for subscription details). + </para> + </section> + + <section id="boost_typetraits.ignored_section"> + <title>This section must not be indexed.</title> + <?BoostAutoIndex IgnoreSection?> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword">template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + </section> + + <section id="boost_typetraits.ignored_block"> + <title>This section contains one block that must not be indexed and one that should be.</title> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword"> + <?BoostAutoIndex IgnoreBlock?> + template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_const</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + <programlisting xmlns:xi="http://www.w3.org/2001/XInclude"><phrase role="keyword"> + template</phrase> <phrase role="special"><</phrase><phrase role="keyword">class</phrase> <phrase role="identifier">T</phrase><phrase role="special">></phrase> +<phrase role="keyword">struct</phrase> <phrase role="identifier">add_volatile</phrase> +<phrase role="special">{</phrase> + <phrase role="keyword">typedef</phrase> <replaceable>see-below</replaceable> <phrase role="identifier">type</phrase><phrase role="special">;</phrase> +<phrase role="special">};</phrase> +</programlisting> + </section> + + <para> + <index type="class_name"> + <title>Class Index</title> + </index> + <index type="typedef_name"> + <title>Typedef Index</title> + </index> + <index type="macro_name"> + <title>Macro Index</title> + </index> + <index type="test_index_1"> + <title>Index Test 1</title> + </index> + <index type="test_index_2"> + <title>Index Test 2</title> + </index> + <index/> + </para> +</chapter> + |