mirror of
https://github.com/USCiLab/cereal.git
synced 2025-07-21 02:22:01 +02:00
166 lines
10 KiB
HTML
166 lines
10 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.17"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>cereal: cereal::specialize< Archive, T, S > Struct Template Reference</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">cereal
|
|
</div>
|
|
<div id="projectbrief">A C++11 library for serialization</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.17 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><b>cereal</b></li><li class="navelem"><a class="el" href="structcereal_1_1specialize.html">specialize</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#related">Related Functions</a> |
|
|
<a href="structcereal_1_1specialize-members.html">List of all members</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">cereal::specialize< Archive, T, S > Struct Template Reference<div class="ingroups"><a class="el" href="group__Access.html">Access Control and Disambiguation</a></div></div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>A class used to disambiguate cases where cereal cannot detect a unique way of serializing a class.
|
|
<a href="structcereal_1_1specialize.html#details">More...</a></p>
|
|
|
|
<p><code>#include <<a class="el" href="specialize_8hpp_source.html">/home/shane/workspace/cereal/include/cereal/specialize.hpp</a>></code></p>
|
|
<div class="dynheader">
|
|
Inheritance diagram for cereal::specialize< Archive, T, S >:</div>
|
|
<div class="dyncontent">
|
|
<div class="center">
|
|
<img src="structcereal_1_1specialize.png" alt=""/>
|
|
</div></div>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="related"></a>
|
|
Related Functions</h2></td></tr>
|
|
<tr><td class="ititle" colspan="2"><p>(Note that these are not member functions.) </p>
|
|
</td></tr>
|
|
<tr class="memitem:gac28bb730353e53b3066cc679e63bb108"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="group__Access.html#gac28bb730353e53b3066cc679e63bb108">specialization</a> </td></tr>
|
|
<tr class="separator:gac28bb730353e53b3066cc679e63bb108"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><h3>template<class Archive, class T, specialization S><br />
|
|
struct cereal::specialize< Archive, T, S ></h3>
|
|
|
|
<p>A class used to disambiguate cases where cereal cannot detect a unique way of serializing a class. </p>
|
|
<p>cereal attempts to figure out which method of serialization (member vs. non-member serialize or load/save pair) at compile time. If for some reason cereal cannot find a non-ambiguous way of serializing a type, it will produce a static assertion complaining about this.</p>
|
|
<p>This can happen because you have both a serialize and load/save pair, or even because a base class has a serialize (public or private with friend access) and a derived class does not overwrite this due to choosing some other serialization type.</p>
|
|
<p>Specializing this class will tell cereal to explicitly use the serialization type you specify and it will not complain about ambiguity in its compile time selection. However, if cereal detects an ambiguity in specializations, it will continue to issue a static assertion.</p>
|
|
<div class="fragment"><div class="line"><span class="keyword">class </span>MyParent</div>
|
|
<div class="line">{</div>
|
|
<div class="line"> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classcereal_1_1access.html">cereal::access</a>;</div>
|
|
<div class="line"> <span class="keyword">template</span> <<span class="keyword">class</span> Archive></div>
|
|
<div class="line"> <span class="keywordtype">void</span> <a class="code" href="functional_8hpp.html#a02f9cfc9a4055c8a49eb050b02cd3357">serialize</a>( Archive & ar ) {}</div>
|
|
<div class="line">};</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="comment">// Although serialize is private in MyParent, to cereal::access it will look public,</span></div>
|
|
<div class="line"><span class="comment">// even through MyDerived</span></div>
|
|
<div class="line"><span class="keyword">class </span>MyDerived : <span class="keyword">public</span> MyParent</div>
|
|
<div class="line">{</div>
|
|
<div class="line"> <span class="keyword">public</span>:</div>
|
|
<div class="line"> <span class="keyword">template</span> <<span class="keyword">class</span> Archive></div>
|
|
<div class="line"> <span class="keywordtype">void</span> load( Archive & ar ) {}</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="keyword">template</span> <<span class="keyword">class</span> Archive></div>
|
|
<div class="line"> <span class="keywordtype">void</span> save( Archive & ar ) {}</div>
|
|
<div class="line">};</div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="comment">// The load/save pair in MyDerived is ambiguous because serialize in MyParent can</span></div>
|
|
<div class="line"><span class="comment">// be accessed from cereal::access. This looks the same as making serialize public</span></div>
|
|
<div class="line"><span class="comment">// in MyParent, making it seem as though MyDerived has both a serialize and a load/save pair.</span></div>
|
|
<div class="line"><span class="comment">// cereal will complain about this at compile time unless we disambiguate:</span></div>
|
|
<div class="line"> </div>
|
|
<div class="line"><span class="keyword">namespace </span>cereal</div>
|
|
<div class="line">{</div>
|
|
<div class="line"> <span class="comment">// This struct specialization will tell cereal which is the right way to serialize the ambiguity</span></div>
|
|
<div class="line"> <span class="keyword">template</span> <<span class="keyword">class</span> Archive> <span class="keyword">struct </span>specialize<Archive, MyDerived, cereal::specialization::member_load_save> {};</div>
|
|
<div class="line"> </div>
|
|
<div class="line"> <span class="comment">// If we only had a disambiguation for a specific archive type, it would look something like this</span></div>
|
|
<div class="line"> <span class="keyword">template</span> <> <span class="keyword">struct </span>specialize<cereal::BinaryOutputArchive, MyDerived, cereal::specialization::member_load_save> {};</div>
|
|
<div class="line">}</div>
|
|
</div><!-- fragment --><p>You can also choose to use the macros CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES or CEREAL_SPECIALIZE_FOR_ARCHIVE if you want to type a little bit less.</p>
|
|
<dl class="tparams"><dt>Template Parameters</dt><dd>
|
|
<table class="tparams">
|
|
<tr><td class="paramname">T</td><td>The type to specialize the serialization for </td></tr>
|
|
<tr><td class="paramname">S</td><td>The specialization type to use for T </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
</div><hr/>The documentation for this struct was generated from the following file:<ul>
|
|
<li><a class="el" href="specialize_8hpp_source.html">specialize.hpp</a></li>
|
|
</ul>
|
|
</div><!-- contents -->
|
|
<div class="ttc" id="afunctional_8hpp_html_a02f9cfc9a4055c8a49eb050b02cd3357"><div class="ttname"><a href="functional_8hpp.html#a02f9cfc9a4055c8a49eb050b02cd3357">cereal::serialize</a></div><div class="ttdeci">void serialize(Archive &, std::less< T > &)</div><div class="ttdoc">Saving for std::less.</div><div class="ttdef"><b>Definition:</b> functional.hpp:39</div></div>
|
|
<div class="ttc" id="aclasscereal_1_1access_html"><div class="ttname"><a href="classcereal_1_1access.html">cereal::access</a></div><div class="ttdoc">A class that can be made a friend to give cereal access to non public functions.</div><div class="ttdef"><b>Definition:</b> access.hpp:240</div></div>
|
|
<!-- HTML footer for doxygen 1.8.3.1-->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Sun Feb 27 2022 19:46:46 for cereal by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.17
|
|
</small></address>
|
|
<script>
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
ga('create', 'UA-42360142-1', 'uscilab.github.io');
|
|
ga('send', 'pageview');
|
|
</script>
|
|
</body>
|
|
</html>
|