spirit::karma specialization for std::optional (C++17)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

spirit::karma specialization for std::optional (C++17)

Emiliano Canedo
Hello,

I'm working in a spirit::karma specialization for std::optional (C++17). I have this code for now:

//-----------------------------------

namespace boost
{
namespace spirit
{
namespace traits
{

// This handles std::optional attributes
template <typename Attribute, typename Exposed>
struct extract_from_attribute<std::experimental::optional<Attribute>, Exposed>
{
    typedef Attribute const& type;
    template <typename Context>
    static type call(std::experimental::optional<Attribute> const& attr, Context& ctx)
    {
        return attr.value();
    }
};

template <typename Attribute, typename Exposed>
struct extract_from_attribute<std::experimental::optional<Attribute const>, Exposed>
{
    typedef Attribute const& type;
    template <typename Context>
    static type call(std::experimental::optional<Attribute const> const& attr, Context& ctx)
    {
        return attr.value();
    }
};

}
}
}

//-----------------------------------

This works good to extract the value, but, I need to handle the calls if the optional have, or not, a value. I tried to understand how karma handle this for boost::optional, but I'm stuck with that. Any idea?

Thanks!!

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: spirit::karma specialization for std::optional (C++17)

Michael Powell-2


On April 21, 2017 10:20:42 AM EDT, Emiliano Canedo <[hidden email]> wrote:

>Hello,
>
>I'm working in a spirit::karma specialization for std::optional
>(C++17). I
>have this code for now:
>
>//-----------------------------------
>
>namespace boost
>{
>namespace spirit
>{
>namespace traits
>{
>
>// This handles std::optional attributes
>template <typename Attribute, typename Exposed>
>struct extract_from_attribute<std::experimental::optional<Attribute>,
>Exposed>
>{
>    typedef Attribute const& type;
>    template <typename Context>
>   static type call(std::experimental::optional<Attribute> const& attr,
>Context& ctx)
>    {
>        return attr.value();
>    }
>};
>
>template <typename Attribute, typename Exposed>
>struct extract_from_attribute<std::experimental::optional<Attribute
>const>,
>Exposed>
>{
>    typedef Attribute const& type;
>    template <typename Context>
>   static type call(std::experimental::optional<Attribute const> const&
>attr, Context& ctx)
>    {
>        return attr.value();
>    }
>};
>
>}
>}
>}
>
>//-----------------------------------
>
>This works good to extract the value, but, I need to handle the calls
>if
>the optional have, or not, a value. I tried to understand how karma
>handle
>this for boost::optional, but I'm stuck with that. Any idea?

Are you trying to invoke the output regardless of optional state? Or can you omit the output when optional does not have a value?

>Thanks!!
>
>
>------------------------------------------------------------------------
>
>------------------------------------------------------------------------------
>Check out the vibrant tech community on one of the world's most
>engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Spirit-general mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/spirit-general

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: spirit::karma specialization for std::optional (C++17)

Emiliano Canedo
I can omit the output when optional doesn't have a value, but I don't know how

On Fri, Apr 21, 2017 at 11:52 AM, Michael <[hidden email]> wrote:


On April 21, 2017 10:20:42 AM EDT, Emiliano Canedo <[hidden email]> wrote:
>Hello,
>
>I'm working in a spirit::karma specialization for std::optional
>(C++17). I
>have this code for now:
>
>//-----------------------------------
>
>namespace boost
>{
>namespace spirit
>{
>namespace traits
>{
>
>// This handles std::optional attributes
>template <typename Attribute, typename Exposed>
>struct extract_from_attribute<std::experimental::optional<Attribute>,
>Exposed>
>{
>    typedef Attribute const& type;
>    template <typename Context>
>   static type call(std::experimental::optional<Attribute> const& attr,
>Context& ctx)
>    {
>        return attr.value();
>    }
>};
>
>template <typename Attribute, typename Exposed>
>struct extract_from_attribute<std::experimental::optional<Attribute
>const>,
>Exposed>
>{
>    typedef Attribute const& type;
>    template <typename Context>
>   static type call(std::experimental::optional<Attribute const> const&
>attr, Context& ctx)
>    {
>        return attr.value();
>    }
>};
>
>}
>}
>}
>
>//-----------------------------------
>
>This works good to extract the value, but, I need to handle the calls
>if
>the optional have, or not, a value. I tried to understand how karma
>handle
>this for boost::optional, but I'm stuck with that. Any idea?

Are you trying to invoke the output regardless of optional state? Or can you omit the output when optional does not have a value?

>Thanks!!
>
>
>------------------------------------------------------------------------
>
>------------------------------------------------------------------------------
>Check out the vibrant tech community on one of the world's most
>engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Spirit-general mailing list
>[hidden email]
>https://lists.sourceforge.net/lists/listinfo/spirit-general

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: spirit::karma specialization for std::optional (C++17)

Michael Powell-2
On Fri, Apr 21, 2017 at 11:06 AM, Emiliano Canedo
<[hidden email]> wrote:
> I can omit the output when optional doesn't have a value, but I don't know
> how

if (opt.has_value()) {
   /* output value */
}

http://en.cppreference.com/w/cpp/utility/optional

> On Fri, Apr 21, 2017 at 11:52 AM, Michael <[hidden email]> wrote:
>>
>>
>>
>> On April 21, 2017 10:20:42 AM EDT, Emiliano Canedo
>> <[hidden email]> wrote:
>> >Hello,
>> >
>> >I'm working in a spirit::karma specialization for std::optional
>> >(C++17). I
>> >have this code for now:
>> >
>> >//-----------------------------------
>> >
>> >namespace boost
>> >{
>> >namespace spirit
>> >{
>> >namespace traits
>> >{
>> >
>> >// This handles std::optional attributes
>> >template <typename Attribute, typename Exposed>
>> >struct extract_from_attribute<std::experimental::optional<Attribute>,
>> >Exposed>
>> >{
>> >    typedef Attribute const& type;
>> >    template <typename Context>
>> >   static type call(std::experimental::optional<Attribute> const& attr,
>> >Context& ctx)
>> >    {
>> >        return attr.value();
>> >    }
>> >};
>> >
>> >template <typename Attribute, typename Exposed>
>> >struct extract_from_attribute<std::experimental::optional<Attribute
>> >const>,
>> >Exposed>
>> >{
>> >    typedef Attribute const& type;
>> >    template <typename Context>
>> >   static type call(std::experimental::optional<Attribute const> const&
>> >attr, Context& ctx)
>> >    {
>> >        return attr.value();
>> >    }
>> >};
>> >
>> >}
>> >}
>> >}
>> >
>> >//-----------------------------------
>> >
>> >This works good to extract the value, but, I need to handle the calls
>> >if
>> >the optional have, or not, a value. I tried to understand how karma
>> >handle
>> >this for boost::optional, but I'm stuck with that. Any idea?
>>
>> Are you trying to invoke the output regardless of optional state? Or can
>> you omit the output when optional does not have a value?
>>
>> >Thanks!!
>> >
>> >
>> >------------------------------------------------------------------------
>> >
>>
>> > >------------------------------------------------------------------------------
>> >Check out the vibrant tech community on one of the world's most
>> >engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> >
>> >------------------------------------------------------------------------
>> >
>> >_______________________________________________
>> >Spirit-general mailing list
>> >[hidden email]
>> >https://lists.sourceforge.net/lists/listinfo/spirit-general
>>
>> --
>> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Spirit-general mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/spirit-general
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Spirit-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/spirit-general
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: spirit::karma specialization for std::optional (C++17)

Emiliano Canedo
Yes, but I need to handle this with the library. When a optional don't have a value, karma must skip this attribute. The same behavior like with boost::optional (Karma handles boost::optional).

For example, I can't do something like this:
static type call(std::experimental::optional<Attribute> const& attr, Context& ctx)
{
    if (attr)
       return attr.value();
    else
       return nullopt;
}

The return type always must be Attribute.

On Fri, Apr 21, 2017 at 12:13 PM, Michael Powell <[hidden email]> wrote:
On Fri, Apr 21, 2017 at 11:06 AM, Emiliano Canedo
<[hidden email]> wrote:
> I can omit the output when optional doesn't have a value, but I don't know
> how

if (opt.has_value()) {
   /* output value */
}

http://en.cppreference.com/w/cpp/utility/optional

> On Fri, Apr 21, 2017 at 11:52 AM, Michael <[hidden email]> wrote:
>>
>>
>>
>> On April 21, 2017 10:20:42 AM EDT, Emiliano Canedo
>> <[hidden email]> wrote:
>> >Hello,
>> >
>> >I'm working in a spirit::karma specialization for std::optional
>> >(C++17). I
>> >have this code for now:
>> >
>> >//-----------------------------------
>> >
>> >namespace boost
>> >{
>> >namespace spirit
>> >{
>> >namespace traits
>> >{
>> >
>> >// This handles std::optional attributes
>> >template <typename Attribute, typename Exposed>
>> >struct extract_from_attribute<std::experimental::optional<Attribute>,
>> >Exposed>
>> >{
>> >    typedef Attribute const& type;
>> >    template <typename Context>
>> >   static type call(std::experimental::optional<Attribute> const& attr,
>> >Context& ctx)
>> >    {
>> >        return attr.value();
>> >    }
>> >};
>> >
>> >template <typename Attribute, typename Exposed>
>> >struct extract_from_attribute<std::experimental::optional<Attribute
>> >const>,
>> >Exposed>
>> >{
>> >    typedef Attribute const& type;
>> >    template <typename Context>
>> >   static type call(std::experimental::optional<Attribute const> const&
>> >attr, Context& ctx)
>> >    {
>> >        return attr.value();
>> >    }
>> >};
>> >
>> >}
>> >}
>> >}
>> >
>> >//-----------------------------------
>> >
>> >This works good to extract the value, but, I need to handle the calls
>> >if
>> >the optional have, or not, a value. I tried to understand how karma
>> >handle
>> >this for boost::optional, but I'm stuck with that. Any idea?
>>
>> Are you trying to invoke the output regardless of optional state? Or can
>> you omit the output when optional does not have a value?
>>
>> >Thanks!!
>> >
>> >
>> >------------------------------------------------------------------------
>> >
>>
>> > >------------------------------------------------------------------------------
>> >Check out the vibrant tech community on one of the world's most
>> >engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> >
>> >------------------------------------------------------------------------
>> >
>> >_______________________________________________
>> >Spirit-general mailing list
>> >[hidden email]
>> >https://lists.sourceforge.net/lists/listinfo/spirit-general
>>
>> --
>> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Spirit-general mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/spirit-general
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Spirit-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/spirit-general
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: spirit::karma specialization for std::optional (C++17)

Michael Powell-2
Post more detail, like your grammar, and perhaps someone can help you.

On Fri, Apr 21, 2017 at 11:21 AM, Emiliano Canedo
<[hidden email]> wrote:

> Yes, but I need to handle this with the library. When a optional don't have
> a value, karma must skip this attribute. The same behavior like with
> boost::optional (Karma handles boost::optional).
>
> For example, I can't do something like this:
> static type call(std::experimental::optional<Attribute> const& attr,
> Context& ctx)
> {
>     if (attr)
>        return attr.value();
>     else
>        return nullopt;
> }
>
> The return type always must be Attribute.
>
> On Fri, Apr 21, 2017 at 12:13 PM, Michael Powell <[hidden email]>
> wrote:
>>
>> On Fri, Apr 21, 2017 at 11:06 AM, Emiliano Canedo
>> <[hidden email]> wrote:
>> > I can omit the output when optional doesn't have a value, but I don't
>> > know
>> > how
>>
>> if (opt.has_value()) {
>>    /* output value */
>> }
>>
>> http://en.cppreference.com/w/cpp/utility/optional
>>
>> > On Fri, Apr 21, 2017 at 11:52 AM, Michael <[hidden email]> wrote:
>> >>
>> >>
>> >>
>> >> On April 21, 2017 10:20:42 AM EDT, Emiliano Canedo
>> >> <[hidden email]> wrote:
>> >> >Hello,
>> >> >
>> >> >I'm working in a spirit::karma specialization for std::optional
>> >> >(C++17). I
>> >> >have this code for now:
>> >> >
>> >> >//-----------------------------------
>> >> >
>> >> >namespace boost
>> >> >{
>> >> >namespace spirit
>> >> >{
>> >> >namespace traits
>> >> >{
>> >> >
>> >> >// This handles std::optional attributes
>> >> >template <typename Attribute, typename Exposed>
>> >> >struct extract_from_attribute<std::experimental::optional<Attribute>,
>> >> >Exposed>
>> >> >{
>> >> >    typedef Attribute const& type;
>> >> >    template <typename Context>
>> >> >   static type call(std::experimental::optional<Attribute> const&
>> >> > attr,
>> >> >Context& ctx)
>> >> >    {
>> >> >        return attr.value();
>> >> >    }
>> >> >};
>> >> >
>> >> >template <typename Attribute, typename Exposed>
>> >> >struct extract_from_attribute<std::experimental::optional<Attribute
>> >> >const>,
>> >> >Exposed>
>> >> >{
>> >> >    typedef Attribute const& type;
>> >> >    template <typename Context>
>> >> >   static type call(std::experimental::optional<Attribute const>
>> >> > const&
>> >> >attr, Context& ctx)
>> >> >    {
>> >> >        return attr.value();
>> >> >    }
>> >> >};
>> >> >
>> >> >}
>> >> >}
>> >> >}
>> >> >
>> >> >//-----------------------------------
>> >> >
>> >> >This works good to extract the value, but, I need to handle the calls
>> >> >if
>> >> >the optional have, or not, a value. I tried to understand how karma
>> >> >handle
>> >> >this for boost::optional, but I'm stuck with that. Any idea?
>> >>
>> >> Are you trying to invoke the output regardless of optional state? Or
>> >> can
>> >> you omit the output when optional does not have a value?
>> >>
>> >> >Thanks!!
>> >> >
>> >> >
>> >>
>> >> > >------------------------------------------------------------------------
>> >> >
>> >>
>> >> >
>> >> > > >------------------------------------------------------------------------------
>> >> >Check out the vibrant tech community on one of the world's most
>> >> >engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> >> >
>> >>
>> >> > >------------------------------------------------------------------------
>> >> >
>> >> >_______________________________________________
>> >> >Spirit-general mailing list
>> >> >[hidden email]
>> >> >https://lists.sourceforge.net/lists/listinfo/spirit-general
>> >>
>> >> --
>> >> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> Check out the vibrant tech community on one of the world's most
>> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> >> _______________________________________________
>> >> Spirit-general mailing list
>> >> [hidden email]
>> >> https://lists.sourceforge.net/lists/listinfo/spirit-general
>> >
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Check out the vibrant tech community on one of the world's most
>> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> > _______________________________________________
>> > Spirit-general mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/spirit-general
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Spirit-general mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/spirit-general
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Spirit-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/spirit-general
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: spirit::karma specialization for std::optional (C++17)

Emiliano Canedo
A complete example:

//--------------------------------------------------------------------------------------------

namespace boost
{
namespace spirit
{
namespace traits
{

// This handles std::optional attributes
template <typename Attribute, typename Exposed>
struct extract_from_attribute<std::experimental::optional<Attribute>, Exposed>
{
    typedef Attribute const& type;
    template <typename Context>
    static type call(std::experimental::optional<Attribute> const& attr, Context& ctx)
    {
        return attr.value();
    }
};

template <typename Attribute, typename Exposed>
struct extract_from_attribute<std::experimental::optional<Attribute const>, Exposed>
{
    typedef Attribute const& type;
    template <typename Context>
    static type call(std::experimental::optional<Attribute const> const& attr, Context& ctx)
    {
        return attr.value();
    }
};

}
}
}

struct MyStruct
{
    std::experimental::optional<int> foo;
    std::experimental::optional<float> flt;
   
    struct Other
    {
        std::experimental::optional<std::string> bar;
    };
    std::vector<Other> other;
};

BOOST_FUSION_ADAPT_STRUCT
(RTB::MyStruct::Other,
bar)

BOOST_FUSION_ADAPT_STRUCT
(RTB::MyStruct,
foo,
flt,
other)

template<typename Iterator>
struct BidRequestSerializer : boost::spirit::karma::grammar<Iterator, MyStruct()>
{
    BidRequestSerializer() : BidRequestSerializer::base_type(start_)
    {
        using boost::spirit::karma::int_;
        using boost::spirit::karma::float_;
        using boost::spirit::karma::string;
        using boost::spirit::karma::lit;

        other_obj_ = '{' << string << '}';
        other_ = lit("other:") << '[' << other_obj_ % ',' << ']';
        start_ = '{' << int_ << ',' << float_ << ',' << other_ << '}';
    }

private:
    boost::spirit::karma::rule<Iterator, MyStruct::Other()> other_obj_;
    boost::spirit::karma::rule<Iterator, std::vector<MyStruct::Other>()> other_;
    boost::spirit::karma::rule<Iterator, MyStruct()> start_;
};

//-------------------------------------------------------------------------------------------------------

On Fri, Apr 21, 2017 at 12:26 PM, Michael Powell <[hidden email]> wrote:
Post more detail, like your grammar, and perhaps someone can help you.

On Fri, Apr 21, 2017 at 11:21 AM, Emiliano Canedo
<[hidden email]> wrote:
> Yes, but I need to handle this with the library. When a optional don't have
> a value, karma must skip this attribute. The same behavior like with
> boost::optional (Karma handles boost::optional).
>
> For example, I can't do something like this:
> static type call(std::experimental::optional<Attribute> const& attr,
> Context& ctx)
> {
>     if (attr)
>        return attr.value();
>     else
>        return nullopt;
> }
>
> The return type always must be Attribute.
>
> On Fri, Apr 21, 2017 at 12:13 PM, Michael Powell <[hidden email]>
> wrote:
>>
>> On Fri, Apr 21, 2017 at 11:06 AM, Emiliano Canedo
>> <[hidden email]> wrote:
>> > I can omit the output when optional doesn't have a value, but I don't
>> > know
>> > how
>>
>> if (opt.has_value()) {
>>    /* output value */
>> }
>>
>> http://en.cppreference.com/w/cpp/utility/optional
>>
>> > On Fri, Apr 21, 2017 at 11:52 AM, Michael <[hidden email]> wrote:
>> >>
>> >>
>> >>
>> >> On April 21, 2017 10:20:42 AM EDT, Emiliano Canedo
>> >> <[hidden email]> wrote:
>> >> >Hello,
>> >> >
>> >> >I'm working in a spirit::karma specialization for std::optional
>> >> >(C++17). I
>> >> >have this code for now:
>> >> >
>> >> >//-----------------------------------
>> >> >
>> >> >namespace boost
>> >> >{
>> >> >namespace spirit
>> >> >{
>> >> >namespace traits
>> >> >{
>> >> >
>> >> >// This handles std::optional attributes
>> >> >template <typename Attribute, typename Exposed>
>> >> >struct extract_from_attribute<std::experimental::optional<Attribute>,
>> >> >Exposed>
>> >> >{
>> >> >    typedef Attribute const& type;
>> >> >    template <typename Context>
>> >> >   static type call(std::experimental::optional<Attribute> const&
>> >> > attr,
>> >> >Context& ctx)
>> >> >    {
>> >> >        return attr.value();
>> >> >    }
>> >> >};
>> >> >
>> >> >template <typename Attribute, typename Exposed>
>> >> >struct extract_from_attribute<std::experimental::optional<Attribute
>> >> >const>,
>> >> >Exposed>
>> >> >{
>> >> >    typedef Attribute const& type;
>> >> >    template <typename Context>
>> >> >   static type call(std::experimental::optional<Attribute const>
>> >> > const&
>> >> >attr, Context& ctx)
>> >> >    {
>> >> >        return attr.value();
>> >> >    }
>> >> >};
>> >> >
>> >> >}
>> >> >}
>> >> >}
>> >> >
>> >> >//-----------------------------------
>> >> >
>> >> >This works good to extract the value, but, I need to handle the calls
>> >> >if
>> >> >the optional have, or not, a value. I tried to understand how karma
>> >> >handle
>> >> >this for boost::optional, but I'm stuck with that. Any idea?
>> >>
>> >> Are you trying to invoke the output regardless of optional state? Or
>> >> can
>> >> you omit the output when optional does not have a value?
>> >>
>> >> >Thanks!!
>> >> >
>> >> >
>> >>
>> >> > >------------------------------------------------------------------------
>> >> >
>> >>
>> >> >
>> >> > > >------------------------------------------------------------------------------
>> >> >Check out the vibrant tech community on one of the world's most
>> >> >engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> >> >
>> >>
>> >> > >------------------------------------------------------------------------
>> >> >
>> >> >_______________________________________________
>> >> >Spirit-general mailing list
>> >> >[hidden email]
>> >> >https://lists.sourceforge.net/lists/listinfo/spirit-general
>> >>
>> >> --
>> >> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>> >>
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> Check out the vibrant tech community on one of the world's most
>> >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> >> _______________________________________________
>> >> Spirit-general mailing list
>> >> [hidden email]
>> >> https://lists.sourceforge.net/lists/listinfo/spirit-general
>> >
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Check out the vibrant tech community on one of the world's most
>> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> > _______________________________________________
>> > Spirit-general mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/spirit-general
>> >
>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Spirit-general mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/spirit-general
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Spirit-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/spirit-general
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Loading...