Questions tagged [partial-ordering]
81 questions
72
votes
4 answers
Why can't I use the method __cmp__ in Python 3 as for Python 2?
The following piece of code
class point:
def __init__(self, x, y):
self.x = x
self.y = y
def dispc(self):
return ('(' + str(self.x) + ',' + str(self.y) + ')')
def __cmp__(self, other):
return ((self.x >…
user1065734
47
votes
2 answers
Why does Rust not implement total ordering via the Ord trait for f64 and f32?
While all the integer types in Rust implement Ord which emphasizes total ordering, the floating point types only implement PartialOrd. This means that there could be floating point values which cannot be compared. This seems difficult to digest…

Shailesh Kumar
- 6,457
- 8
- 35
- 60
47
votes
1 answer
What is the partial ordering procedure in template deduction
Reading the C++11 standard I can't fully understand the meaning of the following statement. Example are very welcome.
Two sets of types are used to determine the partial ordering. For each
of the templates involved there is the original function…

yuan
- 2,434
- 1
- 21
- 29
43
votes
1 answer
Class template specialization partial ordering and function synthesis
The rules for picking which class template specialization is preferred involve rewriting the specializations into function templates and determining which function template is more specialized via the ordering rules for function templates…

Barry
- 286,269
- 29
- 621
- 977
25
votes
2 answers
Template partial ordering - why does partial deduction succeed here
Consider the following simple (to the extent that template questions ever are) example:
#include
template
struct identity;
template <>
struct identity {
using type = int;
};
template void bar(T, T ) {…

Barry
- 286,269
- 29
- 621
- 977
25
votes
4 answers
Partial ordering with function template having undeduced context
While reading another question, i came to a problem with partial ordering, which i cut down to the following test-case
template
struct Const { typedef void type; };
template
void f(T, typename Const::type*) { cout <<…

Johannes Schaub - litb
- 496,577
- 130
- 894
- 1,212
18
votes
6 answers
Topological Sorting using LINQ
I have a list of items that have a partial order relation, i. e, the list can be considered a partially ordered set. I want to sort this list in the same way as in this question. As correctly answered there, this is known as topological…

jpbochi
- 4,366
- 3
- 34
- 43
15
votes
1 answer
Why is a C++ template accepting an array not more specialized than one accepting a pointer according to GCC 5.3 and Clang 4.0?
Why are the next two template declarations ambiguous (so neither is more specialized than the other)? I know this question has been raised many times on Stack Overflow, but usually, people answer how to resolve ambiguity, not why it's…

Vyacheslav Grigoryev
- 201
- 1
- 5
14
votes
2 answers
Generate a DAG from a poset using stricly functional programming
Here is my problem: I have a sequence S of (nonempty but possibly not distinct) sets s_i, and for each s_i need to know how many sets s_j in S (i ≠ j) are subsets of s_i.
I also need incremental performance: once I have all my counts, I may replace…

scand1sk
- 1,114
- 11
- 25
14
votes
2 answers
When is a template more specialized than the other? 'And'/'Or' confusion with logics.
In 14.8.2.4p10 of the C++11 draft, there is written
If for each type being considered a given template is at least as specialized for all types and more specialized for some set of types and the other template is not more specialized for any types…

Johannes Schaub - litb
- 496,577
- 130
- 894
- 1,212
11
votes
2 answers
When are two function templates considered as partially ordered and when are ambiguous?
I'm completely confused after reading the question How to make these std::function parameters unambiguous?, so far I'd thought I understood what partial ordering of function templates is, but after reading that question I wrote down three examples…

Marc Andreson
- 3,405
- 5
- 35
- 51
10
votes
3 answers
partial specialization ordering with non-deduced context
According to [temp.class.order] §14.5.5.2, the selection of a partial specialization of t in this example:
template< typename >
struct s { typedef void v, w; };
template< typename, typename = void >
struct t {};
template< typename c >
struct t< c,…

Potatoswatter
- 134,909
- 25
- 265
- 421
10
votes
1 answer
How does `std::less` work?
Pointer relational operators do not define a total order (§ 5.9 of the C++11 standard):
If two pointers p and q of the same type point to different objects that are not members of the same object or elements of the same array or to different…

rom1v
- 2,752
- 3
- 21
- 47
9
votes
1 answer
Overload resolution for function templates with auto non-type template parameter
What are the rules for the selection of overloaded function templates in case of non-type template parameters, if one of the parameters is a placeholder type. I am confused with the current behavior of the compilers, consider the next…

Fedor
- 17,146
- 13
- 40
- 131
9
votes
2 answers
gcc vs. clang, msvc and icc: Is this function call ambiguous?
All compilers I could get my hands on agree that this is fine:
template
auto foo(Check, T...) -> void;
template
auto foo(int, T...) -> void;
int main()
{
foo(7, "");
}
However, the following code…

Rumburak
- 3,416
- 16
- 27