I'm curious, because I don't understand why VC refuses to inline this function:

Although, the compiler seems to have inlined this implementation:Code:template<typename T, bool UNDERFLOW_T, bool OVERFLOW_T, bool THROW_T, bool LOGGING_T, T UPPER_T, T LOWER_T> CInt<T, UNDERFLOW_T, OVERFLOW_T, THROW_T, LOGGING_T, UPPER_T, LOWER_T> CInt<T, UNDERFLOW_T, OVERFLOW_T, THROW_T, LOGGING_T, UPPER_T, LOWER_T>:: operator + (const CInt& Data) { //if (bOverflow && m_Data + Data.m_Data > boost::integer_traits<T>::const_max) T tmp = m_Data + Data.m_Data; if (OVERFLOW_T) { //T UpperRange = UPPER_T / 2; //T NewValue = m_Data / 2 + Data.m_Data / 2; //T Carry = (m_Data & Data.m_Data & 1); //T Tmp = NewValue + Carry; //if (UpperRange < Tmp) if (tmp < m_Data && Data.m_Data > 0) { if (THROW_T) throw std::overflow_error(""); else set_overflow(); } } //if ( UNDERFLOW_T && m_Data + Data.m_Data < boost::integer_traits<T>::const_min) if (UNDERFLOW_T) { T LowerRange = LOWER_T / 2; T NewValue = m_Data / 2 + Data.m_Data / 2; T Carry = (m_Data ^ Data.m_Data) & 1; T Tmp = NewValue - Carry; if (LowerRange > Tmp) throw std::underflow_error(""); } return tmp; }

Does anyone think they can guess as to why?Code:template<typename T, bool UNDERFLOW_T, bool OVERFLOW_T, bool THROW_T, bool LOGGING_T, T UPPER_T, T LOWER_T> CInt<T, UNDERFLOW_T, OVERFLOW_T, THROW_T, LOGGING_T, UPPER_T, LOWER_T> CInt<T, UNDERFLOW_T, OVERFLOW_T, THROW_T, LOGGING_T, UPPER_T, LOWER_T>:: operator + (const CInt& Data) { T tmp = m_Data + Data.m_Data; if (OVERFLOW_T || UNDERFLOW_T) { if (tmp < m_Data && OVERFLOW_T && Data.m_Data > 0) set_overflow(); if (tmp > m_Data && UNDERFLOW_T && Data.m_Data < 0) set_underflow(); } return tmp; }

Removing the overflow/underflow checking, it just performs an addition operation with 4 instructions.

Even with overflow/underflow checking, I don't see why it can't inline.