func => "atan2 cos sin exp abs log sqrt int",
conversion => 'bool "" 0+',
iterators => '<>',
+ filetest => "-X",
dereferencing => '${} @{} %{} &{} *{}',
+ matching => '~~',
special => 'nomethod fallback =');
use warnings::register;
=head1 DESCRIPTION
+This pragma allows overloading of Perl's operators for a class.
+To overload built-in functions, see L<perlsub/Overriding Built-in Functions> instead.
+
=head2 Declaration of overloaded functions
The compilation directive
B<BUGS> Even in list context, the iterator is currently called only
once and with scalar context.
+=item * I<File tests>
+
+ "-X"
+
+This overload is used for all the filetest operators (C<-f>, C<-x> and
+so on: see L<perlfunc/-X> for the full list). Even though these are
+unary operators, the method will be called with a second argument which
+is a single letter indicating which test was performed. Note that the
+overload key is the literal string C<"-X">: you can't provide separate
+overloads for the different tests.
+
+Calling an overloaded filetest operator does not affect the stat value
+associated with the special filehandle C<_>. It still refers to the
+result of the last C<stat>, C<lstat> or unoverloaded filetest.
+
+If not overloaded, these operators will fall back to the default
+behaviour even without C<< fallback => 1 >>. This means that if the
+object is a blessed glob or blessed IO ref it will be treated as a
+filehandle, otherwise string overloading will be invoked and the result
+treated as a filename.
+
+This overload was introduced in perl 5.12.
+
+=item * I<Matching>
+
+The key C<"~~"> allows you to override the smart matching used by
+the switch construct. See L<feature>.
+
=item * I<Dereferencing>
'${}', '@{}', '%{}', '&{}', '*{}'.
=item * I<Special>
- "nomethod", "fallback", "=", "~~",
+ "nomethod", "fallback", "=".
see L<SPECIAL SYMBOLS FOR C<use overload>>.
func => 'atan2 cos sin exp abs log sqrt',
conversion => 'bool "" 0+',
iterators => '<>',
+ filetest => '-X',
dereferencing => '${} @{} %{} &{} *{}',
+ matching => '~~',
special => 'nomethod fallback ='
=head2 Inheritance and overloading
B<Note.> C<"fallback"> inheritance via @ISA is not carved in stone
yet, see L<"Inheritance and overloading">.
-=head2 Smart Match
-
-The key C<"~~"> allows you to override the smart matching used by
-the switch construct. See L<feature>.
-
=head2 Copy Constructor
The value for C<"="> is a reference to a function with three