<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Re:template class usage in Intel SGX in Intel® Software Guard Extensions (Intel® SGX)</title>
    <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1521843#M5910</link>
    <description>&lt;P&gt;Dear lffa,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Thank you for your nice reply! I'm not sure if your misunderstand the usage of C++'s "&amp;lt;template&amp;gt;", it is a kind of &lt;A href="https://www.geeksforgeeks.org/templates-cpp/" target="_self"&gt;Generic programming&lt;/A&gt; method instead of how to use cpp in SGX. If there are any misunderstanding from my side, feel free to indicate &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt; Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Jin Xin&lt;/P&gt;</description>
    <pubDate>Fri, 08 Sep 2023 09:34:44 GMT</pubDate>
    <dc:creator>MoonHasSevenColor</dc:creator>
    <dc:date>2023-09-08T09:34:44Z</dc:date>
    <item>
      <title>template class usage in Intel SGX</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1520686#M5907</link>
      <description>&lt;P&gt;Dear Intel Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Hope the message finds you well. May I ask a question related Intel SGX. Recently I need use C++'s template class in Intel SGX, and referred from &lt;A href="https://cdrdv2-public.intel.com/671235/intel-sgx-sdk-developer-guidance-intel-sa-00219.pdf" target="_self"&gt;SGX developer guide&lt;/A&gt;, the C++ template class should has been enabled in the latest versions. But when I try to use the template class in Intel SGX, it always exits and reports error: Invalid token: &amp;lt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; The function at Enclave.edl is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;template&amp;lt;typename T&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;public void template_test_sgx(int a);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And the function at Enclave.cpp is:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;template&amp;lt;typename T&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;void template_test_sgx(int a){&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf("Here is template usage in SGX\n");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your help! Have a nice day!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Jin Xin&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 13:32:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1520686#M5907</guid>
      <dc:creator>MoonHasSevenColor</dc:creator>
      <dc:date>2023-09-05T13:32:55Z</dc:date>
    </item>
    <item>
      <title>Re:template class usage in Intel SGX</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1521315#M5909</link>
      <description>&lt;P&gt;A general valid cpp syntax doesn't have "&amp;lt;&amp;gt;" symbol in the declaration of variables. That is why you were getting "Invalid token: &amp;lt;" error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the documentation that you share, the template is an illustration of how you can use a cpp function in Intel SGX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;template&amp;lt; class T, std::size_t A, std::size_t... OLs&amp;gt; is equivalent to creating a function like this in cpp (The class template can’t be used in pure cpp code):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Typedef struct {&lt;/P&gt;&lt;P&gt;size_t offset; size_t len;&lt;/P&gt;&lt;P&gt;} align_req_t;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void *sgx_get_aligned_ptr(void *raw, size_t raw_size, size_t allocate_size, size_t alignment, align_req_t *data, size_t count);&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may refer to this;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;A href="https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/get-started.html" rel="noopener noreferrer" target="_blank"&gt;Intel SGX Get Started official page&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://github.com/intel/linux-sgx/tree/master/SampleCode" rel="noopener noreferrer" target="_blank"&gt;Intel SGX sample code&lt;/A&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Cordially,&lt;/P&gt;&lt;P&gt;Iffa&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Sep 2023 00:09:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1521315#M5909</guid>
      <dc:creator>Iffa_Intel</dc:creator>
      <dc:date>2023-09-07T00:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Re:template class usage in Intel SGX</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1521843#M5910</link>
      <description>&lt;P&gt;Dear lffa,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Thank you for your nice reply! I'm not sure if your misunderstand the usage of C++'s "&amp;lt;template&amp;gt;", it is a kind of &lt;A href="https://www.geeksforgeeks.org/templates-cpp/" target="_self"&gt;Generic programming&lt;/A&gt; method instead of how to use cpp in SGX. If there are any misunderstanding from my side, feel free to indicate &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt; Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Jin Xin&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 09:34:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1521843#M5910</guid>
      <dc:creator>MoonHasSevenColor</dc:creator>
      <dc:date>2023-09-08T09:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: template class usage in Intel SGX</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1523155#M5922</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as mentioned before (mentioned in the &lt;STRONG&gt;official SGX documentation&lt;/STRONG&gt; shared by you), the class template &lt;STRONG&gt;can’t be used in pure cpp code, &lt;/STRONG&gt;hence, the function below is used:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Typedef struct {&lt;/P&gt;
&lt;P&gt;size_t offset; size_t len;&lt;/P&gt;
&lt;P&gt;} align_req_t;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;void *sgx_get_aligned_ptr(void *raw, size_t raw_size, size_t allocate_size, size_t alignment, align_req_t *data, size_t count);&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We &lt;STRONG&gt;highly recommend&lt;/STRONG&gt; that you refer to these &lt;A href="https://github.com/intel/linux-sgx/tree/master/SampleCode" target="_self"&gt;&lt;STRONG&gt;Official Intel SGX sample codes&lt;/STRONG&gt;&lt;/A&gt; that are officially validated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cordially,&lt;/P&gt;
&lt;P&gt;Iffa&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 00:45:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1523155#M5922</guid>
      <dc:creator>Iffa_Intel</dc:creator>
      <dc:date>2023-09-13T00:45:26Z</dc:date>
    </item>
    <item>
      <title>Re:template class usage in Intel SGX</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1526541#M5940</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Calibri, sans-serif; font-size: 11pt;"&gt;Intel will no longer monitor this thread since we have provided a solution.&amp;nbsp;If you need any additional information from Intel, please submit a new question.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Calibri, sans-serif; font-size: 11pt;"&gt;Cordially,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Calibri, sans-serif; font-size: 11pt;"&gt;Iffa&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Sep 2023 05:14:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/template-class-usage-in-Intel-SGX/m-p/1526541#M5940</guid>
      <dc:creator>Iffa_Intel</dc:creator>
      <dc:date>2023-09-22T05:14:04Z</dc:date>
    </item>
  </channel>
</rss>

