IMP logo
IMP Reference Guide  2.20.2
The Integrative Modeling Platform
bracket_macros.h File Reference

Macros to handle array indexing. More...

#include <IMP/kernel_config.h>
+ Include dependency graph for bracket_macros.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IMP_BRACKET(Value, Index, bounds_check_expr, expr)
 Implement operator[] and at() for C++, and getitem for Python. More...
 
#define IMP_CONST_BRACKET(Value, Index, bounds_check_expr, expr)
 Implement operator[] and at() for C++, and getitem for Python. More...
 

Detailed Description

Macros to handle array indexing.

Copyright 2007-2022 IMP Inventors. All rights reserved.

Definition in file bracket_macros.h.

Macro Definition Documentation

#define IMP_BRACKET (   Value,
  Index,
  bounds_check_expr,
  expr 
)

Implement operator[] and at() for C++, and getitem for Python.

The index type is Index and the expression that returns the value is expr. Like the equivalent methods in std::vector, at() performs bound checking; if the bounds_check_expr is false, then a UsageException is thrown. operator[] does no bounds checks, except in debug mode. In Python, bounds checking is always done and results in an IndexException if bounds_check_expr is false.

Definition at line 22 of file bracket_macros.h.

#define IMP_CONST_BRACKET (   Value,
  Index,
  bounds_check_expr,
  expr 
)
Value:
const Value at(Index) const; \
const Value operator[](Index) const;

Implement operator[] and at() for C++, and getitem for Python.

The index type is Index and the expression that returns the value is expr. The value returned is not mutable. Like the equivalent methods in std::vector, at() performs bound checking; if the bounds_check_expr is false, then a UsageException is thrown. operator[] does no bounds checks, except in debug mode. In Python, bounds checking is always done and results in an IndexException if bounds_check_expr is false.

Definition at line 37 of file bracket_macros.h.