:orphan:
# PetscCallCXXAbort
Like `PetscCallCXX()` but calls `MPI_Abort()` instead of returning an error-code 
## Synopsis
```
#include <petscerror.h>
void PetscCallCXXAbort(MPI_Comm comm, ...) noexcept;
```
Collective; No Fortran Support


## Input Parameters

- ***comm        -*** The MPI communicator to abort on
- ***__VA_ARGS__ -*** An arbitrary expression





## Notes
This macro may be used to check C++ expressions for exceptions in cases where you cannot
return an error code. This includes constructors, destructors, copy/move assignment functions
or constructors among others.

If an exception is caught, the macro calls `SETERRABORT()` on `comm`. The exception must
derive from `std::exception` in order to be caught.

If the routine _can_ return an error-code it is highly advised to use `PetscCallCXX()`
instead.

See `PetscCallCXX()` for additional discussion.


## Example Usage
```none
  class Foo
  {
    std::vector<int> data_;

  public:
    // normally std::vector::reserve() may raise an exception, but since we handle it with
    // PetscCallCXXAbort() we may mark this routine as noexcept!
    Foo() noexcept
    {
      PetscCallCXXAbort(PETSC_COMM_SELF, data_.reserve(10));
    }
  };

  std::vector<int> bar()
  {
    std::vector<int> v;

    PetscFunctionBegin;
    // OK!
    PetscCallCXXAbort(PETSC_COMM_SELF, v.emplace_back(1));
    PetscFunctionReturn(v);
  }

  PetscErrorCode baz()
  {
    std::vector<int> v;

    PetscFunctionBegin;
    // WRONG! baz() returns a PetscErrorCode, prefer PetscCallCXX() instead
    PetscCallCXXAbort(PETSC_COMM_SELF, v.emplace_back(1));
    PetscFunctionReturn(PETSC_SUCCESS);
  }
```



## See Also
 `PetscCallCXX()`, `SETERRABORT()`, `PetscCallAbort()`

## Level
beginner

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscerror.h.html#PetscCallCXXAbort">include/petscerror.h</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscerror.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
