Boost BiMap Parse Template Error - c++11

I am getting parse template error when I add #include<boost/bimap.hpp>
I want to find the key of a map from its value and hence thought of using Boost's Bimap but getting below error.
/usr/include/boost/bimap/relation/structured_pair.hpp: In function ‘bool boost::bimaps::relation::operator<(const boost::bimaps::relation::structured_pair<FirstType, SecondType, Info, Layout1>&, const boost::bimaps::relation::structured_pair<FirstType, SecondType, Info, Layout2>&)’:
/usr/include/boost/bimap/relation/structured_pair.hpp:375:19: error: parse error in template argument list
return ( ( a.first < b.first ) ||
^
/usr/include/boost/bimap/relation/structured_pair.hpp: In function ‘bool boost::bimaps::relation::operator<=(const boost::bimaps::relation::structured_pair<FirstType, SecondType, Info, Layout1>&, const boost::bimaps::relation::structured_pair<FirstType, SecondType, Info, Layout2>&)’:
/usr/include/boost/bimap/relation/structured_pair.hpp:383:19: error: parse error in template argument list
return ( ( a.first < b.first ) ||
^
/usr/include/boost/bimap/relation/structured_pair.hpp: In function ‘bool boost::bimaps::relation::operator<(const boost::bimaps::relation::structured_pair<FirstType, SecondType, Info, Layout1>&, const std::pair<F, S>&)’:
/usr/include/boost/bimap/relation/structured_pair.hpp:424:19: error: parse error in template argument list
return ( ( a.first < b.first ) ||
^
/usr/include/boost/bimap/relation/structured_pair.hpp: In function ‘bool boost::bimaps::relation::operator<=(const boost::bimaps::relation::structured_pair<FirstType, SecondType, Info, Layout1>&, const std::pair<F, S>&)’:
/usr/include/boost/bimap/relation/structured_pair.hpp:432:19: error: parse error in template argument list
return ( ( a.first < b.first ) ||
^
/usr/include/boost/bimap/relation/structured_pair.hpp: In function ‘bool boost::bimaps::relation::operator<(const std::pair<F, S>&, const boost::bimaps::relation::structured_pair<FirstType, SecondType, Info, Layout1>&)’:
/usr/include/boost/bimap/relation/structured_pair.hpp:473:19: error: parse error in template argument list
return ( ( a.first < b.first ) ||
^
/usr/include/boost/bimap/relation/structured_pair.hpp: In function ‘bool boost::bimaps::relation::operator<=(const std::pair<F, S>&, const boost::bimaps::relation::structured_pair<FirstType, SecondType, Info, Layout1>&)’:
/usr/include/boost/bimap/relation/structured_pair.hpp:481:19: error: parse error in template argument list
return ( ( a.first < b.first ) ||

Using GCC 4.8.5:
boost 1.64 https://wandbox.org/permlink/kg4tkbEIdHMv4mII
boost 1.60 https://wandbox.org/permlink/1lA2L194rNfZrFsd
boost 1.54 https://wandbox.org/permlink/7RUl49NAy0q9D2u3
boost 1.49 https://wandbox.org/permlink/kpILpo63riVQGVyP
So all in all it looks like you're doing something else wrong. What other includes are there? Check the preprocessed source if possible.

Related

cannot assign a string element to a random function in Swift Xcode

I am trying to generate an automatic password code, however, I get an error with the below code "Cannot convert value of type '[Any]' to specified type 'String'
Output of debugger as follows:
expression failed to parse:
error: Loops + Function.playground:7:25: error: cannot convert value of type '[Any]' to specified type 'String'
var passString:String = []
^~
warning: Loops + Function.playground:9:5: warning: immutable value 'n' was never used; consider replacing with '_' or removing it
for n in 0...5 {
^
_
let alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
var passString:String = []
for n in 0...5 {
passString = passString + alphabet.randomElement()!
}
print(passString)

What is the reason of an error "Array access, index expected"

I get an error 73 "Array access..." with code:
#include "args.bas"
Dim aargs(1) As Args.Arg
Dim args_num As Integer = 0
args_num = Args.ParseArgs(aargs) 'error 73: Array access, index expected, before ')' in 'args_num = Args.ParseArgs(aargs)'
Print args_num
ParseArgs is:
#pragma once
Namespace Args
...
Type CommandGetter As Function(ByVal arg_idx As Long) As String
Function ParseArgs(aargs(Any) As Arg, getcmd As CommandGetter=NULL) As Integer
...
End Function
End Namespace
What's wrong here?
Stupid question :)
Passing of arrays needs (), the correct syntax is:
args_num = Args.ParseArgs(aargs())

Terraform variable validation Terraform v0.13 with length & Substr

Terraform variable validation using length function
Getting error while using length function & substr for vswitch_ids
Condition - vswitch_name value must start with vsw-
variable "vswitch_ids" {
description = "The vswitch IDs."
type = list(string)
validation {
condition = (
length(var.vswitch_ids) > 0 &&
substr(var.switch_ids, 0, 4) == "vsw-"
)
error_message = "The vswitch_name value must start with \"vsw-\"."
}
}
Error: Invalid function argument
on modules/k8s/variables.tf line 34, in variable "vswitch_ids":
34: substr(var.vswitch_ids, 0, 4) == "vsw-"
|----------------
| var.vswitch_ids is list of string with 3 elements
Invalid value for "str" parameter: string required.
The following should work. It will check if all elements in your variable list start with vsw:
variable "vswitch_ids" {
description = "The vswitch IDs."
type = list(string)
validation {
condition = (
length(var.vswitch_ids) > 0 &&
length([for v in var.vswitch_ids: 1 if substr(v, 0, 4) == "vsw-"]) == length(var.vswitch_ids)
)
error_message = "The vswitch_name value must start with \"vsw-\"."
}
}

error when casting an image to different types in C++

I am trying to use the following sentences to cast an image to different types (the library I am using is ITK 5.1 if it helps):
if (outputPixelType == std::string("double"))
{
using OutputPixelType = double;
}
else
{
using OutputPixelType = int;
}
using OutputImageType = itk::Image<OutputPixelType, Dimension>;
I get an error like this using the compiler clang
error: use of undeclared identifier 'OutputPixelType'; did you mean 'outputPixelType'?
using OutputImageType = itk::Image<OutputPixelType, Dimension>;
^~~~~~~~~~~~~~~
outputPixelType
But if I use the following sentences, it works.
using OutputPixelType = int;
using OutputImageType = itk::Image<OutputPixelType, Dimension>;
Why the if statement does not work? How to correct it? Thank you.
I have tried the following command using dovahin's comment:
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
After compiling, I got a different error:
error: expected a type
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
^
error: type-id cannot have a name
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
^~~~~~~~~~~~~~~
error: expected ')'
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
^
note: to match this '('
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
^
error: expected ';' after alias declaration
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
It seems that using does not take ()?A:B statement.
You probably want to use templates:
template<typename OutputPixelType>
void dostuff() {
using OutputImageType = itk::Image<OutputPixelType, Dimension>;
...
}
void fun(std::string outputPixelType) {
if (outputPixelType == std::string("double")) {
dostuff<double>();
} else {
dostuff<int>();
}
}

Comparing std::pair<> first and last from equal_range

In the context of a map (template), for the following usage
auto begin = m_map.find(keyBegin);
auto end = m_map.find(keyEnd);
auto p = equal_range(begin,end,val);
if( !
(
p.first == p.second == m_map.end()
)
)
{
//do something
}
The type of keyBegin and keyEnd is unsigned int.
I get the following compilation error:
error: invalid operands to binary expression
('int' and 'iterator' (aka '__map_iterator<__tree_iterator<std::__1::
__value_type<unsigned int, char>, std::__1::__tree_node<std::__1::__value_type
<unsigned int, char>,
void *> *, long> >'))
p.first == p.second == m_map.end()
Can someone point out the cause of this error? I am of the understanding that the std::pair<> returned by std::equal_range<> has members of type ForwardIterator for first and second respectively.

Resources