| Home | Libraries | People | FAQ | More

## Struct unsafe_access

boost::histogram::unsafe_access — Unsafe read/write access to private data that potentially breaks consistency.

## Synopsis

    // In header: <boost/histogram/unsafe_access.hpp>

    struct unsafe_access {

      // public static functions
      template<typename Histogram> static auto & axes(Histogram &);
      template<typename Histogram> static const auto & axes(const Histogram &);
      template<typename Histogram, unsigned I = 0>
        static decltype(auto)
        axis(Histogram &, std::integral_constant< unsigned, I > = {});
      template<typename Histogram>
        static decltype(auto) axis(Histogram &, unsigned);
      template<typename Histogram> static auto & storage(Histogram &);
      template<typename Histogram> static const auto & storage(const Histogram &);
      template<typename Histogram> static auto & offset(Histogram &);
      template<typename Histogram> static const auto & offset(const Histogram &);
      template<typename Allocator>
        static constexpr auto &
        unlimited_storage_buffer(unlimited_storage< Allocator > &);
      template<typename T>
        static constexpr auto & storage_adaptor_impl(storage_adaptor< T > &);
    };

## Description

This struct enables access to private data of some classes. It is intended for library developers who need this to implement algorithms efficiently, for example, serialization. Users should not use this. If you are a user who absolutely needs this to get a specific effect, please submit an issue on Github. Perhaps the public interface is insufficient and should be extended for your use case.

Unlike the normal interface, the unsafe_access interface may change between versions. If your code relies onunsafe_access, it may or may not break when you update Boost. This is another reason to not use it unless you are ok with these conditions.

### `unsafe_access` public static functions

1.     template<typename Histogram> static auto & axes(Histogram & hist);

   Get axes.

   Parameters:

   `hist` | histogram.

2.     template<typename Histogram> static const auto & axes(const Histogram & hist);

   Get axes.

   Parameters:

   `hist` | histogram.

3.     template<typename Histogram, unsigned I = 0>
         static decltype(auto)
         axis(Histogram & hist, std::integral_constant< unsigned, I > = {});

   Get mutable axis reference with compile-time number.

   Parameters:

   `hist` | histogram.

   Template Parameters:

   `I` | axis index (optional, default: 0).

4.     template<typename Histogram>
         static decltype(auto) axis(Histogram & hist, unsigned i);

   Get mutable axis reference with run-time number.

   Parameters:

   `hist` | histogram.
   `i` | axis index.

5.     template<typename Histogram> static auto & storage(Histogram & hist);

   Get storage.

   Parameters:

   `hist` | histogram.

6.     template<typename Histogram>
         static const auto & storage(const Histogram & hist);

   Get storage.

   Parameters:

   `hist` | histogram.

7.     template<typename Histogram> static auto & offset(Histogram & hist);

   Get index offset.

   Parameters:

   `hist` | histogram

8.     template<typename Histogram>
         static const auto & offset(const Histogram & hist);

   Get index offset.

   Parameters:

   `hist` | histogram

9.     template<typename Allocator>
         static constexpr auto &
         unlimited_storage_buffer(unlimited_storage< Allocator > & storage);

   Get buffer of unlimited_storage.

   Parameters:

   `storage` | instance of unlimited_storage.

10.     template<typename T>
          static constexpr auto & storage_adaptor_impl(storage_adaptor< T > & storage);

    Get implementation of storage_adaptor.

    Parameters:

    `storage` | instance of storage_adaptor.