Giter VIP home page Giter VIP logo

parameter's Introduction

Boost.Parameter

Boost.Parameter, part of collection of the Boost C++ Libraries, is a header-only library that implements named parameters for functions and templates in C++.

Directories

  • doc - Documentation sources
  • include - Interface headers of Boost.Parameter
  • test - Boost.Parameter unit tests

More information

Build status

Branch GitHub Actions AppVeyor Test Matrix Dependencies
master GitHub Actions AppVeyor Tests Dependencies
develop GitHub Actions AppVeyor Tests Dependencies

License

Distributed under the Boost Software License, Version 1.0.

parameter's People

Contributors

beman avatar cromwellenage avatar dabrahams avatar danieljames avatar davedeakins avatar douggregor avatar eldiener avatar glenfe avatar grafikrobot avatar imikejackson avatar jewillco avatar jzmaddock avatar lastique avatar lcaminiti avatar mclow avatar mike-devel avatar morinmorin avatar nmusatti avatar oborce avatar pdimov avatar rick68 avatar sloriot avatar steveire avatar straszheim avatar timblechmann avatar viboes avatar vprus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

parameter's Issues

Merging 'develop' changes to 'master'

I would like to move forward with merging the 'develop' changes which Cromwell Enage has been making to improve the Parameter library to the 'master' branch, so that those changes can be part of the next release of Boost.

With what other Boost libraries do we need to sync in order to merge Parameter 'develop' to 'master' ? As I understand it we probably need to sync this merge with Accumulators, Log, and Convert. Are there other libraries with which we need to sync the changes as we go to the 'master' branch ?

Named arg defaulted when supplied

When supplying a default in the indexer keyword, the result is default when it shouldn't be:

Live On Coliru

#include <boost/log/utility/setup/file.hpp>
#include <iostream>

int main() {
    namespace kw = boost::log::keywords;
    auto test = [](auto params) {
        std::cerr << "Non-defaulted: " << params[kw::file_name] << std::endl;
        std::cerr << "Defaulted:     " << params[kw::file_name | boost::filesystem::path()] << std::endl;
    };

    test((kw::file_name = "aaa"));
    test((kw::file_name = "bbb", kw::auto_flush = false));
    test((kw::auto_flush = false, kw::file_name = "ccc"));
}

Prints:

Non-defaulted: aaa
Defaulted:     ""
Non-defaulted: bbb
Defaulted:     bbb
Non-defaulted: ccc
Defaulted:     ccc

msvc compile error C7631

After I upgrading msvc to latest version, get error C7631.

  • Microsoft Visual Studio Community 2022 (64-bit) - Version 17.5.0

  • Boost 1.81.0

boost\boost\log\keywords\severity.hpp(32,1): error C7631: 'boost::log::v2_mt_nt6::keywords::`anonymous-namespace'::severity': variable with internal linkage declared but not defined

Boost convert may have been broken by Parameter changes

I am seeing failures with Boost convert on the 'develop' side, probably based on some change made to Parameter on the 'develop' branch, Testing Boost convert with gcc-8.1 I see:

In file included from performance.cpp:14:
....../boost/convert/stream.hpp:92:5: error: 'boost::cnv::basic_stream::this_type& boost::cnv::basic_stream::operator()(const type&)' cannot be overloaded with 'boost::cnv::basic_stream::this_type& boost::cnv::basic_stream::operator()(const type&)'
BOOST_CNV_PARAM(precision, int) { return (stream_.precision(arg[cnv::parameter::precision]), *this); }
^~~~~~~~~~~~~~~
....../boost/convert/stream.hpp:91:5: note: previous declaration 'boost::cnv::basic_stream::this_type& boost::cnv::basic_stream::operator()(const type&)'
BOOST_CNV_PARAM(precision, int const) { return (stream_.precision(arg[cnv::parameter::precision]), *this); }
^~~~~~~~~~~~~~~
In file included from ....../boost/convert/printf.hpp:8,
from performance.cpp:15:
....../boost/convert/base.hpp:85:5: error: 'derived_type& boost::cnv::cnvbase< >::operator()(const type&)' cannot be overloaded with 'derived_type& boost::cnv::cnvbase< >::operator()(const type&)'
BOOST_CNV_PARAM (precision, int) { precision_ = arg[ARG::precision]; return dncast(); }
^~~~~~~~~~~~~~~
....../boost/convert/base.hpp:84:5: note: previous declaration 'derived_type& boost::cnv::cnvbase< >::operator()(const type&)'
BOOST_CNV_PARAM (precision, int const) { precision_ = arg[ARG::precision]; return dncast(); }
^~~~~~~~~~~~~~~

as an example of errors. Can this be looked at to determine what change(s) in Parameter caused this problem with Boost convert ?

Clang 3.5-8 warnings related to has_nested_template_fn

As shown in Boost.Flyweight regression tests:

test_assoc_cont_factory

../boost/parameter/aux_/has_nested_template_fn.hpp:39:64: 
  warning: inline function
    'boost::parameter::aux::has_nested_template_fn_impl<
       boost::flyweights::detail::is_tag<mpl_::arg<-1> > 
    >::_check<boost::flyweights::detail::is_tag<mpl_::arg<-1> > >' is not defined
  [-Wundefined-inline]

...

This spurious warning is connected with the constexpr specification of the various _check function templates. Problem reproduced here. I guess the fix is as simple as dropping BOOST_CONSTEXPR, since after all it isn't (AFAICS) needed.

python.hpp conflict: parameter master vs python_parameter master

TBH, I am not clear where this bug report belongs to: boostorg/boost, boostorg/parameter or boostorg/parameter_python. Trying here.

On Linux, I've got fresh super-project at master, bootstrapped, while deploying the headers I'm getting

$ b2 headers
Performing configuration checks

    - default address-model    : 64-bit
    - default architecture     : x86
    - symlinks supported       : yes
error: Cannot create link boost/parameter/python.hpp to libs/parameter/include/boost/parameter/python.hpp.
error: Link previously defined to another file, libs/parameter_python/include/boost/parameter/python.hpp.```

That is because the Boost super-project points to the two master which both include the python.hpp.

https://github.com/boostorg/parameter_python/tree/master/include/boost/parameter/python.hpp
conflicts with
https://github.com/boostorg/parameter/blob/master/include/boost/parameter/python.hpp

missing boost/parameter/is_argument_pack.hpp

Boost.Parameter is broken:

../../boost/graph/named_function_params.hpp:20:10: fatal error: 'boost/parameter/is_argument_pack.hpp' file not found
#include <boost/parameter/is_argument_pack.hpp>

Named template parameters are completely broken in Boost 1.71

Since Boost 1.71 following code fails to compile on VS 2017 - default type is chosen instead of passed one and static assert fires.

#include <boost/parameter/parameters.hpp>
#include <boost/parameter/name.hpp>

BOOST_PARAMETER_TEMPLATE_KEYWORD(type_param)
BOOST_PARAMETER_TEMPLATE_KEYWORD(another_type_param)

class A {};

class B {};

class C {};

template<class... Args>
class CheckParams {
public:
  typedef typename boost::parameter::parameters<
    boost::parameter::optional<tag::type_param>
  >::bind<Args...>::type args;
  typedef typename boost::parameter::value_type<args, tag::type_param,
    B>::type basic_shapes_policy;

  CheckParams() {
    static_assert(std::is_same<basic_shapes_policy, A>::value, "");
  }
};

void test() {
  CheckParams<
      another_type_param<C>,
      type_param<A>
    > instance;
}

BOOST_LOG_TRIVIAL and C++20 modules

Dear all,

I am facing the following challenge when using the BOOST_LOG_TRIVIAL functionality from C++20 modules.

// foo.ixx
module;

#include <boost/log/trivial.hpp>

export module foo;

export namespace foo {

template<typename T>
void bar()
{
    BOOST_LOG_TRIVIAL(info) << "Hello, World!";
}

}
// main.cpp
#include <compare>

import foo;

int main()
{
    foo::bar<int>();
    return 0;
}

This code fails to compile on my Visual Studio 2022 with the following error message.

boost\log\keywords\severity.hpp(32,1): error C7631: 'boost::log::v2_mt_nt6::keywords::`anonymous-namespace'::severity': variable with internal linkage declared but not defined

My current understanding of this issue is that, based on Understanding C++ Modules: Part 3: Linkage and Fragments, severity has module internal linkage because it is in an anonymous namespace. But as bar is a template, it must also be available to importers that instantiate the template, which is not allowed. So the code fails to compile.

Is there any way around this or can the library be improved to also support this scenario?

Thanks in advance,
Felix

Maximum Number of Parameters

Hi,
Is there a maximum number of allowed parameters?
This one fails for me:

BOOST_PARAMETER_MEMBER_FUNCTION(  
		(void), get_info, tag,  
		(required (NIL,*))
		(optional (out(nblks_total),*,nullopt)
				  (out(nfull_total),*,nullopt)
				  (out(nblks_local),*,nullopt)
				  (out(nfull_local),*,nullopt)
				  (out(pdims),*,nullopt)
				  (out(my_ploc),*,nullopt)
				  (out(blks_local),*,nullopt)
				  (out(proc_dist),*,nullopt)
				  (out(blk_size),*,nullopt)
			          (out(blk_offset),*,nullopt)
			          (out(name),*,nullopt)
	)
 ){ ... }

With:

error: wrong number of template arguments (11, should be at least 1)
  BOOST_PARAMETER_MEMBER_FUNCTION(

But it's okay if I remove a few of them.

Compiler error with intel

Hello,

I`ve posted the issue before in Boost.Log but was redirected to this project.

I have trouble to compile the following minimal example using actual 1.72 Boost Log with the intel compiler

icpc version 19.0.5.281 (gcc version 4.8.5 compatibility)

#include "boost/log/trivial.hpp"

using namespace std;

int main(int argc, char** argv){
  BOOST_LOG_TRIVIAL(error) << "Hello world";

  return 0;
}

This results in the following compile error:

icpc    -c -g -I/opt/tools/boost/boost-1.72.0/include -std=c++11 -MMD -MP -MF "build/Debug/Intel-Linux/main.o.d" -o build/Debug/Intel-Linux/main.o main.cpp
/opt/tools/boost/boost-1.72.0/include/boost/log/sources/severity_feature.hpp(252): error: more than one operator "|" matches these operands:
            function template "boost::enable_if<boost::mpl::eval_if<boost::is_same<boost::log::v2_mt_posix::keywords::tag::severity::qualifier, boost::parameter::forward_reference>, boost::mpl::if_<boost::is_const<Default>, boost::mpl::false_, boost::mpl::true_>, boost::mpl::false_>::type, boost::parameter::aux::default_<boost::log::v2_mt_posix::keywords::tag::severity, Default>>::type boost::parameter::keyword<Tag>::operator|(Default &) const [with
                      Tag=boost::log::v2_mt_posix::keywords::tag::severity]"
            function template "boost::enable_if<boost::mpl::eval_if<boost::is_scalar<Default>, boost::mpl::false_, boost::mpl::eval_if<boost::is_same<boost::log::v2_mt_posix::keywords::tag::severity::qualifier, boost::parameter::consume_reference>, boost::mpl::true_, boost::mpl::if_<boost::is_same<boost::log::v2_mt_posix::keywords::tag::severity::qualifier, boost::parameter::forward_reference>, boost::mpl::true_, boost::mpl::false_>>>::type,
                      boost::parameter::aux::default_r_<boost::log::v2_mt_posix::keywords::tag::severity, Default>>::type boost::parameter::keyword<Tag>::operator|(Default &&) const [with Tag=boost::log::v2_mt_posix::keywords::tag::severity]"
            operand types are: const boost::parameter::keyword<boost::log::v2_mt_posix::keywords::tag::severity> | boost::log::v2_mt_posix::trivial::severity_level
          m_SeverityAttr.set_value(args[keywords::severity | m_DefaultSeverity]);
                                                           ^
          detected during:
            instantiation of "boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_severity_logger<BaseT, LevelT>::open_record_unlocked(const ArgsT &) [with BaseT=boost::log::v2_mt_posix::sources::basic_logger<char, boost::log::v2_mt_posix::sources::severity_logger_mt<boost::log::v2_mt_posix::trivial::severity_level>, boost::log::v2_mt_posix::sources::multi_thread_model<boost::log::v2_mt_posix::aux::light_rw_mutex>>, LevelT=boost::log::v2_mt_posix::trivial::severity_level,
                      ArgsT=boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, const boost::log::v2_mt_posix::trivial::severity_level>]" at line 459 of "/opt/tools/boost/boost-1.72.0/include/boost/log/sources/basic_logger.hpp"
            instantiation of "boost::log::v2_mt_posix::record boost::log::v2_mt_posix::sources::basic_composite_logger<CharT, FinalT, ThreadingModelT, FeaturesT>::open_record(const ArgsT &) [with CharT=char, FinalT=boost::log::v2_mt_posix::sources::severity_logger_mt<boost::log::v2_mt_posix::trivial::severity_level>, ThreadingModelT=boost::log::v2_mt_posix::sources::multi_thread_model<boost::log::v2_mt_posix::aux::light_rw_mutex>,
                      FeaturesT=boost::log::v2_mt_posix::sources::features<boost::log::v2_mt_posix::sources::severity<boost::log::v2_mt_posix::trivial::severity_level>>, ArgsT=boost::parameter::aux::tagged_argument<boost::log::v2_mt_posix::keywords::tag::severity, const boost::log::v2_mt_posix::trivial::severity_level>]" at line 6 of "main.cpp"

compilation aborted for main.cpp (code 2)

With gcc everything is fine. It seems that changes came with 1.71 lead to this.

Thanks

Files with executable permissions

Most of the files that were added or changed recently had Linux executable permissions set on the source files. I updated 'develop' removing those executable permissions. No Boost git files should have the executable permission set for them unless, of course, they are really executable files, in which case they almost certainly don't belong under git.

Please remove dependency on Boost Python.

It seems ludicrous to me that Parameter depends on Python. In trying to deal with a modular Boost it causes the rather heavyweight BPL to be pulled in when using Parameters. For example it causes Boost Log to depend on BPL for no reason.

Would it be possible to move the Python Parameter binding stuff to the BPL library instead?

Tests for msvc failures for C11 are not failing

The parameter_msvc11_fail_tests is not failing for msvc-14.1, msvc-14.0, and msvc-12.0. The test does fail for msvc-11.0, but this failure may be because of a bug in msvc-11.0 and not because the logic correctly causes failure.

One test from boost libraries failed to run after boost submodule parameter updated from 5d3e39 to 8f2cd5

Environment:
VS 2017 + Windows Server 2016

Issue description:
One test from boost libraries failed to run after boost submodule parameter updated from 5d3e39 to 8f2cd5 boost/parameter@7b12552.Could you please take a look?

Reproduce steps:.

  1. git clone -c core.autocrlf=true --recursive โ€‹https://github.com/boostorg/boost.git D:\Boost\src
  2. open a VS 2017 x64 command prompt and browse to D:\Boost\src
  3. .\bootstrap
  4. .\b2 headers variant=release --build-dir=..\out\x64rel address-model=64
  5. .\b2 variant=release --build-dir=..\out\x64rel address-model=64
  6. .\b2 -j4 variant=release --build-dir=..\out\x64rel libs\accumulators\test

log_x64_test_1.log

ErrorMessage:
.\boost/parameter/aux_/arg_list.hpp(312): error C2664: 'boost::parameter::aux::tagged_argument_list_of_1<boost::parameter::aux::tagged_argument<Keyword,std::vector<double,std::allocator<_Ty>>>>::tagged_argument_list_of_1(const boost::parameter::aux::tagged_argument_list_of_1<boost::parameter::aux::tagged_argument<Keyword,std::vector<_Ty,std::allocator<_Ty>>>> &)': cannot convert argument 1 from 'const A1' to 'std::vector<double,std::allocator<Ty>> &'
.\boost/parameter/keyword.hpp(66): error C2039: 'qualifier': is not a member of 'boost::accumulators::tag::extended_p_square_probabilities
<0>'
.\boost/parameter/keyword.hpp(98): error C2062: type 'unknown-type' unexpected
.\boost/parameter/keyword.hpp(100): error C2334: unexpected token(s) preceding '{'; skipping apparent function body

Tests for msvc failures are not failing

The tests for parameter_msvc_fail_tests are not failing for msvc-8.0, msvc-9.0, msvc-10.0, and msvc-11.0. These tests are the compile-fail evaluate_category.cpp test and the compile-fail preprocessor_eval_category.cpp test. I am less concerned than usual about these test failures since these are fairly old version of the vc++ compiler, and just may indicate deficiencies in those compilers. But still these test failures should be looked at.

`boost/parameter/python.hpp` doesn't compile with Python 3

I get

C:\boost-git\develop\boost/parameter/python.hpp(66): error C2440: 'initializing'
: cannot convert from 'const char [28]' to 'Py_ssize_t'
C:\boost-git\develop\boost/parameter/python.hpp(66): note: There is no context i
n which this conversion is possible
C:\boost-git\develop\boost/parameter/python.hpp(66): error C2440: 'initializing'
: cannot convert from 'long' to 'const char *'
C:\boost-git\develop\boost/parameter/python.hpp(66): note: Conversion from integ
ral type to pointer type requires reinterpret_cast, C-style cast or function-sty
le cast
C:\boost-git\develop\boost/parameter/python.hpp(68): error C2039: 'ob_type': is
not a member of '_typeobject'
c:\python33\include\object.h(333): note: see declaration of '_typeobject'
C:\boost-git\develop\boost/parameter/python.hpp(70): error C2039: 'ob_type': is
not a member of '_typeobject'
c:\python33\include\object.h(333): note: see declaration of '_typeobject'

Compilation error when no required arg in template class

Hi boost developers.
I have some compilation trouble when I want to use a BOOST_PARAMETER_MEMBER_FUNCTION with no required argument in a template class. There is no issue for non template class or if I add one require arg.
This code can reproduce my issue (tested with several version of boost 1.65,1.69,1.70,1.71,1.72)

#include <iostream>
#include <boost/parameter.hpp>

BOOST_PARAMETER_NAME(arg1)

template <typename T>
struct somebody
{
  BOOST_PARAMETER_MEMBER_FUNCTION(
                                  (void), static f, tag, (optional (arg1,(int),0))
                                  )
  {
    std::cout << arg1 << std::endl;
  }
};

#include <boost/core/lightweight_test.hpp>

int main()
{
  somebody<double>::f();
  somebody<double>::f(4);
  return boost::report_errors();
}

The error obtained with clang++ :

error: template argument for template type parameter must be a type; did you forget 'typename'?

The error obtained with g++ :

In file included from /usr/include/boost/parameter.hpp:18,
                 from test_boostparameter.cpp:2:
test_boostparameter.cpp:9:3: error: type/value mismatch at argument 1 in template parameter list for 'template<class T> template<class Args> struct somebody<T>::boost_param_result_11f'
   BOOST_PARAMETER_MEMBER_FUNCTION(
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_boostparameter.cpp:9:3: note:   expected a type, got 'boost::parameter::aux::argument_pack<somebody<T>::boost_param_params_11f<int> >::type'
test_boostparameter.cpp:9:3: error: expected ';' at end of member declaration
   BOOST_PARAMETER_MEMBER_FUNCTION(
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_boostparameter.cpp: In function 'int main()':
test_boostparameter.cpp:21:23: error: cannot call member function 'int somebody<T>::f() [with T = double]' without object
   somebody<double>::f();

Default parameter value used instead of the specified one

Consider this test case:

#include <string>
#include <iostream>
#include <boost/parameter/keyword.hpp>

namespace keywords {

BOOST_PARAMETER_KEYWORD(tag, file_name)

}

void construct_impl(std::string const& str)
{
    std::cout << "str: " << str << std::endl;
}

template< typename Args >
void construct(Args const& args)
{
    construct_impl(args[keywords::file_name | std::string()]);
}

int main()
{
    construct((keywords::file_name = "sample.log"));
}

Currently, it prints "str: " instead of "str: sample.log". Boost.Parameter uses the default-constructed std::string value to pass to construct_impl instead of the one passed by user.

This causes regressions in Boost.Log (boostorg/log#104) and is reportedly started happening somewhere between Boost 1.69 and 1.71.

PS: Reproduced with gcc 9 and VS2015, but probably not only those compilers.

List of non BOOST-prefixed macros

The following macros are missing a BOOST_ prefix, which is against Boost library guidelines:

./libs/parameter/test/basics.hpp:#ifndef BASICS_050424_HPP
./libs/parameter/test/basics.hpp:#define BASICS_050424_HPP
./boost/parameter/keyword.hpp:#ifndef KEYWORD_050328_HPP
./boost/parameter/keyword.hpp:#define KEYWORD_050328_HPP
./boost/parameter/aux_/unwrap_cv_reference.hpp:#ifndef UNWRAP_CV_REFERENCE_050328_HPP
./boost/parameter/aux_/unwrap_cv_reference.hpp:#define UNWRAP_CV_REFERENCE_050328_HPP
./boost/parameter/aux_/parameter_requirements.hpp:#ifndef PARAMETER_REQUIREMENTS_050331_HPP
./boost/parameter/aux_/parameter_requirements.hpp:#define PARAMETER_REQUIREMENTS_050331_HPP
./boost/parameter/aux_/arg_list.hpp:#ifndef ARG_LIST_050329_HPP
./boost/parameter/aux_/arg_list.hpp:#define ARG_LIST_050329_HPP
./boost/parameter/aux_/default.hpp:#ifndef DEFAULT_050329_HPP
./boost/parameter/aux_/default.hpp:#define DEFAULT_050329_HPP
./boost/parameter/aux_/yesno.hpp:#ifndef YESNO_050328_HPP
./boost/parameter/aux_/yesno.hpp:#define YESNO_050328_HPP

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.