{"record":{"id":"86536eef474291a6","repo":"Yalantis/uCrop","slug":"atnxyzc-empty-instance","errorCode":null,"errorMessage":"atNXYZC(): Empty instance.","messagePattern":"atNXYZC\\(\\): Empty instance\\.","errorType":"exception","errorClass":"CImgInstanceException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":65012,"sourceCode":"    }\n\n    //! Access to pixel value with Dirichlet boundary conditions \\const.\n    T atNXYZC(const int pos, const int x, const int y, const int z, const int c, const T& out_value) const {\n      return (pos<0 || pos>=width())?out_value:_data[pos].atXYZC(x,y,z,c,out_value);\n    }\n\n    //! Access to pixel value with Neumann boundary conditions.\n    /**\n       \\param pos Index of the image element to access.\n       \\param x X-coordinate of the pixel value.\n       \\param y Y-coordinate of the pixel value.\n       \\param z Z-coordinate of the pixel value.\n       \\param c C-coordinate of the pixel value.\n       \\note <tt>list.atNXYZC(p,x,y,z,c);</tt> is equivalent to <tt>list[p].atXYZC(x,y,z,c);</tt>.\n    **/\n    T& atNXYZC(const int pos, const int x, const int y, const int z, const int c) {\n      if (is_empty())\n        throw CImgInstanceException(_cimglist_instance\n                                    \"atNXYZC(): Empty instance.\",\n                                    cimglist_instance);\n\n      return _atNXYZC(pos,x,y,z,c);\n    }\n\n    //! Access to pixel value with Neumann boundary conditions \\const.\n    T atNXYZC(const int pos, const int x, const int y, const int z, const int c) const {\n      if (is_empty())\n        throw CImgInstanceException(_cimglist_instance\n                                    \"atNXYZC(): Empty instance.\",\n                                    cimglist_instance);\n\n      return _atNXYZC(pos,x,y,z,c);\n    }\n\n    T& _atNXYZC(const int pos, const int x, const int y, const int z, const int c) {\n      return _data[cimg::cut(pos,0,width() - 1)].atXYZC(x,y,z,c);","sourceCodeStart":64994,"sourceCodeEnd":65030,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L64994-L65030","documentation":"Non-const CImgList<T>::atNXYZC(pos,x,y,z,c) returns a mutable reference to a pixel of image at index pos with Neumann boundary clamping. It throws CImgInstanceException when the list itself is empty, before any coordinate handling happens.","triggerScenarios":"Calling list.atNXYZC(p,x,y,z,c) for a writable pixel on a CImgList with is_empty()==true (default-constructed or cleared list).","commonSituations":"Pixel-level loops written against a list that failed to load its images; modifying pixels of a list after remove_image() calls emptied it; helper functions receiving an unpopulated list.","solutions":["Check list.is_empty() before the call.","Ensure the list was successfully populated (check load() result / list.size()).","If only one image is needed, operate directly on a CImg instead of a list element.","Catch CImgInstanceException around the pixel access when emptiness is recoverable."],"exampleFix":"// before\nCImgList<float> imgs = load_list(path); // may fail and stay empty\nimgs.atNXYZC(0, 1, 1) = 0.f;\n// after\nCImgList<float> imgs;\nif (!imgs.load(path) || imgs.is_empty()) throw std::runtime_error(\"no images loaded\");\nimgs.atNXYZC(0, 1, 1, 0, 0) = 0.f;","handlingStrategy":"validation","validationCode":"// C++\nif (list.is_empty()) return; // or load/reinit before atNXYZC","typeGuard":"template <typename T>\nbool canSample(const CImgList<T>& l) { return !l.is_empty(); }","tryCatchPattern":"// C++\ntry {\n  list.atNXYZC(p, x, y, z, c) = v;\n} catch (CImgInstanceException& e) {\n  // empty list: recover or log\n}","preventionTips":["Validate list population before any pixel write loop.","Keep load() results checked; failed loads leave the list empty.","Prefer single CImg operations when only one image is needed.","Add debug asserts on list.size() in pixel-processing helpers."],"tags":["cimg","cpp","empty-list","pixel-access"],"backgroundTag":"empty-result-set","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}