Files
ortools-clone/ortools/util/python/pair.swig
Guillaume Chatelet 6af8bd54b4 Turn some .i files into .swig
This helps with the import / export process.
2025-07-02 19:11:40 +00:00

30 lines
1.1 KiB
Plaintext

// Copyright 2010-2025 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// SWIG Macros to use std::pair<T, U> OUTPUT in Python,
//
// Normally we'd simply use:
// ```swig
// %include "std_pair.i"
// %template(IntBoolPair) std::pair<int, bool>;
// ```
// see http://swig.org/Doc4.1/Library.html#Library_std_vector), but
// here we can't, because exceptions are forbidden and std_pair.i will rely on
// on python/pystdcommon.swg which use few throw in type traits...
%include "ortools/base/base.i"
%typemap(out) std::pair<int, bool> {
$result = Py_BuildValue("(ib)", $1.first, $1.second);
}