1  
//
1  
//
2  
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
2  
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
 
3 +
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
3  
//
4  
//
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
5  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
5  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
//
7  
//
7  
// Official repository: https://github.com/boostorg/url
8  
// Official repository: https://github.com/boostorg/url
8  
//
9  
//
9  

10  

10  
#ifndef BOOST_URL_GRAMMAR_IMPL_OPTIONAL_RULE_HPP
11  
#ifndef BOOST_URL_GRAMMAR_IMPL_OPTIONAL_RULE_HPP
11  
#define BOOST_URL_GRAMMAR_IMPL_OPTIONAL_RULE_HPP
12  
#define BOOST_URL_GRAMMAR_IMPL_OPTIONAL_RULE_HPP
12  

13  

13  
#include <boost/url/grammar/error.hpp>
14  
#include <boost/url/grammar/error.hpp>
14  

15  

15  
namespace boost {
16  
namespace boost {
16  
namespace urls {
17  
namespace urls {
17  
namespace grammar {
18  
namespace grammar {
18  

19  

19  
template<class R>
20  
template<class R>
 
21 +
BOOST_URL_CXX14_CONSTEXPR
20  
auto
22  
auto
21  
implementation_defined::optional_rule_t<R>::
23  
implementation_defined::optional_rule_t<R>::
22  
parse(
24  
parse(
23  
    char const*& it,
25  
    char const*& it,
24  
    char const* end) const ->
26  
    char const* end) const ->
25  
        system::result<value_type>
27  
        system::result<value_type>
26  
{
28  
{
27  
    if(it == end)
29  
    if(it == end)
28  
        return boost::none;
30  
        return boost::none;
29  
    auto const it0 = it;
31  
    auto const it0 = it;
30  
    auto rv =
32  
    auto rv =
31  
        this->get().parse(it, end);
33  
        this->get().parse(it, end);
32  
    if(rv)
34  
    if(rv)
33  
        return value_type(*rv);
35  
        return value_type(*rv);
34  
    it = it0;
36  
    it = it0;
35  
    return boost::none;
37  
    return boost::none;
36  
}
38  
}
37  

39  

38  
} // grammar
40  
} // grammar
39  
} // urls
41  
} // urls
40  
} // boost
42  
} // boost
41  

43  

42  
#endif
44  
#endif