Unable to install bcrypto on mac with chip Apple M1 - bcrypt

I have bcrypto as a dependency of 3box which is already a dependency (dependency of dependency), and it seems since bcrypto hasn't been updated for M1 chips there is no way to install it. I've been told to install from the source, but no idea how to do it on Mac. Any suggestion is welcome.
The repo that I'm trying to install is https://github.com/1Hive/honey-pot
Here's a copy of the logs:
[4/4] 🔨 Building fresh packages...
[12/25] â   bcrypto
[-/25] â   waiting...
[-/25] â   waiting...
[-/25] â   waiting...
error /Users/gastonneedleman/Coding/honey-pot/node_modules/libp2p-noise/node_modules/bcrypto: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/gastonneedleman/Coding/honey-pot/node_modules/libp2p-noise/node_modules/bcrypto
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp#7.1.2
gyp info using node#14.16.1 | darwin | x64
gyp info find Python using Python version 3.9.4 found at "/Library/Frameworks/Python.framework/Versions/3.9/bin/python3"
gyp info spawn /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
gyp info spawn args [
gyp info spawn args '/Users/gastonneedleman/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/gastonneedleman/Coding/honey-pot/node_modules/libp2p-noise/node_modules/bcrypto/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/gastonneedleman/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/gastonneedleman/Library/Caches/node-gyp/14.16.1/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/gastonneedleman/Library/Caches/node-gyp/14.16.1',
gyp info spawn args '-Dnode_gyp_dir=/Users/gastonneedleman/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/gastonneedleman/Library/Caches/node-gyp/14.16.1/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/gastonneedleman/Coding/honey-pot/node_modules/libp2p-noise/node_modules/bcrypto',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CC(target) Release/obj.target/bcrypto/src/torsion/src/aead.o
CC(target) Release/obj.target/bcrypto/src/torsion/src/chacha20.o
CC(target) Release/obj.target/bcrypto/src/torsion/src/drbg.o
CC(target) Release/obj.target/bcrypto/src/torsion/src/dsa.o
In file included from ../src/torsion/src/dsa.c:34:
In file included from ../src/torsion/src/asn1.h:13:
In file included from ../src/torsion/src/mpz.h:20:
../src/torsion/src/gmp-compat.h:124:1: warning: unused function 'mpn_tdiv_qr' [-Wunused-function]
mpn_tdiv_qr(mp_limb_t *qp,
^
../src/torsion/src/gmp-compat.h:154:1: warning: unused function 'mpn_gcdext' [-Wunused-function]
mpn_gcdext(mp_limb_t *gp,
^
In file included from ../src/torsion/src/dsa.c:34:
In file included from ../src/torsion/src/asn1.h:13:
../src/torsion/src/mpz.h:456:1: warning: unused function 'torsion_mpz_random_prime' [-Wunused-function]
mpz_random_prime(mpz_t ret, size_t bits, drbg_t *rng) {
^
../src/torsion/src/mpz.h:35:26: note: expanded from macro 'mpz_random_prime'
#define mpz_random_prime torsion_mpz_random_prime
^
In file included from ../src/torsion/src/dsa.c:34:
../src/torsion/src/asn1.h:94:1: warning: unused function 'asn1_read_int' [-Wunused-function]
asn1_read_int(unsigned char *out, size_t out_len,
^
../src/torsion/src/asn1.h:270:1: warning: unused function 'asn1_size_int' [-Wunused-function]
asn1_size_int(const unsigned char *num, size_t len) {
^
../src/torsion/src/asn1.h:331:1: warning: unused function 'asn1_write_int' [-Wunused-function]
asn1_write_int(unsigned char *data, size_t pos,
^
6 warnings generated.
CC(target) Release/obj.target/bcrypto/src/torsion/src/ecc.o
In file included from ../src/torsion/src/ecc.c:158:
In file included from ../src/torsion/src/asn1.h:13:
In file included from ../src/torsion/src/mpz.h:20:
../src/torsion/src/gmp-compat.h:103:1: warning: unused function 'mpz_powm_sec' [-Wunused-function]
mpz_powm_sec(mpz_t rop, const mpz_t base, const mpz_t exp, const mpz_t mod) {
^
In file included from ../src/torsion/src/ecc.c:158:
In file included from ../src/torsion/src/asn1.h:13:
../src/torsion/src/mpz.h:42:1: warning: unused function 'torsion_mpz_roset' [-Wunused-function]
mpz_roset(mpz_t r, const mpz_t x) {
^
../src/torsion/src/mpz.h:25:19: note: expanded from macro 'mpz_roset'
#define mpz_roset torsion_mpz_roset
^
../src/torsion/src/mpz.h:83:1: warning: unused function 'torsion_mpz_export_pad' [-Wunused-function]
mpz_export_pad(unsigned char *out, const mpz_t n, size_t size, int endian) {
^
../src/torsion/src/mpz.h:28:24: note: expanded from macro 'mpz_export_pad'
#define mpz_export_pad torsion_mpz_export_pad
^
../src/torsion/src/mpz.h:456:1: warning: unused function 'torsion_mpz_random_prime' [-Wunused-function]
mpz_random_prime(mpz_t ret, size_t bits, drbg_t *rng) {
^
../src/torsion/src/mpz.h:35:26: note: expanded from macro 'mpz_random_prime'
#define mpz_random_prime torsion_mpz_random_prime
^
In file included from ../src/torsion/src/ecc.c:158:
../src/torsion/src/asn1.h:204:1: warning: unused function 'asn1_read_version' [-Wunused-function]
asn1_read_version(const unsigned char **data, size_t *len,
^
../src/torsion/src/asn1.h:235:1: warning: unused function 'asn1_read_dumb' [-Wunused-function]
asn1_read_dumb(mpz_t n, const unsigned char **data, size_t *len) {
^
../src/torsion/src/asn1.h:286:1: warning: unused function 'asn1_size_mpz' [-Wunused-function]
asn1_size_mpz(const mpz_t n) {
^
../src/torsion/src/asn1.h:301:1: warning: unused function 'asn1_size_version' [-Wunused-function]
asn1_size_version(unsigned char version) {
^
../src/torsion/src/asn1.h:365:1: warning: unused function 'asn1_write_mpz' [-Wunused-function]
asn1_write_mpz(unsigned char *data, size_t pos, const mpz_t n) {
^
../src/torsion/src/asn1.h:395:1: warning: unused function 'asn1_write_version' [-Wunused-function]
asn1_write_version(unsigned char *data, size_t pos, unsigned char version) {
^
../src/torsion/src/asn1.h:403:1: warning: unused function 'asn1_write_dumb' [-Wunused-function]
asn1_write_dumb(unsigned char *data, size_t pos, const mpz_t n) {
^
../src/torsion/src/ecc.c:526:1: warning: unused function 'bytes_equal' [-Wunused-function]
bytes_equal(const unsigned char *a,
^
../src/torsion/src/ecc.c:562:1: warning: unused function 'bytes_lte' [-Wunused-function]
bytes_lte(const unsigned char *a,
^
../src/torsion/src/ecc.c:688:1: warning: unused function 'sc_swap' [-Wunused-function]
sc_swap(scalar_field_t *sc, sc_t a, sc_t b, unsigned int flag) {
^
../src/torsion/src/ecc.c:808:1: warning: unused function 'sc_sub' [-Wunused-function]
sc_sub(scalar_field_t *sc, sc_t r, const sc_t a, const sc_t b) {
^
../src/torsion/src/ecc.c:1760:1: warning: unused function 'fe_random' [-Wunused-function]
fe_random(prime_field_t *fe, fe_t x, drbg_t *rng) {
^
../src/torsion/src/ecc.c:2090:1: warning: unused function 'wge_swap' [-Wunused-function]
wge_swap(wei_t *ec, wge_t *a, wge_t *b, unsigned int flag) {
^
../src/torsion/src/ecc.c:2130:1: warning: unused function 'wge_equal' [-Wunused-function]
wge_equal(wei_t *ec, const wge_t *a, const wge_t *b) {
^
../src/torsion/src/ecc.c:2158:1: warning: unused function 'wge_is_square_var' [-Wunused-function]
wge_is_square_var(wei_t *ec, const wge_t *p) {
^
../src/torsion/src/ecc.c:2166:1: warning: unused function 'wge_equal_x' [-Wunused-function]
wge_equal_x(wei_t *ec, const wge_t *p, const fe_t x) {
^
../src/torsion/src/ecc.c:2325:1: warning: unused function 'wge_dbl' [-Wunused-function]
wge_dbl(wei_t *ec, wge_t *r, const wge_t *p) {
^
../src/torsion/src/ecc.c:2469:1: warning: unused function 'jge_swap' [-Wunused-function]
jge_swap(wei_t *ec, jge_t *a, jge_t *b, unsigned int flag) {
^
../src/torsion/src/ecc.c:2507:1: warning: unused function 'jge_equal' [-Wunused-function]
jge_equal(wei_t *ec, const jge_t *a, const jge_t *b) {
^
../src/torsion/src/ecc.c:2538:1: warning: unused function 'jge_is_square' [-Wunused-function]
jge_is_square(wei_t *ec, const jge_t *p) {
^
../src/torsion/src/ecc.c:2629:1: warning: unused function 'jge_neg_cond' [-Wunused-function]
jge_neg_cond(wei_t *ec, jge_t *r, const jge_t *a, unsigned int flag) {
^
../src/torsion/src/ecc.c:3163:1: warning: unused function 'jge_sub' [-Wunused-function]
jge_sub(wei_t *ec, jge_t *r, const jge_t *a, const jge_t *b) {
^
../src/torsion/src/ecc.c:3311:1: warning: unused function 'jge_mixed_sub' [-Wunused-function]
jge_mixed_sub(wei_t *ec, jge_t *r, const jge_t *a, const wge_t *b) {
^
../src/torsion/src/ecc.c:3387:1: warning: unused function 'jge_validate' [-Wunused-function]
jge_validate(wei_t *ec, const jge_t *p) {
^
../src/torsion/src/ecc.c:4211:1: warning: unused function 'wei_mul_multi_var' [-Wunused-function]
wei_mul_multi_var(wei_t *ec,
^
../src/torsion/src/ecc.c:4729:1: warning: unused function 'mge_zero' [-Wunused-function]
mge_zero(mont_t *ec, mge_t *r) {
^
../src/torsion/src/ecc.c:4747:1: warning: unused function 'mge_validate' [-Wunused-function]
mge_validate(mont_t *ec, const mge_t *p) {
^
../src/torsion/src/ecc.c:4827:1: warning: unused function 'mge_swap' [-Wunused-function]
mge_swap(mont_t *ec, mge_t *a, mge_t *b, unsigned int flag) {
^
../src/torsion/src/ecc.c:4841:1: warning: unused function 'mge_set' [-Wunused-function]
mge_set(mont_t *ec, mge_t *r, const mge_t *a) {
^
../src/torsion/src/ecc.c:4850:1: warning: unused function 'mge_equal' [-Wunused-function]
mge_equal(mont_t *ec, const mge_t *a, const mge_t *b) {
^
../src/torsion/src/ecc.c:4868:1: warning: unused function 'mge_is_zero' [-Wunused-function]
mge_is_zero(mont_t *ec, const mge_t *a) {
^
../src/torsion/src/ecc.c:4882:1: warning: unused function 'mge_dbl' [-Wunused-function]
mge_dbl(mont_t *ec, mge_t *r, const mge_t *p) {
^
../src/torsion/src/ecc.c:5149:1: warning: unused function 'pge_equal' [-Wunused-function]
pge_equal(mont_t *ec, const pge_t *a, const pge_t *b) {
^
../src/torsion/src/ecc.c:5874:1: warning: unused function 'xge_swap' [-Wunused-function]
xge_swap(edwards_t *ec, xge_t *a, xge_t *b, unsigned int flag) {
^
../src/torsion/src/ecc.c:5947:1: warning: unused function 'xge_neg_cond' [-Wunused-function]
xge_neg_cond(edwards_t *ec, xge_t *r, const xge_t *a, unsigned int flag) {
^
../src/torsion/src/ecc.c:6135:1: warning: unused function 'xge_normalize' [-Wunused-function]
xge_normalize(edwards_t *ec, xge_t *r, const xge_t *p) {
^
../src/torsion/src/ecc.c:6159:1: warning: unused function 'xge_normalize_var' [-Wunused-function]
xge_normalize_var(edwards_t *ec, xge_t *r, const xge_t *p) {
^
41 warnings generated.
CC(target) Release/obj.target/bcrypto/src/torsion/src/hash.o
../src/torsion/src/hash.c:68:1: warning: unused function 'read64be' [-Wunused-function]
read64be(const void *src) {
^
1 warning generated.
CC(target) Release/obj.target/bcrypto/src/torsion/src/kdf.o
CC(target) Release/obj.target/bcrypto/src/torsion/src/poly1305.o
CC(target) Release/obj.target/bcrypto/src/torsion/src/rsa.o
In file included from ../src/torsion/src/rsa.c:29:
In file included from ../src/torsion/src/asn1.h:13:
In file included from ../src/torsion/src/mpz.h:20:
../src/torsion/src/gmp-compat.h:124:1: warning: unused function 'mpn_tdiv_qr' [-Wunused-function]
mpn_tdiv_qr(mp_limb_t *qp,
^
../src/torsion/src/gmp-compat.h:154:1: warning: unused function 'mpn_gcdext' [-Wunused-function]
mpn_gcdext(mp_limb_t *gp,
^
In file included from ../src/torsion/src/rsa.c:29:
../src/torsion/src/asn1.h:94:1: warning: unused function 'asn1_read_int' [-Wunused-function]
asn1_read_int(unsigned char *out, size_t out_len,
^
../src/torsion/src/asn1.h:270:1: warning: unused function 'asn1_size_int' [-Wunused-function]
asn1_size_int(const unsigned char *num, size_t len) {
^
../src/torsion/src/asn1.h:331:1: warning: unused function 'asn1_write_int' [-Wunused-function]
asn1_write_int(unsigned char *data, size_t pos,
^
../src/torsion/src/rsa.c:1024:1: warning: unused function 'rsa_pub_set' [-Wunused-function]
rsa_pub_set(rsa_pub_t *r, const rsa_pub_t *k) {
^
6 warnings generated.
CC(target) Release/obj.target/bcrypto/src/torsion/src/salsa20.o
CC(target) Release/obj.target/bcrypto/src/torsion/src/siphash.o
CC(target) Release/obj.target/bcrypto/src/torsion/src/util.o
CC(target) Release/obj.target/bcrypto/src/base58/base58.o
CC(target) Release/obj.target/bcrypto/src/bech32/bech32.o
CC(target) Release/obj.target/bcrypto/src/cash32/cash32.o
CC(target) Release/obj.target/bcrypto/src/murmur3/murmur3.o
CXX(target) Release/obj.target/bcrypto/src/aead.o
CXX(target) Release/obj.target/bcrypto/src/base58.o
CXX(target) Release/obj.target/bcrypto/src/bech32.o
CXX(target) Release/obj.target/bcrypto/src/bcrypto.o
CXX(target) Release/obj.target/bcrypto/src/blake2b.o
CXX(target) Release/obj.target/bcrypto/src/blake2s.o
CXX(target) Release/obj.target/bcrypto/src/cash32.o
CXX(target) Release/obj.target/bcrypto/src/chacha20.o
CXX(target) Release/obj.target/bcrypto/src/dsa.o
CXX(target) Release/obj.target/bcrypto/src/dsa_async.o
CXX(target) Release/obj.target/bcrypto/src/ecdh.o
CXX(target) Release/obj.target/bcrypto/src/ecdsa.o
CXX(target) Release/obj.target/bcrypto/src/eddsa.o
CXX(target) Release/obj.target/bcrypto/src/hash.o
CXX(target) Release/obj.target/bcrypto/src/hmac.o
CXX(target) Release/obj.target/bcrypto/src/keccak.o
CXX(target) Release/obj.target/bcrypto/src/murmur3.o
CXX(target) Release/obj.target/bcrypto/src/pbkdf2.o
CXX(target) Release/obj.target/bcrypto/src/pbkdf2_async.o
CXX(target) Release/obj.target/bcrypto/src/poly1305.o
CXX(target) Release/obj.target/bcrypto/src/rsa.o
CXX(target) Release/obj.target/bcrypto/src/rsa_async.o
CXX(target) Release/obj.target/bcrypto/src/salsa20.o
CXX(target) Release/obj.target/bcrypto/src/scrypt.o
CXX(target) Release/obj.target/bcrypto/src/scrypt_async.o
CXX(target) Release/obj.target/bcrypto/src/siphash.o
CXX(target) Release/obj.target/bcrypto/src/util.o
CC(target) Release/obj.target/bcrypto/src/torsion/src/mini-gmp.o
CC(target) Release/obj.target/bcrypto/src/secp256k1/src/secp256k1.o
In file included from ../src/secp256k1/src/secp256k1.c:12:
In file included from ../src/secp256k1/src/scalar_impl.h:20:
../src/secp256k1/src/scalar_4x64_impl.h:969:5: error: implicitly declaring library function 'memcpy' with type 'void *(void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
memcpy((void *) seed32, (const void *) seed, 32);
^
../src/secp256k1/src/scalar_4x64_impl.h:969:5: note: include the header <string.h> or explicitly provide a declaration for 'memcpy'
1 error generated.
make: *** [Release/obj.target/bcrypto/src/secp256k1/src/secp256k1.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/gastonneedleman/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 20.3.0
gyp ERR! command "/Users/gastonneedleman/.nvm/versions/node/v14.16.1/bin/node" "/Users/gastonneedleman/.nvm/versions/node/v14.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/gastonneedleman/Coding/honey-pot/node_modules/libp2p-noise/node_modules/bcrypto

Related

How to get *any* example of boost::mpl::map working?

Here is my sample code. Can someone please help me with it?
#include <string>
#include <utility> //Not strictly necessary (gets imported implicitely anyway)
#include <boost/mpl/map.hpp>
#include <boost/mpl/size.hpp>
#include <boost/type_traits/is_same.hpp>
typedef boost::mpl::map<
std::pair<int,unsigned>
, std::pair<char,unsigned char>
> m;
int main()
{
std::pair<int,unsigned> b(10,10); //this works
int a = boost::mpl::size<m>::value; //this doesn't
}
The error message:
In file included from /home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/map/aux_/include_preprocessed.hpp:47:0,
from /home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/map/map10.hpp:28,
from /home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/map/map20.hpp:19,
from /home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/map.hpp:36,
from /home/adam/c++/tests/simple_test/test2.cpp:3:
/home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/map/aux_/preprocessed/typeof_based/map10.hpp: In instantiation of ‘struct boost::mpl::map2<std::pair<int, unsigned int>, std::pair<char, unsigned char> >’:
/home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/aux_/preprocessed/gcc/map.hpp:51:8: required from ‘struct boost::mpl::map<std::pair<int, unsigned int>, std::pair<char, unsigned char> >’
/home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/aux_/has_tag.hpp:20:1: required by substitution of ‘template<class U> static char (& boost::mpl::aux::has_tag<boost::mpl::map<std::pair<int, unsigned int>, std::pair<char, unsigned char> >, mpl_::bool_<false> >::gcc_3_2_wknd::test<U>(const volatile boost::mpl::aux::type_wrapper<T>*, boost::mpl::aux::type_wrapper<typename U::tag>*))[2] [with U = boost::mpl::map<std::pair<int, unsigned int>, std::pair<char, unsigned char> >]’
/home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/aux_/has_tag.hpp:20:1: required from ‘const bool boost::mpl::aux::has_tag<boost::mpl::map<std::pair<int, unsigned int>, std::pair<char, unsigned char> >, mpl_::bool_<false> >::value’
/home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/aux_/has_tag.hpp:20:1: required from ‘struct boost::mpl::aux::has_tag<boost::mpl::map<std::pair<int, unsigned int>, std::pair<char, unsigned char> >, mpl_::bool_<false> >’
/home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/sequence_tag.hpp:110:8: required from ‘struct boost::mpl::sequence_tag<boost::mpl::map<std::pair<int, unsigned int>, std::pair<char, unsigned char> > >’
/home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/size.hpp:29:8: required from ‘struct boost::mpl::size<boost::mpl::map<std::pair<int, unsigned int>, std::pair<char, unsigned char> > >’
/home/adam/c++/tests/simple_test/test2.cpp:15:29: required from here
/home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/map/aux_/preprocessed/typeof_based/map10.hpp:31:8: error: no type named ‘first’ in ‘struct std::pair<char, unsigned char>’
struct map2
^~~~
In file included from /home/adam/c++/tests/simple_test/test2.cpp:4:0:
/home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/size.hpp: In instantiation of ‘struct boost::mpl::size<boost::mpl::map<std::pair<int, unsigned int>, std::pair<char, unsigned char> > >’:
/home/adam/c++/tests/simple_test/test2.cpp:15:29: required from here
/home/adam/spack/opt/spack/linux-ubuntu16.04-x86_64/gcc-5.4.0/boost-1.67.0-xcr4z3warx5tptvihmi5biqrq7hpgw7j/include/boost/mpl/size.hpp:29:8: error: no class template named ‘apply’ in ‘struct boost::mpl::size_impl<boost::mpl::non_sequence_tag>’
struct size
^~~~
/home/adam/c++/tests/simple_test/test2.cpp: In function ‘int main()’:
/home/adam/c++/tests/simple_test/test2.cpp:15:31: error: ‘value’ is not a member of ‘boost::mpl::size<boost::mpl::map<std::pair<int, unsigned int>, std::pair<char, unsigned char> > >’
int a = boost::mpl::size<m>::value; //this doesn't
^~~~~
/home/adam/c++/tests/simple_test/test2.cpp:15:6: warning: unused variable ‘a’ [-Wunused-variable]
int a = boost::mpl::size<m>::value; //this doesn't
^
CMakeFiles/libsimple_test.dir/build.make:62: recipe for target 'CMakeFiles/libsimple_test.dir/test2.cpp.o' failed
make[2]: *** [CMakeFiles/libsimple_test.dir/test2.cpp.o] Error 1
CMakeFiles/Makefile2:142: recipe for target 'CMakeFiles/libsimple_test.dir/all' failed
make[1]: *** [CMakeFiles/libsimple_test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
I use C++11 on GCC 7.3.0 and libboost 1.67.0 on Ubuntu 16.04 64bit.
By chance I found a solution: Don't use the standard std::pair, but rather use the re-invented boost::mpl::pair. After simple replacing std::pair into boost::mpl::pair the sample code compiles and runs properly... which leads to another question.

gsoap calc++ example ended up with error

I am trying to build calc++ after looking into tutorial given here https://www.genivia.com/examples/calc++/index.html but end up with error as shown below.
Here are the steps i followed
wsdl2h -o calc.h http://www.genivia.com/calc.wsdl [This created the
header file and i am not sure what to do file "typemap.dat" file so
i proceed with second step]
soapcpp2 -j -r -CL calc.h [This generates the required files and i downloaded the calcclient.cpp , copied the stdsoap2.h and stdsoap2.cpp in the same folder]
g++ -o calcclient calcclient.cpp stdsoap2.cpp soapC.cpp soapcalcProxy.cpp [This step ends with the error shown below]
Can anybody help me regarding this, i am totally new to gsoap and trying to build something with it so i decided to start with gsoap example but getting this big error. I am doing this in Ubuntu and following the exact steps which is given in the tutorial.Please check error below
calcclient.cpp: In function ‘int main(int, char**)’:
calcclient.cpp:58:29: error: no matching function for call to ‘calcProxy::add(double&, double&, double*)’
calc.add(a, b, &result);
^
In file included from calcclient.cpp:41:0:
soapcalcProxy.h:74:21: note: candidate: virtual int calcProxy::add(double, double, double&)
virtual int add(double a, double b, double &result)
^
soapcalcProxy.h:74:21: note: no known conversion for argument 3 from ‘double*’ to ‘double&’
soapcalcProxy.h:76:21: note: candidate: virtual int calcProxy::add(const char*, const char*, double, double, double&)
virtual int add(const char *soap_endpoint, const char *soap_action, double a, double b, double &result);
^
soapcalcProxy.h:76:21: note: candidate expects 5 arguments, 3 provided
calcclient.cpp:61:29: error: no matching function for call to ‘calcProxy::sub(double&, double&, double*)’
calc.sub(a, b, &result);
^
In file included from calcclient.cpp:41:0:
soapcalcProxy.h:78:21: note: candidate: virtual int calcProxy::sub(double, double, double&)
virtual int sub(double a, double b, double &result)
^
soapcalcProxy.h:78:21: note: no known conversion for argument 3 from ‘double*’ to ‘double&’
soapcalcProxy.h:80:21: note: candidate: virtual int calcProxy::sub(const char*, const char*, double, double, double&)
virtual int sub(const char *soap_endpoint, const char *soap_action, double a, double b, double &result);
^
soapcalcProxy.h:80:21: note: candidate expects 5 arguments, 3 provided
calcclient.cpp:64:29: error: no matching function for call to ‘calcProxy::mul(double&, double&, double*)’
calc.mul(a, b, &result);
^
In file included from calcclient.cpp:41:0:
soapcalcProxy.h:82:21: note: candidate: virtual int calcProxy::mul(double, double, double&)
virtual int mul(double a, double b, double &result)
^
soapcalcProxy.h:82:21: note: no known conversion for argument 3 from ‘double*’ to ‘double&’
soapcalcProxy.h:84:21: note: candidate: virtual int calcProxy::mul(const char*, const char*, double, double, double&)
virtual int mul(const char *soap_endpoint, const char *soap_action, double a, double b, double &result);
^
soapcalcProxy.h:84:21: note: candidate expects 5 arguments, 3 provided
calcclient.cpp:67:29: error: no matching function for call to ‘calcProxy::div(double&, double&, double*)’
calc.div(a, b, &result);
^
In file included from calcclient.cpp:41:0:
soapcalcProxy.h:86:21: note: candidate: virtual int calcProxy::div(double, double, double&)
virtual int div(double a, double b, double &result)
^
soapcalcProxy.h:86:21: note: no known conversion for argument 3 from ‘double*’ to ‘double&’
soapcalcProxy.h:88:21: note: candidate: virtual int calcProxy::div(const char*, const char*, double, double, double&)
virtual int div(const char *soap_endpoint, const char *soap_action, double a, double b, double &result);
^
soapcalcProxy.h:88:21: note: candidate expects 5 arguments, 3 provided
calcclient.cpp:70:29: error: no matching function for call to ‘calcProxy::pow(double&, double&, double*)’
calc.pow(a, b, &result);
^
In file included from calcclient.cpp:41:0:
soapcalcProxy.h:90:21: note: candidate: virtual int calcProxy::pow(double, double, double&)
virtual int pow(double a, double b, double &result)
^
soapcalcProxy.h:90:21: note: no known conversion for argument 3 from ‘double*’ to ‘double&’
soapcalcProxy.h:92:21: note: candidate: virtual int calcProxy::pow(const char*, const char*, double, double, double&)
virtual int pow(const char *soap_endpoint, const char *soap_action, double a, double b, double &result);
^
soapcalcProxy.h:92:21: note: candidate expects 5 arguments, 3 provided
Perhaps you are passing one or more arguments as a pointer. The correct proxy call should look like this:
#include "soapcalcProxy.h"
#include "calc.nsmap"
double a, b, result;
calcProxy calc("http://server.com/path");
a = 1.23;
b = 4.56;
int err = calc.add(a, b, result);

std::get on std::tuple results in variadic args reducing to nothing with incomplete type error

The following code produces a huge list of compiler errors:
/// Uses template recursion to bind all args
template<std::size_t N, typename... Args> class Binder
{
public:
Binder(Sqlite3StatementBase &s, std::tuple<Args...> &tup)
{
Binder<N - 1, Args...> b(s, tup);
s.bind(N + 1, std::get<N, Args...>(tup)); // Line 182
}
};
/// Specialization of Binder to end recursion at 0
template<typename... Args> class Binder<0, Args...>
{
public:
Binder(Sqlite3StatementBase &s, std::tuple<Args...> &tup)
{
s.bind(1, std::get<0, Args...>(tup));
}
};
The first batch of errors consists of:
In file included from /usr/include/c++/6/bits/unique_ptr.h:37:0,
from /usr/include/c++/6/condition_variable:43,
from /home/tony/htpc/Dev/logi/src/db/logi-db.h:22,
from /home/tony/htpc/Dev/logi/src/db/logi-sqlite.h:26,
from /home/tony/htpc/Dev/logi/src/db/logi-sqlite.cpp:24:
/usr/include/c++/6/tuple: In instantiation of ‘class std::tuple_element<1ul, std::tuple<unsigned int> >’:
/usr/include/c++/6/tuple:1228:12: recursively required from ‘class std::tuple_element<2ul, std::tuple<unsigned int, unsigned int> >’
/usr/include/c++/6/tuple:1228:12: required from ‘class std::tuple_element<3ul, std::tuple<unsigned int, unsigned int, unsigned int> >’
/usr/include/c++/6/utility:106:69: required by substitution of ‘template<long unsigned int __i, class _Tp> using __tuple_element_t = typename std::tuple_element::type [with long unsigned int __i = 3ul; _Tp = std::tuple<unsigned int, unsigned int, unsigned int>]’
/usr/include/c++/6/tuple:1270:5: required by substitution of ‘template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(std::tuple<_Elements ...>&&) [with long unsigned int __i = 3ul; _Elements = {unsigned int, unsigned int, unsigned int}]’
/home/tony/htpc/Dev/logi/src/db/logi-sqlite.h:182:47: required from ‘logi::Sqlite3Database::Binder<N, Args>::Binder(logi::Sqlite3Database::Sqlite3StatementBase&, std::tuple<_Elements ...>&) [with long unsigned int N = 3ul; Args = {unsigned int, unsigned int, unsigned int}]’
/home/tony/htpc/Dev/logi/src/db/logi-sqlite.h:238:71: required from ‘void logi::Sqlite3Database::Sqlite3Statement<Args>::prepare_row(logi::Sqlite3Database::Sqlite3Statement<Args>::Tup&) [with Args = {unsigned int, unsigned int, unsigned int}; logi::Sqlite3Database::Sqlite3Statement<Args>::Tup = std::tuple<unsigned int, unsigned int, unsigned int>]’
/home/tony/htpc/Dev/logi/src/db/logi-sqlite.h:231:28: required from ‘void logi::Sqlite3Database::Sqlite3Statement<Args>::execute(typename logi::Sqlite3Database::Sqlite3Statement<Args>::Parent::ArgsVector&) [with Args = {unsigned int, unsigned int, unsigned int}; typename logi::Sqlite3Database::Sqlite3Statement<Args>::Parent::ArgsVector = std::vector<std::tuple<unsigned int, unsigned int, unsigned int>, std::allocator<std::tuple<unsigned int, unsigned int, unsigned int> > >]’
/home/tony/htpc/Dev/logi/src/db/logi-sqlite.cpp:354:1: required from here
/usr/include/c++/6/tuple:1228:12: error: invalid use of incomplete type ‘class std::tuple_element<0ul, std::tuple<> >’
So it seems as if the std::get call is causing other parts of the system libraries (not directly related to std::get or std::tuple) to recursively reduce Args... to nothing, and this is happening independently of my recursion of the numerical template parameter N. Is there something I can fix in my code without fundamentally changing my approach, or is it just not possible to use std::get in a context where the tuple's template parameters are variadic?
Given an implementation of the C++14 make_index_sequence function (and its associated types), you can do what you want easily enough:
template<size_t ...indices, typename ...Args>
void binder_helper(Sqlite3StatementBase &s, std::integer_sequence<size_t, indices...>, std::tuple<Args...> &tup)
{
auto dump = {(s.bind(indices, std::get<indices>(tup)), 0)...};
}
template<typename ...Args>
void binder(Sqlite3StatementBase &s, std::tuple<Args...> &tup)
{
binder_helper(s, std::make_index_sequence<sizeof...(Args)>(), tup);
}
With C++17's fold expressions, the oddball stuff in binder_helper can be reduced to something much more reasonable:
template<size_t ...indices, typename ...Args>
void binder_helper(Sqlite3StatementBase &s, std::integer_sequence<size_t, indices...>, std::tuple<Args...> &tup)
{
(s.bind(indices, std::get<indices>(tup)), ...);
}
Note that in the latter case, the standard does not guarantee thatt the calls to s.bind will be executed in order. In the former case, because the expressions are wrapped in a braced-init-list, you're guaranteed in-order evaluation.

Error 2 when running the makefile of open-source code

So I'm trying to run the open-source code from this research paper, but I keep getting [make] Error 2. The makefile for the code was thankfully provided so I all I did was run the make command when I was in the folder that contained the makefile.
I'm new to all of this, I got everything from the internet, so I apologize if I'm a bit ignorant. I'm trying to learn, please be patient (:
QuantumHoneybees-MacBook-Pro:femflip2 Joe$ make
makeCompiling src/adaptive2.cpp ...
In file included from src/adaptive2.cpp:13:
./src/kernel.h:16:20: warning: unused function 'smooth_kernel' [-Wunused-function]
static FLOAT64 smooth_kernel( FLOAT64 r2, FLOAT64 h ) {
^
In file included from src/adaptive2.cpp:15:
./src/util2.h:29:13: warning: unused function 'dump' [-Wunused-function]
static void dump( const char *format, ...) {
^
./src/util2.h:45:13: warning: unused function 'run' [-Wunused-function]
static void run( const char *format, ...) {
^
./src/util2.h:54:20: warning: unused function 'format_str' [-Wunused-function]
static const char *format_str( const char *format, ...) {
^
./src/util2.h:65:13: warning: unused function 'is_nan' [-Wunused-function]
static bool is_nan(const double v) {
^
./src/util2.h:86:17: warning: unused function 'square' [-Wunused-function]
static FLOAT64 square(FLOAT64 a) {
^
./src/util2.h:120:17: warning: unused function 'getSeconds' [-Wunused-function]
static FLOAT64 getSeconds() {
^
./src/util2.h:142:15: warning: unused function 'stretchPosition' [-Wunused-function]
static vec2d stretchPosition( const svd2 &svd, vec2d p, FLOAT64 min, FLOAT64 max, bool inverse=true ) {
^
./src/util2.h:162:28: warning: unused function 'marchPoints' [-Wunused-function]
static std::vector<vec2d> marchPoints( const std::vector<vec2d> &nodes, const std::vector<FLOAT64> &levelsets, bool fill=true ) {
^
./src/util2.h:180:17: warning: unused function 'computeVolume' [-Wunused-function]
static FLOAT64 computeVolume( const std::vector<vec2d> points ) {
^
./src/util2.h:192:17: warning: unused function 'distance' [-Wunused-function]
static FLOAT64 distance( const vec2d &p0, const vec2d &p1, vec2d &p ) {
^
./src/util2.h:222:17: warning: unused function 'detDelaunay' [-Wunused-function]
static FLOAT64 detDelaunay( vec2d p0, vec2d p1, vec2d p2, vec2d p3 ) {
^
src/adaptive2.cpp:53:13: warning: unused function 'sampleVelocity' [-Wunused-function]
static bool sampleVelocity( sorter2& sorter, vec2d pos, FLOAT64 dpx, const std::vector<particle2 *> &neighbors, vec2d &vel ) {
^
13 warnings generated.
Compiling src/ann/ANN.cpp ...
Compiling src/ann/bd_fix_rad_search.cpp ...
Compiling src/ann/bd_pr_search.cpp ...
Compiling src/ann/bd_search.cpp ...
Compiling src/ann/bd_tree.cpp ...
Compiling src/ann/brute.cpp ...
Compiling src/ann/kd_dump.cpp ...
src/ann/kd_dump.cpp:44:14: warning: unused variable 'EPSILON' [-Wunused-const-variable]
const double EPSILON = 1E-5; // small number for float comparison
^
1 warning generated.
Compiling src/ann/kd_fix_rad_search.cpp ...
Compiling src/ann/kd_pr_search.cpp ...
Compiling src/ann/kd_search.cpp ...
Compiling src/ann/kd_split.cpp ...
Compiling src/ann/kd_tree.cpp ...
Compiling src/ann/kd_util.cpp ...
Compiling src/ann/perf.cpp ...
Compiling src/annsorter2.cpp ...
In file included from src/annsorter2.cpp:9:
In file included from ./src/annsorter2.h:10:
In file included from ./src/ann2.h:11:
./src/util2.h:29:13: warning: unused function 'dump' [-Wunused-function]
static void dump( const char *format, ...) {
^
./src/util2.h:45:13: warning: unused function 'run' [-Wunused-function]
static void run( const char *format, ...) {
^
./src/util2.h:54:20: warning: unused function 'format_str' [-Wunused-function]
static const char *format_str( const char *format, ...) {
^
./src/util2.h:65:13: warning: unused function 'is_nan' [-Wunused-function]
static bool is_nan(const double v) {
^
./src/util2.h:86:17: warning: unused function 'square' [-Wunused-function]
static FLOAT64 square(FLOAT64 a) {
^
./src/util2.h:120:17: warning: unused function 'getSeconds' [-Wunused-function]
static FLOAT64 getSeconds() {
^
./src/util2.h:142:15: warning: unused function 'stretchPosition' [-Wunused-function]
static vec2d stretchPosition( const svd2 &svd, vec2d p, FLOAT64 min, FLOAT64 max, bool inverse=true ) {
^
./src/util2.h:162:28: warning: unused function 'marchPoints' [-Wunused-function]
static std::vector<vec2d> marchPoints( const std::vector<vec2d> &nodes, const std::vector<FLOAT64> &levelsets, bool fill=true ) {
^
./src/util2.h:180:17: warning: unused function 'computeVolume' [-Wunused-function]
static FLOAT64 computeVolume( const std::vector<vec2d> points ) {
^
./src/util2.h:192:17: warning: unused function 'distance' [-Wunused-function]
static FLOAT64 distance( const vec2d &p0, const vec2d &p1, vec2d &p ) {
^
./src/util2.h:222:17: warning: unused function 'detDelaunay' [-Wunused-function]
static FLOAT64 detDelaunay( vec2d p0, vec2d p1, vec2d p2, vec2d p3 ) {
^
11 warnings generated.
make: *** [all] Error 2
QuantumHoneybees-MacBook-Pro:femflip2 Joe$ make
Edit:: I've narrowed it down to the makefile in lines 36-44 there is something wrong with what is written. I unfortunately have zero experience with writing makefiles, so I don't know how to fix it. I tried messing around with some lines' indentation because some other threads seem to have that issue, but to no avail.
There's a missing include in fluid2.h, NULL isn't defined.
Either invoke
make OPT="-Wall -Os -include cstddef"
Or add
#include <cstddef>
to the includes in fluid2.h.
It's quicker to just rewrite the terrible included makefile, try this:
CC := g++
CPPFLAGS := -Isrc -Isrc/ann -Isrc/pcgsolver -MMD -MP
CXXFLAGS := -Wall -Os
LDFLAGS := -framework OpenGL -framework GLUT
sources := $(wildcard src/*.cpp src/ann/*.cpp)
objects := $(sources:.cpp=.o)
deps := $(objects:.o=.d)
flip2d: $(objects)
$(LINK.o) $^ $(LDLIBS) -o $#
.PHONY: clean
clean: ; $(RM) $(objects) $(deps) flip2d
-include $(deps)

unordered_map with IP address as a key

I am trying to build a list of linked list in my application. The list will contains unique IP addresses,and for each IP addres I have a list of applications. I am trying to build it using unordered_map to take Boost::boost::asio::ip::address as a the key and std::list as value:
#include <boost/unordered/unordered_map.hpp>
#include <iostream>
#include <list>
using namespace boost::asio::ip;
using namespace std;
typedef int ApplicationID;
typedef address IPAddress;
typedef list <ApplicationID> APP_LIST;
typedef boost::unordered::unordered_map <IPAddress, APP_LIST> USER_MAP;
USER_MAP user_map;
Later I try to get the list associated with an IP address as following:
APP_LIST *list = &user_map[ip];
But I get errors in the compilation, so could you please specify what's the problem?
Is it possible to use Boost:IPaddress as a key function?
Another question is it possible to use char[some_size] as a key value?
Error Output:
In file included from /boost/functional/hash/hash.hpp:535:0,
from /boost/functional/hash.hpp:6,
from /boost/unordered/unordered_map.hpp:21,
from ipc_module.cpp:18:
/boost/functional/hash/extensions.hpp: In member function ‘std::size_t boost::hash<T>::operator()(const T&) const [with T = boost::asio::ip::address, std::size_t = long unsigned int]’:
/boost/unordered/detail/unique.hpp:331:55: instantiated from ‘boost::unordered::detail::table_impl<Types>::value_type& boost::unordered::detail::table_impl<Types>::operator[](const key_type&) [with Types = boost::unordered::detail::map<std::allocator<std::pair<const boost::asio::ip::address, std::list<int> > >, boost::asio::ip::address, std::list<int>, boost::hash<boost::asio::ip::address>, std::equal_to<boost::asio::ip::address> >, boost::unordered::detail::table_impl<Types>::value_type = std::pair<const boost::asio::ip::address, std::list<int> >, boost::unordered::detail::table_impl<Types>::key_type = boost::asio::ip::address]’
/boost/unordered/unordered_map.hpp:1192:26: instantiated from ‘boost::unordered::unordered_map<K, T, H, P, A>::mapped_type& boost::unordered::unordered_map<K, T, H, P, A>::operator[](const key_type&) [with K = boost::asio::ip::address, T = std::list<int>, H = boost::hash<boost::asio::ip::address>, P = std::equal_to<boost::asio::ip::address>, A = std::allocator<std::pair<const boost::asio::ip::address, std::list<int> > >, boost::unordered::unordered_map<K, T, H, P, A>::mapped_type = std::list<int>, boost::unordered::unordered_map<K, T, H, P, A>::key_type = boost::asio::ip::address]’
ipc_module.cpp:175:40: instantiated from here
/boost/functional/hash/extensions.hpp:176:34: error: no matching function for call to ‘hash_value(const boost::asio::ip::address&)’
/boost/functional/hash/extensions.hpp:176:34: note: candidates are:
/boost/smart_ptr/shared_ptr.hpp:708:33: note: template<class T> std::size_t boost::hash_value(const boost::shared_ptr<T>&)
/boost/functional/hash/hash.hpp:144:24: note: std::size_t boost::hash_value(bool)
/boost/functional/hash/hash.hpp:144:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘bool’
/boost/functional/hash/hash.hpp:149:24: note: std::size_t boost::hash_value(char)
/boost/functional/hash/hash.hpp:149:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘char’
/boost/functional/hash/hash.hpp:154:24: note: std::size_t boost::hash_value(unsigned char)
/boost/functional/hash/hash.hpp:154:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘unsigned char’
/boost/functional/hash/hash.hpp:159:24: note: std::size_t boost::hash_value(signed char)
/boost/functional/hash/hash.hpp:159:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘signed char’
/boost/functional/hash/hash.hpp:164:24: note: std::size_t boost::hash_value(short int)
/boost/functional/hash/hash.hpp:164:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘short int’
/boost/functional/hash/hash.hpp:169:24: note: std::size_t boost::hash_value(short unsigned int)
/boost/functional/hash/hash.hpp:169:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘short unsigned int’
/boost/functional/hash/hash.hpp:174:24: note: std::size_t boost::hash_value(int)
/boost/functional/hash/hash.hpp:174:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘int’
/boost/functional/hash/hash.hpp:179:24: note: std::size_t boost::hash_value(unsigned int)
/boost/functional/hash/hash.hpp:179:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘unsigned int’
/boost/functional/hash/hash.hpp:184:24: note: std::size_t boost::hash_value(long int)
/boost/functional/hash/hash.hpp:184:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘long int’
/boost/functional/hash/hash.hpp:189:24: note: std::size_t boost::hash_value(long unsigned int)
/boost/functional/hash/hash.hpp:189:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘long unsigned int’
/boost/functional/hash/hash.hpp:195:24: note: std::size_t boost::hash_value(wchar_t)
/boost/functional/hash/hash.hpp:195:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘wchar_t’
/boost/functional/hash/hash.hpp:202:24: note: std::size_t boost::hash_value(boost::long_long_type)
/boost/functional/hash/hash.hpp:202:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘boost::long_long_type {aka long long int}’
/boost/functional/hash/hash.hpp:207:24: note: std::size_t boost::hash_value(boost::ulong_long_type)
/boost/functional/hash/hash.hpp:207:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘boost::ulong_long_type {aka long long unsigned int}’
/boost/functional/hash/hash.hpp:215:36: note: template<class T> std::size_t boost::hash_value(T* const&)
/boost/functional/hash/hash.hpp:308:24: note: template<class T, unsigned int N> std::size_t boost::hash_value(const T (&)[N])
/boost/functional/hash/hash.hpp:314:24: note: template<class T, unsigned int N> std::size_t boost::hash_value(T (&)[N])
/boost/functional/hash/hash.hpp:327:24: note: std::size_t boost::hash_value(float)
/boost/functional/hash/hash.hpp:327:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘float’
/boost/functional/hash/hash.hpp:332:24: note: std::size_t boost::hash_value(double)
/boost/functional/hash/hash.hpp:332:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘double’
/boost/functional/hash/hash.hpp:337:24: note: std::size_t boost::hash_value(long double)
/boost/functional/hash/hash.hpp:337:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘long double’
/boost/functional/hash/hash.hpp:321:24: note: template<class Ch, class A> std::size_t boost::hash_value(const std::basic_string<Ch, std::char_traits<_CharT>, A>&)
/boost/functional/hash/hash.hpp:343:24: note: std::size_t boost::hash_value(std::type_index)
/boost/functional/hash/hash.hpp:343:24: note: no known conversion for argument 1 from ‘const boost::asio::ip::address’ to ‘std::type_index’
/boost/functional/hash/extensions.hpp:54:17: note: template<class A, class B> std::size_t boost::hash_value(const std::pair<_T1, _T2>&)
/boost/functional/hash/extensions.hpp:63:17: note: template<class T, class A> std::size_t boost::hash_value(const std::vector<_Tp, _Alloc>&)
/boost/functional/hash/extensions.hpp:69:17: note: template<class T, class A> std::size_t boost::hash_value(const std::list<_Tp, _Alloc>&)
/boost/functional/hash/extensions.hpp:75:17: note: template<class T, class A> std::size_t boost::hash_value(const std::deque<_Tp, _Alloc>&)
/boost/functional/hash/extensions.hpp:81:17: note: template<class K, class C, class A> std::size_t boost::hash_value(const std::set<_Key, _Compare, _Alloc>&)
/boost/functional/hash/extensions.hpp:87:17: note: template<class K, class C, class A> std::size_t boost::hash_value(const std::multiset<_Key, _Compare, _Alloc>&)
/boost/functional/hash/extensions.hpp:93:17: note: template<class K, class T, class C, class A> std::size_t boost::hash_value(const std::map<_Key, _Tp, _Compare, _Alloc>&)
/boost/functional/hash/extensions.hpp:99:17: note: template<class K, class T, class C, class A> std::size_t boost::hash_value(const std::multimap<_Key, _Tp, _Compare, _Alloc>&)
/boost/functional/hash/extensions.hpp:105:17: note: template<class T> std::size_t boost::hash_value(const std::complex<_Tp>&)
/boost/functional/hash/extensions.hpp:177:9: warning: control reaches end of non-void function [-Wreturn-type]
/boost/asio/error.hpp: At global scope:
/boost/asio/error.hpp:244:45: warning: ‘boost::asio::error::system_category’ defined but not used [-Wunused-variable]
/boost/asio/error.hpp:246:45: warning: ‘boost::asio::error::netdb_category’ defined but not used [-Wunused-variable]
/boost/asio/error.hpp:248:45: warning: ‘boost::asio::error::addrinfo_category’ defined but not used [-Wunused-variable]
/boost/asio/error.hpp:250:45: warning: ‘boost::asio::error::misc_category’ defined but not used [-Wunused-variable]
Here's what I came up with after a brief inspection of the class interface for ip::address.
I would like to note that it's pretty wasteful to use. Especially if you happen to know that all addresses are ipv4, e.g. I'd prefer to key by ulong then.
namespace boost
{
template <>
struct hash<IPAddress>
{
size_t operator()(IPAddress const& v) const {
if (v.is_v4())
return v.to_v4().to_ulong();
if (v.is_v6())
{
auto const& range = v.to_v6().to_bytes();
return hash_range(range.begin(), range.end());
}
if (v.is_unspecified())
{
// guaranteed to be random: chosen by fair dice roll
return static_cast<size_t>(0x4751301174351161ul);
}
return hash_value(v.to_string());
}
};
}
See it Live on Coliru:
#include <boost/asio.hpp>
#include <boost/unordered/unordered_map.hpp>
#include <iostream>
#include <list>
typedef int ApplicationID;
typedef boost::asio::ip::address IPAddress;
typedef std::list<ApplicationID> APP_LIST;
typedef boost::unordered::unordered_map<IPAddress, APP_LIST> USER_MAP;
namespace boost
{
template <>
struct hash<IPAddress>
{
size_t operator()(IPAddress const& v) const {
if (v.is_v4())
return v.to_v4().to_ulong();
if (v.is_v6())
{
auto const& range = v.to_v6().to_bytes();
return hash_range(range.begin(), range.end());
}
if (v.is_unspecified())
return 0x4751301174351161ul;
return hash_value(v.to_string());
}
};
}
int main()
{
USER_MAP map;
map.insert({ {}, {} });
}
This is an old question, but I recently came across the same issue while writing a game in c++17.
This is how I solved it:
struct endpoint_hash
{
std::size_t operator()(boost::asio::ip::udp::endpoint const& ep) const noexcept
{
auto accum = std::size_t(0);
auto combine = [&accum](auto&& arg) {
boost::hash_combine(accum, arg);
};
combine(ep.port());
if (auto&& addr = ep.address(); addr.is_v4())
{
combine(addr.to_v4().to_ulong());
}
else
{
combine(addr.to_v6().to_bytes());
}
combine(ep.port());
return accum;
}
};
std::unordered_map<boost::asio::ip::udp::endpoint, std::shared_ptr<game_client>, endpoint_hash> cache_;
It will work if you write a hash function for IPaddress.

Resources