Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::contracts::contract_violation

      From cppreference.com
      <cpp‎ |contract
       
       
      Utilities library
       
      Contract support
      Contract-violation information
      contract_violation
      (C++26)
      Helper functions
       
      Defined in header<contracts>
      class contract_violation;
      (since C++26)

      The classstd::contracts::contract_violation defines the type of objects used to represent a contract violation that has been detected during the evaluation of acontract assertion with a particular evaluation semantic.

      Objects of this type can only be created by the implementation when thecontract-violation handler needs to be invoked. Users cannot create such objects directly.

      Contents

      [edit]Member functions

      (constructor)
      [deleted]
      contract_violation objects cannot be constructed by users
      (public member function)
      operator=
      [deleted]
      contract_violation objects cannot be assigned
      (public member function)
      (destructor)
      [possibly virtual]
      destructs thecontract_violation object
      (public member function)
      General contract-violation information
      kind
      returns the kind of the contract assertion violated
      (public member function)
      semantic
      returns the evaluation semantic when the contract violation occurs
      (public member function)
      is_terminating
      returns whether the evaluation semantic is terminating
      (public member function)
      detection_mode
      returns the reason that causes the contract violation
      (public member function)
      evaluation_exception
      returns anstd::exception_ptr to the exception thrown from the predicate evaulation
      (public member function)
      Miscellaneous contract-violation information
      comment
      returns the explanatory string about the contract violation
      (public member function)
      location
      returns astd::source_location indicating the location of the contract violation
      (public member function)

      std::contracts::contract_violation::contract_violation

      contract_violation(const contract_violation&)= delete;
      (since C++26)

      The copy destructor is defined as deleted.std::contracts::contract_violation is notCopyConstructible.

      Notes

      Other constructors are for internal usage only, they are not user-accessible.

      std::contracts::contract_violation::operator=

      contract_violation& operator=(const contract_violation&)= delete;
      (since C++26)

      The copy assignment operator is defined as deleted.std::contracts::contract_violation is notCopyAssignable.

      std::contracts::contract_violation::~contract_violation

      /* see below */ ~contract_violation();
      (since C++26)

      Destructs thecontract_violation object.

      Notes

      It is implementation-defined whether the destructor is virtual.

      std::contracts::contract_violation::kind

      std::contracts::assertion_kind kind()constnoexcept;
      (since C++26)

      Return value

      Returns the enumerator value corresponding to the syntactic form of the violated contract assertion.

      std::contracts::contract_violation::semantic

      std::contracts::evaluation_semantic semantic()constnoexcept;
      (since C++26)

      Return value

      Returns the enumerator value corresponding to the evaluation semantic with which the violated contract assertion was evaluated.

      std::contracts::contract_violation::is_terminating

      bool is_terminating()constnoexcept;
      (since C++26)

      Return value

      If the evaluation semantic is aterminating semantic, returnstrue. Otherwise returnsfalse.

      std::contracts::contract_violation::detection_mode

      std::contracts::detection_mode detection_mode()constnoexcept;
      (since C++26)

      Return value

      Returns the enumerator value corresponding to the reasons that cause the contract violation.

      std::contracts::contract_violation::evaluation_exception

      std::exception_ptr evaluation_exception()constnoexcept;
      (since C++26)

      Return value

      If the contract violation occurred because the evaluation of the predicate exited via an exception, returns anstd::exception_ptr object that refers to that exception or a copy of that exception. Otherwise, returns a nullstd::exception_ptr object.

      std::contracts::contract_violation::comment

      constchar* comment()constnoexcept;
      (since C++26)

      Return value

      Returns an implementation-definednull-terminated multibyte string in theordinary literal encoding.

      Notes

      The C++ standard recommends that the string returned should contain a textual representation of the predicate of the violated contract assertion or an empty string if storing a textual representation is undesired.

      std::contracts::contract_violation::location

      std::source_location location()constnoexcept;
      (since C++26)

      Return value

      Returns astd::source_location object with implementation-defined value.

      Notes

      The C++ standard recommends that the value returned should be a default constructedstd::source_location object or a value identifying the violated contract assertion:

      • When possible, if the violated contract assertion was aprecondition assertion, the source location of the function invocation should be returned.
      • Otherwise, the source location of the contract assertion should be returned.
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/contract/contract_violation&oldid=182115"

      [8]ページ先頭

      ©2009-2025 Movatter.jp