LCOV - code coverage report
Current view: top level - vset/memory/fsb/aspect - ad_offset_by_ptr.hpp (source / functions) Hit Total Coverage
Test: v-set-coverage.info Lines: 6 6 100.0 %
Date: 2019-09-12 Functions: 16 17 94.1 %

          Line data    Source code
       1             : //
       2             : // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2012
       3             : //
       4             : // Copyright: See COPYING file that comes with this distribution
       5             : //
       6             : 
       7             : #ifndef VSET_VSET_MEMORY_FSB_ASPECT_AD_OFFSET_BY_PTR_HPP
       8             : #define VSET_VSET_MEMORY_FSB_ASPECT_AD_OFFSET_BY_PTR_HPP
       9             : 
      10             : #include <vset/buffer/tags.hpp>
      11             : #include <vset/memory/fsb/tags.hpp>
      12             : #include <fas/system/nullptr.hpp>
      13             : 
      14             : namespace vset { namespace memory{ namespace fsb{
      15             : 
      16          31 : struct ad_offset_by_ptr
      17             : {
      18             :   template<typename T>
      19      166266 :   size_t operator()(T& t, typename T::aspect::template advice_cast<_value_type_>::type* ptr) const
      20             :   {
      21      166266 :     if ( ptr == fas_nullptr )
      22          12 :       return static_cast<size_t>(-1);
      23             : 
      24             :     typedef ::vset::buffer::_data_      _buffer_data_;
      25             :     typedef ::vset::buffer::_data_type_ _buffer_data_type_;
      26             :     typedef typename T::aspect::template advice_cast<_buffer_data_type_>::type data_type;
      27             :     return t.get_aspect().template get<_off2pos_>()(t, 
      28      166254 :       static_cast<size_t>( reinterpret_cast<data_type>(ptr) - t.get_aspect().template get<_buffer_data_>()(t) )
      29      332508 :     );
      30             :   }
      31             : };
      32             : 
      33             : }}}
      34             : 
      35             : #endif

Generated by: LCOV version 1.10