When should I use __forceinline instead of inline?

前端 未结 12 1419
旧巷少年郎
旧巷少年郎 2021-01-01 09:34

Visual Studio includes support for __forceinline. The Microsoft Visual Studio 2005 documentation states:

The __forceinline keyword overrides the co

12条回答
  •  我在风中等你
    2021-01-01 09:47

    Actually, boost is loaded with it.

    For example

     BOOST_CONTAINER_FORCEINLINE flat_tree&  operator=(BOOST_RV_REF(flat_tree) x)
        BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
                            allocator_traits_type::is_always_equal::value) &&
                             boost::container::container_detail::is_nothrow_move_assignable::value)
     {  m_data = boost::move(x.m_data); return *this;  }
    
     BOOST_CONTAINER_FORCEINLINE const value_compare &priv_value_comp() const
     { return static_cast(this->m_data); }
    
     BOOST_CONTAINER_FORCEINLINE value_compare &priv_value_comp()
     { return static_cast(this->m_data); }
    
     BOOST_CONTAINER_FORCEINLINE const key_compare &priv_key_comp() const
     { return this->priv_value_comp().get_comp(); }
    
     BOOST_CONTAINER_FORCEINLINE key_compare &priv_key_comp()
     { return this->priv_value_comp().get_comp(); }
    
     public:
     // accessors:
     BOOST_CONTAINER_FORCEINLINE Compare key_comp() const
     { return this->m_data.get_comp(); }
    
     BOOST_CONTAINER_FORCEINLINE value_compare value_comp() const
     { return this->m_data; }
    
     BOOST_CONTAINER_FORCEINLINE allocator_type get_allocator() const
     { return this->m_data.m_vect.get_allocator(); }
    
     BOOST_CONTAINER_FORCEINLINE const stored_allocator_type &get_stored_allocator() const
     {  return this->m_data.m_vect.get_stored_allocator(); }
    
     BOOST_CONTAINER_FORCEINLINE stored_allocator_type &get_stored_allocator()
     {  return this->m_data.m_vect.get_stored_allocator(); }
    
     BOOST_CONTAINER_FORCEINLINE iterator begin()
     { return this->m_data.m_vect.begin(); }
    
     BOOST_CONTAINER_FORCEINLINE const_iterator begin() const
     { return this->cbegin(); }
    
     BOOST_CONTAINER_FORCEINLINE const_iterator cbegin() const
     { return this->m_data.m_vect.begin(); }
    

提交回复
热议问题