advice_concepts.html not found\n
There are 1 comments and replies

Comment on This Page

  • akrzemi1 says:

    Hi, I find this page really useful, even outside the context of submitting a library into Boost. I think there is a small type’o in the part that compares Boost CCL with Concepts lite. The first example says:
    BOOST_CONCEPT_USAGE(Swappable){
    BOOST_CONCEPT_ASSERT((boost::Assignable<T>));
    boost::swap(t1, t2);
    }

    This example does not compile, and because there are header includes in there, it suggests like you are giving a full example, but it is not full, because t1 and t2 are never declared.

    I think it should read:

    BOOST_CONCEPT_ASSERT((boost::Assignable<T>));
    BOOST_CONCEPT_USAGE(Swappable){
    boost::swap(t1, t2);
    }

    One other suggestion, regarding the Concepts Lite example, it is technically correct, but it looks somewhat counter to the intention of the authors. The number of times ‘requires’ is used makes the reader feel, that Concepts Lite are a clumsy feature. The following is an alternative way of expressing the same requirement:

    template <typename T>
    concept bool Swappable = requires(T t1, T t2)
    {
    requires Assignable<T>;
    boost::swap(t1, t2);
    };