How to specify a concept that requires a const method?

Hi,

I have this:


1
2
3
4
class Circle : public GeoObj {
public:
    virtual void draw() const override;
};


So I have created a concept like this:

1
2
3
4
    template<typename T>
    concept GeoObject = requires(const T & x) {
        { x.draw() } -> std::convertible_to<void>;
    };


I require draw() to be a const method. Does this concept GeoObject ensure this is the case?

If not how can I change the concept in order that it enforces constness?

Yes, because it checks for x.draw() where x has type T const.

I think every type is convertible to void.
yes you are correct about every type being convertible to void!

Thanks!
Topic archived. No new replies allowed.