STRUCT DEDUCE_DOMA(3)

NAME
boost::proto::deduce_domain - A pseudo-domain for use in functions and metafunctions that require a domain parameter. It indicates that the domain of the parent node should be inferred from the domains of the child nodes.

SYNOPSIS

// In header: <boost/proto/domain.hpp>
struct deduce_domain {
};

DESCRIPTION

When proto::deduce_domain is used as a domain &#8212; either explicitly or implicitly by proto::make_expr(), proto::unpack_expr(), or Proto's operator overloads &#8212; Proto will use the domains of the child expressions to compute the domain of the parent. It is done in such a way that (A) expressions in domains that share a common super-domain are interoperable, and (B) expressions that are in the default domain (or a sub-domain thereof) are interoperable with all expressions. The rules are as follows:

    &#8226;
                    A sub-domain is stronger than its super-domain.
                  .RE

        &#8226; proto::default_domain
                        and all its sub-domains are weaker than all other domains.
                      .RE

            &#8226;
                            For each child, define a set of domains SN
                            that includes the child's domain and all its super-domains.
                          .RE

                &#8226;
                                Define a set IS that is the intersection of
                                all the individual sets SN that don't contain
                                proto::default_domain.
                              .RE

                    &#8226;
                                    Define a set IW that is the intersection of
                                    all the individual sets SN that contain
                                    proto::default_domain.
                                  .RE

                        &#8226;
                                        Define a set P that is the union of
                                        IS and
                                        IW.
                                      .RE

                            &#8226;
                                            The common domain is the strongest domain in set P, with the
                                            following caveat.
                                          .RE

                                &#8226;
                                                Let U be the union of all sets
                                                SN. If the result is
                                                proto::default_domain
                                                and U contains an element that is not proto::default_domain,
                                                it is an error.
                                              .RE

                            Note: the above description sounds like it would be expensive to compute at compile time. In fact, it can all be done using C++ function overloading.