Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is it possible to adapt member functions using concept maps?

0
Posted

Is it possible to adapt member functions using concept maps?

0

No. Only non-member (free) functions and operators written as non-member (free) functions can be adapted using concept maps. Scott Meyers has advised C++ programmers to prefer non-member (free) functions over member functions in his 2003 article, “How Non-Member Functions Improve Encapsulation.” The same advice applies to concepts. There are several reasons for this design decision, but the main reason boils down to a major syntactic problem with expressing adapted member functions in concept maps. The way one writes a member function requirement in a concept is the same way that one writes a definition of a member function outside of the class. For example, here’s a concept that requires a member function swap: concept MemSwappable { void T::swap(T&); } Now, let’s try to make int, which clearly doesn’t have a member function swap, MemSwappable: concept_map MemSwappable { void int::swap(int&); // ill-formed } The problem, in this case, is that there isn’t a way for the

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123