Boost logo

Boost :

Subject: [boost] [phoenix3] at_c
From: Denis Taniguchi (taniguchi_at_[hidden])
Date: 2010-07-28 15:51:54


Hi,

I think that a reasonable implementation of at_c for the new phoenix3
could be:

#pragma once

// boost headers
#include <boost/fusion/include/at.hpp>
#include <boost/phoenix/function.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/remove_const.hpp>

// std headers
#include <algorithm>
#include <iostream>

namespace boost
{
  namespace phoenix
  {
    template <int N>
    struct at_impl
    {
      template <class Signature>
      struct result;
      
      template <class This, class Arg>
      struct result<This(Arg)>
      {
        typedef typename boost::fusion::result_of::at_c<
          typename boost::remove_reference<Arg>::type
        , N
>::type type;
      };

      template <class Arg>
      typename boost::result_of<at_impl<N>(Arg &)>::type
      operator()(Arg &arg) const
      {
        return fusion::at_c<N>(arg);
      }
    };
  } // namespace phoenix
} // namespace boost

If that piece of code is valid (I have tested but I'm not sure if that's
the right way to do it) how would boost::phoenix::at_c be implemented?
In phoenix2 at_impl was a eval so at_c was a template inline function.
Best regards,

Denis


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk