首页 > 解决方案 > What does .template do?

问题描述

I have a few lines of code like this:

ac_fixed<Wfl, Ifl, true> input_mant;
      // Set the sign bit to zero to ensure a positive value.
      input_mant[Wfl - 1] = 0;
      // Set the bit adjacent to the sign bit to 1 to ensure a normalized mantissa
      input_mant[Wfl - 2] = 1;
      // Set the remaining bits to the bit pattern stored in the last (Wfl - 2) bits in mant_i.
      input_mant.template set_slc(0, mant_i.template slc<Wfl - 2>(0));   // <<< SYNTAX ERROR: 'template'

In which ac_fixed type is defined as:

template<int W, int I, bool S=true, ac_q_mode Q=AC_TRN, ac_o_mode O=AC_WRAP>
class ac_fixed : private ac_private::iv<(W+31+!S)/32>
#ifndef __SYNTHESIS__
__AC_FIXED_UTILITY_BASE
#endif
#ifdef __AC_FIXED_NUMERICAL_ANALYSIS_BASE
, public __AC_FIXED_NUMERICAL_ANALYSIS_BASE
#endif
... (a lot more skipped)

During compiling, the line input.mant_template has "syntax error: 'template'". I don't know what .template does in this case and why it has a syntax error? And not sure where to look inside ac_fixed definition. The files are from the Algorithmic C HLS library in case a full visibility is needed.

标签: c++

解决方案


推荐阅读