Hi Peter,

Thanks a lot!

It worked for me like this (described in
https://www.cplusplus.com/reference/set/set/set/ ):
bool(*fn_pt)(Point<dim>,Point<dim>) = comp_points; //comp_points is my
function as I declared it in the question
std::set< Point<dim>, bool(*)(Point<dim>,Point<dim>) > vertices(fn_pt);

Just for a better understanding, the following approach from your linked
website did not work:
std::set< Point<dim>, decltype(&comp_points) > vertices(&comp_points);

There are four errors:
-decltype cannot resolve address of overloaded function
-template argument 2 is invalid
-request for member ‘insert’ in ‘vertices’, which is of non-class type ‘int’
-cannot resolve overloaded function ‘comp_points’ based on conversion to
type ‘int’

As far as I understood, decltype(&comp_points) returns '
bool(*)(Point<dim>,Point<dim> ' ,i.e it should be exactly the same as my
first version, isn't it?

Best
Simon


Am So., 27. Juni 2021 um 12:25 Uhr schrieb Peter Munch <
[email protected]>:

> Hi Simon,
>
> you don't need to modify the point class. You can simply pas to the
> constructor of the set a comparator. See the first answer in
> https://stackoverflow.com/questions/2620862/using-custom-stdset-comparator
> .
>
> Hope this helps,
> PM
>
> On Sunday, 27 June 2021 at 12:15:40 UTC+2 Simon wrote:
>
>> Dear all,
>>
>> I am trying to create a set of Points<dim>, i.e std::set<Point<dim>>.
>> I get a quite extensive error message when trying to insert a point in
>> the set but for my understanding of the message, the only problem is the
>> missing operator< for two points.
>> (Well I could make use of a std::vector instead but a std::set fits much
>> better for my issue since (i) I need to insert points at arbitrary
>> positions quite often and second (ii) wanna make sure that a given Point is
>> only once in the container.)
>>
>> But irrespective of what container I use, I would like to supplement the
>> Point Class by adding the 'operator<' like in the following:
>>
>> template<int dim, typename Number=double>
>> bool Point<dim>::operator< (const Point<dim,Number>& p)
>> {
>> //...some Asserts
>> return this.norm()<p.norm();
>> }
>>
>> Of course I can not write this piece of code since there is no
>> declaration for a member function 'operator<' in the Point Class.
>> For that reasons my next idea was to modify the file <
>> deal.II/base/point.h
>> <https://www.dealii.org/current/doxygen/deal.II/base_2point_8h_source.html>>
>> by simply adding the missing operator< declaration and the corresponding
>> definition. So I did this but without effect, probably because all the
>> files of the dealii-library are already compiled and executing my program
>> via 'make run' did not see my changes in the Point Class at all. (I also
>> added a dummy command, std::cout<<"...Test..."<<std::endl, which did not
>> appear on my screen either.)
>>
>> I am only familiar with basic cmake- and make-commands.
>> My question is if it is possible to recompile one specific file of the
>> library again?
>> So if this were possible I would appreciate getting some guidance for
>> implementing this.
>> I would also be interested in writing a patch for that issue.
>>
>> Best
>> Simon
>>
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/34faa5ae-9bed-4a66-ad9f-cb2bb59d7ba1n%40googlegroups.com
> <https://groups.google.com/d/msgid/dealii/34faa5ae-9bed-4a66-ad9f-cb2bb59d7ba1n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAM50jEsthHLQf8nb_qUL3ziAebTh4V%2B6p2wQ_C-aUPyKHvMk9g%40mail.gmail.com.

Reply via email to