0% found this document useful (0 votes)
55 views

Std::string Std::wstring Std::basic - String Std::u16string Std::u32string

The document discusses various features and functions provided by the Boost C++ libraries. It mentions that Boost.StringAlgorithms provides string manipulation functions that can operate on std::string and other string types. It also discusses Boost.MinMax, Boost.Foreach, Boost.TypeTraits, Boost.Bind, Boost.Ref, Boost.Filesystem, Boost.Optional and Boost.System libraries and some of their key functions.

Uploaded by

Sumegh Belekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Std::string Std::wstring Std::basic - String Std::u16string Std::u32string

The document discusses various features and functions provided by the Boost C++ libraries. It mentions that Boost.StringAlgorithms provides string manipulation functions that can operate on std::string and other string types. It also discusses Boost.MinMax, Boost.Foreach, Boost.TypeTraits, Boost.Bind, Boost.Ref, Boost.Filesystem, Boost.Optional and Boost.System libraries and some of their key functions.

Uploaded by

Sumegh Belekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Stringhandling

1. The Boost.StringAlgorithms library provides many free-standing functions for string


manipulation. Strings can be of type std::string, std::wstring, or any other
instance of the class template std::basic_string. This includes the string
classes std::u16string and std::u32string introduced with C++11

2. The functions are categorized within different header files. For example, functions
converting from uppercase to lowercase are defined
in boost/algorithm/string/case_conv.hpp.

3. boost/algorithm/string.hpp acts as the common header including all other


header files for convenience.

4. Boost.MinMax provides an algorithm to find the minimum and the maximum of two
values using only one function call, which is more efficient than
calling std::min() and std::max().

5. Boost.MinMax is part of C++11. You find the algorithms from this Boost library in the
header file algorithm if your development environment supports C++11.

6. Coroutines are a feature of other programming languages, which often use the
keyword yield for coroutines

7. programming languages, yield can be used like return

8. C++ doesn’t define a keyword yield.

9. To use cooperative() as a coroutine, the types pull_type and push_type are


used
10. To use coroutines, you need pull_type and push_type. One of these types will be
used to create an object that will be initialized with the function you want to use as a
coroutine. The other type will be the first parameter of the coroutine function.

11. Boost.Foreach provides a macro that simulates the range-based for loop from C++11

12. You can use the macro BOOST_FOREACH, defined in boost/foreach.hpp, to iterate
over a sequence without using iterators

13. Boost.Foreach uses Boost.Range instead of directly accessing the member


functions begin() and end()

14. BOOST_FOREACH expects two parameters. The first parameter is a variable or reference,
and the second is a sequence

15. The Boost.TypeTraits library provides the tools needed to determine a type’s properties
and change them.

16. You can access those functions through the header file type_traits. However,
Boost.TypeTraits provides additional functions.

17. calls several functions to determine type categories. boost::is_integral checks


whether a type is integral – whether it can store
integers. boost::is_floating_point checks whether a type stores floating point
numbers. boost::is_arithmetic checks whether a type supports arithmetic
operators. And boost::is_reference can be used to determine whether a type is a
reference.

18. boost::is_integral and boost::is_floating_point are mutually exclusive. A


type either stores an integer or a floating point number.
However, boost::is_arithmetic and boost::is_reference can apply to
multiple categories

19. Boost.EnableIf makes it possible to disable overloaded function templates or specialized


class templates. Disabling means that the compiler ignores the respective templates
20. You can call the functions introduced in this chapter without using a Boost library; just
include the header file type_traits.

21. defines the function template create(), which returns an object of the type passed as a
template parameter.

22. Boost.Bind is a library that simplifies and generalizes capabilities that originally
required std::bind1st() and std::bind2nd().

23. If your development environment supports C++11, you will find the
function std::bind() in the header file functional.

24. The third parameter of std::for_each() is a function or function object that expects a
sole parameter.

25. std::for_each() passes the numbers in the container v as sole parameters, one
after another, to print().

26. The library Boost.Ref provides two functions, boost::ref() and boost::cref(), in
the header file boost/ref.hpp. They are useful if you use, for
example, std::bind() for a function which expects parameters by reference.
Because std::bind() takes parameters by value, you have to deal with references
explicitly.

27. Boost.Ref was added to the standard library in C++11, where you will find the
functions std::ref() and std::cref() in the header file functional.

28. The library Boost.Filesystem makes it easy to work with files and directories. It provides a
class called boost::filesystem::path that processes paths.

29. boost::system::error_code is the most basic class in Boost.System; it represents


operating system-specific errors. Because operating systems typically enumerate errors,

30. boost::system::error_code saves an error code in a variable of type int.


31. The library Boost.Optional provides the class boost::optional, which can be used for
optional return values. These are return values from functions that may not always return
a result.

32. uses the function get_even_random_number(), which should return an even random
number. It does this in a rather naive fashion by calling the function std::rand() from
the standard library. If std::rand() generates an even random number, that number is
returned by get_even_random_number(). If the generated random number is odd, -1
is returned.

1. For debugging with GDB, the file “sanfoundry” can be created with the command

a) gcc -g -o sanfoundry sanfoundry.c

b) gcc -g sanfoundry.c

c) gdb sanfoundry

d) none of the mentioned

Answer: a

2. For debugging with GDB, the compiled program can be run by the command

a) run

b) execute

c) ./<filename>

d) none of the mentioned

Answer: a

3. In GDB, breakpoints can be set by the command

a) break
b) b

c) both break and b

d) none of the mentioned

Answer: c

4. GDB stands for

a) GNU debugger

b) General debugging breakpoint

c) General debugger

d) None of the mentioned

Answer: a

5. GDB can be used for

a) c language

b) c++ language

c) both c and c++ language

d) none of the mentioned

Answer: c

6. The command “gdb sanfoundy”

a) will start debugging for the file “sanfoundry” if the file is compiled with -g option with GCC

b) will create executable for debugging

c) will provide all errors present in the file “sanfoundry”

d) none of the mentioned

Answer: a
7. In debugging with GDB, break points can be set to

a) any line

b) any function

c) both any line and function

d) none of the mentioned

Answer: c

8. In GDB debugging, we can proceed to the next breakpoint with command

a) next

b) continue

c) both next and continue

d) none of the mentioned

Answer: b

9. At the time of debugging with GDB, if we just press ENTER

a) GDB will repeat the same command you just gave it

b) GDB will do nothing

c) GDB will exit

d) None of the mentioned

Answer: a

10. To print the value of a variable while debugging with GDB, ______ command can be used.

a) printf

b) print

c) show

d) none of the mentioned


Answer: b

1. Which GDB command prints the value of a variable in hex.

a) print/x

b) print/h

c) print/e

d) none of the mentioned

Answer: a

2. Which GDB command interrupts the program whenever the value of a variable is modified and prints
the value old and new values of the variable?

a) watch

b) show

c) trace

d) none of the mentioned

Answer: a

3. Which GDB command produces a stack trace of the function calls that lead to a segmentation fault?

a) trace

b) backtrace

c) forwardtrace

d) none of the mentioned

Answer: b

4. The specific break point can be deleted by _____ command in GDB.

a) delete
b) del

c) remove

d) none of the mentioned

Answer: a

5. The “step” command of GDB

a) executes the current line of the program

b) stops the next statement to be executed

c) executes the current line of the program & stops the next statement to be executed

d) none of the mentioned

Answer: c

6. Which GDB command reloads the debugging information?

a) file

b) reload

c) debug

d) none of the mentioned

Answer: a

7. GDB can be used

a) to find out the memory leakages

b) to get the result of a particular expression in a program

c) to find the reason of segementation fault

d) all of the mentioned

Answer: d
8. Which GDB command can be used to put a breakpoint at the beginning of the program?

a) b main

b) b start

c) break

d) none of the mentioned

Answer: a

9. To put the breakpoint at the current line ____ command can be used?

a) b

b) break

c) both b and break

d) none of the mentioned

Answer: c

10. We can list all the breakpoint in GDB by the command

a) info break

b) break all

c) both info break and break all

d) none of the mentioned

Answer: a

You might also like